/* JEJAK-Lab: sistem visual "kertas lab + tinta + hijau".
   Referensi: NataCode (token & tipografi), Acrylico (dock kaca, PWA ergonomics,
   zero gradient), burjo-pos (kartu tactile, angka tabular), Lenso UI (isi
   berkelompok, kaca hanya di permukaan mengambang, warna semantik). Tanpa
   gradient dekoratif, tanpa emoji, tanpa bayangan berwarna. */

/* ── Font ──────────────────────────────────────────────────────────────── */
/* Neurial Grotesk = isi & UI · IBM Plex Mono = ID, hash, rumus.
   Satu keluarga sans + satu mono: huruf "alat ukur", bukan "template".
   Disimpan lokal supaya app tetap jalan tanpa internet.
   Bobot 600 tidak ada di keluarga ini — browser memakai Bold (700) terdekat. */
@font-face {
  font-family: "Neurial Grotesk";
  src: url("/fonts/neurial-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Neurial Grotesk";
  src: url("/fonts/neurial-bold.woff2") format("woff2");
  font-weight: 600 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Neurial Grotesk";
  src: url("/fonts/neurial-extrabold.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Token ─────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --paper: #e9efe6;
  --card: #ffffff;
  --card-soft: #f4f7f1;
  --ink: #1c2a22;
  --ink-2: #3b4b41;
  --muted: #5e6f64;
  --line: #d9e3d5;
  --line-soft: #e7eee4;

  --accent: #2f5d46;
  --accent-2: #3e7457;
  --accent-fill: #2f5d46;
  --accent-fill-2: #3e7457;
  --on-accent: #ffffff;
  --accent-soft: #e7eee5;
  --accent-line: #d3e1d0;
  --sage: #a9c3ac;
  --sage-soft: #dce8d9;

  --amber: #9a6400;
  --amber-soft: #fbf2e1;
  --red: #a23b33;
  --red-soft: #fae9e6;
  --red-line: #f6ddd8;
  --red-ink: #7a3a3a;
  --red-ink-2: #a06a6a;
  --danger-fill: #a23b33;
  --gray-soft: #eef2ec;
  --scan-bg: #14201a;

  --toast-bg: #1c2a22;
  --toast-ink: #ffffff;
  --backdrop: rgba(28, 42, 34, 0.38);
  --spark-area: rgba(62, 116, 87, 0.12);

  --glass-topbar: rgba(233, 239, 230, 0.74);
  --glass-tabbar: rgba(255, 255, 255, 0.72);
  --glass-sidebar: rgba(255, 255, 255, 0.76);
  --glass-modal: rgba(255, 255, 255, 0.90);
  --glass-login-left: rgba(255, 255, 255, 0.42);
  --glass-login-right: rgba(255, 255, 255, 0.84);
  --glass-edge: rgba(255, 255, 255, 0.78);
  --glass-top-glint: rgba(255, 255, 255, 0.88);
  --glass-divider: rgba(28, 42, 34, 0.12);
  --tab-bg: rgba(255, 255, 255, 0.56);
  --tab-hover: rgba(255, 255, 255, 0.88);
  --row-hover: rgba(231, 238, 229, 0.68);
  --sheen-stroke: rgba(255, 255, 255, 0.86);
  --meniscus-rim: rgba(255, 255, 255, 0.72);
  --tag-shadow: rgba(28, 42, 34, 0.10);

  --bottle-glass: rgba(255, 255, 255, 0.42);
  --bottle-neck: rgba(255, 255, 255, 0.35);
  --bottle-label: rgba(255, 255, 255, 0.94);
  --bottle-shine: rgba(255, 255, 255, 0.65);
  --bottle-surface-stroke: rgba(28, 42, 34, 0.28);
  --bottle-shadow: rgba(28, 42, 34, 0.10);

  /* Cincin fokus: satu nilai untuk semua kolom isian. */
  --ring: rgba(62, 116, 87, 0.16);

  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-pill: 999px;

  --shadow-1: 0 0 0 1px var(--line);
  --shadow-2: 0 12px 32px -18px rgba(28, 42, 34, 0.26), 0 0 0 1px var(--line);
  --shadow-3: 0 24px 64px -20px rgba(28, 42, 34, 0.28);

  --dur-fast: 160ms;
  --dur: 240ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --font: "Neurial Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0e1511;
  --card: #151f19;
  --card-soft: #1c2821;
  --ink: #edf3ee;
  --ink-2: #c6d5c9;
  --muted: #9ab0a1;
  --line: #28382e;
  --line-soft: #212f26;

  --accent: #68c796;
  --accent-2: #7fd4a8;
  --accent-fill: #276143;
  --accent-fill-2: #2f7551;
  --on-accent: #f4faf6;
  --accent-soft: #1b2f24;
  --accent-line: #2e4d3b;
  --sage: #5d826c;
  --sage-soft: #1b2b22;

  --amber: #f3bd59;
  --amber-soft: #2a2315;
  --red: #f2847c;
  --red-soft: #2f1b1a;
  --red-line: #492826;
  --red-ink: #f6b3ad;
  --red-ink-2: #d9948e;
  --danger-fill: #a23b33;
  --gray-soft: #212d26;
  --scan-bg: #0a100c;

  --toast-bg: #223228;
  --toast-ink: #edf3ee;
  --backdrop: rgba(4, 8, 6, 0.66);
  --spark-area: rgba(127, 212, 168, 0.16);

  --glass-topbar: rgba(14, 21, 17, 0.80);
  --glass-tabbar: rgba(21, 31, 25, 0.84);
  --glass-sidebar: rgba(21, 31, 25, 0.86);
  --glass-modal: rgba(21, 31, 25, 0.94);
  --glass-login-left: rgba(17, 26, 21, 0.56);
  --glass-login-right: rgba(21, 31, 25, 0.86);
  --glass-edge: rgba(237, 243, 238, 0.14);
  --glass-top-glint: rgba(237, 243, 238, 0.08);
  --glass-divider: rgba(237, 243, 238, 0.12);
  --tab-bg: rgba(28, 40, 33, 0.62);
  --tab-hover: rgba(34, 49, 40, 0.92);
  --row-hover: rgba(104, 199, 150, 0.11);
  --sheen-stroke: rgba(237, 243, 238, 0.42);
  --meniscus-rim: rgba(237, 243, 238, 0.48);
  --tag-shadow: rgba(0, 0, 0, 0.34);

  --bottle-glass: rgba(255, 255, 255, 0.06);
  --bottle-neck: rgba(255, 255, 255, 0.08);
  --bottle-label: #1c2821;
  --bottle-shine: rgba(255, 255, 255, 0.22);
  --bottle-surface-stroke: rgba(237, 243, 238, 0.28);
  --bottle-shadow: rgba(0, 0, 0, 0.36);

  --ring: rgba(127, 212, 168, 0.24);
  --shadow-2: 0 14px 34px -18px rgba(0, 0, 0, 0.68), 0 0 0 1px var(--line);
  --shadow-3: 0 26px 68px -20px rgba(0, 0, 0, 0.78);
}

/* ── Dasar ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: transparent; padding: 0; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; font-weight: 700; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 12px; }
.mt-lg { margin-top: 20px; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 6px;
}
/* Di dalam wadah ber-overflow hidden cincin digambar ke dalam supaya tidak terpotong. */
.card.flush :focus-visible,
.modal :focus-visible,
.tabbar :focus-visible,
.sidebar :focus-visible { outline-offset: -2px; }

/* ── Kerangka aplikasi ─────────────────────────────────────────────────── */
.app { min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: var(--r-sm); flex: 0 0 auto;
  background: var(--accent-fill); color: var(--on-accent); display: grid; place-items: center;
  box-shadow: 0 8px 18px -8px rgba(28, 42, 34, 0.45);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; white-space: nowrap; }
.brand-text small { display: block; font-size: 11px; color: var(--muted); line-height: 1.3; }
.topbar .spacer { flex: 1; }

.role-chip {
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  padding: 6px 11px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent);
  white-space: nowrap;
}
.icon-btn {
  border: 0; background: var(--card);
  width: 38px; height: 38px; border-radius: var(--r-pill); color: var(--ink-2);
  display: grid; place-items: center; box-shadow: var(--shadow-1);
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--accent); transform: translateY(-1px); }

@media (max-width: 520px) {
  .topbar { gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 14px 8px; }
  .brand { gap: 8px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-mark svg { width: 16px; height: 16px; }
  .brand-text small { display: none; }
  .role-chip { font-size: 10.5px; padding: 5px 10px; }
  .topbar .icon-btn { width: 34px; height: 34px; box-shadow: none; border: 1px solid var(--border); }
  .topbar .icon-btn svg { width: 15px; height: 15px; }
}

.main { padding: 18px 16px 116px; }
@keyframes main-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.main.is-entering { animation: main-enter 190ms cubic-bezier(0.22, 1, 0.36, 1); }
@media (prefers-reduced-motion: reduce) {
  .main.is-entering { animation: none; }
  .tabbar button, .tabbar button svg { transition: none; }
}

/* ── Sidebar (desktop) ─────────────────────────────────────────────────── */
.sidebar { display: none; }
@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: clamp(300px, 23vw, 336px) minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 16px;
    height: calc(100dvh - 32px);
    margin: 16px 10px 16px 16px;
    padding: 20px 16px 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: none;
    overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-line) transparent;
  }
  .sidebar .side-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 4px 6px 18px;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .side-brand .brand-mark {
    width: 44px; height: 44px; border-radius: var(--r-sm);
    box-shadow: none;
  }
  .sidebar .side-brand strong {
    display: block; font-size: 19px; font-weight: 800;
    letter-spacing: -0.045em; line-height: 1.05;
  }
  .sidebar .side-brand small {
    display: block; margin-top: 5px;
    font-family: var(--mono); font-size: 11px; font-weight: 600;
    letter-spacing: 0.08em; line-height: 1.3;
    text-transform: uppercase; color: var(--muted);
  }
  .side-nav { display: flex; flex-direction: column; gap: 3px; padding-top: 16px; }
  .side-nav-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px 7px;
    font-family: var(--mono); font-size: 11px; font-weight: 600;
    letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  }
  .side-nav-head span:last-child { color: var(--accent-2); }
  .navitem {
    display: flex; align-items: center; gap: 11px;
    width: 100%; min-height: 46px; padding: 0 12px;
    border: 0; border-radius: var(--r-xs); background: transparent;
    color: var(--ink-2); font-size: 13.5px; font-weight: 600; text-align: left;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  }
  .navitem svg {
    width: 18px; height: 18px; flex: 0 0 auto;
    color: var(--muted);
    transition: color var(--dur-fast) var(--ease);
  }
  .navitem .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .navitem:hover { background: var(--accent-soft); color: var(--accent); }
  .navitem:hover svg { color: var(--accent-2); }
  .navitem.active {
    background: var(--accent-fill); color: var(--on-accent);
    box-shadow: 0 16px 30px -22px rgba(0, 0, 0, 0.48);
  }
  .navitem.active svg { color: var(--on-accent); }
  .navitem.active .nav-label { font-weight: 700; }
  .navitem:focus-visible, .sidebar .icon-btn:focus-visible {
    outline: 2px solid var(--accent-2); outline-offset: 2px;
  }
  .side-foot {
    margin-top: auto; padding-top: 16px;
    border-top: 1px solid var(--line);
  }
  .side-foot-label {
    margin: 0 0 8px 4px;
    font-family: var(--mono); font-size: 11px; font-weight: 600;
    letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  }
  .user-card {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border: 1px solid var(--line-soft);
    border-radius: var(--r-md); background: var(--card-soft);
    box-shadow: none;
  }
  .avatar {
    width: 34px; height: 34px; border-radius: var(--r-pill);
    background: var(--accent-fill); color: var(--on-accent);
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700; flex: 0 0 auto;
  }
  .side-foot-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
  .user-card .who { min-width: 0; flex: 1; }
  .user-card .who strong {
    display: block; font-size: 12.5px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .user-card .who span {
    display: block; margin-top: 2px;
    font-family: var(--mono); font-size: 11px; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  }
  .sidebar .icon-btn {
    width: 32px; height: 32px; border-radius: var(--r-xs);
    background: var(--card); color: var(--ink-2);
    border: 1px solid var(--line-soft); box-shadow: none;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  }
  .sidebar .icon-btn svg { width: 15px; height: 15px; }
  .sidebar .icon-btn:hover { background: var(--accent-soft); color: var(--accent); transform: none; }
  .topbar { display: none; }
  .main { padding: 32px 36px 56px; }
  .tabbar { display: none; }
}

/* ── Dock (mobile) ─────────────────────────────────────────────────────── */
.tabbar {
  position: fixed; left: 12px; right: 12px; z-index: 40;
  bottom: calc(10px + env(safe-area-inset-bottom));
  margin: 0 auto; max-width: 460px;
  display: flex; align-items: stretch; gap: 4px; padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-2);
}
.tabbar button {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 700; letter-spacing: -0.01em;
  padding: 8px 4px; min-height: 50px; border-radius: var(--r-pill);
  white-space: nowrap; overflow: hidden;
  transition: background 220ms cubic-bezier(0.22, 1, 0.36, 1), color 180ms ease, transform 180ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 220ms ease;
}
.tabbar button:active { transform: scale(0.94); }
.tabbar button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tabbar button svg {
  width: 19px; height: 19px; flex-shrink: 0;
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.tabbar button.active {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}
.tabbar button.active svg { transform: translateY(-1px) scale(1.08); }

/* ── Tipografi utilitas ────────────────────────────────────────────────── */
.kicker {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.hello { margin: 2px 0 16px; }
.hello h2 { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }
.hello p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 24px 0 10px; }
.section-head h3 { font-size: 15px; }
.section-head .link { border: 0; background: transparent; color: var(--accent); font-size: 12.5px; font-weight: 700; padding: 4px 2px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11.5px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* ── Kartu & KPI ───────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 0; border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 16px; }
.card.flush { padding: 0; overflow: hidden; }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--card); border: 0; border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-1);
}
.kpi .num { font-size: 30px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi .lbl { margin-top: 7px; }
.kpi .hint { font-size: 11.5px; margin-top: 6px; color: var(--muted); }
.kpi.warn .num { color: var(--amber); }
.kpi.danger .num { color: var(--red); }
.kpi.good .num { color: var(--accent); }

.banner {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--amber-soft);
  border-radius: var(--r-lg); padding: 16px 18px; margin-bottom: 16px;
  text-align: left; width: 100%; box-shadow: var(--shadow-1);
}
.banner .b-icon { color: var(--amber); flex: 0 0 auto; }
.banner .b-icon svg { width: 18px; height: 18px; }
.banner strong { display: block; font-size: 13px; }
.banner span { display: block; font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.banner .b-go { margin-left: auto; align-self: center; color: var(--amber); font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.banner .b-go svg { width: 14px; height: 14px; vertical-align: -2px; }
.banner.red { background: var(--red-soft); }
.banner.red .b-icon, .banner.red .b-go { color: var(--red); }

/* ── Daftar baris ──────────────────────────────────────────────────────── */
.list { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.row {
  min-width: 0;
  width: 100%; text-align: left; border: 0; background: var(--card);
  border-radius: var(--r-md); padding: 14px 16px; min-height: 56px; display: flex; align-items: center; gap: 13px;
  color: var(--ink); box-shadow: var(--shadow-1);
  transition: background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.row:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.row:active { transform: scale(0.995); }
.row-icon {
  width: 42px; height: 42px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; flex: 0 0 auto;
}
.row-icon svg { width: 19px; height: 19px; }
.row-icon.warn { background: var(--amber-soft); color: var(--amber); }
.row-icon.red { background: var(--red-soft); color: var(--red); }
/* Swatch bahan: kolom kecil berisi shader hidup (fallback: gradient CSS) */
.mat {
  width: 42px; height: 42px; flex: 0 0 auto; border-radius: var(--r-sm); overflow: hidden;
  background: linear-gradient(140deg, var(--c1), var(--c2));
  box-shadow: inset 0 0 0 1px rgba(28, 42, 34, 0.06);
}
.mat canvas { display: block; width: 100%; height: 100%; }

.row-body { min-width: 0; flex: 1; }
.row-body strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-body span { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { text-align: right; flex: 0 0 auto; }
.row-side .qty { font-weight: 800; font-size: 18px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.row-side .unit { display: block; color: var(--muted); font-size: 11px; }

.chip {
  border: 0; background: var(--card); border-radius: var(--r-pill);
  padding: 8px 14px; font-size: 11.5px; font-weight: 700; color: var(--accent);
  font-family: var(--mono); letter-spacing: -0.01em; box-shadow: var(--shadow-1);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.chip:hover { background: var(--accent-soft); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.03em; padding: 5px 10px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--gray-soft); color: var(--muted); }
.badge.plain { background: var(--card-soft); color: var(--ink-2); }

.empty {
  color: var(--muted); font-size: 12.5px; text-align: center;
  padding: 28px 16px; border: 0; border-radius: var(--r-md); background: var(--card-soft);
}

/* ── Tombol ────────────────────────────────────────────────────────────── */
.btn {
  border: 0; border-radius: var(--r-sm);
  min-height: 44px; padding: 12px 20px; font-weight: 700; font-size: 13.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-1);
  transition: background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--card-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-fill); color: var(--on-accent); box-shadow: none; }
.btn-primary:hover { background: var(--accent-fill-2); }
.btn-outline { background: var(--card-soft); color: var(--ink); box-shadow: none; }
.btn-outline:hover { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: var(--red-soft); color: var(--red); box-shadow: none; }
.btn-danger:hover { background: var(--red-line); }
.btn-block { width: 100%; }
.btn-stack { display: grid; gap: 10px; }
.btn-stack .btn { width: 100%; }
@media (min-width: 601px) and (max-width: 1199px) { .btn-stack { grid-template-columns: 1fr 1fr; } }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.link {
  border: 0; background: transparent; color: var(--accent); font-weight: 700; font-size: 12.5px; padding: 4px 2px;
  display: inline-flex; align-items: center; gap: 4px;
}
.link svg { width: 14px; height: 14px; }

/* ── Form ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--line); background: var(--card-soft);
  border-radius: var(--r-sm); padding: 11px 12px; color: var(--ink); outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent-2); background: var(--card); box-shadow: 0 0 0 4px var(--ring);
}
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.form-error {
  background: var(--red-soft); color: var(--red); border-radius: var(--r-sm);
  padding: 9px 11px; font-size: 12.5px; margin-bottom: 12px;
}
.form-error:empty { display: none; }

.search {
  position: relative; display: flex; align-items: center; margin-bottom: 10px;
}
.search svg { position: absolute; left: 15px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 48px; border: 0; background: var(--card);
  border-radius: var(--r-xs); padding: 13px 18px 13px 42px; outline: none;
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--dur-fast) var(--ease);
}
.search input:focus { box-shadow: 0 0 0 1px var(--accent-2), 0 0 0 4px var(--ring); }

/* ── Login (latar difusi WebGL + pelat etsa labu & kartu frosted glass) ── */
.login {
  position: relative; overflow: hidden; min-height: 100dvh; display: grid; place-items: center;
  padding: 32px 20px;
  background: var(--sage-soft);
}
.login-bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; display: block;
}
.login-theme-btn {
  position: fixed; top: max(16px, env(safe-area-inset-top)); right: 16px; z-index: 3;
  background: var(--glass-login-right);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.login-shell {
  --label-accent: #2f5d46;
  --fluid-top: #7fb398;
  --fluid-mid: #3e7457;
  --fluid-deep: #1d4632;
  --curve-tint: rgba(47, 93, 70, 0.14);
  position: relative; z-index: 1;
  width: 100%; max-width: 980px;
  display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 0; align-items: stretch;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  animation: login-reveal 420ms var(--ease) both;
}
.login-shell[data-reagent="guru"] {
  --label-accent: #1c74ae;
  --fluid-top: #77c2eb;
  --fluid-mid: #1c74ae;
  --fluid-deep: #0b3c61;
  --curve-tint: rgba(28, 116, 174, 0.14);
}
.login-shell[data-reagent="siswa"] {
  --label-accent: #4c8c74;
  --fluid-top: #bddccf;
  --fluid-mid: #74ac96;
  --fluid-deep: #376654;
  --curve-tint: rgba(94, 160, 127, 0.14);
}
.login-shell[data-reagent="pengawas"] {
  --label-accent: #6e1e7e;
  --fluid-top: #c472d4;
  --fluid-mid: #6e1e7e;
  --fluid-deep: #360b42;
  --curve-tint: rgba(110, 30, 126, 0.14);
}
:root[data-theme="dark"] .login-shell {
  --label-accent: #68c796;
  --fluid-top: #7fb398;
  --fluid-mid: #469970;
  --fluid-deep: #1f4f38;
}
:root[data-theme="dark"] .login-shell[data-reagent="guru"] {
  --label-accent: #5cb5eb;
  --fluid-top: #7bc7f2;
  --fluid-mid: #2a87c4;
  --fluid-deep: #124870;
}
:root[data-theme="dark"] .login-shell[data-reagent="siswa"] {
  --label-accent: #7cc9ae;
  --fluid-top: #a7d6c5;
  --fluid-mid: #5ea38b;
  --fluid-deep: #2a5948;
}
:root[data-theme="dark"] .login-shell[data-reagent="pengawas"] {
  --label-accent: #cf82e0;
  --fluid-top: #d993e8;
  --fluid-mid: #8c3aa1;
  --fluid-deep: #481557;
}

.login-stage {
  display: flex; flex-direction: column; gap: 12px;
  padding: 28px;
  background: var(--glass-login-left);
  border: 1px solid var(--glass-edge);
  border-right: 1px solid var(--glass-divider);
  border-radius: var(--r-xl) 0 0 var(--r-xl);
  box-shadow: inset 0 1px 0 var(--glass-top-glint);
  backdrop-filter: blur(24px) saturate(145%);
  -webkit-backdrop-filter: blur(24px) saturate(145%);
}
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand .brand-mark {
  width: 46px; height: 46px; border-radius: var(--r-md); box-shadow: var(--shadow-2); flex: 0 0 auto;
}
.login-brand .kicker { display: block; font-size: 11px; margin-bottom: 2px; color: var(--ink-2); }
.login-brand h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }

.login-stage-art {
  --mx: 0;
  --my: 0;
  flex: 1;
  display: grid; place-items: center;
  padding: 2px 0;
}
.login-specimen-svg {
  display: block; width: 100%; max-width: 390px; height: auto;
  overflow: visible;
}

.fluid-stop-top { stop-color: var(--fluid-top); stop-opacity: 0.36; transition: stop-color 360ms var(--ease); }
.fluid-stop-mid { stop-color: var(--fluid-mid); stop-opacity: 0.44; transition: stop-color 360ms var(--ease); }
.fluid-stop-deep { stop-color: var(--fluid-deep); stop-opacity: 0.56; transition: stop-color 360ms var(--ease); }
.curve-stop-top { stop-color: var(--label-accent); stop-opacity: 0.16; transition: stop-color 360ms var(--ease); }

.bp-corner { fill: none; stroke: var(--ink); stroke-opacity: 0.32; stroke-width: 1; }
.bp-plate-meta {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.11em;
  fill: var(--ink-2); opacity: 0.68;
}
.bp-watermark {
  font-family: var(--font); font-size: 126px; font-weight: 800; letter-spacing: -0.05em;
  fill: var(--label-accent); opacity: 0.08;
  transition: fill 360ms var(--ease);
}

.bp-plane-back {
  transform: translate(calc(var(--mx) * -5px), calc(var(--my) * -4px));
  transition: transform 280ms var(--ease);
}
.bp-plane-front {
  transform: translate(calc(var(--mx) * 3px), calc(var(--my) * 2.5px));
  transition: transform 280ms var(--ease);
}

.bp-etch-hex {
  fill: none; stroke: var(--ink); stroke-opacity: 0.24; stroke-width: 0.85;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: lab-stroke-draw 820ms var(--ease) forwards;
}
.bp-axis-hair {
  fill: none; stroke: var(--ink); stroke-opacity: 0.28; stroke-width: 0.9;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: lab-stroke-draw 760ms var(--ease) forwards;
}
.bp-spectrum-area { fill: url(#login-curve-fill); }
.bp-spectrum-curve {
  fill: none; stroke: var(--label-accent); stroke-opacity: 0.48; stroke-width: 1.35;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: lab-stroke-draw 1050ms var(--ease) forwards;
  transition: stroke 360ms var(--ease);
}
.bp-orbit {
  fill: none; stroke: var(--ink); stroke-opacity: 0.16; stroke-width: 0.9;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: lab-stroke-draw 960ms var(--ease) forwards;
}
.bp-mono {
  font-family: var(--mono); font-size: 8.5px; fill: var(--ink-2); opacity: 0.72; letter-spacing: 0.05em;
}
.bp-caustic {
  fill: var(--fluid-mid); opacity: 0.18;
  transition: fill 360ms var(--ease);
}

.bp-liquid-wrap {
  transform-origin: 215px 332px;
  animation: lab-liquid-settle 860ms var(--ease) 120ms both;
}
.bp-liquid { fill: url(#login-fluid-grad); }
.bp-meniscus-plane {
  fill: var(--fluid-top); opacity: 0.34;
  transition: fill 360ms var(--ease);
}
.bp-meniscus-rim {
  fill: none; stroke: var(--meniscus-rim); stroke-width: 1.35;
}
.bp-refract {
  fill: none; stroke: var(--meniscus-rim); stroke-opacity: 0.55; stroke-width: 1;
}
.bp-rod-submerged {
  fill: none; stroke: var(--meniscus-rim); stroke-opacity: 0.78; stroke-width: 1.3; stroke-linecap: round;
}
.bp-rod-glass {
  fill: none; stroke: var(--ink); stroke-opacity: 0.72; stroke-width: 1.25;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: lab-stroke-draw 780ms var(--ease) forwards;
}
.bp-rod-tip { fill: none; stroke: var(--ink); stroke-opacity: 0.72; stroke-width: 1.25; }
.bp-rod-ticks { fill: none; stroke: var(--ink); stroke-opacity: 0.42; stroke-width: 0.9; }

.bp-glass-fill { fill: url(#login-glass-sheen); }
.bp-outline {
  fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: lab-stroke-draw 940ms var(--ease) forwards;
}
.bp-lip {
  fill: var(--bottle-glass); stroke: var(--ink); stroke-width: 1.45;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: lab-stroke-draw 540ms var(--ease) forwards;
}
.bp-neck-ring { fill: none; stroke: var(--ink); stroke-opacity: 0.36; stroke-width: 1; }
.bp-shine {
  fill: none; stroke: var(--sheen-stroke); stroke-width: 2.2; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: lab-stroke-draw 780ms var(--ease) forwards;
}
.bp-hatch-line {
  fill: none; stroke: var(--ink); stroke-opacity: 0.24; stroke-width: 0.9; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: lab-stroke-draw 680ms var(--ease) forwards;
}
.bp-hatch-neck { fill: none; stroke: var(--ink); stroke-opacity: 0.16; stroke-width: 0.8; }

.bp-tag-cord {
  fill: none; stroke: var(--ink); stroke-opacity: 0.48; stroke-width: 1;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: lab-stroke-draw 620ms var(--ease) forwards;
}
.bp-tag-paper {
  fill: var(--bottle-label); stroke: var(--line); stroke-width: 1.1;
  filter: drop-shadow(0 10px 22px var(--tag-shadow));
}
.bp-tag-stripe { fill: var(--label-accent); transition: fill 360ms var(--ease); }
.bp-tag-rule { fill: none; stroke: var(--line-soft); stroke-width: 1; }
.bp-label-formula { font-family: var(--font); font-size: 16px; font-weight: 800; fill: var(--ink); letter-spacing: -0.02em; }
.bp-label-role { font-family: var(--mono); font-size: 6.5px; font-weight: 600; fill: var(--muted); letter-spacing: 0.04em; }

.bp-s1 { animation-delay: 40ms; }
.bp-s2 { animation-delay: 160ms; }
.bp-s3 { animation-delay: 300ms; }

.login-stage-foot {
  border-top: 1px solid var(--glass-divider); padding-top: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.plate-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.plate-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px 5px 6px;
  background: var(--tab-bg);
  border: 1px solid var(--glass-divider);
  border-radius: 4px;
  font-size: 11px; font-weight: 600; color: var(--ink-2);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.plate-tab:hover, .plate-tab:focus-visible {
  background: var(--tab-hover);
  border-color: var(--label-accent);
  color: var(--ink);
  outline: none;
}
.plate-tab.is-active {
  background: var(--tab-hover);
  border-color: var(--label-accent);
  color: var(--ink);
}
.plate-tab-swatch {
  width: 6px; height: 14px; border-radius: 1px;
  box-shadow: 0 0 0 1px var(--glass-divider);
  background: var(--sage-soft);
}
.login-stage-lead { color: var(--ink-2); font-size: 13px; line-height: 1.55; max-width: 40ch; }
.login-stage-meta { font-size: 11.5px; color: var(--ink); font-weight: 600; }

.login-mobile-brand { display: none; }
.login-card {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  background: var(--glass-login-right);
  border: 1px solid var(--glass-edge);
  border-left: 0;
  border-radius: 0 var(--r-xl) var(--r-xl) 0;
  padding: 30px 28px;
  box-shadow: inset 0 1px 0 var(--glass-top-glint);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
}
.login-card h2 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.login-card .sub { color: var(--muted); font-size: 12.5px; margin-top: 5px; margin-bottom: 14px; line-height: 1.5; }

.role-list {
  margin: 2px 0 4px;
  border-top: 1px solid var(--line-soft);
}
.role-row {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 10px 10px 10px 8px; text-align: left;
  border-bottom: 1px solid var(--line-soft);
  border-left: 2px solid transparent;
  background: transparent;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.role-row:hover, .role-row:focus-visible {
  background: var(--row-hover);
  border-left-color: var(--accent);
  outline: none;
}
.role-num { font-size: 11px; color: var(--muted); width: 18px; flex: 0 0 auto; }
.role-body { flex: 1; min-width: 0; }
.role-body strong { display: block; font-size: 13px; font-weight: 700; color: var(--ink); }
.role-body span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.role-code { font-size: 11px; color: var(--accent); font-weight: 600; flex: 0 0 auto; }

@keyframes login-reveal { from { opacity: 0; transform: translateY(10px); } }
@keyframes lab-stroke-draw { to { stroke-dashoffset: 0; } }
@keyframes lab-liquid-settle {
  from { opacity: 0; transform: translateY(14px) scaleY(0.92); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 920px) {
  .login { padding: 20px 14px; }
  .login-shell { max-width: 460px; grid-template-columns: 1fr; gap: 0; }
  .login-stage { display: none; }
  .login-mobile-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
  .login-mobile-brand .brand-mark { width: 42px; height: 42px; border-radius: var(--r-md); }
  .login-mobile-brand h1 { font-size: 20px; font-weight: 800; line-height: 1.1; }
  .login-mobile-brand span { display: block; font-size: 12px; color: var(--muted); }
  .login-card {
    padding: 24px 20px;
    border-left: 1px solid var(--glass-edge);
    border-radius: var(--r-xl);
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-shell, .bp-liquid-wrap, .bp-etch-hex, .bp-axis-hair, .bp-spectrum-curve,
  .bp-orbit, .bp-rod-glass, .bp-outline, .bp-lip, .bp-shine, .bp-hatch-line, .bp-tag-cord {
    animation: none !important;
    stroke-dashoffset: 0 !important;
  }
  .bp-plane-back, .bp-plane-front { transform: none !important; }
}

/* ── Hak Akses & Audit ─────────────────────────────────────────────────── */
.perm-group { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.perm-list { display: grid; gap: 6px; margin-top: 8px; }
.perm-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.perm-item input { width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 auto; }
.perm-item.locked { color: var(--muted); cursor: not-allowed; }
.rbac-user-row { cursor: default; }
.rbac-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* ── Sensor ────────────────────────────────────────────────────────────── */
.sensor {
  background: var(--card); border: 0; border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--shadow-1);
  transition: background var(--dur) var(--ease);
}
.sensor.warn { background: var(--amber-soft); }
.sensor.danger { background: var(--red-soft); }
.sensor-title { margin-bottom: 8px; }
.sensor-refresh { width: 34px; height: 34px; background: var(--card-soft); box-shadow: none; }
.sensor-refresh:hover { background: var(--accent-soft); }
.sensor-refresh.loading svg { animation: spin 0.8s linear infinite; }
.sensor-status { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.sensor-status .sensor-link { margin-left: auto; }
.sensor-status .badge { transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.sensor-status .badge svg { width: 12px; height: 12px; }
.sensor-status .door-badge .door-svg { width: 16px; height: 16px; flex-shrink: 0; overflow: visible; }
.door-svg .door-leaf {
  transform-origin: 6.5px 12.5px;
  transition: transform 360ms var(--ease);
}
.door-badge.is-open .door-leaf {
  transform: scaleX(0.42) skewY(-18deg);
}
.door-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.door-card.is-open { background: var(--red-soft); }
.door-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 0 12px;
  min-height: 210px;
}
.cabinet-svg {
  width: 170px;
  height: 170px;
  color: var(--accent);
  overflow: visible;
}
.door-card.is-open .cabinet-svg { color: var(--red); }
.cabinet-body { stroke: currentColor; fill: var(--card-soft); }
.cabinet-interior line { stroke: var(--border-strong); }
.cabinet-interior rect { fill: var(--accent-soft); stroke: currentColor; stroke-width: 1.5; opacity: 0.9; }
.door-card.is-open .cabinet-interior rect { fill: var(--card); }
.cabinet-panel { fill: var(--card); stroke: currentColor; }
.cabinet-window { fill: var(--accent-soft); stroke: currentColor; opacity: 0.75; }
.door-card.is-open .cabinet-window { fill: var(--red-soft); }
.cabinet-handle { fill: currentColor; }
.cabinet-door {
  transform-origin: 40px 90px;
  transition: transform 420ms var(--ease);
}
.door-card.is-open .cabinet-door {
  transform: scaleX(0.32) skewY(-18deg);
}
.door-note { text-align: center; margin: 0; }
.sensor-hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.sensor-hero { background: var(--accent-soft); border-radius: var(--r-md); padding: 14px 16px 13px; }
.sensor-hero-temp { background: var(--card-soft); }
.sensor.warn .sensor-hero, .sensor.danger .sensor-hero { background: var(--card); }
.sensor-hero-label { display: flex; align-items: center; gap: 6px; color: var(--accent); }
.sensor-hero-label svg { width: 14px; height: 14px; }
.sensor-hero .kicker { color: var(--accent); }
.sensor-value {
  font-size: clamp(32px, 6.5vw, 42px); font-weight: 800; letter-spacing: -0.05em;
  line-height: 1; margin-top: 8px; font-variant-numeric: tabular-nums;
}
.sensor-rh-line { display: flex; align-items: center; gap: 5px; }
.sensor-rh-line svg { width: 13px; height: 13px; flex: 0 0 auto; color: var(--accent); }
.sensor-rh-line strong { color: var(--ink-2); font-weight: 600; }
.sensor-meaning { margin-top: 6px; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.sensor-acuan { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.sensor-acuan-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
.sensor-acuan-row .sensor-acuan { margin-top: 0; }
.sensor-acuan-btn { font-size: 11.5px; }

.sensor-chart { margin-top: 14px; }
.sensor-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; }
.sensor-tabs { flex: 0 1 200px; margin: 0; }
.sensor-tabs .tab { padding: 7px 8px; font-size: 11.5px; }
.sensor-chart-head > .kicker { flex: 1; }
.sensor-chart-note { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.sensor-chart-note.reading { color: var(--accent); font-weight: 600; }

.spark-wrap { position: relative; height: 44px; margin-top: 10px; touch-action: pan-y; cursor: crosshair; }
.spark { display: block; width: 100%; height: 44px; }
.spark-wrap .spark { margin: 0; height: 100%; }
.spark-cursor {
  position: absolute; top: 0; bottom: 0; width: 1.5px;
  background: var(--accent-2); opacity: 0.45; transform: translateX(-50%);
  pointer-events: none;
}
.spark-dot {
  position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--card);
  transform: translate(-50%, -50%); pointer-events: none;
}
.spark-caption { margin-top: 4px; font-size: 11px; color: var(--muted); }
.spark path.line { fill: none; stroke: var(--accent-2); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.spark path.area { fill: var(--spark-area); stroke: none; }
.spark line.base { stroke: var(--accent-line); stroke-width: 1; }

.sensor-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; font-size: 11.5px; color: var(--muted); }
.sensor-facts > span { display: inline-flex; align-items: center; gap: 5px; }
.sensor-facts svg { width: 13px; height: 13px; flex: 0 0 auto; }
.sensor-facts strong { color: var(--ink-2); font-weight: 600; }

.sensor-details { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.sensor-details summary {
  display: flex; align-items: center; gap: 6px; list-style: none;
  cursor: pointer; font-size: 11.5px; font-weight: 700; color: var(--accent);
}
.sensor-details summary::-webkit-details-marker { display: none; }
.sensor-details summary .chev { margin-left: auto; display: grid; place-items: center; transition: transform var(--dur-fast) var(--ease); }
.sensor-details summary .chev svg { width: 14px; height: 14px; }
.sensor-details[open] summary .chev { transform: rotate(90deg); }
.sensor-detail-body { padding-top: 10px; animation: detail-in var(--dur) var(--ease); }
.sensor-help dl { margin: 10px 0 0; }
.sensor-help dt { margin-top: 10px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.sensor-help dt:first-child { margin-top: 0; }
.sensor-help dd { margin: 2px 0 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
.sensor-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 14px; }
.sensor-detail-grid span {
  display: block; font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.sensor-detail-grid strong { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--ink-2); overflow-wrap: anywhere; }
.sensor-hash { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.sensor-hash b { flex: 0 0 auto; font-weight: 600; color: var(--ink-2); }
.sensor-hash code { overflow-wrap: anywhere; }
.sensor-hash .link { flex: 0 0 auto; font-family: var(--font); }
.sensor-detail-link { margin-top: 10px; }
.sensor-chart-link { margin-top: 4px; font-size: 11.5px; }
.sensor.is-fresh .sensor-value { animation: value-in var(--dur) var(--ease); }
@keyframes detail-in { from { opacity: 0; transform: translateY(-3px); } }
@keyframes value-in { from { opacity: 0; transform: translateY(6px); } }

.sensor-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.metric {
  flex: 1 1 0; min-width: 84px; background: var(--card-soft);
  border-radius: var(--r-md); padding: 10px 12px;
}
.metric .k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.metric .v { font-size: 13.5px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Riwayat sensor ────────────────────────────────────────────────────── */
.riwayat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.riwayat-top h2 { margin-top: 4px; font-size: 30px; line-height: 1.12; letter-spacing: -0.03em; }
.riwayat-top p { margin-top: 6px; max-width: 62ch; }
.riwayat-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.riwayat-actions .icon-btn { width: 40px; height: 40px; }
.riwayat-filters { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-top: 18px; }
.riwayat-device { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.riwayat-device select {
  display: block; margin-top: 6px; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--r-xs);
  background: var(--card-soft); color: var(--ink); font-size: 12.5px; font-weight: 600;
  text-transform: none; letter-spacing: normal;
}
.riwayat-filters .chips { margin-top: 0; }
.riwayat-proof { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.riwayat-proof .link { margin-left: auto; }
.riwayat-note { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.riwayat-note svg { width: 14px; height: 14px; flex: 0 0 auto; }

/* Grafik riwayat: kartu terang dengan angka besar dan sumbu yang jelas. */
.riwayat-chart-card {
  --hc-h: 260px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}
.riwayat-chart-card .card-title { align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.riwayat-chart-card .card-title h3 { color: var(--ink); font-size: 22px; letter-spacing: -0.02em; }
.riwayat-chart-card .kicker { color: var(--muted); }
.riwayat-chart-card .card-title > .kicker { padding-top: 3px; }
.hc-chart { margin-top: 2px; }
.hc-head { min-height: 36px; flex-wrap: wrap; }
.riwayat-chart-card .hc-tabs { flex: 0 1 300px; min-width: 0; margin: 0; padding: 4px; gap: 3px; background: var(--card-soft); }
.riwayat-chart-card .hc-tabs .tab { padding: 8px 12px; font-size: 11.5px; color: var(--muted); }
.riwayat-chart-card .hc-tabs .tab:hover { color: var(--ink); }
.riwayat-chart-card .hc-tabs .tab.active { background: var(--card); color: var(--accent); box-shadow: var(--shadow-1); }
.riwayat-chart-card .sensor-chart-note { color: var(--muted); }
.riwayat-chart-card .sensor-chart-note.reading { color: var(--accent); }
.hc-panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.hc-now { display: flex; flex-direction: column; gap: 4px; }
.hc-now-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.hc-now-value {
  font-size: clamp(34px, 5vw, 52px); font-weight: 800; letter-spacing: -0.05em;
  line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums;
}
.hc-now-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; }
.hc-frame { display: grid; grid-template-columns: 48px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 12px; margin-top: 10px; }
.hc-yaxis { position: relative; grid-column: 1; grid-row: 1; height: var(--hc-h); }
.hc-yaxis span { position: absolute; right: 0; transform: translateY(-50%); font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.hc-plot { grid-column: 2; grid-row: 1; height: var(--hc-h); margin-top: 0; }
.hc-xaxis { grid-column: 2; grid-row: 2; display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.hc-xaxis span { white-space: nowrap; }
.riwayat-chart-card .hc-grid line { stroke: var(--line); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.riwayat-chart-card .spark-dot { width: 10px; height: 10px; }
.hc-end {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 0 3px var(--card);
  transform: translate(-50%, -50%); pointer-events: none;
}
.hc-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 11px; color: var(--muted); }
.hc-empty { padding: 34px 0 20px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* Tabel catatan: grid 5 kolom di desktop, dua baris di ponsel. */
.riwayat-head,
.riwayat-row {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, .8fr) minmax(0, .8fr) minmax(0, .7fr) minmax(0, .9fr);
  gap: 10px; align-items: center;
}
.riwayat-head { padding: 0 14px 8px; color: var(--muted); font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.riwayat-head span:nth-child(n+2) { text-align: right; }
.riwayat-table { display: grid; gap: 6px; }
.riwayat-row { padding: 11px 14px; border-radius: var(--r-sm); background: var(--card-soft); font-size: 12px; }
.riwayat-row .r-time { font-family: var(--mono); font-size: 11px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.riwayat-row .r-values { display: contents; }
.riwayat-row .r-air, .riwayat-row .r-temp, .riwayat-row .r-rh { text-align: right; font-variant-numeric: tabular-nums; }
.riwayat-row .r-air { font-weight: 800; font-size: 13px; }
.riwayat-row .r-temp, .riwayat-row .r-rh { color: var(--ink-2); }
.riwayat-row .r-door { text-align: right; }
.riwayat-row .r-closed { color: var(--muted); font-size: 11px; }
.riwayat-row .r-label { display: none; }
.riwayat-more { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.riwayat-more .btn { min-height: 40px; padding: 9px 16px; font-size: 12.5px; }

@media (max-width: 600px) {
  .riwayat-top h2 { font-size: 26px; }
  .riwayat-actions { width: 100%; }
  .riwayat-actions .btn { flex: 1; }
  .riwayat-device { width: 100%; }
  .riwayat-device select { width: 100%; }
  .riwayat-proof .link { margin-left: 0; }
  .riwayat-chart-card { --hc-h: 190px; }
  .riwayat-chart-card .card-title h3 { font-size: 20px; }
  .hc-frame { grid-template-columns: 40px minmax(0, 1fr); column-gap: 8px; }
  .hc-yaxis span { font-size: 11px; }
  .hc-xaxis { font-size: 11px; }
  .hc-now-value { font-size: 38px; }
  .hc-head .sensor-chart-note { width: 100%; text-align: right; }
  .riwayat-head { display: none; }
  .riwayat-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "time door" "values values"; gap: 5px 10px; padding: 12px 14px; }
  .riwayat-row .r-time { grid-area: time; }
  .riwayat-row .r-door { grid-area: door; }
  .riwayat-row .r-values { display: flex; grid-area: values; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
  .riwayat-row .r-air, .riwayat-row .r-temp, .riwayat-row .r-rh { text-align: left; }
  .riwayat-row .r-label { display: inline; margin-right: 3px; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
  .riwayat-more .btn { width: 100%; }
}

/* ── Scan ──────────────────────────────────────────────────────────────── */
.scan-frame {
  position: relative; border-radius: var(--r-lg); overflow: hidden;
  background: var(--scan-bg); aspect-ratio: 4 / 3; display: grid; place-items: center; color: #cfe0d6;
}
.scan-frame video { width: 100%; height: 100%; object-fit: cover; }
.scan-target {
  width: 58%; aspect-ratio: 1; border: 1px solid rgba(169, 195, 172, 0.36);
  border-radius: var(--r-lg); display: grid; place-items: center; text-align: center;
  color: rgba(214, 232, 216, 0.9); font-size: 12px; padding: 12px; gap: 6px;
}
.scan-target svg { width: 26px; height: 26px; }
.scan-hint {
  position: absolute; inset: auto 12px 12px; background: rgba(20, 32, 26, 0.86);
  border-radius: var(--r-pill); padding: 9px 14px;
  font-size: 11px; text-align: center;
}
.scan-corners { position: absolute; inset: 16px; pointer-events: none; }
.scan-corners i { position: absolute; width: 22px; height: 22px; border: 2px solid rgba(169, 195, 172, 0.9); }
.scan-corners i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: var(--r-xs) 0 0 0; }
.scan-corners i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 var(--r-xs) 0 0; }
.scan-corners i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 var(--r-xs); }
.scan-corners i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 var(--r-xs) 0; }
.manual-row { display: flex; gap: 8px; margin-top: 12px; }
.manual-row input {
  flex: 1; min-width: 0; min-height: 48px; border: 0;
  background: var(--card-soft); border-radius: var(--r-xs); padding: 13px 18px; outline: none;
}
.manual-row input:focus { box-shadow: 0 0 0 4px var(--ring); }
.demo-ids { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ── Detail ────────────────────────────────────────────────────────────── */
.detail-head { display: flex; align-items: flex-start; gap: 13px; }
.detail-head .row-icon { width: 50px; height: 50px; border-radius: var(--r-md); }
.detail-head .row-icon svg { width: 23px; height: 23px; }
.detail-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.detail-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.stock-line { display: flex; align-items: baseline; gap: 7px; margin: 18px 0 2px; }
.stock-line .big { font-size: 42px; font-weight: 800; letter-spacing: -0.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.stock-line .unit { color: var(--muted); font-size: 13px; font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.note {
  margin-top: 14px; background: var(--accent-soft);
  border-radius: var(--r-md); padding: 14px 16px; font-size: 12.5px; color: var(--ink-2); line-height: 1.55;
}
.note b { color: var(--accent); }
.note.warn { background: var(--amber-soft); }
.note.warn b { color: var(--amber); }
.batch-list { display: grid; gap: 10px; }
.batch {
  border: 0; border-radius: var(--r-md); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; background: var(--card-soft);
}
.batch .b-main { flex: 1; min-width: 0; }
.batch .b-main strong { font-size: 13px; }
.batch .b-main span { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.batch .b-qty { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 4px; border-radius: var(--r-pill); background: var(--line-soft); margin-top: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--accent-2); }
.bar i.amber { background: var(--amber); }
.bar i.red { background: var(--red); }

/* ── Timeline transaksi ────────────────────────────────────────────────── */
.timeline { display: grid; gap: 0; }
.event { display: grid; grid-template-columns: 15px 1fr; gap: 11px; padding: 11px 0; position: relative; }
.event::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 1px; background: var(--line); }
.event:first-child::before { top: 13px; }
.event:last-child::before { bottom: calc(100% - 13px); }
.event .dot {
  width: 12px; height: 12px; border-radius: 3px; background: var(--accent-2);
  margin-top: 4px; z-index: 1; border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--accent-line);
}
.event .e-body { min-width: 0; }
.event .e-body strong { font-size: 12.5px; }
.event .e-body p { margin: 2px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.event .tx { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.event .tx button { border: 0; background: transparent; color: var(--accent); font-size: 11px; padding: 0; text-decoration: underline; }

/* ── Praktikum ─────────────────────────────────────────────────────────── */
.session-date {
  width: 50px; flex: 0 0 auto; text-align: center; background: var(--accent-soft);
  color: var(--accent); border-radius: var(--r-md); padding: 9px 4px;
}
.session-date strong { display: block; font-size: 18px; line-height: 1; font-variant-numeric: tabular-nums; }
.session-date span { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.incident {
  background: var(--red-soft);
  border-radius: var(--r-md); padding: 14px 16px; margin-top: 10px;
}
.incident strong { font-size: 12.5px; color: var(--red); }
.incident p { margin: 3px 0 0; font-size: 12px; color: var(--red-ink); line-height: 1.5; }
.incident .tx { font-size: 11px; color: var(--red-ink-2); margin-top: 4px; font-family: var(--mono); }

/* ── Bukti & audit ─────────────────────────────────────────────────────── */
.verdict {
  display: flex; align-items: center; gap: 11px; border-radius: var(--r-md);
  padding: 15px 16px; border: 0; background: var(--accent-soft);
  margin-top: 12px;
}
.verdict.bad { background: var(--red-soft); }
.verdict .v-icon { color: var(--accent); flex: 0 0 auto; }
.verdict.bad .v-icon { color: var(--red); }
.verdict .v-icon svg { width: 20px; height: 20px; }
.verdict strong { display: block; font-size: 13.5px; color: var(--accent); }
.verdict.bad strong { color: var(--red); }
.verdict span { display: block; font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.hashline {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.hashline b { color: var(--ink-2); font-weight: 600; }
.anchor-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line-soft);
}
.anchor-row:last-child { border-bottom: 0; }
.anchor-row .a-time { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.anchor-row .a-hash { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.anchor-row .a-count { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.anchor-row .verdict-chip { min-width: 66px; text-align: center; }
.anchor-row .verdict-chip.ok { background: var(--accent-soft); color: var(--accent); }
.anchor-row .verdict-chip.bad { background: var(--red-soft); color: var(--red); }
.anchor-row .a-door-alert { color: var(--red); font-weight: 700; }
.tamper-box {
  margin-top: 12px; border-radius: var(--r-md); padding: 14px 16px;
  background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 35%, transparent);
}
.tamper-head { display: flex; align-items: flex-start; gap: 11px; }
.tamper-head .v-icon { color: var(--red); flex: 0 0 auto; margin-top: 2px; }
.tamper-head .v-icon svg { width: 20px; height: 20px; }
.tamper-head strong { display: block; font-size: 13.5px; color: var(--red); }
.tamper-head span { display: block; font-size: 12px; color: var(--ink-2); margin-top: 2px; line-height: 1.45; }
.tamper-hashes {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--red) 20%, transparent);
  display: grid; gap: 6px; font-size: 12px;
}
.tamper-hashes > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tamper-hashes span { color: var(--muted); min-width: 195px; }
.tamper-hashes code { font-family: var(--mono); font-size: 11.5px; color: var(--ink); }
.tamper-hashes em { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.tamper-hashes em.ok { background: var(--accent-soft); color: var(--accent); }
.tamper-hashes em.bad { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ── Modal / sheet ─────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: var(--backdrop);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 20px; } }
.modal {
  position: relative; width: 100%; max-width: 460px; background: var(--card);
  border-radius: var(--r-xl) var(--r-xl) 0 0; border: 0;
  padding: 26px 22px calc(22px + env(safe-area-inset-bottom));
  max-height: 90dvh; overflow: auto; box-shadow: var(--shadow-3);
  animation: sheet-up var(--dur) var(--ease);
}
@media (min-width: 640px) { .modal { border-radius: var(--r-xl); padding-bottom: 22px; } }
@keyframes sheet-up { from { transform: translateY(14px); opacity: 0; } }
.modal h3 { font-size: 18px; letter-spacing: -0.02em; }
.modal .sub { margin: 4px 0 16px; color: var(--muted); font-size: 12.5px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }
.modal-close {
  position: absolute; top: 14px; right: 14px; border: 0; background: var(--gray-soft);
  border-radius: var(--r-pill); width: 36px; height: 36px; color: var(--ink-2);
  display: grid; place-items: center;
}
.modal-close svg { width: 15px; height: 15px; }

/* Alokasi FEFO di sheet */
.alloc { display: grid; gap: 8px; margin-top: 10px; }
.alloc-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border: 0; border-radius: var(--r-md); background: var(--card-soft);
}
.alloc-row .a-b { font-size: 12px; font-weight: 700; }
.alloc-row .a-e { font-size: 11px; color: var(--muted); }
.alloc-row .a-q { margin-left: auto; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.steps { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.steps i { height: 4px; flex: 1; border-radius: var(--r-pill); background: var(--line); }
.steps i.on { background: var(--accent); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast-root {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 200;
  display: grid; gap: 8px; width: min(calc(100% - 32px), 420px); pointer-events: none;
}
.toast {
  background: var(--toast-bg); color: var(--toast-ink); border-radius: var(--r-md); padding: 14px 18px;
  font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-3);
  animation: pop var(--dur) var(--ease);
}
.toast.error { background: var(--danger-fill); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ── Loading ───────────────────────────────────────────────────────────── */
.loader { display: grid; place-items: center; min-height: 40vh; color: var(--muted); gap: 12px; font-size: 13px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--line);
  border-top-color: var(--accent-2); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Aksesibilitas gerak ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ── Penyesuaian desktop (setelah dock, biar tidak tertimpa urutan) ───── */
@media (min-width: 1024px) {
  .tabbar { display: none; }
  .main { padding: 32px 36px 56px; }
  .main > * { max-width: 1180px; }
}

/* ── Menu QR: kaya menu restoran, tiap botol/alat punya QR-nya sendiri ─── */
.qr-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.qr-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px 10px; border: 0; border-radius: var(--r-md);
  background: var(--card); box-shadow: var(--shadow-1);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.qr-card:hover { background: var(--card-soft); transform: translateY(-2px); }
.qr-thumb {
  display: grid; place-items: center; width: 80px; height: 80px;
  border-radius: var(--r-sm); background: var(--card-soft); overflow: hidden;
}
.qr-card.qr-loaded .qr-thumb, [data-qr-load].qr-loaded .qr-thumb { background: #fff; }
.qr-thumb img { width: 76px; height: 76px; image-rendering: pixelated; }
.qr-name {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; font-weight: 600; color: var(--ink);
}
.qr-id {
  font-size: 11px; font-weight: 700; color: var(--accent);
  font-family: var(--mono); letter-spacing: -0.01em;
}

/* ── QR di kartu detail bahan/alat ─────────────────────────────────────── */
.qr-detail {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-top: 12px;
  border: 0; border-radius: var(--r-md); background: var(--card-soft);
}
.qr-detail .qr-thumb { width: 52px; height: 52px; flex: 0 0 auto; }
.qr-detail .qr-thumb img { width: 48px; height: 48px; }
.qr-detail-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.qr-detail-info strong { font-size: 12px; }
.qr-detail-info span { font-size: 11px; color: var(--muted); }

/* ── Detail bahan: kartu spesimen + botol SVG ─────────────────────────── */
/* Terang dan datar: warna bahan hanya jadi aksen, bukan latar gelap. */
.detail-hero {
  position: relative; overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  grid-template-rows: auto 1fr;
  grid-template-areas: "head figure" "foot figure";
  gap: 10px 24px;
  padding: 22px;
  background: var(--card);
  color: var(--ink);
}
.detail-hero::before {
  content: ""; position: absolute; z-index: 0;
  width: 260px; height: 260px; border-radius: 50%;
  right: -54px; top: -78px;
  background: var(--c2); opacity: 0.24;
}
.specimen-head, .specimen-foot, .specimen-figure { position: relative; z-index: 1; }
.specimen-head {
  grid-area: head; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start;
}
.specimen-head h2 {
  margin-top: 12px; font-size: 32px; line-height: 1.05;
  letter-spacing: -0.045em; color: var(--ink);
}
.specimen-head p { margin-top: 6px; font-size: 12px; color: var(--muted); }
.specimen-head .badge { margin-top: 12px; }
.specimen-head .badge + .badge { margin-top: 6px; }
.specimen-figure {
  grid-area: figure; width: 190px;
  align-self: center; justify-self: end;
  cursor: crosshair; outline: none;
}
.specimen-figure:focus-visible {
  outline: 2px solid var(--accent-line); outline-offset: 4px;
  border-radius: var(--r-xs);
}
.specimen-bottle { display: block; width: 100%; height: auto; }
.specimen-foot { grid-area: foot; align-self: end; min-width: 0; }
.hero-stock { text-align: left; }
.hero-stock .big {
  display: block; font-size: 46px; font-weight: 800; line-height: 0.95;
  letter-spacing: -0.055em; font-variant-numeric: tabular-nums; color: var(--ink);
}
.hero-stock .unit { display: block; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.specimen-percent {
  margin-top: 14px; font-family: var(--mono); font-size: 13px;
  font-weight: 700; color: var(--accent-2);
}
.specimen-percent span { font-weight: 400; color: var(--muted); }
.specimen-note { margin-top: 4px; max-width: 38ch; font-size: 11px; color: var(--muted); }

/* Botol: garis tipis, isi transparan, tanpa filter atau bayangan berat. */
.bottle-shadow { fill: var(--bottle-shadow); }
.bottle-glass {
  fill: var(--bottle-glass); stroke: var(--ink-2);
  stroke-width: 1.2; vector-effect: non-scaling-stroke;
}
.bottle-line {
  fill: none; stroke: var(--ink-2);
  stroke-width: 1.2; vector-effect: non-scaling-stroke;
}
.bottle-shine {
  fill: none; stroke: var(--bottle-shine);
  stroke-width: 6; stroke-linecap: round;
}
.bottle-surface {
  stroke: var(--bottle-surface-stroke); stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.bottle-neck {
  fill: var(--bottle-neck); stroke: var(--ink-2);
  stroke-width: 1.2; vector-effect: non-scaling-stroke;
}
.bottle-cap { fill: var(--ink-2); }
.bottle-rib { stroke: var(--glass-divider); stroke-width: 1; }
.bottle-ring { fill: var(--ink-2); }
.bottle-label { fill: var(--bottle-label); stroke: var(--line); stroke-width: 1; }
.bottle-formula {
  fill: var(--ink); font-family: var(--mono);
  font-weight: 700; letter-spacing: -0.03em;
}
.bottle-sub {
  fill: var(--muted); font-family: var(--mono);
  letter-spacing: 0.14em;
}
.bottle-scale {
  fill: none; stroke: var(--accent-line);
  stroke-width: 1; vector-effect: non-scaling-stroke;
}
.bottle-mark { fill: var(--accent-2); }
.bottle-guide {
  stroke: var(--accent-2); stroke-width: 1;
  vector-effect: non-scaling-stroke;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease);
}
.specimen-figure:hover .bottle-guide,
.specimen-figure:focus-visible .bottle-guide { opacity: 1; }

@media (max-width: 600px) {
  .detail-hero {
    grid-template-columns: minmax(0, 1fr) 116px;
    grid-template-rows: auto auto;
    grid-template-areas: "head head" "foot figure";
    gap: 16px 14px;
    padding: 18px;
  }
  .detail-hero::before { width: 180px; height: 180px; right: -46px; top: -64px; }
  .specimen-head h2 { margin-top: 10px; font-size: 24px; }
  .specimen-head p { font-size: 11.5px; }
  .specimen-figure { width: 116px; align-self: end; }
  .hero-stock .big { font-size: 38px; }
  .specimen-percent { margin-top: 12px; font-size: 11.5px; }
  .specimen-note { max-width: 24ch; font-size: 11px; }
}

.detail-body { padding: 18px 20px 20px; }

/* Tab isi detail — satu kartu, tiga panel, tanpa reload halaman. */
.tabs { display: flex; gap: 4px; padding: 4px; margin: 16px 0 14px; background: var(--card-soft); border-radius: var(--r-xs); }
.tabs .tab {
  flex: 1; border: 0; background: transparent; border-radius: calc(var(--r-xs) - 2px); padding: 10px 6px;
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.tabs .tab.active { background: var(--card); color: var(--accent); box-shadow: var(--shadow-1); }

/* Chip filter di halaman Bahan — sans, bukan mono seperti chip ID. */
.bahan-page { max-width: 1120px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips .chip { font-family: var(--font); font-size: 12px; }
.chips .chip[aria-pressed="true"] { background: var(--accent-fill); color: var(--on-accent); }

/* Batch yang dipakai lebih dulu saat pengeluaran (FEFO). */
.batch.next { background: var(--accent-soft); }
.next-chip {
  display: inline-block; margin-left: 6px; padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-style: normal; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--accent); background: var(--card);
  border: 1px solid var(--accent-line);
  vertical-align: 1px;
}

/* Daftar di dalam kartu jadi satu blok bersambung: pemisah tipis, sudut hanya
   di ujung, satu lapis permukaan. Pola "grouped content" ala pengaturan iOS. */
.card .list { gap: 0; }
.card .row { background: var(--card); box-shadow: none; border-radius: 0; }
.card .row + .row { border-top: 1px solid var(--line); }
.card .row:first-child { border-radius: var(--r-md) var(--r-md) 0 0; }
.card .row:last-child { border-radius: 0 0 var(--r-md) var(--r-md); }
.card .row:only-child { border-radius: var(--r-md); }
.card .row:hover { background: var(--card-soft); box-shadow: none; transform: none; }

/* ── Bento grid ────────────────────────────────────────────────────────── */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.bento > .card { margin-top: 0; }
.bento > .banner { margin-bottom: 0; }
.b-3 { grid-column: span 3; }
.b-4 { grid-column: span 4; }
.b-5 { grid-column: span 5; }
.b-6 { grid-column: span 6; }
.b-7 { grid-column: span 7; }
.b-8 { grid-column: span 8; }
.b-12 { grid-column: span 12; }

/* Kartu besar di layar sempit: penuh; di desktop lebar: 8/7 dan 5/4. */
.b-lg-8, .b-lg-7, .b-lg-5, .b-lg-4 { grid-column: span 2; }
@media (min-width: 1200px) {
  .b-lg-8 { grid-column: span 8; }
  .b-lg-7 { grid-column: span 7; }
  .b-lg-5 { grid-column: span 5; }
  .b-lg-4 { grid-column: span 4; }
}

/* Kartu hero ikut tinggi kartu aksi di sebelahnya. */
.bento > .card.flush { display: flex; flex-direction: column; }
.bento > .card.flush .detail-hero { flex: 1; height: auto; min-height: 300px; }
@media (min-width: 760px) { .bento > .card.flush .detail-hero { min-height: 300px; } }
.bento > .kpis { margin-bottom: 0; }
.card > .tabs:first-child { margin-top: 0; }

@media (max-width: 1199px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .b-3, .b-4, .b-5, .b-6 { grid-column: span 1; }
  .b-7, .b-8, .b-12 { grid-column: span 2; }
}
@media (max-width: 600px) {
  .bento { gap: 12px; }
  .b-3, .b-4, .b-5, .b-6 { grid-column: span 2; }
}

/* Kartu sapaan + ringkasan di Beranda */
.greet { display: flex; flex-direction: column; gap: 16px; }
.greet h2 { font-size: 30px; line-height: 1.15; letter-spacing: -0.03em; }
.greet p { margin-top: 6px; color: var(--muted); font-size: 13px; }
.greet .kicker { margin-bottom: 8px; }
.greet-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.accent-card {
  background: var(--sage-soft);
  box-shadow: var(--shadow-1);
}
.accent-card .big-num { font-size: 44px; font-weight: 800; letter-spacing: -0.05em; line-height: 1; }
.stat-card .num { font-size: 40px; font-weight: 800; letter-spacing: -0.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-card .lbl { margin-top: 10px; }
.stat-card .hint { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title h3 { font-size: 15px; }
.bento .section-head { margin-top: 0; }

/* ── Panduan keselamatan praktikum (Siswa & Lab) ── */
.safety-box { display: flex; flex-direction: column; gap: 10px; }
.safety-sec { padding: 10px 12px; background: var(--paper); border-radius: var(--r-sm); }
.safety-sec .kicker { display: block; font-size: 11px; margin-bottom: 3px; }
.safety-sec ul { margin: 6px 0 0 16px; padding: 0; font-size: 12px; }
.safety-sec li { margin-bottom: 3px; }
.safety-sec li:last-child { margin-bottom: 0; }

/* ── Kaca (permukaan mengambang) ───────────────────────────────────────── */
/* Hanya topbar, dock, sidebar, dan sheet. Kolom isian tetap permukaan biasa,
   karena kaca di atas teks panjang membuat huruf sulit dibaca.
   Tanpa dukungan backdrop-filter, keempatnya kembali ke latar solid. */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .topbar {
    background: var(--glass-topbar);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
  }
  .tabbar {
    background: var(--glass-tabbar);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
  }
  .sidebar {
    background: var(--glass-sidebar);
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
  }
  .modal {
    background: var(--glass-modal);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
  }
}

