:root {
  --brand: #0F3A73;
  --accent: #3BA516;
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #16202e;
  --muted: #667085;
  --line: #e4e7ec;
  --red: #c0392b;
  --red-bg: #fdecea;
  --amber: #a15c00;
  --amber-bg: #fff4e0;
  --green: #1e7b4b;
  --green-bg: #e6f6ed;
  --blue-bg: #e8f0fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); }
h2, h3 { margin: 0; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.small, small { font-size: 12.5px; }
.loading { padding: 24px; color: var(--muted); }
.loading.full { padding: 30vh 0; text-align: center; }
.grow { flex: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- auth ---------- */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #0F3A73 0%, #0b2a54 60%, #0a2347 100%); }
.auth-logo { display: block; width: 230px; max-width: 80%; margin: 0 auto 18px; }
.auth-foot { color: #9fb3cf; font-size: 13px; font-style: italic; margin-top: 16px; }
.center { text-align: center; justify-content: center; }
.pw-wrap { position: relative; }
.pw-wrap .inp { padding-right: 62px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 4px 8px; }
.login-chip { background: #f2f6fb; border: 1px solid #dbe5f1; border-radius: 8px; padding: 10px 12px; display: grid; gap: 2px; }
.login-chip small { color: var(--muted); }
.login-chip strong { font-size: 16px; word-break: break-all; }
.steps { margin: 4px 0 8px 18px; padding: 0; display: grid; gap: 4px; }
.cred { display: grid; gap: 10px; background: #f2f6fb; border: 1px solid #dbe5f1; border-radius: 10px; padding: 14px; }
.cred div { display: grid; gap: 2px; }
.cred small { color: var(--muted); }
.cred strong { font-size: 18px; }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .5px; }
.seg { display: flex; background: #f2f4f7; border-radius: 9px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 7px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 14px; }
.me-link { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; padding: 6px; margin: -6px; border-radius: 8px; }
.me-link:hover, .me-link.active { background: #1d2939; }
.me-link > span:last-child { display: grid; }
.me-name { font-weight: 600; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.powered { display: flex; align-items: center; gap: 6px; color: #667085; font-size: 11.5px; margin-top: 8px; }
.powered img { width: 16px; height: 16px; border-radius: 3px; }
.auth-card { background: var(--card); width: 100%; max-width: 400px; border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-brand { font-weight: 800; color: var(--brand); letter-spacing: .3px; margin-bottom: 10px; }
.auth-card h2 { margin-bottom: 18px; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; font-size: 14px; flex-wrap: wrap; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.side { width: 240px; background: #101828; color: #d0d5dd; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.org { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid #1d2939; border-top: 4px solid var(--brand); }
.org strong { color: #fff; display: block; }
.org small { color: #98a2b3; }
.org .logo { max-width: 48px; max-height: 40px; border-radius: 6px; background: #fff; padding: 2px; }
.nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { color: #d0d5dd; text-decoration: none; padding: 9px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.nav a:hover { background: #1d2939; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.me { padding: 14px 16px; border-top: 1px solid #1d2939; display: grid; gap: 4px; font-size: 13px; }
.me small { color: #98a2b3; text-transform: capitalize; }
.me .btn { margin-top: 6px; background: #1d2939; color: #fff; border-color: #344054; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 24px; background: var(--card); border-bottom: 1px solid var(--line); font-weight: 700; font-size: 18px; }
.menu-btn { display: none; }
main { padding: 24px; display: grid; gap: 18px; align-content: start; }
.banner { padding: 10px 24px; font-size: 14px; }
.banner.info { background: var(--blue-bg); }
.banner.warn { background: var(--amber-bg); color: var(--amber); }
.banner a { font-weight: 600; }

/* ---------- blocks ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.flush { padding: 0; overflow-x: auto; }
.card.error { border-left: 4px solid var(--red); }
.card.tip { border-left: 4px solid var(--accent); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head.pad { padding: 14px 16px 0; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 4px; }
.card .stat { box-shadow: none; border: 1px solid var(--line); }
.stat small { color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-size: 11.5px; }
.stat strong { font-size: 20px; }
.stat span { color: var(--muted); font-size: 12.5px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .inp { width: auto; min-width: 180px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.savebar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 40%); padding: 14px 0 6px; display: flex; justify-content: flex-end; }
.note { border-bottom: 1px solid var(--line); padding: 10px 0; display: grid; gap: 4px; }
.role-help { margin-right: 10px; }

/* ---------- table ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #f9fafb; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl.compact td { padding: 7px 8px; font-size: 13px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.dim td { opacity: .55; }
.tbl tr.st-under td:first-child { box-shadow: inset 4px 0 var(--red); }
.tbl tr.st-over td:first-child { box-shadow: inset 4px 0 #e69500; }
.tbl td.actions { text-align: right; white-space: nowrap; }
.tbl td.empty { text-align: center; color: var(--muted); padding: 28px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 5px; font-size: 13.5px; font-weight: 600; min-width: 160px; }
.field small { font-weight: 400; color: var(--muted); }
.inp { width: 100%; padding: 9px 11px; border: 1px solid #d0d5dd; border-radius: 8px; font: inherit; font-weight: 400; background: #fff; color: var(--ink); }
.inp:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.inp.tiny { width: 80px; padding: 5px 8px; }
input[type=color].inp { padding: 2px; height: 40px; width: 70px; }
textarea.inp { resize: vertical; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; font-weight: 400; cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.btn { border: 1px solid #d0d5dd; background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: #f9fafb; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); border-color: #f1b0a8; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; padding: 11px; }
.icon-btn { border: 0; background: none; font-size: 18px; cursor: pointer; color: inherit; padding: 4px 8px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #f2f4f7; color: #344054; text-transform: capitalize; }
.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); }
.badge.blue { background: var(--blue-bg); color: var(--brand); }
.logo-preview { max-height: 48px; max-width: 180px; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }
.brand-preview { color: #fff; border-radius: 8px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; min-width: 220px; min-height: 40px; }
.brand-preview span { color: #111; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }

/* ---------- modal & toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(16, 24, 40, .5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 24px 48px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; right: 16px; top: 16px; display: grid; gap: 8px; z-index: 60; max-width: 380px; }
.toast { background: #101828; color: #fff; padding: 11px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; }
.toast.err { background: var(--red); }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .side { position: fixed; left: -260px; z-index: 40; transition: left .2s; }
  body.nav-open .side { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-btn { display: inline-block; }
  main { padding: 14px; }
  .topbar { padding: 0 12px; }
}
.stack > .btn { justify-self: start; }
