/* ==========================================================================
   TWI · Production CSS (extracted from design-tokens.css + custom)
   ========================================================================== */

:root {
  --bg: #070a13; --bg-2: #0c1220; --surface: #111a2e; --surface-2: #182441; --surface-3: #1e2c52;
  --border: #1f2c4a; --border-soft: #1a2440; --border-strong: #2a3a60;
  --text: #e6ecf7; --text-dim: #93a3c4; --text-mute: #5e6f93; --text-faint: #3d4a6a;
  --sky: #38bdf8; --sky-strong: #0ea5e9; --sky-soft: rgba(56,189,248,.12);
  --green: #22c55e; --green-soft: rgba(34,197,94,.12);
  --amber: #f59e0b; --amber-soft: rgba(245,158,11,.12);
  --red: #ef4444; --red-soft: rgba(239,68,68,.14);
  --violet: #8b5cf6; --violet-soft: rgba(139,92,246,.14);
  --radius: 14px; --radius-sm: 10px;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --sidebar-w: 248px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(56,189,248,.08), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(139,92,246,.06), transparent 60%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(56,189,248,.22); color: var(--text); }

/* ===== Layout ===== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
aside.sidebar {
  background: linear-gradient(180deg, #0a1020 0%, #070a13 100%);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; border-bottom: 1px solid var(--border-soft); margin-bottom: 12px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--sky), #6366f1); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #0a1020; box-shadow: 0 4px 14px rgba(56,189,248,.4); }
.brand-text b { font-size: 14px; letter-spacing: .3px; display: block; }
.brand-text span { display: block; color: var(--text-mute); font-size: 11px; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title { color: var(--text-mute); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.2px; padding: 6px 10px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; color: var(--text-dim); text-decoration: none; border-radius: 9px; font-weight: 500; font-size: 13.5px; }
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: linear-gradient(90deg, rgba(56,189,248,.22), rgba(56,189,248,.04)); color: #fff; box-shadow: inset 0 0 0 1px rgba(56,189,248,.25); }
.nav a .icon { width: 18px; height: 18px; display: grid; place-items: center; color: var(--text-mute); }
.nav a.active .icon { color: var(--sky); }
.nav a .badge { margin-left: auto; font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--red-soft); color: #fca5a5; }

.side-footer { margin-top: auto; padding: 12px; border-top: 1px solid var(--border-soft); color: var(--text-mute); font-size: 11px; }

main.main { display: flex; flex-direction: column; min-width: 0; }
header.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px;
  background: rgba(7,10,19,.6); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar-h);
}
.crumbs { color: var(--text-dim); font-size: 13px; }
.crumbs b { color: var(--text); }
.search { flex: 1; max-width: 480px; margin: 0 18px; position: relative; }
.search input { width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 9px 12px 9px 36px; font-size: 13px; }
.search input::placeholder { color: var(--text-mute); }
.search input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(56,189,248,.15); }
.search .icon { position: absolute; left: 11px; top: 9px; color: var(--text-mute); pointer-events: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-dim); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.user-pill { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #f59e0b, #ef4444); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #1a0a00; }
.user-pill .name { font-size: 12.5px; }
.user-pill .role { display: block; color: var(--text-mute); font-size: 10.5px; }

.content { padding: 24px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; letter-spacing: -.2px; }
.page-head p { margin: 0; color: var(--text-dim); font-size: 13px; }
.page-head .actions { display: flex; gap: 8px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 500; cursor: pointer; transition: background .12s ease; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: linear-gradient(180deg, var(--sky), var(--sky-strong)); border-color: transparent; color: #001a2a; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: linear-gradient(180deg, #ef4444, #b91c1c); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; padding: 11px; font-size: 14px; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(56,189,248,.18); }

/* ===== Cards ===== */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 32px rgba(0,0,0,.35); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-head .meta { color: var(--text-mute); font-size: 11.5px; }
.panel-body { padding: 14px 16px; }
.panel-body.tight { padding: 0; }

/* ===== KPI ===== */
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--sky); }
.kpi.green::before { background: var(--green); }
.kpi.amber::before { background: var(--amber); }
.kpi.red::before { background: var(--red); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { color: var(--text-mute); font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }
.kpi-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--sky-soft); color: var(--sky); }
.kpi.green .kpi-icon { background: var(--green-soft); color: var(--green); }
.kpi.amber .kpi-icon { background: var(--amber-soft); color: var(--amber); }
.kpi.red .kpi-icon { background: var(--red-soft); color: var(--red); }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 8px; letter-spacing: -.5px; }
.kpi-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ===== Grid ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table thead th { text-align: left; font-weight: 600; color: var(--text-mute); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; padding: 10px 14px; background: rgba(255,255,255,.02); border-bottom: 1px solid var(--border-soft); }
.table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text-dim); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(56,189,248,.04); }
.table tbody td b { color: var(--text); font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: 12px; }

/* ===== Chips ===== */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.chip.green  { background: var(--green-soft);  color: #4ade80; }
.chip.amber  { background: var(--amber-soft);  color: #fbbf24; }
.chip.red    { background: var(--red-soft);    color: #fca5a5; }
.chip.sky    { background: var(--sky-soft);    color: #7dd3fc; }
.chip.violet { background: var(--violet-soft); color: #c4b5fd; }
.chip.mute   { background: rgba(255,255,255,.04); color: var(--text-mute); }
.chip .dot   { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 4px; }
.input, .select { width: 100%; background: var(--bg-2); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 10px 12px; font-size: 13px; font-family: inherit; }
.input:focus, .select:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(56,189,248,.15); }
.input.error { border-color: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,.20); }
.input.has-icon { padding-left: 36px; }
.input-wrap { position: relative; }
.input-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-mute); pointer-events: none; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--sky); }
.help { font-size: 11px; color: var(--text-mute); }
.help.error { color: #fca5a5; }
.btn-2fa-back { background: transparent; border: none; color: var(--text-mute); font-size: 11.5px; cursor: pointer; }
.btn-2fa-back:hover { color: var(--text); }

/* ===== Alerts ===== */
.alert { padding: 12px 14px; border-radius: 10px; display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border-soft); background: var(--bg-2); margin-bottom: 14px; }
.alert .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); flex: none; }
.alert.success .ic { background: var(--green-soft); color: var(--green); }
.alert.warn .ic { background: var(--amber-soft); color: var(--amber); }
.alert b { color: var(--text); display: block; font-size: 13px; margin-bottom: 2px; }
.alert p { margin: 0; color: var(--text-dim); font-size: 12px; }

/* ===== Login (auth) layout ===== */
.auth-wrap { display: grid; grid-template-columns: 1fr 1.1fr; min-height: 100vh; }
.auth-visual { position: relative; overflow: hidden; border-right: 1px solid var(--border); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(135deg, rgba(56,189,248,.04), transparent 40%), var(--bg-2); }
.auth-visual::before { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(56,189,248,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(56,189,248,.04) 1px, transparent 1px); background-size: 40px 40px; mask-image: radial-gradient(circle at 30% 50%, black, transparent 70%); }
.auth-visual .vtop, .auth-visual .vmid, .auth-visual .vbot { position: relative; z-index: 1; }
.auth-visual h1 { font-size: 38px; line-height: 1.15; margin: 0 0 12px; letter-spacing: -.5px; }
.auth-visual h1 .grad { background: linear-gradient(90deg, #38bdf8, #818cf8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-visual p { color: var(--text-dim); font-size: 14px; margin: 0; max-width: 480px; }
.auth-visual .stats { display: flex; gap: 32px; margin-top: 28px; }
.auth-visual .stats div b { font-family: var(--font-mono); font-size: 22px; display: block; color: var(--text); }
.auth-visual .stats div span { color: var(--text-mute); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 48px 32px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 24px 60px rgba(0,0,0,.45); padding: 36px 32px; }
.auth-card h2 { margin: 0 0 4px; font-size: 22px; }
.auth-card .sub { color: var(--text-dim); font-size: 13px; margin: 0 0 24px; }
.auth-card .row { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 18px; }
.auth-card .forgot { font-size: 12px; color: var(--sky); }
.auth-card .divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-mute); font-size: 11px; }
.auth-card .divider::before, .auth-card .divider::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }
.auth-card .footer-link { text-align: center; color: var(--text-mute); font-size: 11.5px; margin-top: 18px; }
.badge-2fa { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; background: var(--violet-soft); color: #c4b5fd; font-size: 10.5px; font-weight: 600; }
.totp-secret { font-family: var(--font-mono); font-size: 16px; letter-spacing: 2px; background: var(--bg-2); padding: 14px; border: 1px solid var(--border-soft); border-radius: 10px; text-align: center; word-break: break-all; color: var(--text); }
.totp-qr { background: #fff; padding: 16px; border-radius: 12px; display: grid; place-items: center; max-width: 220px; margin: 0 auto 12px; }
.totp-qr img { max-width: 100%; height: auto; }
.security-note { margin-top: 18px; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 9px; font-size: 11px; color: var(--text-mute); display: flex; gap: 8px; align-items: flex-start; }
.security-note .ic { color: var(--green); flex: none; }

footer.foot { padding: 18px 24px; color: var(--text-mute); font-size: 11.5px; border-top: 1px solid var(--border); margin-top: auto; display: flex; justify-content: space-between; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  aside.sidebar { display: none; }
}

/* ===== Empty state ===== */
.empty { text-align: center; padding: 48px 24px; color: var(--text-mute); }
.empty .ic { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--surface-2); color: var(--text-dim); }
.empty b { display: block; color: var(--text); font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.empty p { margin: 0; font-size: 12px; }

/* ===== Util ===== */
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.text-sm { font-size: 12.5px; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 16px; }

/* ===== Tabs (Update Section) ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.tabs .tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 8px 8px 0 0;
  transition: color .12s ease, background .12s ease;
}
.tabs .tab:hover {
  color: var(--text);
  background: rgba(255,255,255,.025);
  text-decoration: none;
}
.tabs .tab.active {
  color: var(--sky);
  border-bottom-color: var(--sky);
  background: linear-gradient(180deg, var(--sky-soft), transparent);
}
.tabs .tab .ic { font-size: 14px; }

/* ===== Calendar (Monthly Schedule) ===== */
.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-h {
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-mute);
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}
.cal-d {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  position: relative;
  font-size: 12.5px;
  color: var(--text-dim);
  transition: background .12s ease, border-color .12s ease;
}
.cal-d:hover { border-color: var(--border); background: var(--surface); }
.cal-empty { background: transparent; border-color: transparent; }
.cal-today {
  background: linear-gradient(135deg, var(--sky-soft), transparent);
  border-color: var(--sky);
  color: var(--sky);
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--sky-soft-2, rgba(56,189,248,.22));
}
.cal-num { font-family: var(--font-mono); font-size: 12px; }

/* ===== 3-col footer ===== */
.foot-3col {
  display: grid !important;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.foot-3col .foot-developer {
  text-align: center;
  white-space: nowrap;
}
@media (max-width: 800px) {
  .foot-3col {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .foot-3col > * { text-align: center !important; }
}
