/* Layout: fixed left sidebar (brand + screens) beside a single working column; on phones the sidebar folds into a top bar with a scrolling tab row. Quantities are set in mono. */
:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --side: #0f6b43;
  --side-ink: #ffffff;
  --side-muted: #cdeedd;
  --side-hover: #0b5a38;
  --side-active: #ffffff;
  --side-active-ink: #0b5a38;
  --ink: #13241b;
  --muted: #5a6f63;
  --line: #dfe8e2;
  --accent: #0f7a4a;
  --accent-ink: #ffffff;
  --accent-soft: #e0f3e8;
  --in: #0b7a55;
  --in-soft: #dcf3ea;
  --out: #c0392b;
  --out-soft: #fbe3e0;
  --warn: #8f5a00;
  --warn-soft: #fdf0d3;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --font-num: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --radius: 12px;
}
/* Green and white is the owner's brand, so the page stays light on every device. */
:root { color-scheme: light; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; }
h1, h2 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
svg.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Shell */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
aside { background: var(--side); color: var(--side-ink); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding-inline: 6px; }
.mark { width: 36px; height: 36px; border-radius: 10px; background: var(--side-active); color: var(--side-active-ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; flex: none; }
.brand b { display: block; font-family: var(--font-display); font-size: 1.05rem; line-height: 1.15; }
.brand small { color: var(--side-muted); font-size: 0.78rem; }
.sidenav { display: grid; gap: 2px; }
.sidenav button { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 10px 12px; border-radius: 10px; font-weight: 600; color: var(--side-muted); white-space: nowrap; }
.sidenav button:hover { color: var(--side-ink); background: var(--side-hover); }
.sidenav button[aria-current="page"] { background: var(--side-active); color: var(--side-active-ink); }
.sidenav button:focus-visible { outline-color: var(--side-ink); }
.sidenav .mobileonly { display: none; }
.sidenav .sep { height: 1px; background: var(--side-muted); opacity: 0.35; margin: 8px 6px; }
.addphone { display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 11px 12px; background: var(--side-active); color: var(--side-active-ink); font-weight: 700; }
.addphone:hover { filter: brightness(0.96); }
.addphone:disabled { opacity: 0.5; cursor: not-allowed; }
dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100% - 32px)); max-height: calc(100% - 32px); background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(10, 35, 22, 0.28); }
dialog::backdrop { background: rgba(10, 30, 20, 0.45); }
.dlg { display: grid; gap: 14px; padding: 20px; }
.dlg .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.x { border: 0; background: var(--bg); width: 34px; height: 34px; border-radius: 999px; font-size: 1.2rem; line-height: 1; color: var(--muted); }
.hint { color: var(--muted); font-size: 0.82rem; margin: -6px 0 0; }
.notlisted { justify-self: start; font-size: 0.88rem; }
.sidefoot { margin-top: auto; color: var(--side-muted); font-size: 0.78rem; padding-inline: 6px; }
main { padding-inline: 28px; padding-block: 24px 48px; display: grid; gap: 18px; align-content: start; max-width: 1100px; width: 100%; min-width: 0; }
.pagehead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.pagehead .acts { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 820px) {
  .addphone { display: none; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  aside { position: sticky; height: auto; flex-direction: column; gap: 10px; padding: 12px 16px 8px; border-right: 0; border-bottom: 1px solid var(--line); z-index: 5; }
  .sidenav { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; scrollbar-width: none; }
  .sidenav .sep, .sidefoot { display: none; }
  .sidenav .mobileonly:not([hidden]) { display: flex; }
  .sidenav button { padding: 8px 12px; }
  main { padding-inline: 16px; padding-block: 18px 40px; }
  h1 { font-size: 1.35rem; }
}

/* Summary strip */
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.strip div { padding: 14px 18px; border-left: 1px solid var(--line); min-width: 0; }
.strip div:first-child { border-left: 0; }
.strip b { display: block; font-family: var(--font-num); font-size: 1.6rem; line-height: 1.2; }
.strip span { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.strip .low b { color: var(--warn); }
.strip .zero b { color: var(--out); }
@media (max-width: 560px) {
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip div:nth-child(3) { border-left: 0; }
  .strip div:nth-child(n+3) { border-top: 1px solid var(--line); }
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 14px; min-width: 0; align-content: start; }
.cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); grid-template-areas: "restock brands" "restock recent"; gap: 18px; align-items: start; }
.cols > :nth-child(1) { grid-area: restock; }
.cols > :nth-child(2) { grid-area: brands; }
.cols > :nth-child(3) { grid-area: recent; }
@media (max-width: 1000px) { .cols { grid-template-columns: minmax(0, 1fr); grid-template-areas: "restock" "brands" "recent"; } }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-weight: 500; }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0; }

/* Controls */
.field { display: grid; gap: 5px; min-width: 0; }
.field label { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
input, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
input:focus, select:focus { border-color: var(--accent); outline: none; }
.search { max-width: 260px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 14px; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 5px 10px; font-size: 0.85rem; }
.btn.in { color: var(--in); }
.btn.out { color: var(--out); }
.btn.danger { color: var(--out); }
.btn.danger.armed { background: var(--out); color: var(--surface); border-color: var(--out); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .num { font-size: 0.78rem; opacity: 0.75; margin-left: 4px; }

/* Phone list */
.items { display: grid; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 12px 2px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item[data-row] { cursor: pointer; border-radius: 10px; margin-inline: -8px; padding-inline: 10px; }
.item[data-row]:hover { background: var(--bg); }
.item .name { font-weight: 600; overflow-wrap: anywhere; }
.item .meta { color: var(--muted); font-size: 0.82rem; }
.brandtag { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.qty { text-align: right; min-width: 72px; }
.qty b { font-family: var(--font-num); font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.qty small { display: block; color: var(--muted); font-size: 0.72rem; }
.acts { display: flex; gap: 6px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; margin-left: 6px; vertical-align: 2px; }
.pill.ok { background: var(--in-soft); color: var(--in); }
.pill.low { background: var(--warn-soft); color: var(--warn); }
.pill.faulty { background: var(--out-soft); color: var(--out); }
button.pill { border: 0; font: inherit; font-size: 0.72rem; font-weight: 700; line-height: inherit; cursor: pointer; }
button.pill:hover { text-decoration: underline; }
.pill.zero { background: var(--out-soft); color: var(--out); }
@media (max-width: 560px) {
  .item.withacts { grid-template-columns: minmax(0, 1fr) auto; }
  .item.withacts .acts { grid-column: 1 / -1; }
  .item.withacts .acts .btn { flex: 1; justify-content: center; }
}

/* Brand bars */
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 90px minmax(0, 1fr) 48px; gap: 10px; align-items: center; font-size: 0.9rem; }
.bar .track { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar .num { text-align: right; font-weight: 700; }

/* Recent list */
.recent { display: grid; }
.recent div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 0.92rem; }
.recent div:first-child { border-top: 0; }
.recent small { color: var(--muted); display: block; font-size: 0.78rem; }
.recent .q { font-family: var(--font-num); font-weight: 700; }
.q.in { color: var(--in); }
.q.out { color: var(--out); }

/* Record form */
.toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle button { border: 2px solid var(--line); background: var(--surface); border-radius: 12px; padding: 14px; font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.toggle button[aria-pressed="true"][data-type="in"] { border-color: var(--in); background: var(--in-soft); color: var(--in); }
.toggle button[aria-pressed="true"][data-type="out"] { border-color: var(--out); background: var(--out-soft); color: var(--out); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.preview { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px; border-radius: 12px; background: var(--bg); border: 1px dashed var(--line); font-family: var(--font-num); font-size: 1.6rem; flex-wrap: wrap; }
.preview small { font-family: var(--font-body); font-size: 0.8rem; color: var(--muted); width: 100%; text-align: center; }
.preview .arrow { color: var(--muted); font-size: 1.1rem; }
.preview .after.in { color: var(--in); }
.preview .after.out { color: var(--out); }
.err { color: var(--out); font-weight: 600; min-height: 1.2em; margin: 0; }

/* History table */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.r, th.r { text-align: right; }
td.qin { color: var(--in); font-weight: 700; }
td.qout { color: var(--out); font-weight: 700; }
td .note { color: var(--muted); font-size: 0.82rem; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters select, .filters input { width: auto; min-width: 140px; flex: 1 1 140px; }

/* Brand tiles: Phones in stock opens on one tile per brand, so the page stays short however many models there are */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 16px; display: grid; gap: 6px; }
.tile:hover { border-color: var(--accent); }
.tile .tname { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
.tile .tcount { font-family: var(--font-num); font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.tile .tsub { color: var(--muted); font-size: 0.82rem; }
.tile .tflags { display: flex; gap: 6px; flex-wrap: wrap; min-height: 20px; }
.tile .tflags .pill { margin-left: 0; }
.crumb { display: flex; align-items: center; gap: 8px; font-weight: 600; flex-wrap: wrap; }
.crumb b { font-family: var(--font-display); font-size: 1.1rem; }
@media (max-width: 420px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tile .tcount { font-size: 1.5rem; } }
/* New / Used switch */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 6px 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.condrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.cond { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin-left: 6px; vertical-align: 2px; border: 1px solid var(--line); color: var(--muted); }
.cond.used { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty strong { color: var(--ink); font-family: var(--font-display); font-size: 1.1rem; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; max-width: calc(100% - 32px); z-index: 10; }
/* Sign-in screen covers the app until a staff member signs in */
.login { position: fixed; inset: 0; z-index: 20; background: var(--side); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.login form { background: var(--surface); border-radius: 16px; padding: 24px; width: min(380px, 100%); display: grid; gap: 14px; box-shadow: 0 24px 60px rgba(10, 35, 22, 0.28); }
.login .brand b { color: var(--ink); }
.login .brand small { color: var(--muted); }
.login .mark { background: var(--side); color: var(--side-ink); }
.login .btn { justify-content: center; padding: 12px; }
.login .hint { margin: 0; }
.signout { margin-top: 8px; color: var(--side-muted); text-decoration: underline; font-weight: 500; }
.link.small { font-size: 0.85rem; }

/* Activity log (owner only) */
.log { display: grid; }
.logrow { display: grid; grid-template-columns: 8.5rem 6rem minmax(0, 1fr); gap: 10px; padding: 9px 0 9px 10px; border-top: 1px solid var(--line); border-left: 3px solid var(--line); font-size: 0.92rem; }
.logrow:first-child { border-top: 0; }
.logrow.added { border-left-color: var(--in); }
.logrow.deleted { border-left-color: var(--out); }
.logrow.changed { border-left-color: var(--warn); }
.logrow .when { color: var(--muted); font-size: 0.82rem; }
.logrow .who { font-weight: 600; overflow-wrap: anywhere; }
.logrow .what { overflow-wrap: anywhere; }
@media (max-width: 820px) {
  .logrow { grid-template-columns: auto minmax(0, 1fr); }
  .logrow .what { grid-column: 1 / -1; }
}
