:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #1a2233;
  --ink-soft: #5a6577;
  --line: #e4e8f0;
  --brand: #1f3a5f;
  --brand-2: #2c5fa8;
  --accent: #d4af37;
  --shadow: 0 1px 3px rgba(20, 33, 61, .06), 0 8px 24px rgba(20, 33, 61, .06);
  --radius: 12px;

  --sev-low: #1f9d55;
  --sev-medium: #c98a00;
  --sev-high: #e2660f;
  --sev-critical: #d23b3b;

  --st-open: #d23b3b;
  --st-investigating: #c98a00;
  --st-resolved: #2c5fa8;
  --st-closed: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

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

/* ---------- Top bar ---------- */
.topbar {
  background: linear-gradient(180deg, var(--brand), #16273f);
  color: #fff;
  padding: 0;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .mark {
  width: 40px; height: 40px; border-radius: 9px;
  background: var(--accent);
  color: #16273f;
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
}
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .2px; font-weight: 650; }
.brand .sub { font-size: 12px; color: #b9c6db; margin-top: 1px; letter-spacing: .3px; text-transform: uppercase; }
.topbar nav { display: flex; gap: 8px; align-items: center; }
.topbar nav a {
  color: #dbe4f1; padding: 8px 14px; border-radius: 8px; font-size: 14px;
  font-weight: 500;
}
.topbar nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.topbar nav a.active { background: rgba(255,255,255,.16); color: #fff; }

/* ---------- Layout ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 28px; }
.page-head { margin-bottom: 22px; }
.page-head h2 { margin: 0 0 4px; font-size: 24px; font-weight: 680; }
.page-head p { margin: 0; color: var(--ink-soft); }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand-2); }
.stat.crit::before { background: var(--sev-critical); }
.stat.open::before { background: var(--st-open); }
.stat.res::before { background: var(--sev-low); }
.stat .num { font-size: 30px; font-weight: 720; line-height: 1; }
.stat .lbl { color: var(--ink-soft); font-size: 13px; margin-top: 6px; text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-toolbar {
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.search { flex: 1 1 260px; position: relative; }
.search input {
  width: 100%; padding: 10px 12px 10px 38px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 14px; background: #fbfcfe;
}
.search input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(44,95,168,.12); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); }
select.filter {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fbfcfe; font-size: 14px; color: var(--ink); cursor: pointer; min-width: 150px;
}
select.filter:focus { outline: none; border-color: var(--brand-2); }
.result-count { color: var(--ink-soft); font-size: 13px; margin-left: auto; }

/* ---------- Table ---------- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 820px; }
table.data thead th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink-soft); padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: #fafbfd; white-space: nowrap; font-weight: 650;
}
table.data tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink); }
table.data tbody tr { cursor: pointer; transition: background .12s; border-left: 4px solid transparent; }
table.data tbody tr:hover { background: #f6f9ff; }
table.data tbody tr:last-child td { border-bottom: none; }
/* Rows are colour-coded by severity: a left accent bar + a faint row tint. */
table.data tbody tr.sev-low { border-left-color: var(--sev-low); background: rgba(31,157,85,.045); }
table.data tbody tr.sev-medium { border-left-color: var(--sev-medium); background: rgba(201,138,0,.05); }
table.data tbody tr.sev-high { border-left-color: var(--sev-high); background: rgba(226,102,15,.055); }
table.data tbody tr.sev-critical { border-left-color: var(--sev-critical); background: rgba(210,59,59,.055); }
table.data tbody tr.sev-low:hover,
table.data tbody tr.sev-medium:hover,
table.data tbody tr.sev-high:hover,
table.data tbody tr.sev-critical:hover { background: #eef4ff; }
.t-title { font-weight: 600; color: var(--ink); }
.t-filing { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; color: var(--ink-soft); }
.lock-hint { color: var(--ink-soft); font-size: 12px; display: inline-flex; align-items: center; gap: 5px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 640; white-space: nowrap; border: 1px solid transparent;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sev-low { color: var(--sev-low); background: rgba(31,157,85,.10); }
.sev-medium { color: var(--sev-medium); background: rgba(201,138,0,.12); }
.sev-high { color: var(--sev-high); background: rgba(226,102,15,.12); }
.sev-critical { color: var(--sev-critical); background: rgba(210,59,59,.12); }
.badge.sev-low, .badge.sev-medium, .badge.sev-high, .badge.sev-critical { }
.st-open { color: var(--st-open); background: rgba(210,59,59,.10); }
.st-investigating { color: var(--st-investigating); background: rgba(201,138,0,.12); }
.st-resolved { color: var(--st-resolved); background: rgba(44,95,168,.12); }
.st-closed { color: var(--st-closed); background: rgba(107,114,128,.12); }

.empty { padding: 48px; text-align: center; color: var(--ink-soft); }

/* ---------- Pagination ---------- */
.card-foot { padding: 14px 18px; border-top: 1px solid var(--line); background: #fafbfd; }
.card-foot:empty, .pager:empty { display: none; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.page-btn {
  min-width: 38px; padding: 8px 12px; border: 1px solid var(--line); background: #fff;
  border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer;
  transition: background .12s, border-color .12s;
}
.page-btn:hover:not(:disabled):not(.active) { background: #f0f5ff; border-color: var(--brand-2); }
.page-btn.active { background: var(--brand-2); color: #fff; border-color: var(--brand-2); cursor: default; }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Report detail banner ---------- */
.doc-banner {
  background: linear-gradient(180deg, var(--brand), #16273f); color: #fff;
  padding: 12px 16px; border-radius: 9px; font-weight: 650; font-size: 14px;
  letter-spacing: .2px; margin-bottom: 16px; text-align: center;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 9px;
  font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  background: var(--brand-2); color: #fff; transition: filter .12s, background .12s;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.primary { background: var(--brand-2); }
.btn.gold { background: var(--accent); color: #3a2f06; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #f6f9ff; }
.btn.danger { background: var(--sev-critical); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 60px rgba(15,23,42,.35); overflow: hidden; animation: pop .16s ease;
  max-height: calc(100vh - 40px); display: flex; flex-direction: column;
}
.modal-head, .modal-foot { flex-shrink: 0; }
#pw-step, #detail-step { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.modal-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-head .x { cursor: pointer; color: var(--ink-soft); font-size: 22px; line-height: 1; background: none; border: none; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.lock-icon { width: 46px; height: 46px; border-radius: 10px; background: rgba(44,95,168,.1); color: var(--brand-2); display: grid; place-items: center; margin-bottom: 14px; }
.pw-field { margin-top: 6px; }
.pw-field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 600; }
.pw-field input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px;
}
.pw-field input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(44,95,168,.12); }
.pw-error { color: var(--sev-critical); font-size: 13px; margin-top: 10px; display: none; }
.pw-error.show { display: block; }

/* Detail view inside modal */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin: 4px 0 14px; }
.detail-grid .full { grid-column: 1 / -1; }
.detail-item .k { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); font-weight: 650; }
.detail-item .v { font-size: 14px; margin-top: 2px; }
.detail-block { margin-top: 12px; }
.detail-block .k { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); font-weight: 650; margin-bottom: 4px; }
.detail-block p { margin: 0; font-size: 14px; color: #2c3648; }

/* ---------- Forms (admin) ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px;
  font-family: inherit; background: #fbfcfe;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(44,95,168,.12);
}
.field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 9px; margin-bottom: 18px; font-size: 14px; border: 1px solid transparent; }
.alert.ok { background: rgba(31,157,85,.1); color: #146c3a; border-color: rgba(31,157,85,.25); }
.alert.err { background: rgba(210,59,59,.1); color: #9b2020; border-color: rgba(210,59,59,.25); }

/* ---------- Admin table actions ---------- */
.row-actions { display: flex; gap: 8px; }
.pill-file { font-size: 12px; color: var(--sev-low); font-weight: 600; }
.pill-nofile { font-size: 12px; color: var(--ink-soft); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #16273f, #24406b); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.35); width: 100%; max-width: 400px; padding: 34px; }
.login-card .mark { width: 52px; height: 52px; border-radius: 12px; background: var(--accent); color: #16273f; display: grid; place-items: center; font-weight: 800; font-size: 26px; margin: 0 auto 16px; }
.login-card h2 { text-align: center; margin: 0 0 4px; }
.login-card p.sub { text-align: center; color: var(--ink-soft); margin: 0 0 22px; font-size: 14px; }

.site-foot { text-align: center; color: var(--ink-soft); font-size: 13px; padding: 26px; }

code.inline { background: #eef2f8; padding: 2px 7px; border-radius: 6px; font-size: 13px; }

@media (max-width: 780px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .topbar nav a { padding: 8px 10px; }
}
