/* DBI Assess design system — mobile first, large touch targets, DBI green & blue. */
:root {
  --green: #03c14b;
  --green-600: #02a540;
  --green-700: #04813a;
  --green-50: #e9fbef;
  --blue: #0b7be8;
  --blue-600: #0966c2;
  --blue-50: #e8f2fd;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f5f7f6;
  --card: #ffffff;
  --red: #d92d20;
  --red-50: #fef3f2;
  --amber: #b54708;
  --amber-50: #fffaeb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --font: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --nav-w: 232px;
  --top-h: 60px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); color: var(--ink); background: var(--bg); -webkit-tap-highlight-color: transparent; }
a { color: var(--blue-600); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
code { font-family: var(--mono); font-size: .9em; background: #f2f4f7; padding: .1em .35em; border-radius: 6px; font-variant-ligatures: none; }
pre.code { font-family: var(--mono); background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 10px; overflow-x: auto; font-size: 14px; line-height: 1.5; font-variant-ligatures: none; }
pre.code code { background: none; padding: 0; color: inherit; }
.ic { width: 20px; height: 20px; flex-shrink: 0; vertical-align: -4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--top-h); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-size: 1.1rem; }
.brand b { color: var(--green); }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who-text b { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.who-text small { color: var(--muted); font-size: .75rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: #fff; background: linear-gradient(135deg, var(--green), var(--blue)); flex-shrink: 0; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; border-radius: 12px; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: #f2f4f7; }

.sidenav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.sidenav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; min-height: 48px; justify-content: center; }
.sidenav a.active { color: var(--green-700); background: var(--green-50); }
main.page { max-width: 1080px; margin: 0 auto; padding: 20px 16px 110px; }
.credit { text-align: center; color: var(--muted); font-size: .8rem; padding: 28px 0 8px; }
.credit b { color: var(--ink-2); font-weight: 600; }

@media (min-width: 880px) {
  .sidenav { top: var(--top-h); bottom: 0; right: auto; width: var(--nav-w); flex-direction: column; justify-content: flex-start; gap: 4px; padding: 16px 12px; border-top: 0; border-right: 1px solid var(--line); }
  .sidenav a { flex: 0; flex-direction: row; gap: 12px; font-size: .95rem; padding: 12px 14px; justify-content: flex-start; }
  main.page { margin-left: var(--nav-w); max-width: none; padding: 28px 32px 40px; }
  main.page > * { max-width: 1040px; }
}

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
@media (max-width: 639px) { .grid.cols-4 { grid-template-columns: 1fr 1fr; } .grid.cols-4 .card { padding: 14px; } .grid.cols-4 .stat { gap: 10px; } .grid.cols-4 .stat .ico { width: 38px; height: 38px; } .grid.cols-4 .stat b { font-size: 1.2rem; } }
@media (min-width: 640px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } .grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head p { color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent; font: 600 1rem var(--font); cursor: pointer; text-decoration: none; transition: background .15s, transform .05s; user-select: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-600); }
.btn.blue { background: var(--blue); color: #fff; }
.btn.blue:hover { background: var(--blue-600); }
.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: #f9fafb; }
.btn.danger { background: var(--red); color: #fff; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: .9rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn .spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; color: var(--ink-2); }
.input, input.input, textarea.input, select.input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1.5px solid #d0d5dd; border-radius: 12px; font: 16px var(--font); color: var(--ink); background: #fff; }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 4px rgba(11, 123, 232, .15); }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--green); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #f2f4f7; color: var(--ink-2); white-space: nowrap; }
.badge.green { background: var(--green-50); color: var(--green-700); }
.badge.blue { background: var(--blue-50); color: var(--blue-600); }
.badge.red { background: var(--red-50); color: var(--red); }
.badge.amber { background: var(--amber-50); color: var(--amber); }

.stat { display: flex; align-items: center; gap: 14px; }
.stat .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--green-50); color: var(--green-700); }
.stat .ico.blue { background: var(--blue-50); color: var(--blue-600); }
.stat b { display: block; font-size: 1.5rem; line-height: 1.1; }
.stat small { color: var(--muted); }

.progress { height: 8px; background: #eaecf0; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--blue)); border-radius: 99px; transition: width .3s; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; color: #98a2b3; }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--blue-50); color: #0b4a8b; font-size: .92rem; }
.alert.warn { background: var(--amber-50); color: var(--amber); }
.alert.error { background: var(--red-50); color: var(--red); }
.alert.ok { background: var(--green-50); color: var(--green-700); }
.skeleton { background: linear-gradient(90deg, #eef0f2 25%, #f6f7f8 37%, #eef0f2 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 10px; min-height: 18px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fcfcfd; }
table.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }

/* ---------- toasts, modal, network pill ---------- */
#toasts { position: fixed; z-index: 100; left: 50%; top: 14px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { pointer-events: auto; padding: 12px 16px; border-radius: 12px; background: #101828; color: #fff; box-shadow: var(--shadow-lg); font-weight: 500; transition: opacity .3s, transform .3s; }
.toast.ok { background: var(--green-700); } .toast.error { background: var(--red); } .toast.info { background: var(--blue-600); }
.toast.out { opacity: 0; transform: translateY(-8px); }
.modal-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(16, 24, 40, .55); display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 18px; width: min(100%, 520px); max-height: 90vh; overflow: auto; padding: 22px; box-shadow: var(--shadow-lg); }
.modal-body { color: var(--ink-2); }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.net-pill { position: fixed; z-index: 80; left: 50%; bottom: 84px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; display: flex; gap: 8px; align-items: center; padding: 10px 16px; border-radius: 999px; background: #101828; color: #fff; font-size: .88rem; transition: .25s; }
.net-pill.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- auth pages ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 15% 10%, rgba(3, 193, 75, .16), transparent 45%), radial-gradient(circle at 90% 90%, rgba(11, 123, 232, .16), transparent 45%), var(--bg); }
.auth-card { width: min(100%, 430px); background: #fff; border-radius: 22px; padding: 28px 24px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.auth-card .logo { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 18px; }
.auth-card .logo img { max-width: 240px; height: auto; }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; right: 2px; top: 2px; }

/* ---------- admin ---------- */
body.admin .sidenav a { font-size: .72rem; }
.menu-btn { display: inline-grid; }
body.admin .sidenav { display: none; }
body.admin .sidenav.open { display: flex; position: fixed; top: var(--top-h); left: 0; bottom: 0; right: auto; width: 260px; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 16px 12px; border-top: 0; border-right: 1px solid var(--line); box-shadow: var(--shadow-lg); z-index: 50; }
body.admin .sidenav.open a { flex: 0; flex-direction: row; gap: 12px; font-size: .95rem; padding: 12px 14px; justify-content: flex-start; }
body.admin main.page { padding-bottom: 40px; }
@media (min-width: 880px) {
  .menu-btn { display: none; }
  body.admin .sidenav { display: flex; }
  body.admin .sidenav a { font-size: .95rem; }
}
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .input { width: auto; min-width: 200px; flex: 1; max-width: 360px; }
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabbar button { border: 0; background: none; padding: 12px 14px; font: 600 .95rem var(--font); color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabbar button[aria-selected="true"] { color: var(--green-700); border-bottom-color: var(--green); }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; margin: 18px 0 8px; }
.form-grid { display: grid; gap: 0 14px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid #f2f4f7; }
.switch-row:last-child { border-bottom: 0; }
.switch-row b { display: block; font-size: .95rem; }
.switch-row small { color: var(--muted); }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #d0d5dd; transition: .15s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { left: 23px; }
.switch input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.modal.wide { width: min(100%, 860px); }
.panel-wrap { position: fixed; inset: 0; z-index: 85; background: rgba(16, 24, 40, .45); display: flex; justify-content: flex-end; }
.panel { width: min(100%, 880px); height: 100%; overflow-y: auto; background: var(--bg); box-shadow: var(--shadow-lg); }
.panel-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.panel-body { padding: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; width: 72px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.qrow { display: flex; gap: 12px; align-items: flex-start; }
.qrow .qn { width: 34px; height: 34px; border-radius: 10px; background: var(--blue-50); color: var(--blue-600); font-weight: 800; display: grid; place-items: center; flex-shrink: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.live { background: var(--green); box-shadow: 0 0 0 4px rgba(3, 193, 75, .2); }
.dot.idle { background: #f79009; } .dot.off { background: #98a2b3; }
.bar { height: 8px; background: #eaecf0; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--blue); }
.stat .ico.amber { background: var(--amber-50); color: var(--amber); }
.stat .ico.red { background: var(--red-50); color: var(--red); }
ul.list { list-style: none; margin: 8px 0 0; padding: 0; }
ul.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
ul.list li:last-child { border-bottom: 0; }
ul.list li > a { flex: 1; min-width: 0; display: flex; flex-direction: column; color: inherit; text-decoration: none; }
ul.list li > a:hover b { color: var(--blue-600); }
.empty-line { display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 14px 0; margin: 0; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; }
label.field .hint { display: block; }
details > summary { padding: 6px 0; }
[hidden] { display: none !important; }
@media (max-width: 520px) { body.admin .who-text { display: none; } }
