/* Upstairs Inventory — brand: deep green, cream, gold, orange */
:root {
  --green-900: #0d2a20;
  --green-800: #123a2c;
  --green-700: #1a4d3b;
  --green-100: #e3eee8;
  --cream: #f6f2ea;
  --cream-2: #efe8db;
  --gold: #c4963a;
  --gold-600: #a97c27;
  --orange: #d4703a;
  --ink: #1d2420;
  --muted: #66706a;
  --line: #e2dccf;
  --card: #ffffff;
  --ok: #2f7d4f;
  --warn: #b7791f;
  --bad: #c0392b;
  --info: #2b6cb0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(13, 42, 32, .06), 0 4px 14px rgba(13, 42, 32, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar: 232px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 var(--font); color: var(--ink); background: var(--cream); -webkit-text-size-adjust: 100%; }
a { color: var(--green-700); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.stack > * + * { margin-top: .75rem; }
.mt { margin-top: 1rem; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--green-900); color: #dfe9e3; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { width: 40px; height: 40px; border-radius: 8px; }
.brand b { display: block; font-size: 1.05rem; letter-spacing: .06em; color: #fff; font-style: italic; }
.brand span { font-size: .7rem; color: var(--gold); letter-spacing: .08em; text-transform: uppercase; }
.nav { padding: .5rem; flex: 1; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; color: #cfdcd5; text-decoration: none; border-radius: 8px; font-size: .95rem; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--green-700); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav .sep { margin: .75rem .75rem .25rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: #7f9a8c; }
.nav svg, .bottomnav svg { width: 20px; height: 20px; flex: none; }
.count { margin-left: auto; background: var(--orange); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 .45rem; min-width: 1.3rem; text-align: center; line-height: 1.3rem; }
.sidebar .me { padding: .75rem 1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; }
.sidebar .me a { color: var(--gold); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(246,242,234,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: .6rem 1.25rem; display: flex; align-items: center; gap: .75rem; }
.topbar h1 { margin: 0; font-size: 1.15rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .logo-sm { display: none; width: 32px; height: 32px; border-radius: 6px; }
.content { padding: 1.25rem; max-width: 1280px; width: 100%; }

.syncpill { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: .2rem .65rem; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.syncpill i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.syncpill.offline i { background: var(--muted); }
.syncpill.pending i { background: var(--warn); }
.syncpill.syncing i { background: var(--info); animation: pulse 1s infinite; }
.syncpill.error i { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }

.bottomnav { display: none; }
.topbar > span { display: flex; gap: .5rem; align-items: center; }
.curtoggle { display: inline-flex; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 2px; cursor: pointer; font-size: .75rem; font-weight: 700; }
.curtoggle .cur { padding: .15rem .5rem; border-radius: 99px; color: var(--muted); }
.curtoggle .cur.on { background: var(--green-800); color: #fff; }

/* overview dashboard (KPI cards with trend, bars, donut) */
.overview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: .75rem; flex-wrap: wrap; }
.overview-head h2 { margin: 0; font-size: 1.35rem; }
.overview-head select { width: auto; min-height: 38px; font-weight: 600; }
.kpi2-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.kpi2 { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem .6rem; display: flex; flex-direction: column; gap: .15rem; text-decoration: none; color: inherit; min-width: 0; }
.kpi2 .top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.kpi2 .label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi2 .value { font-size: 1.55rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi2 .sub { font-size: .74rem; color: var(--muted); }
.kpi2 svg.spark { width: 100%; height: 38px; margin-top: .2rem; }
.delta { display: inline-flex; align-items: center; gap: .15rem; font-size: .72rem; font-weight: 700; border-radius: 99px; padding: .1rem .45rem; white-space: nowrap; }
.delta.up-good, .delta.down-good { background: #e1f1e7; color: var(--ok); }
.delta.up-bad, .delta.down-bad { background: #f8e0dd; color: var(--bad); }
.delta.flat { background: var(--cream-2); color: var(--muted); }
.grid.chart-row { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.chart svg text { font-size: 11px; fill: var(--muted); }
.legend-inline { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; margin-top: .4rem; color: var(--ink); }
.legend-inline i, .legend-row i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; flex: none; }
.donutwrap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.donutwrap .legend { min-width: 200px; }
.donutwrap svg.donut { width: 160px; height: 160px; flex: none; }
.donutwrap .donut-total { font-size: 17px; font-weight: 800; fill: var(--ink); }
.legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .35rem; font-size: .83rem; }
.legend-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: .5rem; align-items: center; }
.legend-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.legend-row .val { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: right; }
.charttip { position: fixed; z-index: 300; display: none; pointer-events: none; background: var(--green-900); color: #fff; font-size: .78rem; padding: .45rem .6rem; border-radius: 8px; box-shadow: var(--shadow); max-width: 240px; }
.charttip b { display: block; margin-bottom: .1rem; }
.alertstrip { display: flex; gap: .5rem; flex-wrap: wrap; }
.alertstrip a { display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; font-size: .85rem; font-weight: 600; border-radius: 99px; padding: .35rem .8rem; border: 1px solid; }
.alertstrip a b { font-variant-numeric: tabular-nums; }
.alertstrip a svg { width: 16px; height: 16px; }
.alertstrip .red { background: #fdf1ef; border-color: #efc4bf; color: #8a2a20; }
.alertstrip .orange { background: #fdf7ea; border-color: #f0d9a8; color: #7a5410; }
.alertstrip .ok { background: #f1f8f3; border-color: #c9e3d2; color: var(--ok); }
@media (max-width: 1100px) { .kpi2-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.chart-row { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .kpi2-grid { gap: .6rem; } .kpi2 { padding: .7rem .75rem .5rem; } .kpi2 .value { font-size: 1.2rem; } .donutwrap svg.donut { width: 130px; height: 130px; } }
@media (max-width: 420px) { .donutwrap { flex-direction: column; align-items: stretch; } .donutwrap svg.donut { align-self: center; } }

/* critical dashboard */
.alerts { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .75rem; }
.alertcard { display: flex; gap: .75rem; align-items: center; padding: .8rem 1rem; border-radius: var(--radius); text-decoration: none; color: inherit; border: 1px solid; background: #fff; }
.alertcard b { font-size: 1.5rem; line-height: 1; font-variant-numeric: tabular-nums; }
.alertcard .t { font-size: .85rem; font-weight: 600; }
.alertcard .s { font-size: .75rem; color: var(--muted); }
.alertcard svg { width: 26px; height: 26px; flex: none; }
.alertcard.red { border-color: #efc4bf; background: #fdf1ef; color: #8a2a20; }
.alertcard.orange { border-color: #f0d9a8; background: #fdf7ea; color: #7a5410; }
.alertcard.ok { border-color: #c9e3d2; background: #f1f8f3; color: var(--ok); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.fact { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.fact .l { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fact .v { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fact .s { font-size: .78rem; color: var(--muted); }
.cover { display: inline-block; min-width: 3.2rem; text-align: center; border-radius: 6px; padding: .05rem .4rem; font-weight: 700; font-size: .82rem; }
.cover.crit { background: #f8e0dd; color: var(--bad); } .cover.warn { background: #fbefd9; color: var(--warn); } .cover.ok { background: #e1f1e7; color: var(--ok); }

/* ---------- components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.kpi { position: relative; overflow: hidden; text-decoration: none; color: inherit; display: block; }
.kpi .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .value { font-size: 1.6rem; font-weight: 700; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--muted); }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--green-700)); }
.kpi.gold { --accent: var(--gold); } .kpi.orange { --accent: var(--orange); } .kpi.red { --accent: var(--bad); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line); background: #fff; padding: .55rem .9rem; border-radius: 9px; cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .92rem; min-height: 40px; }
.btn:hover { border-color: #cfc6b4; }
.btn.primary { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.btn.primary:hover { background: var(--green-700); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { background: #fff; color: var(--bad); border-color: #e9c2bd; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: .3rem .6rem; min-height: 32px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: .3rem .8rem; cursor: pointer; font-size: .85rem; white-space: nowrap; }
.chip.on { background: var(--green-800); color: #fff; border-color: var(--green-800); }

label.f { display: block; font-size: .82rem; font-weight: 600; color: #3d4741; }
label.f > input, label.f > select, label.f > textarea, .input { display: block; width: 100%; margin-top: .25rem; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], input[type=email], input[type=tel], select, textarea {
  border: 1px solid #d6cfc0; background: #fff; border-radius: 9px; padding: .55rem .7rem; min-height: 42px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(196,150,58,.45); border-color: var(--gold); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: .1rem; flex: none; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; border-radius: 6px; padding: .12rem .45rem; background: var(--cream-2); color: #5b5446; white-space: nowrap; }
.badge.approved, .badge.ok, .badge.received, .badge.closed { background: #e1f1e7; color: var(--ok); }
.badge.pending, .badge.low, .badge.partial { background: #fbefd9; color: var(--warn); }
.badge.rejected, .badge.cancelled, .badge.negative, .badge.out, .badge.deleted { background: #f8e0dd; color: var(--bad); }
.badge.edited { background: #ede7f6; color: #5b3f8c; }
mark { background: #fbe7b0; color: inherit; border-radius: 3px; padding: 0 1px; }
.searchbar { position: sticky; top: 57px; z-index: 10; }
.searchbar input[type=search] { font-size: 1.02rem; min-height: 46px; padding-left: 2.4rem; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366706a' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") no-repeat .8rem center / 18px; }
.rowactions { display: flex; gap: .3rem; justify-content: flex-end; flex-wrap: wrap; }
.imp-table input, .imp-table select { min-height: 34px; padding: .3rem .45rem; font-size: .85rem; }
.imp-table td { padding: .3rem .4rem; }
.imp-table tr.skip td { opacity: .45; }
.imp-table tr.err td { background: #fdf1ef; }
.drop-zone { border: 2px dashed #cfc6b4; border-radius: var(--radius); padding: 2rem 1rem; text-align: center; background: #fffdf8; cursor: pointer; }
.drop-zone.over { border-color: var(--gold); background: #fdf7ea; }
.changes { margin: .25rem 0 0; padding-left: 1.1rem; font-size: .82rem; }
.badge.local { background: #e5eefa; color: var(--info); }
.badge.type { background: var(--green-100); color: var(--green-800); }

/* tables: become cards on narrow screens */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #faf8f3; padding: .55rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: .55rem .7rem; border-bottom: 1px solid #f0ebe1; vertical-align: top; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover { background: #fbf9f4; }
table.t tfoot td { font-weight: 700; background: #faf8f3; border-top: 2px solid var(--line); padding: .55rem .7rem; }
table.t tr.group td { background: var(--green-100); font-weight: 700; color: var(--green-800); }
table.t th.num, table.t td.num { text-align: right; }

.list { display: flex; flex-direction: column; gap: .5rem; }
.li { display: flex; gap: .75rem; align-items: center; padding: .7rem .8rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: inherit; }
.li .grow { min-width: 0; }
.li .t1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .t2 { font-size: .82rem; color: var(--muted); }
a.li:hover { border-color: #cfc6b4; }
/* Icons are inline SVGs with no intrinsic size: always size them explicitly. */
svg { width: 20px; height: 20px; flex: none; }
.li > svg { width: 22px; height: 22px; color: var(--green-700); }
.chart svg { width: 100%; height: auto; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.alert { border-radius: 10px; padding: .7rem .9rem; font-size: .9rem; border: 1px solid; }
.alert.warn { background: #fdf5e6; border-color: #f0d9a8; color: #7a5410; }
.alert.bad { background: #fbeceb; border-color: #efc4bf; color: #8a2a20; }
.alert.info { background: #eaf2fb; border-color: #c4d8f0; color: #234e7d; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: .6rem .9rem; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--green-800); border-bottom-color: var(--gold); }

/* line editor */
.lines .line { display: grid; grid-template-columns: 1fr 120px 110px 120px 40px; gap: .5rem; align-items: end; padding: .6rem 0; border-bottom: 1px dashed var(--line); }
.lines .line .name { font-weight: 600; }
.lines .line .meta { font-size: .78rem; color: var(--muted); }
.lines .line input, .lines .line select { min-height: 40px; }
.lines .head { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-bottom: .25rem; }

/* picker */
.picker { position: relative; }
.picker .drop { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; }
.picker .opt { padding: .55rem .75rem; cursor: pointer; display: flex; justify-content: space-between; gap: .5rem; }
.picker .opt:hover, .picker .opt.hl { background: var(--cream); }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.4rem; }
.timeline li::before { content: ""; position: absolute; left: .3rem; top: .35rem; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.timeline li::after { content: ""; position: absolute; left: .55rem; top: 1rem; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }

/* charts */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: .5rem; align-items: center; font-size: .85rem; margin: .35rem 0; }
.hbar .bar { height: 10px; border-radius: 6px; background: var(--cream-2); overflow: hidden; }
.hbar .bar i { display: block; height: 100%; background: var(--green-700); border-radius: 6px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(13,42,32,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { padding: 1rem 1.1rem .5rem; display: flex; justify-content: space-between; align-items: center; }
.modal header h2 { margin: 0; }
.modal .body { padding: .5rem 1.1rem 1rem; overflow-y: auto; }
.modal footer { padding: .75rem 1.1rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.toasts { position: fixed; z-index: 200; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; width: min(440px, calc(100% - 2rem)); }
.toast { background: var(--green-900); color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); font-size: .92rem; animation: up .2s ease-out; }
.toast.bad { background: var(--bad); } .toast.warn { background: var(--warn); }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

/* auth */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; background: radial-gradient(circle at 50% 0%, var(--green-700), var(--green-900) 70%); }
.auth .card { width: min(400px, 100%); padding: 1.5rem; }
.auth .logo { display: block; width: 150px; height: 150px; margin: -.25rem auto .5rem; border-radius: 16px; }
.auth h1 { text-align: center; }

/* print */
.print-head { display: none; }
@media print {
  body { background: #fff; font-size: 11px; }
  .sidebar, .topbar, .bottomnav, .no-print, .toasts { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card, .tablewrap { box-shadow: none; border: 0; padding: 0; }
  .print-head { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--green-800); padding-bottom: 8px; margin-bottom: 12px; }
  .print-head img { width: 54px; height: 54px; }
  table.t th { position: static; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- mobile */
@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .topbar { padding: .55rem .9rem; }
  .topbar .logo-sm { display: block; }
  .content { padding: .9rem .9rem calc(84px + env(safe-area-inset-bottom)); }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: var(--green-900); padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a, .bottomnav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem .2rem .45rem; color: #b9cbc1; text-decoration: none; font-size: .68rem; background: none; border: 0; cursor: pointer; position: relative; }
  .bottomnav a.active { color: #fff; }
  .bottomnav .plus { color: var(--green-900); }
  .bottomnav .plus span.circle { width: 46px; height: 46px; border-radius: 50%; background: var(--gold); display: flex; align-items: center; justify-content: center; margin-top: -20px; box-shadow: 0 4px 12px rgba(0,0,0,.3); color: #fff; }
  .bottomnav .count { position: absolute; top: 2px; right: 22%; margin: 0; }
  .grid.two { grid-template-columns: 1fr; }
  .alerts { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .alertcard { padding: .6rem .7rem; gap: .5rem; } .alertcard svg { display: none; }
  .facts { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .topbar .syncpill { font-size: .72rem; padding: .2rem .5rem; }
  .kpi .value { font-size: 1.3rem; }
  .grid.kpis { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .card { padding: .85rem; }
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td, table.t.cards tfoot { display: block; width: 100%; }
  table.t.cards tr { border-bottom: 1px solid var(--line); padding: .45rem .2rem; }
  table.t.cards td { border: 0; padding: .12rem .5rem; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  table.t.cards td::before { content: attr(data-label); font-size: .75rem; color: var(--muted); text-align: left; font-weight: 600; }
  table.t.cards td:first-child { font-weight: 700; text-align: left; }
  table.t.cards td:first-child::before { display: none; }
  .lines .line { grid-template-columns: 1fr 1fr; }
  .lines .line .name-cell { grid-column: 1 / -1; }
  .lines .head { display: none !important; }
  .modal { max-height: 96vh; }
  .overlay { align-items: flex-end; padding: 0; }
  .overlay .modal { border-radius: 16px 16px 0 0; width: 100%; }
}
