/* Boldfit ITAM — styled on the internal-ds tokens (tokens.css), own identity:
   light top-bar frame (not the rail), teal primary, yellow only for the mark
   and "New". Every value comes from a token; no hard-coded colour. */

@font-face {
  font-family: 'Figtree Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url('/fonts/figtree-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--text-body-leading);
  background: var(--background);
  color: var(--foreground);
  min-height: 100%;
}

.hidden { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: var(--text-data); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }

/* ---------- top bar ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 28px; height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: auto; color: var(--foreground); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub {
  font-size: var(--text-label); font-weight: var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); text-transform: uppercase; color: var(--ink-3);
}
.tabs { display: flex; gap: 2px; height: 100%; }
.tab {
  font: inherit; font-weight: 600; color: var(--ink-2);
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 0 14px; cursor: pointer; height: 100%;
  transition: color var(--dur-fast) var(--ease-soft);
}
.tab:hover { color: var(--foreground); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- layout ---------- */
.main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.view.hidden { display: none; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; gap: 16px; }
h1 { font-size: var(--text-section); font-weight: var(--text-section-weight); letter-spacing: -0.01em; }
.view-desc { color: var(--ink-2); font-size: var(--text-body); margin-top: 2px; }

/* ---------- cards & tiles ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 16px; margin-bottom: 16px;
}
.card-label {
  font-size: var(--text-label); font-weight: var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 12px;
}
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 16px;
}
.tile .lbl {
  font-size: var(--text-label); font-weight: var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); text-transform: uppercase; color: var(--ink-3);
}
.tile .num {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--text-tile); font-weight: 800; color: var(--foreground);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 .card { margin-bottom: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* bar list (categories) */
.bar-row { display: grid; grid-template-columns: 140px 1fr 40px; gap: 10px; align-items: center; padding: 4px 0; }
.bar-row .cat { font-size: var(--text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { background: var(--muted); border-radius: var(--radius-xs); height: 8px; overflow: hidden; }
.bar-row .fill { background: var(--chart-1); height: 100%; border-radius: var(--radius-xs); }
.bar-row .n { text-align: right; color: var(--ink-2); font-family: var(--font-mono); font-size: var(--text-data); font-variant-numeric: tabular-nums; }

.model-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 24px; }
.model-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: var(--text-body); }
.model-row .n { font-family: var(--font-mono); font-size: var(--text-data); font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* activity + lists */
.feed-item { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: var(--text-body); align-items: baseline; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .when { color: var(--ink-3); font-size: var(--text-data); font-family: var(--font-mono); margin-left: auto; white-space: nowrap; }

/* ---------- toolbar & inputs ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type="search"] { flex: 1; min-width: 240px; }
input, select, textarea {
  font: inherit; font-size: var(--text-body); color: var(--foreground);
  background: var(--card); border: 1px solid var(--input);
  border-radius: var(--radius-md); padding: 5px 10px; height: 30px;
}
textarea { height: auto; }
select[size] { height: auto; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 1px;
}

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-size: var(--text-body); font-weight: 600;
  height: 30px; padding: 0 12px; border-radius: var(--radius-md);
  border: 1px solid var(--input); background: var(--card); color: var(--foreground);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-soft), border-color var(--dur-fast) var(--ease-soft);
}
.btn:hover { background: var(--muted); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--foreground)); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--muted); color: var(--foreground); }
.btn-sm { height: 24px; padding: 0 8px; font-size: var(--text-data); }
.btn-danger { color: var(--destructive); }

/* ---------- tables ---------- */
.table-card { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  font-size: var(--text-label); font-weight: var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); text-transform: uppercase;
  color: var(--ink-3); background: var(--muted);
  position: sticky; top: 0;
}
td { font-size: var(--text-body); }
tbody tr { transition: background var(--dur-fast) var(--ease-soft); }
tbody tr:hover { background: var(--accent); }
tbody tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; }
td .sub { color: var(--ink-3); font-size: var(--text-data); }
.empty { padding: 32px; text-align: center; color: var(--ink-2); }
.empty.hidden { display: none; }
.row-link { cursor: pointer; color: var(--primary); font-weight: 600; }
.row-link:hover { text-decoration: underline; }

/* ---------- pills (state only, dot + label) ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  border-radius: var(--radius-pill); padding: 1px 9px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: var(--radius-pill); background: currentColor; }
.pill.ok   { background: var(--ok-soft);   color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.mute { background: var(--mute-soft); color: var(--mute); }
.pill.teal { background: var(--secondary); color: var(--secondary-foreground); }
.pill.brand { background: var(--brand); color: var(--brand-foreground); }
.pill.brand::before { display: none; }

/* ---------- dialogs ---------- */
dialog {
  margin: auto; border: 0; border-radius: var(--radius-xl);
  background: var(--popover); color: var(--popover-foreground);
  padding: 20px; width: min(640px, 92vw);
  box-shadow: var(--shadow-overlay);
}
dialog.wide { width: min(760px, 94vw); }
dialog::backdrop { background: color-mix(in srgb, var(--foreground) 40%, transparent); }
dialog h2 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 14px 0; }
.form-grid label, .stack {
  display: flex; flex-direction: column; gap: 4px;
  font-size: var(--text-label); font-weight: var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); text-transform: uppercase; color: var(--ink-3);
}
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: span 1; } }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.stack { margin: 12px 0; }
#assign-person { width: 100%; }
#assign-person option { padding: 4px 8px; font-size: var(--text-body); }

/* detail grids */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 20px; margin: 14px 0; }
@media (max-width: 600px) { .detail-grid { grid-template-columns: 1fr 1fr; } }
.detail-grid .k {
  font-size: var(--text-label); font-weight: var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); text-transform: uppercase; color: var(--ink-3);
}
.detail-grid .v { font-size: var(--text-body); }
.detail-grid .v.mono { font-size: var(--text-data); }
.section-label {
  font-size: var(--text-label); font-weight: var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); text-transform: uppercase;
  color: var(--ink-3); margin: 16px 0 8px;
}
.history-item { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: var(--text-body); }
.history-item:last-child { border-bottom: 0; }
.history-item .when { color: var(--ink-3); font-size: var(--text-data); font-family: var(--font-mono); }

/* ---------- audit ---------- */
.head-actions { display: flex; gap: 8px; }
.audit-hero { text-align: center; padding: 48px 24px; }
.audit-hero h2 { font-size: var(--text-section); font-weight: var(--text-section-weight); margin-bottom: 6px; }
.audit-hero p { color: var(--ink-2); max-width: 480px; margin: 0 auto 16px; }

.progress-wrap { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; }
.progress {
  flex: 1; height: 8px; background: var(--muted);
  border-radius: var(--radius-pill); overflow: hidden;
}
.progress .fill {
  height: 100%; background: var(--primary); border-radius: var(--radius-pill);
  transition: width var(--dur-base) var(--ease-soft);
}
.progress-num { font-family: var(--font-mono); font-size: var(--text-data); font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }

.scan-row { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.scan-row input#audit-scan {
  flex: 1; min-width: 260px; height: 36px;
  border: 2px solid var(--primary); font-family: var(--font-mono);
}
.outcome-btns { display: inline-flex; gap: 4px; }
.obtn {
  font: inherit; font-size: var(--text-data); font-weight: 700;
  height: 24px; padding: 0 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--input); background: var(--card); color: var(--ink-2); cursor: pointer;
}
.obtn:hover { background: var(--muted); }
.obtn.on-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.obtn.on-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.obtn.on-crit { background: var(--crit-soft); border-color: var(--crit); color: var(--crit); }
tr.row-flash { animation: rowflash 1.2s var(--ease-soft); }
@keyframes rowflash { 0% { background: var(--secondary); } 100% { background: transparent; } }
.check-row { display: flex; gap: 8px; align-items: center; margin: 14px 0; font-size: var(--text-body); }
.check-row input { height: auto; }
.audit-counts { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.report-note { font-size: var(--text-data); color: var(--ink-2); }

/* ---------- user menu ---------- */
.user-menu { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--popover); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay);
  min-width: 200px; padding: 6px; display: flex; flex-direction: column;
}
.menu.hidden { display: none; }
.menu-head {
  padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
  font-size: var(--text-data); color: var(--ink-2);
}
.menu-head strong { display: block; color: var(--foreground); font-size: var(--text-body); }
.menu-item {
  font: inherit; font-size: var(--text-body); text-align: left;
  background: none; border: 0; border-radius: var(--radius-sm);
  padding: 7px 10px; cursor: pointer; color: var(--foreground);
}
.menu-item:hover { background: var(--muted); }

/* ---------- role gating ---------- */
body:not([data-role="Admin"]) .admin-only { display: none !important; }

/* ---------- bulk bar ---------- */
.bulk-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--secondary); color: var(--secondary-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 6px 12px; margin-bottom: 12px; font-size: var(--text-body);
}
.bulk-bar.hidden { display: none; }
.sel-col { width: 28px; }
.sel-col input, .sel-cell input { height: auto; }

/* ---------- import ---------- */
.import-inputs { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; }
#import-text { width: 100%; font-family: var(--font-mono); font-size: var(--text-data); }
#import-preview { margin-top: 10px; max-height: 240px; overflow: auto; font-size: var(--text-data); }
#import-preview .imp-err { color: var(--crit); }
#import-preview .imp-ok { color: var(--ok); }

/* ---------- camera ---------- */
#camera-video { width: 100%; border-radius: var(--radius-lg); background: #000; aspect-ratio: 4 / 3; margin-top: 8px; }

/* ---------- audit mobile cards ---------- */
#audit-cards { display: none; }
.audit-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 12px 14px; margin-bottom: 10px;
}
.audit-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.audit-card .meta-line { color: var(--ink-2); font-size: var(--text-data); margin: 2px 0 10px; }
.audit-card .outcome-btns { display: flex; gap: 8px; width: 100%; }
.audit-card .obtn { flex: 1; height: 40px; font-size: var(--text-body); }
.audit-card .note-line { margin-top: 8px; font-size: var(--text-data); color: var(--ink-2); }

/* ---------- responsive top bar ---------- */
@media (max-width: 760px) {
  .topbar-inner { gap: 10px; padding: 0 12px; height: 52px; }
  .brand-text { display: none; }
  .tabs { flex: 1; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 0 10px; white-space: nowrap; }
  .hide-sm { display: none; }
  .main { padding: 16px 12px; }
  .view-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .head-actions { flex-wrap: wrap; }
  /* audit: cards instead of table */
  #audit-table-card { display: none; }
  #audit-cards { display: block; }
  .scan-row input#audit-scan { min-width: 0; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--foreground); color: var(--background);
  padding: 8px 16px; border-radius: var(--radius-lg);
  font-size: var(--text-body); font-weight: 600;
  box-shadow: var(--shadow-overlay); z-index: 50;
}
.toast.error { background: var(--destructive); color: var(--destructive-foreground); }
.toast.hidden { display: none; }
