/* ==========================================================================
   Procurement & Inventory — design system
   Light and dark, dense enough for real data entry, no framework.
   ========================================================================== */

:root {
  --bg:            #f5f6f8;
  --surface:       #ffffff;
  --surface-2:     #fafbfc;
  --surface-3:     #f0f2f5;
  --border:        #e2e5ea;
  --border-strong: #cbd1d9;
  --text:          #16191d;
  --text-2:        #4a5159;
  --text-3:        #838b95;

  --accent:        #1f4e79;
  --accent-hover:  #17395a;
  --accent-soft:   #e8f0f8;
  --accent-text:   #1f4e79;

  --success:       #1a7f47;
  --success-soft:  #e4f4ea;
  --warn:          #9a6208;
  --warn-soft:     #fdf1dc;
  --danger:        #b3261e;
  --danger-soft:   #fdeaea;
  --info:          #1d5c8f;
  --info-soft:     #e6f1f9;
  --neutral-soft:  #eef0f3;

  --radius:    8px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  --shadow-1: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.04);
  --shadow-2: 0 4px 12px rgba(16,24,40,.08), 0 2px 4px rgba(16,24,40,.04);
  --shadow-3: 0 18px 44px rgba(16,24,40,.18), 0 4px 12px rgba(16,24,40,.10);

  --sidebar-w: 244px;
  --topbar-h:  58px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg:            #0f1115;
  --surface:       #171a20;
  --surface-2:     #1c2027;
  --surface-3:     #232830;
  --border:        #2a2f38;
  --border-strong: #3a414c;
  --text:          #e9ecf1;
  --text-2:        #aab2bd;
  --text-3:        #737c88;

  --accent:        #5b9bd5;
  --accent-hover:  #7db0e0;
  --accent-soft:   #17273a;
  --accent-text:   #8ec0ea;

  --success:       #4ec27e;
  --success-soft:  #12301f;
  --warn:          #e0a94a;
  --warn-soft:     #33270f;
  --danger:        #f0736a;
  --danger-soft:   #371816;
  --info:          #6fb1e0;
  --info-soft:     #14283a;
  --neutral-soft:  #242932;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 12px rgba(0,0,0,.45);
  --shadow-3: 0 18px 44px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 620; letter-spacing: -.01em; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.brand-mark, .login-mark {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 17px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong {
  font-size: 13.5px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text span { font-size: 11.5px; color: var(--text-3); }

.sidebar-close { display: none; margin-left: auto; }

.nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }

.nav-group {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3);
  padding: 16px 8px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 1px;
  transition: background .12s, color .12s;
}
.nav-item::before {
  content: attr(data-icon);
  width: 18px; flex: 0 0 18px;
  text-align: center;
  font-size: 13px;
  opacity: .8;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.nav-item.active::before { opacity: 1; }

.sidebar-foot { border-top: 1px solid var(--border); padding: 10px; }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 8px;
  background: none; border: 0; border-radius: var(--radius-sm);
  cursor: pointer; text-align: left; color: inherit; font: inherit;
}
.user-chip:hover { background: var(--surface-3); }

.avatar {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta strong { font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 11px; color: var(--text-3); text-transform: capitalize; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 16px; font-weight: 650; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.menu-btn { display: none; }

.view { padding: 20px; flex: 1; outline: none; }
.view:focus { outline: none; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px;
  font: inherit; font-size: 13.5px; font-weight: 550;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
:root[data-theme="dark"] .btn-primary { color: #0f1115; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
:root[data-theme="dark"] .btn-danger { color: #0f1115; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2);
  cursor: pointer; font-size: 15px;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ── Cards & panels ─────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 16px; }

.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 14px; font-weight: 620; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* ── Stat tiles ─────────────────────────────────────────────────────────── */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color .12s, transform .12s;
}
a.stat:hover { border-color: var(--border-strong); text-decoration: none; transform: translateY(-1px); }
.stat-label {
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3);
}
.stat-value {
  font-size: 25px; font-weight: 650; letter-spacing: -.02em;
  margin-top: 5px; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.stat-value.sm { font-size: 19px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  font-size: 11.5px; font-weight: 650; letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th .sort-arrow { opacity: .55; font-size: 9px; margin-left: 3px; }

table.data td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: 0; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--text-3); }
.strong { font-weight: 600; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ── Badges ─────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
  background: var(--neutral-soft); color: var(--text-2);
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn    { background: var(--warn-soft);    color: var(--warn); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent-text); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Progress ───────────────────────────────────────────────────────────── */

.bar {
  height: 6px; border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden; min-width: 54px;
}
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.done > i { background: var(--success); }

/* ── Forms ──────────────────────────────────────────────────────────────── */

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}
.field > span .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-weight: 400; color: var(--text-3); font-size: 11.5px; }

input[type="text"], input[type="password"], input[type="email"], input[type="tel"],
input[type="number"], input[type="date"], input[type="url"], input[type="search"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 7px 10px;
  font: inherit; font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-3); color: var(--text-3); cursor: not-allowed;
}
input.err, select.err, textarea.err { border-color: var(--danger); }
textarea { resize: vertical; min-height: 68px; line-height: 1.45; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23838b95' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }

.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

.checkbox {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; cursor: pointer; margin-bottom: 12px;
}

.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid-3 { display: grid; gap: 0 16px; grid-template-columns: repeat(3, minmax(0,1fr)); }

fieldset.group {
  border: 0; padding: 0; margin: 0 0 4px;
}
fieldset.group > legend {
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-3);
  padding: 0 0 8px;
  margin-top: 6px;
}

/* ── Filter bar ─────────────────────────────────────────────────────────── */

.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.filters .search { flex: 1 1 240px; min-width: 180px; max-width: 380px; }
.filters select, .filters input[type="date"] { width: auto; min-width: 130px; }
.filters .spacer { margin-left: auto; }

/* ── Line-item editor ───────────────────────────────────────────────────── */

table.lines { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lines th {
  font-size: 11px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
  color: var(--text-3); text-align: left;
  padding: 7px 8px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
table.lines td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
table.lines input, table.lines select {
  padding: 5px 7px; font-size: 13px; border-color: var(--border);
}
table.lines input:focus, table.lines select:focus { border-color: var(--accent); }
table.lines td.num input { text-align: right; }
table.lines tfoot td { padding: 8px; font-weight: 600; }
.line-total { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 550; }

.totals-box {
  margin-left: auto;
  width: 100%;
  max-width: 300px;
  font-size: 13.5px;
}
.totals-box .row {
  display: flex; justify-content: space-between; gap: 20px;
  padding: 5px 0;
}
.totals-box .row.grand {
  border-top: 1px solid var(--border-strong);
  margin-top: 5px; padding-top: 9px;
  font-size: 16px; font-weight: 680;
}
.totals-box .row span:last-child { font-variant-numeric: tabular-nums; }

/* ── Detail view ────────────────────────────────────────────────────────── */

.detail-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px;
  margin-bottom: 16px;
}
.detail-head .titles h2 {
  font-size: 20px; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.detail-head .titles p { margin: 4px 0 0; color: var(--text-3); font-size: 13px; }
.detail-head .acts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-3); white-space: nowrap; }
.kv dd { margin: 0; }

.party {
  font-size: 13.5px; line-height: 1.6;
}
.party strong { display: block; font-size: 14.5px; margin-bottom: 2px; }

/* ── Timeline (shipment tracking) ───────────────────────────────────────── */

.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li {
  position: relative;
  padding: 0 0 18px 24px;
  border-left: 2px solid var(--border);
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 3px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border-strong);
  border: 2px solid var(--surface);
}
.timeline li.current::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline .t-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline .t-time { font-size: 12px; color: var(--text-3); }
.timeline .t-desc { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* ── Board (shipment kanban) ────────────────────────────────────────────── */

.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.board-col {
  flex: 0 0 265px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.board-col h3 {
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between;
}
.board-col .items { padding: 8px; display: flex; flex-direction: column; gap: 8px;
  max-height: 60vh; overflow-y: auto; }
.board-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px; cursor: pointer;
  font-size: 12.5px;
}
.board-card:hover { border-color: var(--border-strong); }
.board-card strong { font-size: 13px; display: block; }

/* ── Modal ──────────────────────────────────────────────────────────────── */

.modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16,20,26,.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 16px;
  overflow-y: auto;
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  width: 100%;
  max-width: 560px;
  animation: rise .16s ease-out;
  margin: auto 0;
}
.modal.wide  { max-width: 900px; }
.modal.xwide { max-width: 1180px; }

.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 15.5px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px; max-height: 68vh; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-foot .left { margin-right: auto; }

/* ── Toasts ─────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(400px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-3);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
  animation: rise .16s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warn    { border-left-color: var(--warn); }
.toast .close { margin-left: auto; cursor: pointer; color: var(--text-3);
  background: none; border: 0; font-size: 15px; line-height: 1; padding: 0 2px; }

/* ── Loading ────────────────────────────────────────────────────────────── */

.loading-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 300;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%;
  animation: slide 1s linear infinite;
}
@keyframes slide {
  from { background-position: -50% 0 } to { background-position: 150% 0 }
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 4px;
  height: 13px;
}
@keyframes shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }

/* ── Empty & error states ───────────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-3);
}
.empty .icon { font-size: 30px; opacity: .55; }
.empty h3 { margin: 12px 0 5px; font-size: 15px; color: var(--text-2); }
.empty p { margin: 0 auto 16px; max-width: 400px; font-size: 13.5px; }

.notice {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 14px;
}
.notice-warn   { background: var(--warn-soft);   border-color: transparent; color: var(--warn); }
.notice-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.notice-info   { background: var(--info-soft);   border-color: transparent; color: var(--info); }
.notice-success{ background: var(--success-soft);border-color: transparent; color: var(--success); }

/* ── Pagination ─────────────────────────────────────────────────────────── */

.pager {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-3);
}
.pager .spacer { margin-left: auto; }
.pager .pages { display: flex; gap: 4px; align-items: center; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */

.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  padding: 8px 14px;
  font-size: 13.5px; font-weight: 550;
  color: var(--text-2);
  background: none; border: 0; border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

/* ── Autocomplete ───────────────────────────────────────────────────────── */

.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 3px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  max-height: 260px; overflow-y: auto;
  min-width: 260px;
}
.combo-list:empty { display: none; }
.combo-opt { padding: 7px 11px; cursor: pointer; font-size: 13px; }
.combo-opt:hover, .combo-opt.hl { background: var(--accent-soft); }
.combo-opt small { display: block; color: var(--text-3); font-size: 11.5px; }

/* ── Login ──────────────────────────────────────────────────────────────── */

.login {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 50% -12%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 372px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 26px;
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 17px; }
.login-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }
.login-error {
  background: var(--danger-soft); color: var(--danger);
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px;
}

/* ── File list ──────────────────────────────────────────────────────────── */

.files { display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface-2);
}
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.file-row .size { color: var(--text-3); font-size: 12px; white-space: nowrap; }

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-3);
  }
  .sidebar.open { transform: none; }
  .sidebar-close { display: grid; }
  .menu-btn { display: grid; }
  .view { padding: 14px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 0 12px; }
  .topbar h1 { font-size: 15px; }
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; max-width: none; min-height: 100vh; }
  .modal-foot { border-radius: 0; position: sticky; bottom: 0; }
  .modal-body { max-height: none; }
}

.scrim {
  position: fixed; inset: 0; background: rgba(16,20,26,.4); z-index: 35;
}

@media print {
  .sidebar, .topbar, .toasts, .loading-bar { display: none !important; }
  .view { padding: 0; }
  .card { border: 0; box-shadow: none; }
}
