/* CIS Tracker — design system (redesign) */

:root {
  --bg-base: #090b0f;
  --bg-surface: #0f1218;
  --bg-elevated: #141922;
  --bg-hover: #1a2030;
  --bg-active: #1e2738;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);
  --text: #eef2f7;
  --text-secondary: #b4bcc9;
  --text-muted: #7a8496;
  --text-subtle: #5c6578;
  --accent: #3d9cf5;
  --accent-hover: #5aadff;
  --accent-muted: rgba(61, 156, 245, 0.14);
  --accent-border: rgba(61, 156, 245, 0.35);
  --good: #34d399;
  --good-muted: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-muted: rgba(251, 191, 36, 0.12);
  --bad: #f87171;
  --bad-muted: rgba(248, 113, 113, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-md: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 40px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI Variable", "SF Pro Text", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --sidebar-w: 248px;
  --transition: 0.18s ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-base);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 0% -10%, rgba(61, 156, 245, 0.07), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(52, 211, 153, 0.04), transparent 50%);
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
table { border-collapse: collapse; }

/* ── Shell ── */
.app-shell {
  display: flex;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: rgba(15, 18, 24, 0.92);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
}

.app-sidebar-head {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.04em;
}

.app-sidebar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.app-sidebar-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.app-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
}

.app-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.app-sidebar-nav a:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.app-sidebar-nav a.active {
  color: var(--text);
  background: var(--accent-muted);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-subtle);
  flex-shrink: 0;
  opacity: 0.5;
}

.app-sidebar-nav a.active .nav-dot {
  background: var(--accent);
  opacity: 1;
  box-shadow: 0 0 8px rgba(61, 156, 245, 0.5);
}

.app-sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 14px;
  border-top: 1px solid var(--border);
}

.app-main {
  flex: 1;
  padding: 28px 32px 48px;
  max-width: 1480px;
  min-width: 0;
}

.guest {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: min(400px, 100%);
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

/* ── Page header ── */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0;
}

.page-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  max-width: 56ch;
  text-wrap: pretty;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

/* ── Cards ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 20px; }

.card-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: -0.01em;
}

.panel-live {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.06), rgba(61, 156, 245, 0.05));
  border-color: rgba(61, 156, 245, 0.15);
}

/* ── Typography ── */
.title-xl {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.title-lg {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.title-md {
  font-size: 15px;
  font-weight: 600;
}

.muted { color: var(--text-muted); }
.muted-2 { color: var(--text-secondary); }
.subtle { font-size: 12px; color: var(--text-muted); }
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ── Forms ── */
.label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}

.input {
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  width: 100%;
  font-size: 14px;
  color: var(--text);
  display: block;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input::placeholder { color: var(--text-subtle); }

.input:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

select.input {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), transform 0.12s ease, color var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.14);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: var(--bad-muted);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* ── Segmented controls ── */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.seg a,
.seg button {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: calc(var(--radius-md) - 3px);
  color: var(--text-muted);
  border: none;
  background: transparent;
  transition: background var(--transition), color var(--transition);
}

.seg a:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.seg a.active,
.seg .btn-primary {
  background: var(--bg-elevated) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-strong) !important;
}

.source-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  line-height: 1.5;
  border: 1px solid var(--border);
}

.badge-good {
  background: var(--good-muted);
  color: var(--good);
  border-color: rgba(52, 211, 153, 0.25);
}

.badge-warn {
  background: var(--warn-muted);
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.25);
}

.badge-bad {
  background: var(--bad-muted);
  color: var(--bad);
  border-color: rgba(248, 113, 113, 0.25);
}

.badge-info {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  font-size: 13px;
}

.table thead th {
  text-align: left;
  padding: 11px 12px;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 11px 12px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-edge th:first-child,
.table-edge td:first-child { padding-left: 20px; }

.table-edge th:last-child,
.table-edge td:last-child { padding-right: 20px; }

.empty-row td {
  padding: 48px 20px !important;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Layout ── */
.row { display: flex; gap: 16px; }
.row-tight { display: flex; gap: 8px; flex-wrap: wrap; }
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.col { flex: 1; }
.spacer { flex: 1; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }

/* ── Stat cards ── */
.stat {
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}

.stat:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  opacity: 0;
  transition: opacity var(--transition);
}

.stat.is-accent::before { background: var(--accent); opacity: 1; }
.stat.is-good::before { background: var(--good); opacity: 1; }
.stat.is-bad::before { background: var(--bad); opacity: 1; }

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  margin-top: 6px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-value.is-good { color: var(--good); }
.stat-value.is-bad { color: var(--bad); }
.stat-value.is-accent { color: var(--accent); }

/* ── Utilities ── */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.pad-3 { padding: 12px; }
.pad-4 { padding: 16px; }
.pad-5 { padding: 20px; }

.text-good { color: var(--good); }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-muted-2 { color: var(--text-secondary); }

.hidden { display: none !important; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.full { width: 100%; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.link-muted {
  font-size: 12px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.link-muted:hover { color: var(--accent); }

/* ── Copy box ── */
.copy-box {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  word-break: break-all;
  cursor: pointer;
  transition: border-color var(--transition);
}

.copy-box:hover { border-color: var(--accent-border); }
.copy-box.flash { border-color: var(--good); }

/* ── Notices ── */
.hint {
  background: var(--accent-muted);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.notice-bad {
  background: var(--bad-muted);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fecaca;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

.notice-good {
  background: var(--good-muted);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: #86efac;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

[x-cloak] { display: none !important; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .app-main { padding: 20px 16px 32px; }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .grid-stats { grid-template-columns: 1fr; }
  .app-sidebar { width: 56px; }
  .app-sidebar-title,
  .app-sidebar-sub,
  .app-sidebar-nav span:not(.nav-dot) { display: none; }
  .app-sidebar-head { padding: 14px 10px; }
  .brand-mark { margin: 0 auto; }
}
