/* =========================================================
   Tokens
   ========================================================= */
:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #edf1f4;
  --border: #e0e5ea;
  --border-strong: #cbd3db;
  --text: #172029;
  --text-2: #3e4a56;
  --muted: #6d7a86;

  --brand: #1f5f8b;
  --brand-hover: #184b6e;
  --brand-soft: #e5eff7;
  --brand-ink: #174a6c;
  --bar-1: #123c5a;
  --bar-2: #1f5f8b;

  --green: #2f7a4f;  --green-bg: #e5f3ea;
  --amber: #a5620a;  --amber-bg: #fcf0dc;
  --red: #b42318;    --red-bg: #fde8e6;
  --blue: #2d5fa8;   --blue-bg: #e6eefb;
  --violet: #6b46b8; --violet-bg: #efe9fb;
  --teal: #13737a;   --teal-bg: #e0f3f3;
  --pink: #b03a76;   --pink-bg: #fbe6f0;
  --gray: #6b625c;   --gray-bg: #efebe7;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgb(15 25 35 / .05);
  --shadow: 0 1px 2px rgb(15 25 35 / .04), 0 4px 16px rgb(15 25 35 / .06);
  --shadow-lg: 0 24px 64px rgb(10 20 30 / .22);
  --font: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1418; --surface: #161d23; --surface-2: #1b232a; --surface-3: #232d35;
    --border: #2a353f; --border-strong: #3a4753;
    --text: #eef2f5; --text-2: #c9d2da; --muted: #8d9aa6;
    --brand: #6fb3e0; --brand-hover: #8cc4ea; --brand-soft: #142a3a; --brand-ink: #9fcdec;
    --bar-1: #0c2536; --bar-2: #143a54;
    --green: #6cc795; --green-bg: #183223; --amber: #e9b45e; --amber-bg: #372912;
    --red: #f2837a; --red-bg: #3d1a18; --blue: #86adf0; --blue-bg: #1a2741;
    --violet: #b59cf0; --violet-bg: #2a2142; --teal: #6fcfd3; --teal-bg: #133234;
    --pink: #ee8fbd; --pink-bg: #3a1a2a; --gray: #b3a9a5; --gray-bg: #2b2526;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .3); --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 18px rgb(0 0 0 / .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1418; --surface: #161d23; --surface-2: #1b232a; --surface-3: #232d35;
  --border: #2a353f; --border-strong: #3a4753;
  --text: #eef2f5; --text-2: #c9d2da; --muted: #8d9aa6;
  --brand: #6fb3e0; --brand-hover: #8cc4ea; --brand-soft: #142a3a; --brand-ink: #9fcdec;
  --bar-1: #0c2536; --bar-2: #143a54;
  --green: #6cc795; --green-bg: #183223; --amber: #e9b45e; --amber-bg: #372912;
  --red: #f2837a; --red-bg: #3d1a18; --blue: #86adf0; --blue-bg: #1a2741;
  --violet: #b59cf0; --violet-bg: #2a2142; --teal: #6fcfd3; --teal-bg: #133234;
  --pink: #ee8fbd; --pink-bg: #3a1a2a; --gray: #b3a9a5; --gray-bg: #2b2526;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .3); --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 18px rgb(0 0 0 / .25);
}

/* =========================================================
   Base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -.015em; line-height: 1.2; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; padding: 12px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tone-text-amber { color: var(--amber); font-weight: 600; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

.container { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; outline: none; }

/* =========================================================
   Top bar
   ========================================================= */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(100deg, var(--bar-1), var(--bar-2));
  box-shadow: 0 6px 24px rgb(10 40 70 / .18);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; flex: none; }
.brand-mark img { width: 36px; height: 36px; display: block; filter: drop-shadow(0 1px 2px rgb(0 0 0 / .25)); }
.nav { display: flex; gap: 4px; margin: 0 auto; padding: 4px; border-radius: 12px; background: rgb(0 0 0 / .14); }
.nav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9px;
  color: rgb(255 255 255 / .82); font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav a .ic { width: 16px; height: 16px; opacity: .85; }
.nav a:hover { color: #fff; background: rgb(255 255 255 / .1); }
.nav a.active { background: #fff; color: #123c5a; box-shadow: 0 2px 8px rgb(0 0 0 / .15); }
:root[data-theme="dark"] .nav a.active { background: rgb(255 255 255 / .92); }
.theme-toggle { color: #fff; background: rgb(255 255 255 / .12); border-color: transparent; }
.theme-toggle:hover { background: rgb(255 255 255 / .2); color: #fff; }
.when-dark { display: none; }
:root[data-theme="dark"] .when-dark { display: block; }
:root[data-theme="dark"] .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .when-dark { display: block; }
  :root:not([data-theme="light"]) .when-light { display: none; }
}

/* =========================================================
   Buttons & inputs
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn .ic { width: 16px; height: 16px; }
.btn.sm { height: 31px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgb(20 60 100 / .25), inset 0 1px 0 rgb(255 255 255 / .12); }
:root[data-theme="dark"] .btn-primary { color: #0b1a24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #0b1a24; } }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn-soft:hover { filter: brightness(.97); }
.btn-danger { background: var(--red); color: #fff; }
.danger-text { color: var(--red) !important; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.sm:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm .ic { width: 16px; height: 16px; }

.link { display: inline-flex; align-items: center; gap: 2px; color: var(--brand-ink); font-weight: 600; font-size: 13px; background: none; border: 0; padding: 0; }
.link .ic { width: 15px; height: 15px; }
.link:hover { text-decoration: underline; }

input, select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236d7a86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }

/* =========================================================
   Page structure
   ========================================================= */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; font-weight: 800; }
.sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15.5px; font-weight: 700; }
.pill-count { font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-2); padding: 2px 9px; border-radius: 99px; margin-right: auto; margin-left: 8px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
/* Grid/flex children may shrink below their content's natural width (otherwise phones get sideways scrolling) */
.grid-2 > *, .stats > *, .detail-grid > *, .card-grid > *, .acq-main > *, .form-grid > *, .choice-grid > *, .sp-grid > * { min-width: 0; }
.grid-2 > .panel { margin-bottom: 20px; }
.stack > .panel { margin-bottom: 20px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 170px; }
.search { position: relative; flex: 1; min-width: 220px; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; pointer-events: none; }
.search input { padding-left: 38px; }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 11px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text-2);
}
.chip .ic { width: 14px; height: 14px; color: var(--muted); }
.chip b { color: var(--text); }
button.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip.active .ic { color: inherit; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 34px; height: 20px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .15s; }
.switch span::after { content: ''; position: absolute; width: 16px; height: 16px; top: 2px; left: 2px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow-sm); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; letter-spacing: .01em; }
.tone-green { color: var(--green); background: var(--green-bg); }
.tone-amber { color: var(--amber); background: var(--amber-bg); }
.tone-red { color: var(--red); background: var(--red-bg); }
.tone-blue { color: var(--blue); background: var(--blue-bg); }
.tone-violet { color: var(--violet); background: var(--violet-bg); }
.tone-teal { color: var(--teal); background: var(--teal-bg); }
.tone-pink { color: var(--pink); background: var(--pink-bg); }
.tone-gray { color: var(--gray); background: var(--gray-bg); }


/* =========================================================
   Dashboard
   ========================================================= */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 6px;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.stat-top { display: flex; justify-content: space-between; align-items: center; }
.stat-label { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; }
.stat-icon .ic { width: 17px; height: 17px; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12.5px; color: var(--muted); }
.stat-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.stat-warn .stat-icon { background: var(--amber-bg); color: var(--amber); }
.stat-warn .stat-value { color: var(--amber); }

.due-list, .stock-list, .doc-mini { list-style: none; margin: 0; padding: 0; }
.due-list li, .stock-list li, .doc-mini li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.due-list li:first-child, .stock-list li:first-child, .doc-mini li:first-child { border-top: 0; padding-top: 2px; }
.due-who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.due-who b, .stock-list b, .doc-mini b { display: block; font-weight: 700; }
.due-who small, .stock-list small, .doc-mini small { display: block; color: var(--muted); font-size: 12.5px; }
.due-who:hover b { color: var(--brand-ink); }
.due-when { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.with-icon { display: flex; align-items: center; gap: 8px; }
.h-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; }
.h-icon .ic { width: 15px; height: 15px; }
.panel-head:has(+ .panel-sub) { margin-bottom: 2px; }
.panel-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.compliance { grid-template-columns: 1.45fr 1fr; align-items: start; }
.panel-alert { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }


/* Phones: 16px form fields stop iOS Safari zooming in on every tap into a field */
@media (max-width: 760px) {
  input, select, textarea { font-size: 16px; }
  .scan-input { font-size: 15px; }
  .table.articles input, .cell-input { font-size: 16px; }
}

.doc-ico { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; flex: none; }
.doc-ico .ic { width: 17px; height: 17px; }

/* =========================================================
   Timeline / events
   ========================================================= */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 8px; border-radius: 10px; position: relative; }
.event-row:hover { background: var(--surface-2); }
.event-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.event-icon .ic { width: 16px; height: 16px; }
.event-main { flex: 1; min-width: 0; padding-top: 5px; }
.event-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-weight: 600; }
.event-detail { color: var(--muted); font-weight: 500; font-size: 13.5px; }
.event-detail b { color: var(--text); font-weight: 700; }
.event-notes { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }
.event-when { color: var(--muted); font-size: 12.5px; padding-top: 7px; white-space: nowrap; }
.row-actions { opacity: 0; transition: opacity .15s; padding-top: 1px; }
.event-row:hover .row-actions, .event-row:focus-within .row-actions { opacity: 1; }
.strong-link { font-weight: 700; }
.strong-link:hover { color: var(--brand-ink); text-decoration: underline; }
.dot { color: var(--muted); }

.timeline .tl-group { position: relative; }
.timeline .tl-group + .tl-group { margin-top: 10px; }
.tl-date { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 8px; position: sticky; top: 64px; background: var(--surface); z-index: 1; }
.timeline .event-list { position: relative; }
.timeline .event-list::before { content: ''; position: absolute; left: 23px; top: 18px; bottom: 18px; width: 2px; background: var(--border); border-radius: 2px; }
.timeline .event-icon { position: relative; z-index: 1; box-shadow: 0 0 0 4px var(--surface); }
.timeline .event-row:hover .event-icon { box-shadow: 0 0 0 4px var(--surface-2); }

/* =========================================================
   Cards
   ========================================================= */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 14px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card-top { display: flex; align-items: flex-start; gap: 12px; }
.card h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.sci { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); min-height: 43px; }
.sex { font-size: 14px; font-weight: 700; }
.sex-male { color: var(--blue); }
.sex-female { color: var(--pink); }
.sex-unknown { color: var(--muted); font-size: 12px; }
.group-pill { font-size: 11.5px; font-weight: 800; padding: 1px 7px; border-radius: 99px; background: var(--blue-bg); color: var(--blue); font-variant-numeric: tabular-nums; }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.mini-stats div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.mini-stats dt { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.mini-stats dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.param-row { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.param-row span { display: inline-flex; align-items: center; gap: 5px; }
.param-row .ic { width: 15px; height: 15px; color: var(--muted); }


/* documents */
.card-grid.docs { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.doc-card { padding: 0; overflow: hidden; gap: 0; }
.doc-thumb { height: 120px; background: linear-gradient(135deg, var(--surface-3), var(--surface-2)); display: grid; place-items: center; position: relative; color: var(--muted); border-bottom: 1px solid var(--border); }
.doc-thumb .ic { width: 38px; height: 38px; stroke-width: 1.5; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb .ext { position: absolute; bottom: 12px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; background: var(--brand); color: #fff; padding: 2px 7px; border-radius: 5px; }
.doc-body { padding: 14px 16px 0; display: flex; flex-direction: column; gap: 6px; }
.doc-body h3 { display: block; font-size: 15px; }
.doc-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.doc-card .card-foot { margin: 12px 16px 0; padding: 8px 0 10px; }

.form-intro { margin-bottom: 16px; }
.form-heading { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--border); gap: 2px; }
.form-heading h4 { font-size: 15px; font-weight: 800; margin: 0; }

/* ---- sign-in, user menu, users & groups ---- */
body.signed-out .nav, body.signed-out .settings-link, body.signed-out .user-menu { display: none; }
body.signed-out .theme-toggle { margin-left: auto; }
.auth-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; padding: 24px 0; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 24px; font-weight: 800; }
.auth-card > .muted { margin-top: -10px; }
.auth-mark { width: 56px; height: 56px; }
.auth-mark img { width: 56px; height: 56px; filter: none; }
.auth-card .form-error { margin: 0; }
.auth-submit, .auth-sso { width: 100%; height: 44px; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.user-menu { position: relative; margin-left: 8px; }
.user-btn { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgb(255 255 255 / .55); background: rgb(255 255 255 / .16); color: #fff; font-weight: 800; font-size: 13px; }
.user-btn:hover { background: rgb(255 255 255 / .26); }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; }
.user-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-head b { display: block; }
.user-head small { color: var(--muted); font-size: 12px; }
.user-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 9px; font-size: 14px; text-align: left; color: var(--text); }
.user-item:hover { background: var(--surface-3); }
.user-item .ic { width: 16px; height: 16px; color: var(--muted); }
.settings-link + .theme-toggle, .user-menu + .settings-link { margin-left: 8px; }
.panel-head.pad { padding: 16px 20px 0; }
.perm-table td, .perm-table th { white-space: nowrap; }
.perm-grid { display: flex; flex-direction: column; gap: 6px; }
.perm-grid.is-admin { opacity: .45; pointer-events: none; }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.perm-row > span { font-weight: 600; font-size: 13.5px; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 9px; gap: 2px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); }
.check-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 200px; overflow: auto; }
.check { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 99px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.check:has(input:disabled) { opacity: .75; cursor: default; }
form.read-only input:disabled, form.read-only select:disabled, form.read-only textarea:disabled { opacity: 1; background: var(--surface-2); color: var(--text); cursor: default; }
@media (max-width: 760px) {
  .perm-row { flex-direction: column; align-items: flex-start; }
}

/* ---- label printing ---- */
.label-opts { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.copies { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.copies input { width: 70px; height: 34px; }
.copies select { height: 34px; width: auto; }
.copies select.needs-value { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.copies .req { color: var(--red); }
.specimen-required { display: flex; align-items: center; gap: 6px; margin: -4px 0 10px; font-size: 13px; font-weight: 600; color: var(--red); }
.specimen-required .ic { width: 15px; height: 15px; }
.label-preview { width: 100%; height: 300px; border: 1px solid var(--border); border-radius: 12px; background: #e7e3df; display: block; }
.print-help { margin-top: 12px; font-size: 13.5px; color: var(--text-2); }
.print-help summary { cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; color: var(--brand-ink); }
.print-help summary .ic { width: 15px; height: 15px; }
.print-help ol { margin: 8px 0 6px; padding-left: 20px; }
.print-help li { margin: 3px 0; }
.print-frame { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }

/* ---- asset tags & scanning ---- */
.code-chip { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); letter-spacing: .02em; white-space: nowrap; }
.code-chip.lg { font-size: 13px; padding: 3px 9px; }
.asset-card .card-top { flex-wrap: wrap; }
.id-settings { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.id-settings .field { width: 140px; }
.id-settings input { text-transform: uppercase; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-weight: 700; }
.batch .batch-common { margin-bottom: 14px; }
.scan-box { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--brand); border-radius: 14px; background: var(--brand-soft); }
.scan-box > .ic { width: 26px; height: 26px; color: var(--brand-ink); flex: none; }
.scan-input { flex: 1; height: 44px; font-size: 17px; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: .03em; border-color: transparent; background: var(--surface); }
.scan-cam { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.scan-cam video { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; background: #111; }
.scan-feedback { min-height: 28px; display: flex; align-items: center; gap: 6px; margin: 8px 2px 4px; font-size: 14px; }
.scan-feedback .ic { width: 17px; height: 17px; }
.scan-feedback.ok { color: var(--green); }
.scan-feedback.warn { color: var(--amber); }
.scan-feedback.err { color: var(--red); }
.scan-feedback b { color: var(--text); }
.scan-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.batch-list { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.batch-list .table th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.batch-list tr.flash td { animation: rowflash 1.2s ease-out; }
@keyframes rowflash { from { background: var(--green-bg); } to { background: transparent; } }
.cell-input { width: 90px; height: 30px; text-align: right; padding: 0 8px; }
.batch-empty { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 26px; color: var(--muted); }
.batch-empty .ic { width: 22px; height: 22px; }
.batch-count { font-weight: 600; }

/* ---- settings ---- */
.settings-link + .theme-toggle { margin-left: 8px; }
.settings-link.active { background: #fff; color: #123c5a; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--border-strong); }
.choice.on { border-color: var(--brand); background: var(--brand-soft); }
.choice input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
.choice b { display: block; font-size: 14.5px; }
.choice small { display: block; color: var(--text-2); font-size: 13px; margin-top: 3px; line-height: 1.45; }

/* ---- asset photos ---- */
.avatar.has-photo { padding: 0; overflow: hidden; background: var(--surface-3); }
.avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-photo { border: 0; padding: 0; background: none; border-radius: 20px; cursor: zoom-in; }
.hero-photo:hover .avatar { box-shadow: 0 0 0 3px var(--brand-soft); }
.tone-text-red { color: var(--red); font-weight: 600; }
.photos-panel { transition: box-shadow .15s, border-color .15s; }
.photos-panel.drag { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.photos-panel .panel-head .pill-count { margin-right: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo-tile { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: var(--surface-3); cursor: zoom-in; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.photo-tile:hover img { transform: scale(1.04); }
.photo-badge { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgb(0 0 0 / .55); color: #ffd25e; }
.photo-badge .ic { width: 12px; height: 12px; fill: currentColor; }
.photo-badge.cam { left: auto; right: 6px; color: #fff; }
.photo-badge.cam .ic { fill: none; }
.photo-empty { display: flex; align-items: center; gap: 10px; padding: 18px; border: 1.5px dashed var(--border-strong); border-radius: 12px; color: var(--muted); font-size: 13.5px; }
.photo-empty .ic { width: 22px; height: 22px; flex: none; }

.dialog.dialog-camera { width: min(760px, calc(100vw - 32px)); }
.cam-stage { position: relative; border-radius: 14px; overflow: hidden; background: #111; aspect-ratio: 4 / 3; display: grid; place-items: center; }
.cam-stage video, .cam-stage .cam-shot { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.cam-bar { display: flex; align-items: center; gap: 12px; margin-top: 14px; min-height: 64px; }
.cam-device { width: auto; max-width: 240px; }
.cam-capture { width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--brand); background: var(--surface); box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 32px var(--brand); transition: transform .1s; }
.cam-capture:hover:not(:disabled) { transform: scale(1.05); }
.cam-capture:active:not(:disabled) { transform: scale(.94); }
.cam-capture:disabled { opacity: .4; cursor: not-allowed; }
.cam-count { min-width: 60px; text-align: right; }
.cam-review { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.cam-review .cam-caption { flex: 1 1 220px; }

.dialog.dialog-viewer { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: #111; color: #eee; }
.viewer { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.viewer-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; background: #0c0c0c; }
.viewer-stage img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; display: block; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgb(255 255 255 / .14); color: #fff; display: grid; place-items: center; }
.viewer-nav:hover { background: rgb(255 255 255 / .26); }
.viewer-nav.prev { left: 12px; } .viewer-nav.next { right: 12px; }
.viewer-close { position: absolute; top: 10px; right: 10px; background: rgb(0 0 0 / .5); border-color: transparent; color: #fff; }
.viewer-close:hover { background: rgb(0 0 0 / .7); color: #fff; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: var(--surface); color: var(--text); flex-wrap: wrap; }
.viewer-caption { height: 34px; border-color: transparent; background: transparent; font-weight: 600; padding-left: 6px; }
.viewer-caption:hover { border-color: var(--border); }
.viewer-meta { padding-left: 6px; }
.viewer-bar [data-v="primary"] .ic { fill: #f5b301; color: #f5b301; }


.dialog.dialog-lg { width: min(820px, calc(100vw - 32px)); }

/* table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.clickable { cursor: pointer; transition: background .1s; }
.table tr.clickable:hover { background: var(--surface-2); }
.table td.actions { width: 1%; padding: 8px 10px; }

/* =========================================================
   Asset detail
   ========================================================= */
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; font-size: 13.5px; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }
.back-link .ic { width: 16px; height: 16px; }
.hero { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.hero-main { flex: 1; min-width: 220px; }
.hero-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-title h1 { font-size: 30px; font-weight: 800; }
.detail-grid { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.kv { margin: 0; display: grid; gap: 0; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.kv div:first-child { border-top: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.notes { margin-top: 12px; padding: 12px; background: var(--surface-2); border-radius: 10px; font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; }
.param-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.param-tiles div { display: flex; flex-direction: column; gap: 3px; padding: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.param-tiles .ic { color: var(--brand-ink); width: 17px; height: 17px; }
.param-tiles b { font-size: 14px; }
.param-tiles small { color: var(--muted); font-size: 11.5px; }
.danger-zone { text-align: center; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: color-mix(in srgb, var(--brand) 12%, transparent); }
.chart .pt { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }

/* =========================================================
   Empty / loading
   ========================================================= */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty > .ic { width: 40px; height: 40px; padding: 9px; border-radius: 12px; background: var(--surface-3); color: var(--text-2); margin-bottom: 6px; }
.empty h3 { color: var(--text); font-size: 16px; }
.empty .btn { margin-top: 10px; }
.loading { display: flex; justify-content: center; gap: 6px; padding: 80px 0; }
.loading span { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); animation: bounce 1s infinite ease-in-out; opacity: .4; }
.loading span:nth-child(2) { animation-delay: .15s; }
.loading span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.7); opacity: .3; } 40% { transform: scale(1); opacity: 1; } }
.enter { animation: enter .28s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* =========================================================
   Dialog
   ========================================================= */
.dialog {
  border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog-sm { width: min(400px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(10 15 20 / .45); backdrop-filter: blur(3px); }
.dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.dialog-body { padding: 22px 24px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dialog-head h2 { font-size: 19px; font-weight: 800; }
.dialog-head p { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.dialog-head .icon-btn { width: 34px; height: 34px; border-color: transparent; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.half { grid-column: span 1; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.req { color: var(--brand); }
.hint { color: var(--muted); font-size: 12px; }
.form-error { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--red-bg); color: var(--red); font-size: 13.5px; font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; align-items: center; }
.confirm { text-align: center; }
.confirm p { font-size: 15px; margin: 10px 0 0; }
.confirm .dialog-actions { justify-content: center; }
.confirm-icon { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto; display: grid; place-items: center; background: var(--red-bg); color: var(--red); }

.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border: 1.5px dashed var(--border-strong); border-radius: 12px; cursor: pointer; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; }
.dropzone .ic { width: 24px; height: 24px; color: var(--brand-ink); }
.dropzone .dz-text { font-weight: 600; color: var(--text); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--green); background: var(--green-bg); }
.field label.dropzone { font-size: 12.5px; font-weight: 500; }

/* toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 16px; border-radius: 12px; background: var(--text); color: var(--surface); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .2s ease-out; transition: opacity .3s, transform .3s; }
.toast .ic { width: 17px; height: 17px; color: var(--green); }
.toast-error .ic { color: var(--red); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1020px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .nav a { padding: 8px 10px; }
  .nav a .ic { display: none; }
}
@media (max-width: 760px) {
  .container { padding: 20px 16px 96px; }
  .topbar-inner { padding: 10px 16px; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .page-head h1 { font-size: 24px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 20px rgb(0 0 0 / .08); justify-content: space-around; gap: 0;
  }
  .nav a { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 4px; color: var(--muted); flex: 1; min-width: 0; }
  .nav a .ic { display: block; width: 20px; height: 20px; }
  .nav a:hover { background: transparent; color: var(--text); }
  .nav a.active { background: var(--brand-soft); color: var(--brand-ink); box-shadow: none; }
  .theme-toggle { margin-left: auto; }
  .tl-date { top: 54px; }
  .toasts { bottom: 84px; left: 16px; right: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.half { grid-column: 1 / -1; }
  .toolbar select { flex: 1; min-width: 0; }
  .search { min-width: 100%; }
  .due-when { display: none; }
  .row-actions { opacity: 1; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 24px; }
  .spark { display: none; }
  .param-tiles { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }


@keyframes spin { to { transform: rotate(360deg); } }

.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 13px; }

.tab-count:not(:empty) { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); }

.tbl-toolbar { display: flex; align-items: center; gap: 14px; padding: 9px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search.sm { flex: 0 1 220px; min-width: 150px; }
.search.sm input { height: 32px; border-radius: 99px; font-size: 13px; padding-left: 32px; }
.search.sm .ic { width: 15px; height: 15px; left: 11px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--text-2); font-size: 13px; font-weight: 600; padding: 4px 6px; border-radius: 7px; }
.link-btn .ic { width: 15px; height: 15px; }
.link-btn:hover { background: var(--surface-3); color: var(--text); }
.pager { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.pager b { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: 99px; color: var(--text); font-weight: 600; margin: 0 2px; }

.notify-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 0.8fr); gap: 12px; margin-top: 12px; }
.notify-alerts { display: grid; gap: 8px; margin-top: 14px; }
.notify-alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.notify-alert .inline-check span { display: flex; flex-direction: column; }
.notify-alert small { color: var(--muted); font-size: 12px; }
.notify-topic { display: flex; align-items: center; gap: 8px; }
.notify-topic input { width: 200px; height: 34px; }
.inline-check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.inline-check input { margin-top: 3px; }
.notify-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.notify-actions .muted { margin-left: auto; }
@media (max-width: 760px) { .notify-grid { grid-template-columns: 1fr; } .notify-topic input { width: 100%; } .notify-topic { width: 100%; } }
.inline-check input[type="checkbox"] { width: 17px; height: 17px; min-height: 0; flex: none; padding: 0; margin: 2px 0 0; accent-color: var(--brand); }
.notify-grid > .field { grid-column: auto; }
/* Settings → Share links */
.share-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.share-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.share-list li .grow { flex: 1; min-width: 200px; }
.share-list li small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.share-list li.inactive { opacity: .6; }
.share-scope { display: grid; gap: 6px; padding-top: 6px; }
.share-species-list { display: grid; gap: 6px; max-height: 240px; overflow: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.share-qr { display: grid; place-items: center; padding: 10px; }
.share-qr img { width: 240px; height: 240px; background: #fff; border-radius: 12px; padding: 8px; }
.share-qr-url { text-align: center; word-break: break-all; color: var(--muted); }

.inline-check input[type="radio"] { width: 17px; height: 17px; min-height: 0; flex: none; padding: 0; margin: 2px 0 0; accent-color: var(--brand); }
.share-scope .inline-check { align-items: center; }

.section-title { font-size: 15px; margin: 18px 0 10px; color: var(--text-2); }

.task-list { list-style: none; margin: 0; padding: 0; display: grid; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.task-row:first-child { border-top: 0; }
.task-row .grow { flex: 1; min-width: 0; display: grid; }
.task-row small { font-size: 12.5px; }

.offline-bar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px;
               background: var(--amber); color: #fff; font-size: 13.5px; font-weight: 600; }
.offline-bar .ic { width: 16px; height: 16px; }

.howto-steps { margin: 0; padding-left: 20px; font-size: 13.5px; display: grid; gap: 4px; }
.code-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 12px; overflow-x: auto; white-space: pre; margin: 0; }

.paste-box { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 12px 14px; border: 1.5px dashed var(--border-strong, var(--border));
             border-radius: 10px; color: var(--muted); font-size: 13px; cursor: text; caret-color: transparent; outline: none; }
.paste-box:focus { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.paste-box .ic { width: 16px; height: 16px; flex: none; }
.paste-box img { display: none; }

.storage-cards { display: grid; gap: 12px; }
.storage-store { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.storage-head { display: flex; align-items: flex-start; gap: 12px; }
.storage-head .grow { flex: 1; min-width: 0; }
.storage-head code { word-break: break-all; }
.storage-steps { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; counter-reset: s; }
.storage-steps li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.storage-steps li > span { min-width: 130px; }
.storage-steps li small { color: var(--muted); }
.storage-steps .ic { width: 16px; height: 16px; flex: none; }
.storage-steps .waiting { color: var(--muted); }
.storage-steps .running .ic { color: var(--brand-ink); animation: spin 1s linear infinite; }
.storage-steps .running small { color: var(--brand-ink); }
.storage-steps .ok .ic { color: var(--green); }
.storage-steps .failed { color: var(--red); }
.storage-steps .failed small { color: var(--red); font-weight: 600; }
.storage-steps .skipped { color: var(--muted); opacity: .6; }
.storage-verdict { margin: 10px 0 0; font-size: 13px; font-weight: 600; }
.storage-verdict.ok { color: var(--green); }
.storage-verdict.bad { color: var(--red); }

.printer-status { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; }
.printer-status .ic { width: 15px; height: 15px; flex: none; }
.printer-status.warn { color: var(--amber, #b45309); }

/* Settings → Label printer */
.queue-head { display: flex; align-items: center; gap: 8px; margin: 18px 0 6px; }
.queue-head h3 { margin: 0; font-size: 14px; }
[data-printer-panel] .task-row .grow small.danger-text { display: block; }
.copy-code { display: inline-block; margin-top: 4px; padding: 4px 8px; border-radius: 6px; background: var(--surface-2); user-select: all; word-break: break-all; }

.storage-auto { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 12px; }
.storage-every { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
.storage-every select { width: auto; }
.storage-last { display: flex; align-items: flex-start; gap: 6px; margin: 8px 0 0; font-size: 13px; }
.storage-last .ic { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.storage-last.ok { color: var(--green, #15803d); }
.storage-last.bad { color: var(--red); }

/* entries saved offline, waiting to be sent */
.offline-bar.pending { background: var(--surface-2); color: var(--text); border-bottom: 1px solid var(--border); }
.offline-bar .link { font-weight: 700; white-space: nowrap; }

.task-row .grow > small:not(.muted) + small.muted { display: block; }

.task-row .grow > small:not(.muted) { display: block; }

.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.status-tile { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); min-width: 0; }
.status-tile > div { display: grid; gap: 2px; min-width: 0; }
.status-tile small { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.status-tile b { font-size: 15px; }
.status-tile .muted { overflow-wrap: anywhere; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 5px; background: var(--muted); }
.status-tile.good .status-dot { background: var(--green, #15803d); }
.status-tile.warn .status-dot { background: var(--amber); }
.status-tile.bad .status-dot { background: var(--red); }
.status-tile.bad { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); }

/* System status: test results */
.test-row { flex-wrap: wrap; }
.test-checks { flex-basis: 100%; margin-left: 40px; font-size: 13px; }
.test-checks summary { cursor: pointer; color: var(--muted); }
.test-checks ul { margin: 6px 0 0; padding-left: 0; list-style: none; display: grid; gap: 2px; }

/* storage cards: how much each holds */
.storage-usage { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.usage-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.usage-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.usage-bar span { display: block; height: 100%; background: var(--green, #15803d); }
.usage-bar.warn span { background: var(--amber); }
.usage-bar.bad span { background: var(--red); }
.usage-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.usage-cap { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; font-weight: 400; }
.usage-cap input { width: 90px; }

/* label dialogs: where to print */
.print-target { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 10px 0 0; }
.target-pick { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.target-pick .ic { width: 16px; height: 16px; }
.target-pick select { width: auto; max-width: 100%; font-weight: 400; }

.scan-inbox { margin-bottom: 18px; border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); }
.scan-inbox .panel-head h2 { display: flex; align-items: center; gap: 8px; }
.scan-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.scan-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); min-width: 0; }
.scan-main { flex: 1; min-width: 0; }
.scan-main h3 { margin: 0; font-size: 15px; }
.scan-read { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 0; }
.scan-read .ic { width: 15px; height: 15px; }
.scan-item .stepper { flex: none; display: flex; align-items: center; gap: 6px; }

@media (max-width: 640px) {
  .scan-item { flex-direction: column; align-items: stretch; }
  .scan-item .stepper { justify-content: flex-end; }
}

/* forms: a list of checkboxes (e.g. a station's services) */
.choice-list { display: grid; gap: 6px; }
.choice-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 400; }
.choice-item input { margin-top: 3px; width: auto; }
.choice-item span { display: grid; gap: 2px; }
.choice-item:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); }

/* Take photo: choose a camera station or this device's camera */
.cam-choices { display: grid; gap: 8px; }
.cam-choice { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
.cam-choice:hover { border-color: var(--brand); }
.cam-choice span { display: grid; gap: 2px; }
.cam-stage .cam-live { width: 100%; height: 100%; object-fit: contain; display: block; }

/* System status → Stations: name, online and services on one line */
.station-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* Stations: the one-line install command */
.install-box { border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--border)); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.install-box h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 15px; }
.install-cmd { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.install-cmd code { flex: 1; min-width: 0; word-break: break-all; padding: 8px 10px; border-radius: 8px; background: var(--surface-3); font-size: 12.5px; }
.manual-steps > summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }

/* System status → Stations → Log */
.station-log { max-height: min(60vh, 520px); overflow: auto; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-3);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.dialog.dialog-wide { width: min(860px, calc(100vw - 32px)); }

.paste-zone { outline: none; }
.paste-zone:focus-visible, .paste-zone.drag { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); }
.paste-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.paste-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.paste-list img, .paste-file { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--surface-3); display: grid; place-items: center; flex: none; }
.paste-list .grow { display: grid; min-width: 0; }

.demo-banner { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 7px 16px; background: var(--amber-bg); color: var(--amber); font-size: 13px; border-bottom: 1px solid color-mix(in srgb, var(--amber) 25%, transparent); text-align: center; }
.demo-banner .ic { width: 16px; height: 16px; flex: none; }
.demo-banner b { font-weight: 700; }
.demo-banner .btn { color: inherit; border-color: color-mix(in srgb, var(--amber) 40%, transparent); }

.inline-setting { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; white-space: nowrap; }
.inline-setting input { width: 64px; height: 30px; padding: 0 6px; }
.task-row.due { border-left: 3px solid var(--amber); padding-left: 8px; }

.ai-stats { margin: 4px 0 12px; }
.ai-budget { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 14px; }
.ai-budget input { width: 90px; height: 32px; padding: 0 8px; }
.ai-bar { flex: 1 1 160px; max-width: 320px; height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.ai-bar span { display: block; height: 100%; background: var(--green); }
.ai-bar.near span { background: var(--amber); }
.ai-bar.over span { background: var(--red); }
.ai-grid { margin-bottom: 12px; }

/* phones: a row of tabs scrolls sideways inside itself instead of widening the page */
.segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented button { white-space: nowrap; flex: none; }

/* movies: posters on an item's page and the Movies page */
.movie-list li { align-items: flex-start; }
.movie-list .grow { display: grid; gap: 2px; min-width: 0; }
.movie-poster { width: 54px; height: 80px; object-fit: cover; border-radius: 6px; background: var(--surface-3); flex: none; display: grid; place-items: center; color: var(--muted); }
.movie-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.movie-grid > * { min-width: 0; }
.movie-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s; }
.movie-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.movie-card img, .movie-card-none { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: block; background: var(--surface-3); }
.movie-card-none { display: grid; place-items: center; align-content: center; gap: 8px; padding: 10px; text-align: center; color: var(--muted); }
.movie-card-body { padding: 8px 10px 10px; display: grid; gap: 1px; }
.movie-card-body b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.movie-card-body small { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* series: seasons folded out into their episodes */
.season-list { display: grid; gap: 4px; margin-top: 6px; }
.season summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-ink); }
.episode-list { margin: 4px 0 6px; padding-left: 4px; list-style: none; display: grid; gap: 2px; font-size: 13px; }
.episode-list small { margin-left: 6px; }
.series-card .card-top { align-items: flex-start; }
.movie-poster.none { width: 54px; height: 80px; }

/* a movie's own page, and a box set opened into its films */
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13.5px; font-weight: 600; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.crumbs .ic { width: 16px; height: 16px; }
.movie-hero { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 22px; }
.movie-hero > .grow { min-width: 0; }
.movie-big { width: 220px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 12px; box-shadow: var(--shadow); flex: none; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.movie-big.none .ic { width: 40px; height: 40px; }
.movie-plot { margin: 10px 0 12px; font-size: 15px; line-height: 1.55; max-width: 70ch; }
.movie-kv { max-width: 560px; }
.movie-kv dd { text-align: left; }
.box-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); margin-bottom: 8px; }
.box-manage { margin-top: 10px; }
.box-manage > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-ink); }
.movie-poster-link { flex: none; }
@media (max-width: 640px) {
  .movie-hero { flex-direction: column; }
  .movie-big { width: 160px; }
}

/* Add a disc: print its label as it's saved */
.auto-label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.auto-label .print-target { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
