/*
 * School Inventory — dark navy theme on top of Pico CSS.
 * Colours are tokens on :root; components below only use the tokens.
 */

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../vendor/fonts/inter-latin-wght-normal.260c81a4759b.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../vendor/fonts/inter-latin-ext-wght-normal.1ad231aac0a8.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* UAE dirham sign: too new for Inter and system fonts (built by scripts/build_dirham_font.py). */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: block;
  font-weight: 100 900;
  src: url("../vendor/fonts/dirham-sign.8d7d0140bf92.woff2") format("woff2");
  unicode-range: U+20C3;
}

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  /* Surfaces */
  --bg: #0a1224;
  --bg-sidebar: #0b1528;
  --surface: #101a2e;
  --surface-2: #16233d;
  --surface-3: #1b2a48;
  --input: #0c1629;
  --border: #1c2a45;
  --border-strong: #273859;
  /* Text */
  --text: #eaf0fb;
  --text-2: #b3bfd8;
  --muted: #8392b0;
  /* Accent & status */
  --primary: #2563eb;
  --primary-hover: #1d4fd8;
  --primary-text: #6ea8ff;
  --primary-soft: rgba(37, 99, 235, 0.16);
  --ok: #34d17a;
  --ok-bg: rgba(34, 197, 94, 0.15);
  --warn: #fb9a3c;
  --warn-bg: rgba(234, 108, 12, 0.18);
  --bad: #f87171;
  --bad-bg: rgba(239, 68, 68, 0.16);
  --info: #6ea8ff;
  --info-bg: rgba(59, 130, 246, 0.16);
  --neutral-bg: rgba(148, 163, 184, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.8);

  /* Pico mapping */
  --pico-font-family: "Inter Variable", system-ui, "Segoe UI", Roboto, sans-serif;
  --pico-font-size: 15px;
  --pico-line-height: 1.5;
  --pico-background-color: var(--bg);
  --pico-color: var(--text);
  --pico-muted-color: var(--muted);
  --pico-muted-border-color: var(--border);
  --pico-border-radius: var(--radius-sm);
  --pico-spacing: 1rem;
  --pico-primary: var(--primary-text);
  --pico-primary-hover: #93c0ff;
  --pico-primary-underline: rgba(110, 168, 255, 0.4);
  --pico-primary-background: var(--primary);
  --pico-primary-hover-background: var(--primary-hover);
  --pico-primary-border: var(--primary);
  --pico-primary-hover-border: var(--primary-hover);
  --pico-primary-focus: rgba(37, 99, 235, 0.45);
  --pico-primary-inverse: #fff;
  --pico-secondary: var(--text-2);
  --pico-secondary-background: var(--surface-2);
  --pico-secondary-border: var(--border-strong);
  --pico-secondary-hover-background: var(--surface-3);
  --pico-secondary-hover-border: var(--border-strong);
  --pico-secondary-inverse: var(--text);
  --pico-card-background-color: var(--surface);
  --pico-card-border-color: var(--border);
  --pico-card-sectioning-background-color: var(--surface-2);
  --pico-form-element-background-color: var(--input);
  --pico-form-element-selected-background-color: var(--surface-2);
  --pico-form-element-border-color: var(--border-strong);
  --pico-form-element-color: var(--text);
  --pico-form-element-placeholder-color: #5f6f8f;
  --pico-form-element-active-background-color: var(--input);
  --pico-form-element-active-border-color: var(--primary);
  --pico-form-element-focus-color: rgba(37, 99, 235, 0.35);
  --pico-form-element-spacing-vertical: 0.6rem;
  --pico-form-element-spacing-horizontal: 0.85rem;
  --pico-form-label-font-weight: 500;
  --pico-table-border-color: var(--border);
  --pico-dropdown-background-color: var(--surface-2);
  --pico-dropdown-border-color: var(--border-strong);
  --pico-dropdown-hover-background-color: var(--surface-3);
  --pico-dropdown-color: var(--text);
  --pico-progress-background-color: var(--surface-3);
  --pico-progress-color: var(--primary);
  --pico-typography-spacing-vertical: 1rem;
}

html { scroll-padding-top: 5rem; }
body { background: var(--bg); color: var(--text); }
a { text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; }
h1, h2, h3, h4 { color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 1.85rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
small, .small { font-size: 0.82rem; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--pico-font-family-monospace); font-size: 0.88em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.text-info { color: var(--info); }
.icon { flex: none; vertical-align: -0.2em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
hr { border-color: var(--border); }

/* ------------------------------------------------------------------ layout */
.app {
  display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--bg-sidebar) 235px, var(--border) 235px 236px, var(--bg) 236px);
}
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  background: var(--bg-sidebar); border-right: 1px solid var(--border); padding: 1.25rem 0.9rem 1rem;
  scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0.6rem 1.5rem; color: var(--text); font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand .logo { color: #4f8df5; fill: rgba(79, 141, 245, 0.25); }
.side-nav { display: flex; flex-direction: column; gap: 0.3rem; }
.side-nav a {
  display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 0.9rem; border-radius: 10px;
  color: var(--text-2); font-weight: 500;
}
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-nav a[aria-current="page"] {
  background: var(--primary); color: #fff; box-shadow: 0 8px 20px -10px rgba(37, 99, 235, 0.9);
}
.side-nav .count { margin-left: auto; font-size: 0.72rem; font-weight: 700; background: var(--bad-bg); color: var(--bad); border-radius: 999px; padding: 0.05rem 0.45rem; }
.side-nav a[aria-current="page"] .count { background: rgba(255, 255, 255, 0.2); color: #fff; }
.sidebar-school { margin-top: auto; padding: 2rem 0.5rem 0.5rem; text-align: center; }
.sidebar-school .art { width: 116px; height: 100px; display: block; margin: 0 auto 0.6rem; }
.sidebar-school strong { display: block; font-size: 0.98rem; color: var(--text); }
.sidebar-school small { color: var(--muted); }

.scrim { display: none; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem 1.75rem; background: rgba(10, 18, 36, 0.88); backdrop-filter: blur(10px);
}
.topbar form.search { flex: 1; max-width: 30rem; margin: 0; position: relative; }
.topbar form.search .icon { position: absolute; z-index: 5; left: 0.9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.topbar form.search input { margin: 0; padding-left: 2.6rem; height: 2.65rem; background: var(--surface); border-color: var(--border); border-radius: 10px; }
.topbar .spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 10px;
  color: var(--text-2); background: transparent; border: 1px solid transparent; position: relative; padding: 0; margin: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot { position: absolute; top: 0.45rem; right: 0.5rem; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--bg); }
.menu-btn { display: none !important; }
.user-chip { display: flex !important; align-items: center; gap: 0.7rem; color: var(--text); list-style: none; cursor: pointer; }
.avatar {
  display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; font-weight: 700; font-size: 0.88rem;
}
.user-chip .who { line-height: 1.25; text-align: left; }
.user-chip .who strong { display: block; font-size: 0.92rem; }
.user-chip .who small { color: var(--muted); }
.content { padding: 0.75rem 1.75rem 3rem; width: 100%; max-width: 1440px; }

/* Dropdown menus (Pico details.dropdown) */
details.dropdown { margin: 0; }
details.dropdown.plain > summary { border: none !important; background: none !important; padding: 0 !important; height: auto !important; box-shadow: none !important; }
details.dropdown.plain > summary::after { display: none !important; }
details.dropdown > ul { min-width: 15rem; border-radius: 10px; box-shadow: var(--shadow); }
details.dropdown > ul li a, details.dropdown > ul li button.link { display: flex; gap: 0.6rem; align-items: center; color: var(--text); }
.notif-list a { justify-content: space-between; }
.notif-list .empty { padding: 0.5rem 0; color: var(--muted); }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 50;
    transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(2, 6, 16, 0.6); z-index: 40; }
  .menu-btn { display: inline-grid !important; }
  .topbar { padding: 0.7rem 1rem; gap: 0.5rem; }
  .topbar .spacer { display: none; }
  .topbar form.search { max-width: none; }
  .content { padding: 0.5rem 1rem 3rem; }
  .user-chip .who { display: none; }
}

/* ------------------------------------------------------------ page header */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem 1.5rem; margin: 0.75rem 0 1.5rem; }
.page-head h1 { margin: 0; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin: 0.35rem 0 0; }
.page-head .back { color: var(--text-2); display: inline-grid; place-items: center; }
.page-head .back:hover { color: var(--text); }
.page-head .aside { color: var(--text-2); font-size: 0.9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.actions form { margin: 0; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem 1.35rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card-head h2 { margin: 0; font-size: 1.1rem; display: flex; align-items: center; gap: 0.5rem; }
.card-head a.more { font-size: 0.88rem; font-weight: 500; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 1rem; color: var(--muted); font-size: 0.85rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.25rem; margin-bottom: 1.25rem; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1.25rem; align-items: start; }
.grid-2 > .card, .grid-2-1 > .card { margin-bottom: 0; }
@media (max-width: 1100px) {
  .grid-2, .grid-2-1, .grid-main-side { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------ stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.stat { display: flex; align-items: center; gap: 1.1rem; padding: 1.35rem 1.4rem; margin: 0; }
.stat .stat-icon { width: 52px; height: 52px; flex: none; }
.stat .label { color: var(--text-2); font-size: 0.9rem; font-weight: 500; }
.stat .value { font-size: 1.9rem; font-weight: 700; line-height: 1.15; margin: 0.1rem 0; color: var(--text); }
.stat .delta { font-size: 0.85rem; font-weight: 500; }
.stat a { color: inherit; }
.tint-blue { color: #4f8df5; fill: rgba(79, 141, 245, 0.28); }
.tint-indigo { color: #7aa7ff; fill: rgba(99, 142, 255, 0.22); }
.tint-amber { color: #f5b53d; fill: rgba(245, 181, 61, 0.3); }
.tint-sky { color: #62b4ff; fill: rgba(98, 180, 255, 0.25); }
@media (max-width: 1200px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) {
  .stats { gap: 0.75rem; }
  .stat { padding: 1rem; gap: 0.6rem; flex-direction: column; align-items: flex-start; }
  .stat .stat-icon { width: 34px; height: 34px; }
  .stat .value { font-size: 1.45rem; }
}

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table { margin-bottom: 0; font-size: 0.9rem; border-collapse: separate; border-spacing: 0; width: 100%; }
table th, table td { background: transparent !important; border-bottom: 1px solid var(--border); padding: 0.8rem 0.9rem; vertical-align: middle; }
table thead th {
  background: var(--surface-2) !important; color: var(--text); font-weight: 600; font-size: 0.86rem; border-bottom: none; white-space: nowrap;
}
table thead th:first-child { border-radius: 8px 0 0 8px; }
table thead th:last-child { border-radius: 0 8px 8px 0; }
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover td { background: rgba(255, 255, 255, 0.018) !important; }
table td { color: var(--text-2); }
table td a { color: var(--text); font-weight: 500; }
table td a:hover { color: var(--primary-text); }
table td small { display: block; color: var(--muted); }
table.compact th, table.compact td { padding: 0.65rem 0.75rem; }
tr.row-dim td { opacity: 0.55; }
td.actions-cell { white-space: nowrap; text-align: right; }
.empty-state { color: var(--muted); padding: 1.5rem 0.5rem; text-align: center; margin: 0; }

/* ------------------------------------------------------------------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.22rem 0.6rem; border-radius: 6px;
  font-size: 0.76rem; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--text-2);
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 0.92rem; line-height: 1.2; border: 1px solid var(--primary);
  background: var(--primary); color: #fff; cursor: pointer; width: auto; margin: 0; white-space: nowrap; box-shadow: none;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; text-decoration: none; }
.btn.secondary { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn.secondary:hover { background: var(--surface-3); }
.btn.ghost { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: #b91c1c; border-color: #b91c1c; }
.btn.danger:hover { background: #991b1b; border-color: #991b1b; }
.btn.lg { padding: 0.8rem 1.2rem; font-size: 0.98rem; }
.btn { width: auto !important; }
.btn.block { width: 100% !important; }
.tool {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 7px; margin: 0; padding: 0;
  border: 1px solid var(--border-strong); background: transparent; color: var(--primary-text);
}
.tool:hover { background: var(--primary-soft); text-decoration: none; }
.tool.danger { color: var(--bad); }
.tool.danger:hover { background: var(--bad-bg); }
.tool + .tool, .tool + form, form + .tool { margin-left: 0.35rem; }
button.link { background: none; border: none; color: var(--primary-text); padding: 0; margin: 0; width: auto; font-weight: 500; }
form.inline { display: inline; margin: 0; }
.big-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.big-actions form { margin: 0; }
@media (max-width: 600px) {
  .big-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .big-actions .btn, .big-actions form, .big-actions form .btn { width: 100%; }
}

/* ------------------------------------------------------------------- forms */
label { font-size: 0.86rem; color: var(--text); margin-bottom: 0.35rem; }
input:not([type="checkbox"], [type="radio"], [type="range"]), select, textarea { border-radius: var(--radius-sm); font-size: 0.93rem; }
/* Text box with suggestions (datalist): same chevron as a select; the browser's own picker button sits invisibly on top of it. */
input[list] { background-image: var(--pico-icon-chevron); background-position: center right 0.75rem; background-size: 1rem auto; background-repeat: no-repeat; padding-inline-end: 2.5rem; }
input[list]::-webkit-calendar-picker-indicator { opacity: 0; cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.field { min-width: 0; }
.field > small { display: block; margin-top: -0.55rem; margin-bottom: 0.9rem; color: var(--muted); }
.field-error { color: var(--bad) !important; }
.req { color: var(--bad); }
.form-errors { background: var(--bad-bg); color: var(--bad); padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.form-errors p { margin: 0; }
.form-section { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 1.25rem 0 0.8rem; font-weight: 600; }
.form-foot { display: flex; justify-content: flex-end; gap: 0.75rem; flex-wrap: wrap; border-top: 1px solid var(--border); margin-top: 0.5rem; padding-top: 1.1rem; }
.form-narrow { max-width: 48rem; }
fieldset.inline-radios { display: flex; gap: 1.5rem; flex-wrap: wrap; border: none; padding: 0; margin: 0 0 1rem; }
fieldset.inline-radios legend { width: 100%; font-size: 0.86rem; margin-bottom: 0.35rem; }
fieldset.inline-radios label { color: var(--text-2); }
.search-input { position: relative; }
.search-input .icon { position: absolute; z-index: 5; left: 0.85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input input { width: 100%; padding-left: 2.5rem !important; margin: 0 !important; }
.toolbar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .search-input { flex: 1; min-width: 14rem; }
.toolbar > select, .toolbar > input, .toolbar > .field input { margin: 0; width: auto; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0 0.9rem; align-items: end; padding-top: 0.75rem; }
.filters label { font-size: 0.8rem; color: var(--text-2); }
.filters select, .filters input { margin-bottom: 0.75rem; font-size: 0.88rem; }
.more-filters { margin: 0 0 1rem; }
.more-filters > summary { font-size: 0.88rem; color: var(--text-2); }
@media (max-width: 700px) {
  .form-grid, .form-grid.three { grid-template-columns: minmax(0, 1fr); }
  .form-foot .btn { flex: 1; }
}

/* ------------------------------------------------------------- tabs, pager */
.tabs { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 0.6rem; margin-bottom: 1.25rem; }
.tabs a {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-weight: 500; font-size: 0.9rem;
}
.tabs a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager { display: flex; gap: 0.35rem; align-items: center; }
.pager a, .pager span.current {
  display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; padding: 0 0.5rem; border-radius: 7px;
  border: 1px solid var(--border-strong); color: var(--text-2); font-size: 0.85rem;
}
.pager a:hover { background: var(--surface-2); text-decoration: none; }
.pager span.current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager .gap { color: var(--muted); padding: 0 0.2rem; }

/* ---------------------------------------------------------------- messages */
.messages { margin: 0.5rem 0 0; }
.flash { display: flex; gap: 0.6rem; align-items: center; padding: 0.75rem 1rem; border-radius: 10px; margin-bottom: 0.5rem; background: var(--info-bg); color: var(--info); border: 1px solid rgba(110, 168, 255, 0.2); }
.flash.success { background: var(--ok-bg); color: var(--ok); border-color: rgba(52, 209, 122, 0.25); }
.flash.warning { background: var(--warn-bg); color: var(--warn); border-color: rgba(251, 154, 60, 0.25); }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: rgba(248, 113, 113, 0.25); }

/* ------------------------------------------------------------------ charts */
.chart-legend { display: flex; gap: 1rem; font-size: 0.82rem; color: var(--text-2); align-items: center; }
.chart-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { width: 0.65rem; height: 0.65rem; border-radius: 50%; display: inline-block; flex: none; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart-scroll { overflow-x: auto; }
.chart-scroll svg.chart { min-width: 34rem; }
svg.chart text { fill: var(--muted); font-size: 11px; font-family: var(--pico-font-family); }
svg.chart .grid { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
svg.chart .hit { fill: transparent; cursor: default; }
svg.chart .hit:hover { fill: rgba(255, 255, 255, 0.04); }
.donut-wrap { display: grid; grid-template-columns: minmax(9rem, 12rem) 1fr; gap: 1.5rem; align-items: center; }
.donut-wrap svg { width: 100%; height: auto; }
svg.chart .donut-total { fill: var(--text); font-size: 22px; font-weight: 700; }
svg.chart .donut-caption { fill: var(--muted); font-size: 9px; }
.donut-legend { list-style: none; padding: 0; margin: 0; }
.donut-legend li { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0; list-style: none; color: var(--text-2); font-size: 0.9rem; }
.donut-legend li .pct { margin-left: auto; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .donut-wrap { grid-template-columns: 1fr; } .donut-wrap svg { max-width: 12rem; margin: 0 auto; } }
.tooltip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 0.5rem 0.7rem; font-size: 0.8rem;
  box-shadow: var(--shadow); line-height: 1.5; white-space: nowrap;
}
.tooltip .swatch { margin-right: 0.35rem; }
.tooltip b { font-weight: 700; }
details.data-table { margin-top: 0.5rem; }
details.data-table > summary { font-size: 0.8rem; color: var(--muted); display: inline-block; }
details.data-table > summary::after { float: none; display: inline-block; margin-left: 0.4rem; vertical-align: middle; }

/* ----------------------------------------------------------- misc widgets */
.item-thumb { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 7px; flex: none; }
.item-thumb.warn { background: var(--warn-bg); color: var(--warn); }
.item-thumb.bad { background: var(--bad-bg); color: var(--bad); }
.item-thumb.info { background: var(--info-bg); color: var(--info); }
.item-thumb.ok { background: var(--ok-bg); color: var(--ok); }
.with-thumb { display: flex; align-items: center; gap: 0.7rem; }
dl.facts { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: 0.6rem 1.5rem; margin: 0; }
dl.facts dt { color: var(--muted); font-weight: 400; }
dl.facts dd { margin: 0; color: var(--text); }
aside dl.facts { grid-template-columns: max-content 1fr; gap: 0.6rem 1rem; }
@media (max-width: 520px) { dl.facts { grid-template-columns: 1fr; gap: 0; } dl.facts dd { margin-bottom: 0.6rem; } }
.qr-card { text-align: center; }
.qr-card svg.qr { width: 11rem; height: 11rem; background: #fff; border-radius: 10px; padding: 0.45rem; }
.qr-card .tag { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.02em; margin: 0.6rem 0 0.1rem; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline > li { list-style: none; position: relative; padding: 0 0 1rem 1.5rem; margin: 0; }
.timeline > li::before { content: ""; position: absolute; left: 0.2rem; top: 0.4rem; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px var(--surface); }
.timeline > li::after { content: ""; position: absolute; left: 0.49rem; top: 1.15rem; bottom: 0.1rem; width: 1px; background: var(--border-strong); }
.timeline > li:last-child::after { display: none; }
.timeline > li.loan::before { background: var(--info); }
.timeline > li.stock::before { background: var(--ok); }
.timeline > li.maintenance::before { background: var(--warn); }
.timeline .when { font-size: 0.78rem; color: var(--muted); display: block; }
.timeline .what { color: var(--text); }
.timeline ul { margin: 0.25rem 0 0; padding-left: 1rem; font-size: 0.85rem; color: var(--text-2); }
.timeline ul li { list-style: disc; }
.person-results { max-height: 17rem; overflow-y: auto; border: 1px solid var(--border-strong); background: var(--input); border-radius: var(--radius-sm); padding: 0.35rem 0.8rem; margin-bottom: 0.4rem; }
.person-results .person-option { display: flex; align-items: flex-start; gap: 0.7rem; width: 100%; padding: 0.5rem 0.25rem; margin: 0; line-height: 1.35; color: var(--text); cursor: pointer; border-bottom: 1px solid var(--border); }
.person-results .person-option:last-child { border-bottom: none; }
.person-results .person-option:hover { background: var(--surface-2); }
.person-results .person-option input { flex: none; margin: 0.15rem 0 0; }
.person-results .person-option strong { display: block; font-weight: 500; }
.person-results .person-option small { display: block; margin: 0.1rem 0 0; color: var(--muted); }
progress { margin: 0 !important; height: 0.55rem; border-radius: 99px; }
.progress-row { display: flex; gap: 1rem; align-items: center; }
.progress-row progress { flex: 1; }
.scan-msg { display: flex; gap: 0.5rem; align-items: center; font-weight: 600; padding: 0.65rem 0.9rem; border-radius: var(--radius-sm); background: var(--ok-bg); color: var(--ok); margin: 0.75rem 0 0; }
.scan-msg.error { background: var(--bad-bg); color: var(--bad); }
tr.verified td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
tr.flash-row td { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: var(--ok-bg); } to { background: transparent; } }
.count-form { display: flex; gap: 0.4rem; align-items: center; margin: 0; }
.count-form input { width: 6.5rem; margin: 0 !important; padding: 0.35rem 0.6rem !important; height: 2.1rem; }
.count-form .btn { padding: 0.4rem 0.8rem; font-size: 0.82rem; }
tr.row-error td { background: var(--bad-bg) !important; color: var(--bad); }
tr.row-create td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
tr.row-update td:first-child { box-shadow: inset 3px 0 0 var(--info); }
.kind-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1.25rem; }
.kind-cards .card { display: flex; flex-direction: column; margin: 0; }
.kind-cards .card p { color: var(--text-2); flex: 1; }
.kind-cards .card .stat-icon { width: 44px; height: 44px; margin-bottom: 0.6rem; }
.report-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.report-cards a.card { display: flex; gap: 0.9rem; align-items: flex-start; margin: 0; color: var(--text); }
.report-cards a.card:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.report-cards a.card strong { display: block; }
.report-cards a.card p { margin: 0.2rem 0 0; color: var(--text-2); font-size: 0.88rem; }
.report-cards .item-thumb { width: 2.4rem; height: 2.4rem; }

/* ------------------------------------------------------------------ login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(900px 480px at 15% -10%, rgba(37, 99, 235, 0.2), transparent), var(--bg); }
.login-card { width: 100%; max-width: 25rem; }
.login-card .brand { padding: 0 0 0.25rem; }
.login-card h1 { font-size: 1.45rem; margin: 0.75rem 0 0.25rem; }

@media print {
  .sidebar, .topbar, .no-print, .messages { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; border-color: #ccc; background: #fff; color: #000; }
  body, table td, table td a, h1, h2 { color: #000 !important; background: #fff !important; }
  table thead th { background: #eee !important; color: #000 !important; }
}

.show-sm { display: none !important; }
@media (max-width: 700px) {
  .hide-sm { display: none; }
  .show-sm { display: block !important; }
}
.kind-cards a.card { color: var(--text); }
.kind-cards a.card:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.kind-cards a.card .btn { align-self: flex-start; }
