/* Admin console: same brand, calmer and denser */
body.admin { background: #fbf5f6; }
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: #fff; border-right: 1px solid var(--line);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; text-decoration: none; color: inherit; }
.side .brand img { width: 46px; height: 46px; border-radius: 50%; }
.side .brand .wordmark { font-size: 1.5rem; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--ink); font-weight: 700; min-height: 42px;
}
.nav a:hover { background: var(--blush); }
.modal-body:focus { outline: none; }
.nav a[aria-current='page'] { background: var(--pink-ribbon); color: #fff; }
.nav .badge { margin-left: auto; background: var(--pink); color: #fff; border-radius: 999px; font-size: 0.75rem; padding: 1px 8px; }
.nav a[aria-current='page'] .badge { background: #fff; color: var(--pink-deep); }
.side .who { margin-top: auto; padding: 10px; font-size: 0.82rem; color: var(--muted); border-top: 1px solid var(--line); }

.main { padding: 22px 26px 80px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-family: var(--script); font-weight: 400; font-size: 2.1rem; margin-right: auto; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .input { min-height: 40px; width: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi .k { font-size: 0.8rem; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; }
.kpi .v { font-size: 1.5rem; font-weight: 900; margin-top: 2px; }
.kpi .s { font-size: 0.82rem; color: var(--muted); }
.kpi.accent { background: var(--pink-ribbon); color: #fff; }
.kpi.accent .k, .kpi.accent .s { color: rgba(255, 255, 255, 0.85); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.panel { padding: 16px; }
.panel h2 { font-size: 1.05rem; font-weight: 900; color: var(--choc); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.panel h2 .right { margin-left: auto; }

table.t { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.t th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.t td { padding: 10px; border-bottom: 1px solid #f6e3ea; vertical-align: middle; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #fff7fa; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t tfoot td { font-weight: 900; border-top: 2px solid var(--line); border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }

.pos { color: var(--ok); }
.neg { color: var(--bad); }

dialog.modal {
  border: 0; border-radius: 22px; padding: 0; width: min(760px, 96vw); max-height: 92vh; box-shadow: 0 30px 80px rgba(62, 33, 23, 0.3);
}
dialog.modal::backdrop { background: rgba(62, 33, 23, 0.45); }
.modal-head { position: sticky; top: 0; background: #fff; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.2rem; font-weight: 900; margin-right: auto; }
.modal-body { padding: 18px 20px; }
.modal-foot { position: sticky; bottom: 0; background: #fff; display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.check { display: flex; gap: 8px; align-items: center; min-height: 40px; font-weight: 700; }
.check input { width: 20px; height: 20px; accent-color: var(--pink); }

.cost-box { background: var(--cream); border: 2px dashed var(--pink-soft); border-radius: 16px; padding: 14px; }
.cost-box .r { display: flex; justify-content: space-between; padding: 3px 0; }
.cost-box .r.big { font-weight: 900; font-size: 1.1rem; }
.rline { display: grid; grid-template-columns: 1fr 110px 60px 100px 40px; gap: 8px; align-items: center; margin-bottom: 8px; }
.rline .input { min-height: 40px; padding: 6px 10px; }
.rline[data-cat] { grid-template-columns: 1fr 80px; }
.rline[data-area] { grid-template-columns: 1fr 100px 70px 40px; }
.rline .icon-btn { width: 38px; height: 38px; }
.rline .cost { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

.chart { width: 100%; height: 200px; }
.legend { display: flex; gap: 14px; font-size: 0.82rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { max-width: 400px; text-align: center; padding: 28px; }
.login img { width: 140px; margin: 0 auto 12px; border-radius: 50%; }

.mtop, .mobile-nav { display: none; }
.dl { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.pname { display: flex; align-items: center; gap: 10px; }
.sheet-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px 16px; }
.sheet-nav a { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px 12px; border-radius: 14px; background: var(--blush); color: var(--ink); font-weight: 800; text-decoration: none; }
.sheet-nav a[aria-current='page'] { background: var(--pink-ribbon); color: #fff; }
.sheet-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 16px 18px; }
.sheet-foot .small { flex: 1 1 100%; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 12px 12px calc(92px + env(safe-area-inset-bottom)); }

  /* top app bar */
  .mtop {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; z-index: 35;
    padding: 8px 12px; background: rgba(255, 255, 255, 0.94); border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  }
  .mbrand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
  .mbrand img { width: 36px; height: 36px; border-radius: 50%; }
  .mbrand .wordmark { font-size: 1.45rem; }

  /* bottom tab bar */
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 18px rgba(163, 14, 74, 0.08);
  }
  .mobile-nav a, .mobile-nav button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 54px; border: 0; background: none; border-radius: 14px; color: var(--muted); font-size: 0.72rem; font-weight: 800; text-decoration: none; cursor: pointer;
  }
  .mobile-nav .mi { font-size: 1.25rem; line-height: 1; }
  .mobile-nav [aria-current='page'] { color: var(--pink-deep); background: var(--blush); }
  .mbadge { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--pink); color: #fff; font-size: 0.7rem; display: grid; place-items: center; }

  .demo-banner { font-size: 0.75rem; padding: 4px 10px; }
  .page-head { gap: 8px; margin-bottom: 12px; }
  .page-head h1 { font-size: 1.75rem; flex: 1 1 100%; }
  .page-head .btn { flex: 1 1 auto; }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar .input, .toolbar .dl { width: 100%; }
  .toolbar .search { grid-column: 1 / -1; }
  .dl { display: grid; gap: 2px; }
  .dl .input { width: 100%; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 12px; }
  .kpi .v { font-size: 1.15rem; }
  .kpi .k { font-size: 0.68rem; }
  .kpi.accent { grid-column: 1 / -1; }
  .cols { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .panel { padding: 14px; }
  .panel h2 { flex-wrap: wrap; }
  .panel h2 .right.input { margin-left: 0; width: 100%; }

  /* tables become cards */
  .table-wrap { overflow: visible; }
  table.t.cards, table.t.cards tbody, table.t.cards tfoot { display: block; width: 100%; }
  table.t.cards thead { display: none; }
  table.t.cards tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; padding: 12px 14px; border-bottom: 1px solid #f6e3ea; }
  .card > table.t.cards tr, .card.table-wrap table.t.cards tr { padding: 12px 16px; }
  table.t.cards td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  table.t.cards td::before { content: attr(data-l); display: block; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.3px; text-transform: uppercase; color: var(--muted); }
  table.t.cards td[data-l='']::before { display: none; }
  table.t.cards td:first-child { grid-column: 1 / -1; font-size: 1rem; }
  table.t.cards td:first-child::before { display: none; }
  table.t.cards td:empty { display: none; }
  table.t.cards td[colspan] { grid-column: 1 / -1; text-align: center; }
  table.t.cards tr.click:active td { background: none; }
  table.t.cards tr.click:active { background: #fff7fa; }
  table.t.cards tfoot tr { display: flex; justify-content: space-between; gap: 10px; padding: 8px 14px; }
  table.t.cards tfoot td { font-weight: 900; }
  table.t.cards tfoot td[colspan] { text-align: left; grid-column: auto; }
  table.t.cards tfoot td.num { text-align: right; flex: none; }
  table.t.cards tfoot td::before { display: none; }

  /* dialogs become full-screen sheets */
  dialog.modal, dialog.modal[style] { width: 100vw !important; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  dialog.modal.sheet { height: auto; max-height: 85dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  .modal-head { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .modal-head h2 { font-size: 1.05rem; }
  .modal-body { padding: 14px; }
  .modal-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
  .modal-foot .btn { flex: 1 1 auto; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }

  /* recipe lines: ingredient on its own row */
  .rline { grid-template-columns: minmax(0, 1fr) 34px 92px 44px; grid-template-areas: 'ing ing ing ing' 'qty unit cost del'; gap: 6px 8px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
  .rline > :nth-child(1) { grid-area: ing; }
  .rline > :nth-child(2) { grid-area: qty; }
  .rline > :nth-child(3) { grid-area: unit; }
  .rline > :nth-child(4) { grid-area: cost; }
  .rline > :nth-child(5) { grid-area: del; }
  .rline.small.muted { display: none; }
  .rline .icon-btn { width: 44px !important; height: 44px !important; }
  .rline[data-area] { grid-template-columns: minmax(0, 1fr) 80px 44px; grid-template-areas: 'ing ing ing' 'qty unit del'; }
  .rline[data-area] > :nth-child(4) { grid-area: del; }
  .rline[data-cat] { grid-template-columns: minmax(0, 1fr) 80px; grid-template-areas: 'ing qty'; border: 0; }
  .rline .cost { white-space: nowrap; }
  .cost-box .r { gap: 12px; }
  .t tr.click:hover td, table.t.cards tr.click:hover td { background: none; }
  .toolbar > * { min-width: 0; }
  .toolbar .dl { grid-column: 1 / -1; grid-template-columns: 44px minmax(0, 1fr); display: grid; align-items: center; gap: 8px; }
  .toolbar .dl .input { min-width: 0; }
  .toolbar .dl span { min-width: 36px; }
  .cost-box .r > :last-child { text-align: right; }
  .check { min-height: 44px; }
  .btn.small { min-height: 44px; }
  .t td, .t th { padding: 8px 6px; }
  .chart { height: 160px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

@media print {
  .side, .mobile-nav, .mtop, .toolbar, .no-print, .demo-banner { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body.admin { background: #fff; }
  .print-break { page-break-after: always; }
}
