:root {
  --navy: #12305a; --navy-2: #1b3f73; --navy-ink: #0d2240;
  --teal: #0f8f83; --teal-soft: #e3f5f2; --teal-ink: #0b6e65;
  --bg: #f3f5f8; --card: #ffffff; --line: #dde3ea; --line-2: #eef1f5;
  --ink: #17202b; --muted: #5d6b7c; --faint: #8a97a6;
  --ok: #18794e; --ok-soft: #e4f4ea; --warn: #9a5b00; --warn-soft: #fff3dc; --bad: #b42318; --bad-soft: #fde8e6;
  --info-soft: #e8eefb; --info: #1d4ed8;
  --vault: #2f6b4f; --vault-soft: #e5f1ea; --aw: #1b3f73; --aw-soft: #e7eef9;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,32,56,.06), 0 4px 14px rgba(16,32,56,.06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
a { color: var(--teal-ink); }
h1, h2, h3 { margin: 0; color: var(--navy-ink); }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
button, input, select, textarea { font: inherit; }
.boot { padding: 48px; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---------- sign-in ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-brand { background: linear-gradient(160deg, var(--navy) 0%, #0b2547 70%, #0a3a4f 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-brand h1 { color: #fff; font-size: 30px; line-height: 1.2; margin-top: 28px; }
.login-brand p { color: #c8d6ea; max-width: 440px; line-height: 1.55; }
.brand-mark { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; }
.brand-mark .logo { width: 34px; height: 34px; border-radius: 8px; background: #5fd3c4; color: var(--navy); display: grid; place-items: center; font-weight: 800; }
.login-apps { display: grid; gap: 10px; max-width: 440px; }
.login-apps div { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 12px 14px; color: #dbe6f5; }
.login-apps b { color: #fff; }
.login-form { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 20px; margin-bottom: 6px; }
.login-card .muted { margin-bottom: 22px; line-height: 1.5; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--navy); color: #cfdbec; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side .brand-mark { color: #fff; padding: 4px 8px 18px; }
.nav-group { margin: 10px 0 4px; padding: 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #8fa6c4; display: flex; align-items: center; gap: 6px; }
.nav-group .dot { width: 8px; height: 8px; border-radius: 50%; }
.side a.nav { display: flex; align-items: center; gap: 10px; color: #dce6f3; text-decoration: none; padding: 8px 10px; border-radius: 8px; margin: 1px 0; }
.side a.nav:hover { background: rgba(255,255,255,.07); }
.side a.nav.active { background: rgba(95,211,196,.16); color: #fff; box-shadow: inset 3px 0 0 #5fd3c4; }
.side .spacer { flex: 1; }
.side .me { border-top: 1px solid rgba(255,255,255,.1); padding: 12px 10px 0; font-size: 12.5px; }
.side .me b { color: #fff; display: block; font-size: 13px; }
.side .me button { margin-top: 10px; width: 100%; }
.main { padding: 22px 28px 48px; min-width: 0; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.btn.menu-btn { display: none; }

/* ---------- cards & grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.card > .bd { padding: 16px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 24px; font-weight: 650; color: var(--navy-ink); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--faint); margin-top: 2px; }
.app-card .hd .title { display: flex; align-items: center; gap: 10px; }
.app-badge { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.app-badge.aw { background: var(--aw-soft); color: var(--aw); } .app-badge.fv { background: var(--vault-soft); color: var(--vault); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td .name { font-weight: 600; color: var(--navy-ink); }
td .sub { color: var(--muted); font-size: 12px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--line-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.badge.teal { background: var(--teal-soft); color: var(--teal-ink); }
.badge .pip { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 550; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f5f7fa; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; } .btn.primary:hover { background: var(--teal-ink); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; } .btn.navy:hover { background: var(--navy-2); }
.btn.danger { color: var(--bad); border-color: #f1c4bf; } .btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost-light { background: transparent; border-color: rgba(255,255,255,.25); color: #e6eef8; } .btn.ghost-light:hover { background: rgba(255,255,255,.08); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 12.5px; color: var(--navy-ink); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%; border: 1px solid #cdd5df; border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink); }
textarea { min-height: 76px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { width: 240px; }
.toolbar select, .toolbar input[type=date] { width: auto; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 550; }
.tabs a.active { color: var(--navy-ink); border-bottom-color: var(--teal); }

.notice { border-radius: 10px; padding: 12px 14px; border: 1px solid; margin-bottom: 14px; line-height: 1.5; }
.notice.info { background: var(--info-soft); border-color: #c9d6f5; color: #1e3a8a; }
.notice.warn { background: var(--warn-soft); border-color: #f1d9a6; color: #6b4100; }
.notice.bad { background: var(--bad-soft); border-color: #f1c4bf; color: #8a1c13; }
.notice.ok { background: var(--ok-soft); border-color: #bfe3cc; color: #0f5132; }
.error-text { color: var(--bad); font-size: 13px; margin: 8px 0; min-height: 1em; }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(13,34,64,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .hd { padding: 16px 18px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; }
.modal .bd { padding: 16px 18px; }
.modal .ft { padding: 12px 18px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }
.secret { display: flex; gap: 8px; align-items: center; background: #0d2240; color: #e6f7f4; padding: 10px 12px; border-radius: 8px; font-family: Consolas, monospace; font-size: 15px; letter-spacing: .5px; word-break: break-all; }
.secret .btn { margin-left: auto; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--navy-ink); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; font-size: 13px; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 28px; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; } .login-brand { padding: 28px 20px; } .login-brand h1 { font-size: 22px; } .login-apps { display: none; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .btn.menu-btn { display: inline-flex; }
  .main { padding: 16px; }
  .g2 { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .toolbar input[type=search] { width: 100%; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
