/* BluAudit - same design system as BluPulse */
:root {
  --bg: #060a14;
  --surface: rgba(255, 255, 255, .035);
  --surface-solid: #0e1526;
  --surface-2: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .08);
  --border-2: rgba(255, 255, 255, .14);
  --text: #e8edf8;
  --text-2: #b4bed3;
  --muted: #7f8ba6;
  --accent: #4c8dff;
  --accent-2: #22d3ee;
  --violet: #9b7bff;
  --ok: #2fd47c;
  --warn: #f6b042;
  --crit: #ff5470;
  --info: #5ab8ff;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .55);
  --sidebar-w: 252px;
  --sidebar-bg: rgba(10, 16, 32, .78);
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f1f4fa;
  --surface: rgba(255, 255, 255, .78);
  --surface-solid: #ffffff;
  --surface-2: rgba(15, 30, 70, .05);
  --border: rgba(15, 30, 70, .09);
  --border-2: rgba(15, 30, 70, .16);
  --text: #131b2e;
  --text-2: #3d4963;
  --muted: #6b7690;
  --accent: #2f6bf0;
  --accent-2: #0ab3d4;
  --ok: #17a85b;
  --warn: #d98a0b;
  --crit: #e5304f;
  --shadow: 0 10px 34px -14px rgba(25, 45, 100, .25);
  --sidebar-bg: rgba(255, 255, 255, .86);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--bg); min-height: 100vh; -webkit-font-smoothing: antialiased;
}
.backdrop {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(76, 141, 255, .20), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, rgba(155, 123, 255, .14), transparent 60%),
    radial-gradient(800px 500px at 50% 120%, rgba(34, 211, 238, .08), transparent 60%),
    var(--bg);
}
[data-theme="light"] .backdrop {
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(47, 107, 240, .12), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, rgba(124, 92, 230, .09), transparent 60%),
    var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 22px 0 12px; letter-spacing: -.01em; }
.card > h2:first-of-type { margin-top: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.ic { flex-shrink: 0; }

/* ---------- layout: sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 30;
  display: flex; flex-direction: column; gap: 6px; padding: 18px 14px;
  background: var(--sidebar-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-text b { display: block; font-size: 17px; letter-spacing: -.01em; line-height: 1.15; }
.brand-text small { color: var(--muted); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(76, 141, 255, .22), rgba(76, 141, 255, .05)); color: var(--accent); font-weight: 600; }
.nav-item .badge { margin-left: auto; background: var(--accent); color: #fff; font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--violet)); color: #fff; font-weight: 700;
}
.who b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { color: var(--muted); font-size: 11.5px; }
.foot-actions { display: flex; gap: 8px; }
.icon-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 10px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.content { max-width: 1280px; padding: 28px 32px 70px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 0; color: var(--muted); }
.mobilebar { display: none; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--sidebar-bg); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.menu-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.nav-scrim { display: none; }

/* ---------- cards, stats ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.card.danger { border-color: rgba(255, 84, 112, .45); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; color: var(--muted); box-shadow: var(--shadow); }
.stat span { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--text); margin-bottom: 2px; white-space: nowrap; }
.stat.warn span { color: var(--crit); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: 0; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover td, table tr:hover td { background: var(--surface-2); }
th:hover { background: none; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 2px solid var(--border-2); }
tr.dim { opacity: .55; }
.scroll { overflow-x: auto; }
td.bad { color: var(--crit); font-weight: 600; }
td.warnc { color: var(--warn); font-weight: 600; }
tr[hidden] { display: none; }
td.mono { white-space: nowrap; font-size: 13px; }

/* ---------- badges ---------- */
.tag { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); vertical-align: middle; border: 1px solid var(--border); }
.st { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.st-active, .st-verified, .st-completed { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.st-lost, .st-stolen, .st-missing { background: color-mix(in srgb, var(--crit) 16%, transparent); color: var(--crit); }
.st-new, .st-in_progress { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.st-pending { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

/* ---------- forms ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 18px; }
.grid .wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
label[hidden] { display: none; }
label.check { flex-direction: row; align-items: center; gap: 9px; color: var(--text-2); padding-top: 22px; }
label.check.wide { padding-top: 0; }
input, select, textarea {
  font: inherit; font-size: 14px; padding: 10px 12px; width: 100%;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text);
}
select option { background: var(--surface-solid); color: var(--text); }
input[type=checkbox] { width: 17px; height: 17px; padding: 0; accent-color: var(--accent); }
input[type=file] { padding: 8px; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
::placeholder { color: var(--muted); opacity: .8; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 18px; border: 0; border-radius: var(--radius-sm); cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2)));
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: var(--surface-2); color: var(--text-2); box-shadow: none; border: 1px solid var(--border-2); }
.btn.ghost:hover { color: var(--text); }
.btn.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); box-shadow: none; border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.btn.crit, .danger-btn { background: color-mix(in srgb, var(--crit) 18%, transparent); color: var(--crit); box-shadow: none; border: 1px solid color-mix(in srgb, var(--crit) 45%, transparent); }
.actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; grid-column: 1 / -1; }
.inline-form { display: flex; gap: 10px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.inline-form input { max-width: 280px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filters input[name=q] { max-width: 340px; }
.filters select { width: auto; }
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid transparent; }
.flash.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.flash.err { background: color-mix(in srgb, var(--crit) 14%, transparent); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 35%, transparent); }
.flash.info { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ---------- audits ---------- */
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 14px; }
.tab { font: inherit; font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2); cursor: pointer; }
.tab b { margin-left: 6px; font-weight: 700; }
.tab.on { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.scanbox { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.scanbox input { font-family: var(--mono); font-size: 17px; max-width: 460px; padding: 13px 16px; }
.note { min-width: 120px; width: 140px; padding: 6px 9px; font-size: 13px; }
#items th, #items td { padding: 10px 8px; }
.rowbtns { display: flex; gap: 6px; flex-wrap: nowrap; white-space: nowrap; }
.rowbtns .btn.small { padding: 5px 10px; font-size: 12.5px; }
.rowbtns form { margin: 0; }
.diff { color: var(--muted); }
.diff b { color: var(--text); font-weight: 600; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: 380px; padding: 13px 18px; border-radius: var(--radius-sm); background: var(--surface-solid); border: 1px solid var(--border-2); box-shadow: var(--shadow); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.toast.err { border-color: color-mix(in srgb, var(--crit) 55%, transparent); }

/* ---------- device files ---------- */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 8px; }
.file { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.file .thumb { position: relative; height: 130px; overflow: hidden; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex-shrink: 0; }
.file .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.file .meta .tag { align-self: flex-start; }
.file .meta { padding: 10px 12px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
.file .meta .name { color: var(--text); font-weight: 600; word-break: break-all; }
.file .meta form { margin-top: 4px; }

/* ---------- auth ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-wave { position: fixed; left: 0; right: 0; bottom: 9%; width: 100%; height: 170px; opacity: .6; pointer-events: none; z-index: -1; }
.auth-card {
  width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 32px 30px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 22px; box-shadow: var(--shadow);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.auth-brand b { font-size: 21px; letter-spacing: -.02em; display: block; line-height: 1.1; }
.auth-brand small { color: var(--muted); }
.auth-card p { margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; width: 272px; background: var(--surface-solid); }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 80px rgba(0, 0, 0, .6); }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .5); }
  .main { margin-left: 0; }
  .mobilebar { display: flex; }
  .content { padding: 20px 16px 60px; }
  h1 { font-size: 21px; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat span { font-size: 20px; }
  .card { padding: 16px; }
  .scanbox input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Phase 3: client portal ---------- */
.logo-mono { display: inline-grid; place-items: center; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; flex-shrink: 0; }
.brand-img { display: block; object-fit: contain; border-radius: 8px; flex-shrink: 0; }
.logo-prev { display: flex; align-items: center; gap: 14px; }
.logo-prev img { max-height: 48px; max-width: 160px; border-radius: 8px; background: var(--surface-2); padding: 4px; }
.check { display: flex; align-items: center; gap: 8px; flex-direction: row; font-size: 13px; color: var(--text-2); }
.check input { width: auto; }
.powered { display: block; color: var(--muted); font-size: 11px; text-align: center; margin-top: 10px; }
.sidebar-foot .powered { margin-top: 8px; }
.req-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.quote { border-left: 3px solid var(--border-2); padding: 2px 0 2px 12px; margin: 10px 0; color: var(--text-2); }
.reply { background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: var(--radius-sm); padding: 10px 14px; margin: 10px 0 0; }
.st-req-open { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.st-req-in_progress { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.st-req-resolved { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.st-req-rejected { background: var(--surface-2); color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 22px; margin: 0; }
.kv dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
.kv dd { margin: 0; word-break: break-word; }
.foot-actions { flex-wrap: wrap; }
.foot-actions .icon-btn { white-space: nowrap; }
.brand.has-logo { flex-direction: column; align-items: flex-start; gap: 8px; }
.brand.has-logo .brand-img { max-width: 190px !important; }
td .inline-form { margin: 0; }

/* Phase 5: self-scan */
pre.copy { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; user-select: all; }
.auth-card details { margin-top: 6px; }
.auth-card summary { cursor: pointer; }
.auth-card .stack { display: grid; gap: 12px; }
