:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-dark: #0f172a;
  --surface-dark-2: #111827;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-weak: #dbeafe;
  --primary-dark: #1d4ed8;
  --success: #15803d;
  --success-weak: #dcfce7;
  --danger: #dc2626;
  --danger-weak: #fee2e2;
  --warning: #d97706;
  --warning-weak: #ffedd5;
  --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 16px 32px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.14);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --nav-width: 272px;
}

* { box-sizing: border-box; }
html { font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; background:
  radial-gradient(circle at top left, rgba(37,99,235,.08), transparent 30%),
  radial-gradient(circle at bottom right, rgba(15,23,42,.04), transparent 24%),
  var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

/* Auth */
.auth-screen { min-height: 100vh; padding: 24px; display: grid; place-items: center; }
.auth-layout { width: min(1120px, 100%); display: grid; grid-template-columns: 1.12fr .88fr; gap: 24px; align-items: stretch; }
.auth-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow-md); }
.auth-panel-brand { padding: 40px; background:
  linear-gradient(160deg, rgba(37,99,235,.06), rgba(15,23,42,.02)),
  var(--surface);
}
.auth-card { padding: 36px; display: grid; align-content: center; }
.brand-lockup { display: flex; align-items: center; gap: 16px; }
.brand-mark { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(135deg, var(--surface-dark), #1e293b); color: #fff; font-size: 1.05rem; font-weight: 800; letter-spacing: .04em; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 14px; font-size: .88rem; }
.eyebrow { margin: 0 0 6px; color: var(--primary); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 800; }
h1, h2, h3 { margin: 0; color: var(--text); }
h1 { font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.05; }
h2 { font-size: 1.75rem; line-height: 1.1; }
h3 { font-size: 1.1rem; line-height: 1.2; }
.auth-copy, .muted { color: var(--muted); }
.auth-copy { margin: 26px 0; max-width: 52ch; line-height: 1.65; font-size: 1rem; }
.auth-feature-list { display: grid; gap: 12px; }
.auth-feature { display: flex; align-items: flex-start; gap: 10px; color: #334155; line-height: 1.5; }
.feature-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--primary); margin-top: .45rem; flex: 0 0 auto; }
.auth-helper { margin: 12px 0 24px; line-height: 1.55; }

.stack { display: grid; gap: 16px; }
.stack label, .field { display: grid; gap: 8px; }
.stack label span, .field span, .field-label { font-size: .78rem; font-weight: 700; color: #475569; }
input, select, textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
textarea { min-height: 96px; resize: vertical; }

.btn {
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 11px 16px;
  font-weight: 700;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--surface-dark); color: #fff; }
.btn.primary:hover { background: #162033; }
.btn.secondary { background: var(--primary-weak); color: var(--primary-dark); }
.btn.secondary:hover { background: #cfe1ff; }
.btn.danger { background: var(--danger-weak); color: var(--danger); }
.btn.danger:hover { background: #fecaca; }
.btn.ghost { background: transparent; border-color: var(--line); color: inherit; }
.btn.ghost:hover { background: #f8fafc; }
.btn.small { padding: 9px 12px; font-size: .85rem; border-radius: 12px; }
.full { width: 100%; }
.form-error { margin-top: 12px; background: var(--danger-weak); color: var(--danger); border-radius: 14px; padding: 12px 14px; font-size: .92rem; }

/* App shell */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); }
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--nav-width);
  background: linear-gradient(180deg, var(--surface-dark), var(--surface-dark-2));
  color: #e5eefc;
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.05);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.brand strong { display: block; font-size: 1rem; font-weight: 800; color: #fff; }
.brand span { display: block; margin-top: 4px; color: #93a4c5; font-size: .76rem; }
.nav-list { display: grid; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: transparent; border: 0; color: #c7d2e7;
  border-radius: 14px; padding: 12px 14px; font-weight: 700;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(37,99,235,.18); color: #fff; box-shadow: inset 0 0 0 1px rgba(96,165,250,.2); }
.nav-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.nav-icon svg { width: 18px; height: 18px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding: 16px 8px 0; }
.user-chip { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.avatar { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff; font-weight: 800; }
.user-chip strong { display: block; color: #fff; }
.user-chip span { display: block; color: #8ea0c2; font-size: .76rem; margin-top: 3px; }
.sidebar .btn.ghost { color: #dce6f8; border-color: rgba(255,255,255,.1); }
.sidebar .btn.ghost:hover { background: rgba(255,255,255,.06); }
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .48); backdrop-filter: blur(3px);
  z-index: 30;
}
.main-content {
  grid-column: 2;
  min-width: 0;
  padding: 20px 28px 44px;
  max-width: 1440px;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  margin: -20px -28px 24px;
  padding: 18px 28px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(243,246,251,.88);
  border-bottom: 1px solid rgba(226,232,240,.8);
  backdrop-filter: blur(10px);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar h2 { font-size: clamp(1.45rem, 1.2vw + 1rem, 2rem); }
.mobile-menu {
  display: none;
  width: 42px; height: 42px; padding: 0;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
}
.mobile-menu svg { width: 18px; height: 18px; }
.view { display: none; }
.view.active { display: block; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card h3 { font-size: 1.1rem; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.small-text { font-size: .83rem; }
.metric { font-size: clamp(1.8rem, 2vw + 1rem, 2.7rem); font-weight: 800; letter-spacing: -.03em; }
.metric-label { margin-top: 6px; font-size: .78rem; color: var(--muted); font-weight: 700; }
.stats-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: var(--shadow-sm); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
th { position: sticky; top: 0; background: #f8fafc; color: #64748b; text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 800; }
tbody tr:last-child td { border-bottom: 0; }
.rank { font-size: 1.15rem; font-weight: 800; }
.points { font-weight: 800; }
.positive { color: var(--success); }
.negative { color: var(--danger); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; font-size: .72rem; font-weight: 800;
  background: #eef2f7; color: #475569;
}
.badge.admin { background: #e0ecff; color: var(--primary-dark); }
.badge.good { background: var(--success-weak); color: var(--success); }
.badge.bad { background: var(--danger-weak); color: var(--danger); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar select, .toolbar input { width: auto; min-width: 180px; }
.round-list { display: grid; gap: 14px; }
.round-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.round-number {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(160deg, #eff6ff, #f8fafc);
  border: 1px solid #dbeafe;
  display: grid; place-items: center;
  text-align: center; font-size: .72rem; font-weight: 700; color: var(--primary-dark);
}
.round-number b { display: block; font-size: 1.35rem; line-height: 1; margin-top: 4px; }
.round-card h3 { font-size: 1.12rem; }
.round-meta { color: var(--muted); font-size: .88rem; margin-top: 6px; line-height: 1.45; }
.round-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status-dot { width: 8px; height: 8px; display: inline-block; border-radius: 999px; margin-right: 6px; background: #94a3b8; }
.status-dot.open { background: var(--success); }
.status-dot.closed { background: var(--danger); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full-span { grid-column: 1 / -1; }
.checkbox-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; color: #475569; font-size: .84rem; font-weight: 700; }
.check input { width: auto; }

/* New round result cards */
.results-stack { display: grid; gap: 14px; }
.result-card-item {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  padding: 16px;
}
.result-card-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.result-card-top .result-card-title { font-size: 1rem; font-weight: 800; }
.result-card-top .result-card-subtitle { margin-top: 4px; color: var(--muted); font-size: .8rem; }
.result-points-chip {
  min-width: 58px; text-align: center; padding: 8px 10px; border-radius: 999px;
  background: #f8fafc; border: 1px solid var(--line); font-weight: 800;
}
.result-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.result-form-grid .field.compact input,
.result-form-grid .field.compact select { padding: 10px 12px; }
.toggle-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.toggle-card {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  min-height: 52px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--surface-soft); color: #334155; font-size: .84rem; font-weight: 700;
}
.toggle-card input { width: 16px; height: 16px; margin: 0; }
.result-card-footer { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.result-card-footer .small-text { margin: 0; }
.results-wrap { overflow: visible; }

.empty {
  padding: 28px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255,255,255,.65);
}
.bar-score { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; }
.stars { letter-spacing: 2px; color: var(--warning); }
.statute { padding: 16px 0; border-bottom: 1px solid var(--line); }
.statute:last-child { border-bottom: 0; }
.statute h3 { margin-bottom: 8px; font-size: 1.05rem; }
.statute p, .statute li { color: #334155; line-height: 1.65; }
.statute ul { margin: 8px 0 0; padding-left: 20px; }
.audit-item { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.audit-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: .76rem; color: var(--muted); }
.audit-title { font-weight: 800; margin: 8px 0; }
.diff-list { display: grid; gap: 8px; margin-top: 10px; }
.diff { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; font-size: .82rem; }
.diff b { display: block; margin-bottom: 4px; color: var(--text); }
.diff .before { color: var(--danger); }
.diff .after { color: var(--success); }
.permissions { display: flex; gap: 8px; flex-wrap: wrap; }
.permission-pill { padding: 7px 10px; border-radius: 999px; background: #eff6ff; font-size: .72rem; font-weight: 800; color: var(--primary-dark); }

.modal { border: 0; padding: 0; width: min(760px, calc(100% - 24px)); max-height: calc(100vh - 24px); background: transparent; }
.modal::backdrop { background: rgba(15,23,42,.56); backdrop-filter: blur(3px); }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 22px;
  max-height: calc(100vh - 24px);
  overflow: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.icon-btn {
  width: 38px; height: 38px; padding: 0;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-soft); color: var(--text);
}
.icon-btn svg { width: 18px; height: 18px; }
.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 100;
  max-width: min(420px, calc(100% - 24px));
  padding: 12px 14px; border-radius: 14px;
  box-shadow: var(--shadow-lg); color: #fff; font-weight: 700; font-size: .88rem;
  background: var(--surface-dark);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@media (max-width: 1200px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease;
    width: min(88vw, 320px);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { grid-column: 1; padding: 14px 16px 34px; }
  .topbar { margin: -14px -16px 20px; padding: 14px 16px; }
  .mobile-menu { display: inline-grid; place-items: center; }
  .grid.cols-2, .grid.cols-3, .form-grid { grid-template-columns: 1fr; }
  .round-card { grid-template-columns: 64px minmax(0, 1fr); }
  .round-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .result-form-grid { grid-template-columns: 1fr; }
  .toggle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .auth-screen { padding: 14px; }
  .auth-panel-brand, .auth-card { padding: 24px; }
  .brand-lockup { align-items: flex-start; }
  .stats-row { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; }
  .toolbar select, .toolbar input, .toolbar button { width: 100%; min-width: 0; }
  .table-wrap { border-radius: 16px; }
  table { min-width: 100%; }
  thead { display: none; }
  tbody, tr, td { display: block; width: 100%; }
  tbody tr { padding: 14px; border-bottom: 1px solid #eef2f7; }
  tbody tr:last-child { border-bottom: 0; }
  td { padding: 0; border-bottom: 0; margin-bottom: 10px; }
  td:last-child { margin-bottom: 0; }
  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 800;
  }
  .rank { font-size: 1rem; }
  .toggle-grid { grid-template-columns: 1fr; }
  .result-card-footer { align-items: stretch; }
  .result-card-footer .btn { width: 100%; }
  .modal { width: calc(100% - 12px); }
  .modal-card { padding: 18px; border-radius: 20px; }
  .topbar h2 { font-size: 1.45rem; }
}

/* Score-centric audit */
.audit-intro { margin-bottom: 14px; }
.audit-detail { margin-top: 8px; color: #334155; line-height: 1.55; font-size: .88rem; }

/* Inline current-time control */
.time-input-wrap { position: relative; }
.time-input-wrap input { padding-right: 48px; }
.time-now-action {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; border-radius: 11px;
  display: grid; place-items: center; color: var(--primary-dark); background: var(--primary-weak);
}
.time-now-action:hover { background: #cfe1ff; }
.time-now-action svg { width: 17px; height: 17px; }
.inline-hint { display: block; margin-top: 6px; color: var(--muted); font-size: .72rem; line-height: 1.35; }
.success-hint { color: var(--success); }

/* Premium monthly cubata */
.premium-banner {
  margin: 0 0 16px; padding: 15px 16px; border-radius: 18px;
  background: linear-gradient(135deg, #f4ead0, #e8e3d7);
  border: 1px solid #c9ad69;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
  color: #57451d;
}
.premium-banner strong { display: block; font-size: 1rem; margin: 2px 0 4px; }
.premium-banner span { display: block; font-size: .82rem; opacity: .86; }
.premium-kicker { font-size: .68rem; letter-spacing: .12em; font-weight: 900; color: #8a6b25; }
.premium-option {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 12px;
  min-height: 62px; padding: 12px 14px; border-radius: 16px;
  background: linear-gradient(135deg, #f5ecd6, #e7e2d6);
  border: 1px solid #c9ad69;
  color: #5d4a1d;
}
.premium-option input { width: 18px; height: 18px; margin: 0; }
.premium-option b, .premium-option small { display: block; }
.premium-option b { font-size: .88rem; }
.premium-option small { margin-top: 3px; color: #836a32; font-size: .72rem; }
.bar-card { display: flex; flex-direction: column; }
.bar-score small { font-size: .7rem; color: var(--muted); margin-left: 2px; }
.bar-card-meta { margin: 12px 0 16px; color: #475569; font-size: .86rem; line-height: 1.5; }
.bar-rate-cta { margin-top: auto; }
.bar-edit-cta { margin-top: 8px; align-self: flex-start; }
.bar-rate-note { margin: auto 0 0; padding-top: 10px; }
