:root {
  --navy: #0d2a4a; --navy-2: #12375f; --navy-3: #1b4876; --orange: #f58220; --orange-2: #e06f0d;
  --bg: #f3f5f9; --card: #fff; --line: #e3e8ef; --text: #1d2939; --muted: #667085;
  --red: #d92d20; --red-bg: #fef3f2; --amber: #b54708; --amber-bg: #fffaeb; --green: #067647; --green-bg: #ecfdf3;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--navy-3); }
.hidden { display: none !important; }
.mono { font-family: Consolas, "Cascadia Mono", Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand b { font-size: 18px; letter-spacing: .5px; }
.brand span { display: block; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; opacity: .75; }

/* ---------- Auth screens ---------- */
#auth { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #1b4876 0%, transparent 60%), linear-gradient(160deg, #0a2340, #0d2a4a 55%, #102f52); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth-card .brand { color: var(--navy); margin-bottom: 22px; }
.auth-card h2 { margin: 0 0 4px; font-size: 20px; }
.auth-card p.lead { margin: 0 0 20px; color: var(--muted); }
.auth-foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); }
.qr { display: block; margin: 8px auto 12px; border: 1px solid var(--line); border-radius: 8px; }

/* ---------- Layout ---------- */
#app { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }
aside { background: var(--navy); color: #dbe4ef; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
aside .brand { color: #fff; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
nav { padding: 12px 10px; flex: 1; overflow: auto; }
nav .sec { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; opacity: .5; padding: 14px 10px 6px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #dbe4ef; text-decoration: none; margin-bottom: 2px; }
nav a:hover { background: rgba(255,255,255,.06); }
nav a.active { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--orange); }
nav a svg { width: 18px; height: 18px; opacity: .85; }
.who { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.who b { color: #fff; display: block; }
.who .role { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--orange); }
.who button { margin-top: 10px; width: 100%; }
main { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }

/* ---------- Components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.stat { padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.stat .v { font-size: 30px; font-weight: 700; margin-top: 4px; color: var(--navy); }
.stat.warn .v { color: var(--amber); } .stat.bad .v { color: var(--red); }
.stat a { font-size: 12px; text-decoration: none; }
.two { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }

button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { background: #f8fafc; }
button.primary, .btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--orange-2); }
button.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
button.danger { color: var(--red); border-color: #fecdca; }
button.danger:hover { background: var(--red-bg); }
button.ghost { border-color: transparent; background: transparent; }
aside button.ghost { color: #dbe4ef; border-color: rgba(255,255,255,.15); }
aside button.ghost:hover { background: rgba(255,255,255,.06); }
button.icon { padding: 5px 7px; border-color: transparent; background: transparent; color: var(--muted); }
button.icon:hover { background: #eef2f6; color: var(--navy); }
button.icon svg { width: 16px; height: 16px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.block { width: 100%; justify-content: center; padding: 11px; }

label { display: block; font-size: 12px; font-weight: 600; color: #344054; margin: 0 0 5px; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-3); box-shadow: 0 0 0 3px rgba(27,72,118,.15); }
input[type=checkbox] { width: auto; margin: 0; accent-color: var(--orange); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13px; margin: 6px 0; cursor: pointer; }
.err { background: var(--red-bg); color: var(--red); padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.note { background: #eef4fb; color: var(--navy-2); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.note.warn { background: var(--amber-bg); color: var(--amber); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px; border-bottom: 1px solid var(--line); }
.toolbar input[type=search] { flex: 1 1 240px; }
.toolbar select { flex: 0 1 170px; width: auto; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); background: #f9fafb; font-weight: 600; position: sticky; top: 0; }
tbody tr:hover { background: #fafbfd; }
tr.clickable { cursor: pointer; }
td .title { font-weight: 600; color: var(--navy); }
td.actions { white-space: nowrap; text-align: right; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.cell-secret { display: inline-flex; align-items: center; gap: 2px; }
.cell-secret .val { min-width: 74px; display: inline-block; }
.trunc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #eef2f6; color: #344054; white-space: nowrap; }
.badge.navy { background: #e6eef8; color: var(--navy-2); }
.badge.orange { background: #fff1e5; color: #b5520a; }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.green { background: var(--green-bg); color: var(--green); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button { border: none; border-radius: 0; background: none; padding: 12px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--navy); border-bottom-color: var(--orange); font-weight: 600; }

.bar-row { display: grid; grid-template-columns: 1fr 2fr 32px; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: #eef2f6; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--navy-3); border-radius: 4px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(13,42,74,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 760px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 25px 60px rgba(0,0,0,.3); }
.modal.sm { max-width: 440px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 17px; }
.modal .body { padding: 20px; overflow: auto; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.detail { display: grid; grid-template-columns: 150px 1fr; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.detail > div { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.detail > div:nth-last-child(-n+2) { border-bottom: none; }
.detail .k { background: #f9fafb; color: var(--muted); font-size: 12px; font-weight: 600; }
.detail .v { display: flex; align-items: center; gap: 6px; word-break: break-all; }
.notes { white-space: pre-wrap; background: #f9fafb; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 14px; }
.custom-row { display: grid; grid-template-columns: 1fr 1.4fr auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.group-list { max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }

#toast { position: fixed; bottom: 22px; right: 22px; z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; animation: pop .18s ease-out; }
.toast.bad { background: var(--red); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.mobile-top { display: none; }
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  aside { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  aside.open { transform: none; }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; background: var(--navy); color: #fff; padding: 10px 14px; }
  .mobile-top button { color: #fff; border-color: rgba(255,255,255,.2); background: transparent; }
  main { padding: 16px; }
  .detail { grid-template-columns: 1fr; } .detail .k { border-bottom: none; padding-bottom: 2px; }
}

/* ---------- Logo ---------- */
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.auth-brand img { height: 52px; width: auto; }
.auth-brand span { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); }
.side-brand { padding: 16px 14px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo-box { background: #fff; border-radius: 10px; padding: 10px 12px; display: flex; justify-content: center; }
.logo-box img { height: 40px; width: auto; max-width: 100%; }
.side-sub { text-align: center; color: #fff; opacity: .7; font-size: 11px; letter-spacing: 3px; text-transform: uppercase; margin-top: 10px; }
.side-sub::after { content: ""; display: block; width: 28px; height: 2px; background: var(--orange); margin: 6px auto 0; border-radius: 2px; }
.mobile-logo { background: #fff; border-radius: 8px; padding: 4px 8px; display: flex; }
.mobile-logo img { height: 26px; width: auto; }

/* ---------- Documents ---------- */
.dropzone { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 76px; padding: 14px; border: 2px dashed #c7d2e0; border-radius: 10px; background: #f8fafc; cursor: pointer; text-align: center; font-weight: 400; font-size: 13px; color: var(--text); }
.dropzone:hover, .dropzone.over { border-color: var(--orange); background: #fff7ef; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.doc-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 2px 0 4px; }
td.actions .btn { padding: 5px 9px; font-size: 12.5px; }
td.actions .btn svg, .modal .btn svg { width: 14px; height: 14px; }
.modal footer .danger { margin-right: auto; }
