:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --ink: #182230;
  --ink-soft: #344054;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --nav: #101828;
  --nav-soft: #1d2939;
  --nav-muted: #98a2b3;
  --green: #067647;
  --green-bg: #ecfdf3;
  --amber: #b54708;
  --amber-bg: #fffaeb;
  --red: #b42318;
  --red-bg: #fef3f2;
  --blue-bg: #eff6ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 10px 28px rgba(16, 24, 40, .07);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 650;
}

a:hover { text-decoration: underline; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--nav);
  color: white;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid rgba(255, 255, 255, .08);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
  padding: 4px 6px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--nav);
  font-weight: 850;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, .08);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: contain;
  background: white;
  padding: 5px;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, .08);
}

.brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.brand small {
  display: block;
  color: var(--nav-muted);
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav a {
  color: #d0d5dd;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 700;
}

.nav a:hover {
  background: var(--nav-soft);
  color: white;
  text-decoration: none;
}

.nav a.active {
  background: #ffffff;
  color: var(--nav);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .12);
}

.sidebar-footer {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, .04);
  color: var(--nav-muted);
}

.sidebar-footer span {
  display: block;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.sidebar-footer strong {
  display: block;
  color: white;
  margin-top: 4px;
  font-size: 18px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.metric.danger strong { color: var(--red); }

.split,
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel.narrow { max-width: 760px; }

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.3;
}

.panel p { margin-top: 0; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head h2 { margin: 0; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr:hover td { background: #fcfcfd; }
tbody tr:last-child td { border-bottom: 0; }

.button {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  color: var(--ink-soft);
  padding: 9px 13px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  max-width: 100%;
}

.button:hover {
  background: var(--surface-soft);
  text-decoration: none;
}

.button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.button.primary:hover { background: #1e40af; }

.button.ghost {
  background: white;
  color: var(--ink-soft);
  border-color: var(--line);
}

.google-button {
  width: 100%;
  margin: 8px 0 16px;
  background: white;
  color: var(--ink);
}

.google-button::before {
  content: "G";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: #1a73e8;
  font-weight: 900;
}

.login-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  margin: 0 0 16px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f2f4f7;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status.validation_passed,
.status.submitted,
.status.registered,
.status.accepted,
.status.active,
.status.parsed {
  background: var(--green-bg);
  color: var(--green);
}

.status.validation_failed,
.status.failed,
.status.suspended {
  background: var(--red-bg);
  color: var(--red);
}

.status.uploaded,
.status.pending,
.status.corrected,
.status.resubmitted {
  background: var(--amber-bg);
  color: var(--amber);
}

.form-control,
.form-select,
.form-stack input,
.form-stack select,
.form-stack textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: white;
}

.form-control:focus,
.form-select:focus,
.form-stack input:focus,
.form-stack select:focus,
.form-stack textarea:focus {
  outline: 3px solid rgba(29, 78, 216, .14);
  border-color: var(--brand);
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-stack label {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-weight: 800;
}

.checkline {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  font-weight: 700 !important;
}

.checkline input { width: auto; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.meta-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
  min-width: 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

dd {
  margin: 5px 0 0;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.rank-list {
  display: grid;
  gap: 8px;
}

.rank-list div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-soft);
}

.rank-list span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-weight: 650;
}

.rank-list strong {
  color: var(--brand);
  font-size: 16px;
}

.finding-list {
  display: grid;
  gap: 10px;
}

.finding {
  border-left: 4px solid var(--line-strong);
  background: var(--surface-soft);
  padding: 12px;
  border-radius: 8px;
}

.finding p {
  margin: 5px 0;
  color: var(--ink-soft);
}

.finding small { color: var(--muted); }
.finding.error { border-left-color: var(--red); }
.finding.warning { border-left-color: var(--amber); }
.finding.info { border-left-color: var(--brand); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.actions form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 14px;
}

.muted { color: var(--muted); }

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.message {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  padding: 12px 14px;
  font-weight: 750;
}

.message.success {
  border-color: #abefc6;
  background: var(--green-bg);
  color: var(--green);
}

.message.error {
  border-color: #fecdca;
  background: var(--red-bg);
  color: var(--red);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-panel {
  width: min(440px, calc(100vw - 32px));
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-brand {
  color: var(--ink);
  margin-bottom: 24px;
  border-bottom: 0;
  padding: 0;
}

.login-brand small { color: var(--muted); }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .main { padding: 18px; }
  .split,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .userbox {
    justify-content: space-between;
    white-space: normal;
  }
  .metric-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .inline-form {
    grid-template-columns: 1fr;
  }
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  td,
  th {
    white-space: normal;
    min-width: 120px;
  }
}
