/* ============================================================
   OHP COMMAND NETWORK — records-management UI
   Flat, professional, data-forward. No glassmorphism theatrics.
   ============================================================ */
:root {
  --bg:          #e9edf3;
  --surface:     #ffffff;
  --surface-2:   #f5f7fb;
  --surface-3:   #eef2f8;

  --rail-top:    #0d2c52;
  --rail-bot:    #081d38;
  --rail-line:   rgba(255,255,255,0.08);

  --border:      #dce3ee;
  --border-2:    #c7d1e1;

  --ink:         #16202f;
  --muted:       #586079;
  --faint:       #8a94a8;

  --primary:     #1f5fbf;
  --primary-700: #1a4f9e;
  --primary-50:  #ecf2fc;

  --gold:        #a87c1c;
  --gold-bright: #e6b545;

  --green:  #1f9d57;  --green-bg:  #e6f6ed;
  --red:    #d23a4a;  --red-bg:    #fcebed;
  --amber:  #b9801a;  --amber-bg:  #fbf1de;
  --slate:  #64708a;  --slate-bg:  #eef1f6;

  --shadow-sm: 0 1px 2px rgba(16,24,40,0.06);
  --shadow:    0 6px 18px -8px rgba(16,24,40,0.18);
  --r:    10px;
  --r-sm: 7px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
::selection { background: rgba(31,95,191,0.18); }

/* legacy hooks from earlier markup — neutralised */
#bg-canvas, .bg-aurora, .bg-grid, .bg-scanline { display: none !important; }

/* ============================ LOGIN ============================ */
.landing {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    linear-gradient(180deg, #0d2c52 0%, #081d38 100%);
  position: relative;
}
.landing::after { /* faint top accent bar */
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--gold-bright), var(--primary));
}
.login-card {
  width: min(410px, 92vw); background: var(--surface); border-radius: 14px;
  padding: 38px 34px 30px; text-align: center; box-shadow: 0 24px 60px -20px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.08);
}
.login-card::before { display: none; }

.ohp-badge { width: 104px; height: auto; display: block; margin: 0 auto 18px; }
/* kill old decorative shells if present */
.shield, .dps-shield { display: none !important; }

.brand-kicker {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 3px;
  color: var(--gold); text-transform: uppercase; margin-bottom: 6px; font-weight: 700;
}
.brand-title { font-size: 25px; font-weight: 800; letter-spacing: -0.4px; margin: 0 0 6px; color: var(--ink); }
.brand-sub { color: var(--muted); font-size: 13px; margin: 0 0 2px; }
.brand-agency { color: var(--faint); font-size: 11px; margin: 0; }
.brand-motto {
  font-family: var(--mono); font-size: 10px; letter-spacing: 2.5px;
  color: var(--faint); text-transform: uppercase; margin: 20px 0; font-weight: 700;
}
.chevrons { display: none; }

.btn-discord {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px 18px; border: 0; border-radius: 9px; cursor: pointer;
  font-family: var(--font); font-size: 14.5px; font-weight: 700; color: #fff;
  background: #5865F2; transition: background .14s;
}
.btn-discord:hover { background: #4853c4; }
.btn-discord svg { width: 20px; height: 20px; }

.secure-row {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 16px; color: var(--faint); font-size: 11px;
}
.secure-row .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.login-error {
  margin-bottom: 16px; padding: 10px 13px; border-radius: 8px; font-size: 13px;
  background: var(--red-bg); border: 1px solid #f3c2c7; color: #9a2330; text-align: left;
}

/* ============================ APP SHELL ======================= */
.app { min-height: 100vh; display: flex; }

.sidebar {
  width: 244px; flex-shrink: 0; padding: 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--rail-top), var(--rail-bot));
  color: #cdd7e8;
}
.sb-brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px; border-bottom: 1px solid var(--rail-line); }
.ohp-badge-mini { width: 34px; height: auto; display: block; }
.sb-brand b { font-size: 14px; letter-spacing: .3px; color: #fff; }
.sb-brand span { display: block; font-size: 9.5px; color: #7e90ad; font-family: var(--mono); letter-spacing: 1.5px; margin-top: 1px; }

#nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-section-label { font-size: 10px; font-family: var(--mono); letter-spacing: 1.5px; color: #66789a; text-transform: uppercase; padding: 12px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 7px;
  color: #aebacf; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: background .12s, color .12s;
}
.nav-item svg { width: 17px; height: 17px; opacity: .9; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active { background: rgba(31,95,191,0.28); color: #fff; box-shadow: inset 2px 0 0 var(--gold-bright); }
.nav-spacer { flex: 1; }

.sb-user { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin: 10px; border-radius: 9px; background: rgba(0,0,0,0.22); border: 1px solid var(--rail-line); }
.sb-user img { width: 34px; height: 34px; border-radius: 7px; object-fit: cover; background: #14365f; }
.sb-user .nm { font-size: 12.5px; font-weight: 600; color: #fff; }
.sb-user .rk { font-size: 10.5px; color: var(--gold-bright); font-family: var(--mono); margin-top: 1px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; height: 58px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: -.2px; margin: 0; }
.topbar .crumb { font-family: var(--mono); font-size: 10px; color: var(--faint); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 1px; }
.btn-logout { padding: 7px 13px; border-radius: 7px; border: 1px solid var(--border-2); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 12.5px; cursor: pointer; transition: .12s; }
.btn-logout:hover { color: var(--red); border-color: #e6b3b8; background: var(--red-bg); }

#content { padding: 24px 26px 50px; }

/* ============================ CARDS / PRIMITIVES ============== */
.glass, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.view { animation: fade .16s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.section-head h2 { font-size: 14px; margin: 0; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--ink); }
.section-head h2::before { content: ''; display: inline-block; width: 3px; height: 13px; background: var(--gold); margin-right: 9px; vertical-align: -1px; border-radius: 2px; }
.section-head .rule { flex: 1; height: 1px; background: var(--border); }

/* ── Stat tiles ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { padding: 16px 18px; position: relative; }
.stat .lbl { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .3px; text-transform: uppercase; }
.stat .val { font-size: 30px; font-weight: 800; letter-spacing: -1px; margin-top: 4px; line-height: 1; color: var(--ink); }
.stat .spark { position: absolute; right: 16px; top: 16px; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.stat .spark svg { width: 16px; height: 16px; }

/* ── Toolbar / filters ── */
.toolbar { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.search { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface); }
.search input { flex: 1; background: transparent; border: 0; outline: 0; color: var(--ink); font-size: 13.5px; font-family: var(--font); }
.search svg { width: 15px; height: 15px; color: var(--faint); }
.chip { padding: 8px 13px; border-radius: 7px; border: 1px solid var(--border-2); background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; transition: .12s; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Roster: data rows, not floaty cards ── */
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.member {
  padding: 13px 15px; cursor: pointer; display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  transition: border-color .12s, background .12s;
}
.member::after { display: none; }
.member:hover { border-color: var(--primary); background: var(--primary-50); }
.member .av { width: 40px; height: 40px; border-radius: 7px; object-fit: cover; background: var(--surface-3); flex-shrink: 0; border: 1px solid var(--border); }
.member .head { display: contents; }
.member .who { min-width: 0; flex: 1; }
.member .who .cs { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .3px; }
.member .who .nm { font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .rkrow { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.member .rkrow > span:last-child { display: none; } /* hide long rank name; pill is enough */
.rank-pill { padding: 3px 8px; border-radius: 5px; background: var(--slate-bg); border: 1px solid var(--border-2); color: var(--primary-700); font-weight: 700; font-size: 10.5px; font-family: var(--mono); letter-spacing: .5px; }
.member .meta { display: none; } /* status/certs moved into compact form below */
/* compact status line under the name */
.member .who .subline { display: flex; align-items: center; gap: 7px; margin-top: 3px; font-size: 11px; color: var(--muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.badges { display: flex; gap: 4px; }
.cert { font-family: var(--mono); font-size: 9px; font-weight: 700; padding: 2px 5px; border-radius: 4px; letter-spacing: .4px; }
.cert.hsu  { background: var(--green-bg); color: #157a41; }
.cert.teu  { background: #e2f0fb; color: #1763a8; }
.cert.swat { background: var(--red-bg); color: #b32a38; }
.ia-flag { font-family: var(--mono); font-size: 10px; }

/* ── Rank structure ── */
.rank-section { margin-bottom: 18px; }
.rank-section h3 { font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; color: var(--gold); text-transform: uppercase; margin: 0 0 8px; font-weight: 700; }
.rank-row { display: flex; align-items: center; gap: 14px; padding: 11px 15px; border: 1px solid var(--border); background: var(--surface); margin-bottom: -1px; }
.rank-section .rank-row:first-of-type { border-top-left-radius: var(--r-sm); border-top-right-radius: var(--r-sm); }
.rank-section .rank-row:last-of-type { border-bottom-left-radius: var(--r-sm); border-bottom-right-radius: var(--r-sm); }
.rank-row:hover { background: var(--surface-2); }
.rank-row .abbr { font-family: var(--mono); font-weight: 700; color: var(--primary-700); width: 52px; font-size: 12px; }
.rank-row .nm { font-weight: 600; flex: 1; font-size: 13.5px; }
.rank-row .cnt { font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* ============================ DATA TABLE ===================== */
.table-wrap { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data thead th {
  text-align: left; padding: 10px 14px; background: var(--surface-3); color: var(--muted);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border);
}
table.data tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--ink); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill.green { background: var(--green-bg); color: #157a41; }
.pill.red { background: var(--red-bg); color: #b32a38; }
.pill.amber { background: var(--amber-bg); color: #94650f; }
.pill.slate { background: var(--slate-bg); color: var(--slate); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* ============================ PERMISSIONS (RBAC) ============= */
.perm-admin { display: grid; grid-template-columns: 232px 1fr; gap: 18px; align-items: start; }
.role-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.role-list-head { padding: 11px 14px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: var(--surface-3); border-bottom: 1px solid var(--border); }
.role-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: background .1s; }
.role-item:last-child { border-bottom: 0; }
.role-item:hover { background: var(--surface-2); }
.role-item.active { background: var(--primary-50); box-shadow: inset 3px 0 0 var(--primary); }
.role-item .ab { font-family: var(--mono); font-weight: 700; font-size: 11px; color: var(--primary-700); width: 42px; }
.role-item .rn { font-size: 13px; font-weight: 600; color: var(--ink); flex: 1; }
.role-item .ct { font-size: 11px; color: var(--faint); font-family: var(--mono); }

.perm-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.perm-panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.perm-panel-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.perm-panel-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.perm-panel-head .admin-note { font-size: 11.5px; color: var(--faint); }
.perm-group { padding: 6px 20px 10px; }
.perm-group-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--gold); padding: 16px 0 4px; }
.perm-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.perm-group .perm-switch-row:last-child { border-bottom: 0; }
.psr-text b { font-size: 13.5px; font-weight: 600; color: var(--ink); display: block; }
.psr-text small { font-size: 12px; color: var(--muted); }

/* iOS-style switch */
.switch { position: relative; width: 40px; height: 23px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; background: var(--border-2); border-radius: 20px; transition: background .16s; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform .16s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + .track { opacity: .5; }

/* ============================ CITATIONS ====================== */
.cite-layout { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .cite-layout { grid-template-columns: 1fr; } }
.cite-form { padding: 18px 20px; }
.cite-form h3 { margin: 0 0 4px; font-size: 15px; }
.cite-form .hint { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.cite-stats { display: flex; gap: 10px; margin-bottom: 14px; }
.cite-stat { flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; }
.cite-stat .n { font-size: 20px; font-weight: 800; }
.cite-stat .l { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }

/* ============================ FORM FIELDS ==================== */
.field { margin: 0 0 13px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; letter-spacing: .2px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--ink); font-size: 13.5px; font-family: var(--font); transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.field textarea { resize: vertical; min-height: 64px; }
.field-row { display: flex; gap: 11px; }
.field-row .field { flex: 1; }

.btn { padding: 9px 15px; border-radius: 8px; border: 1px solid transparent; font-weight: 600; font-size: 13.5px; cursor: pointer; transition: .12s; font-family: var(--font); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-700); }
.btn.ghost { background: var(--surface); border-color: var(--border-2); color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.block { width: 100%; }
.btn.danger { background: var(--surface); border-color: #e6b3b8; color: var(--red); }
.btn.danger:hover { background: var(--red-bg); }

/* ============================ REFERENCE PAGES =============== */
.ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.ref-item { display: flex; gap: 11px; padding: 10px 13px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-sm); align-items: center; }
.ref-item .code { font-family: var(--mono); font-weight: 700; color: var(--primary-700); min-width: 48px; }
.uof-row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border: 1px solid var(--border); background: var(--surface); margin-bottom: -1px; }
.uof-row:first-of-type { border-radius: var(--r-sm) var(--r-sm) 0 0; }
.uof-row:last-of-type { border-radius: 0 0 var(--r-sm) var(--r-sm); }
.uof-row .lv { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-family: var(--mono); flex-shrink: 0; }

/* ============================ LOCKED / EMPTY ================ */
.locked { display: grid; place-items: center; padding: 60px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.locked svg { width: 38px; height: 38px; color: var(--faint); margin-bottom: 12px; }
.empty { padding: 28px; text-align: center; color: var(--faint); font-size: 13px; }

/* ============================ MODAL ========================= */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(12,24,44,0.5); display: grid; place-items: center; padding: 20px; animation: fade .12s; }
.modal { width: min(460px, 94vw); background: var(--surface); border-radius: 12px; padding: 24px; box-shadow: 0 30px 70px -20px rgba(0,0,0,0.5); max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 3px; font-size: 17px; }
.modal .modal-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

/* ============================ TOAST ========================= */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(12px); z-index: 80; padding: 11px 18px; border-radius: 9px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; opacity: 0; transition: .2s; box-shadow: var(--shadow); pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #156b3a; }
.toast.err { background: #b32a38; }

/* ============================ LOADER ======================= */
.boot { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: var(--bg); transition: opacity .3s; }
.boot.gone { opacity: 0; pointer-events: none; }
.boot .spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border-2); border-top-color: var(--primary); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ RESPONSIVE =================== */
.menu-btn { display: none; width: 36px; height: 36px; border-radius: 7px; border: 1px solid var(--border-2); background: var(--surface); place-items: center; cursor: pointer; color: var(--muted); }
@media (max-width: 880px) {
  .sidebar { position: fixed; left: -260px; z-index: 60; transition: left .2s; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  .menu-btn { display: inline-grid; }
  #content { padding: 18px 16px 40px; }
  .perm-admin, .cite-layout { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
