:root {
  --red: #e32f20;
  --red-deep: #9c1c13;
  --yellow: #ffa700;
  --black: #191919;
  --ink: #242424;
  --muted: rgba(36, 36, 36, 0.62);
  --muted-soft: rgba(36, 36, 36, 0.44);
  --line: rgba(25, 25, 25, 0.12);
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --surface: #ffffff;
  --wash: #f5f7fb;
  --blue: #1f6f8b;
  --green: #148463;
  --shadow: 0 20px 70px rgba(25, 25, 25, 0.12);
  --radius: 8px;
  --content-max: 1520px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: #ffffff;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(227, 47, 32, 0.06), transparent 22rem),
    linear-gradient(300deg, rgba(31, 111, 139, 0.07), transparent 30rem),
    #ffffff;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  padding: 0.78rem 0.82rem;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  border-top: 1px solid var(--line);
  color: rgba(36, 36, 36, 0.84);
}

.number {
  text-align: right;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.2rem;
}

.login-panel {
  display: grid;
  width: min(100%, 28rem);
  gap: 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.4rem);
}

.login-panel label,
.field,
.select-field {
  display: grid;
  gap: 0.38rem;
}

.login-panel label span,
.field span,
.select-field span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(25, 25, 25, 0.16);
  border-radius: var(--radius);
  padding: 0.74rem 0.82rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
}

textarea {
  min-height: 9rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(227, 47, 32, 0.58);
  box-shadow: 0 0 0 3px rgba(227, 47, 32, 0.12);
}

.app-shell {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  gap: 1.1rem;
  min-height: 100vh;
  padding: 1.1rem;
}

.glass-panel {
  border: 1px solid rgba(25, 25, 25, 0.12);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(245, 247, 251, 0.74)),
    var(--panel);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 1.1rem;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 2.2rem);
  overflow-y: auto;
  padding: 0.95rem;
}

.brand-row,
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-lockup {
  padding: 0.25rem 0.2rem 1.25rem;
}

.brand-mark {
  display: grid;
  width: 3rem;
  height: 3rem;
  overflow: hidden;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  box-shadow: 0 12px 28px rgba(227, 47, 32, 0.24);
  font-weight: 900;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-lockup strong,
.brand-lockup small,
.brand-row strong,
.brand-row small {
  display: block;
}

.brand-lockup strong,
.brand-row strong {
  font-size: 1.24rem;
  font-weight: 900;
}

.brand-lockup small,
.brand-row small {
  color: var(--muted);
  font-size: 0.82rem;
}

.nav-list {
  display: grid;
  gap: 0.64rem;
}

.nav-group {
  display: grid;
  gap: 0.34rem;
}

.nav-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.32rem;
  color: var(--muted-soft);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  list-style: none;
  text-transform: uppercase;
  cursor: pointer;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary::after {
  content: "⌄";
}

.nav-group:not([open]) summary::after {
  transform: rotate(-90deg);
}

.nav-group:not([open]) > .nav-item {
  display: none;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 0.72rem 0.8rem;
  color: rgba(36, 36, 36, 0.66);
  background: transparent;
  text-align: left;
  transition: 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  color: var(--ink);
  background: rgba(227, 47, 32, 0.08);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
}

.sidebar-note {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding: 0.9rem 0.15rem 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.app-version {
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.12rem 0.42rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.74rem;
  font-weight: 850;
}

.status-dot {
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(20, 132, 99, 0.12);
}

.content {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1rem;
  min-width: 0;
  max-width: var(--content-max);
}

.topbar {
  position: sticky;
  z-index: 5;
  top: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.86rem 1rem;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 44px rgba(25, 25, 25, 0.08);
  backdrop-filter: blur(18px);
}

.topbar-title {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.2rem);
}

.topbar-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.topbar-actions .select-field {
  width: min(24rem, 34vw);
}

.eyebrow {
  margin: 0 0 0.22rem;
  color: var(--red-deep);
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.view {
  display: grid;
  gap: 1rem;
  padding-bottom: 1.2rem;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading h2,
.panel-header h3 {
  margin: 0;
}

.section-heading h2 {
  font-size: clamp(1.5rem, 2.7vw, 2.35rem);
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--panel-strong);
  box-shadow: 0 14px 44px rgba(25, 25, 25, 0.07);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(22rem, 0.75fr);
  align-items: start;
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.metric-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem;
  background: rgba(255, 255, 255, 0.86);
}

.metric-card strong {
  display: block;
  margin-top: 0.24rem;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.compact .metric-card {
  padding: 0.7rem;
}

.compact .metric-card strong {
  font-size: 1.15rem;
}

.status-pill,
.role-pill,
.hash-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
  border: 1px solid rgba(25, 25, 25, 0.12);
  border-radius: 999px;
  padding: 0.28rem 0.56rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.76rem;
  font-weight: 800;
}

.status-pill.draft {
  border-color: rgba(31, 111, 139, 0.25);
  color: var(--blue);
  background: rgba(31, 111, 139, 0.08);
}

.status-pill.open {
  border-color: rgba(20, 132, 99, 0.25);
  color: var(--green);
  background: rgba(20, 132, 99, 0.1);
}

.status-pill.closed,
.status-pill.tallied,
.status-pill.sealed {
  border-color: rgba(227, 47, 32, 0.25);
  color: var(--red-deep);
  background: rgba(227, 47, 32, 0.08);
}

.status-pill.archived {
  border-color: rgba(100, 116, 139, 0.25);
  color: var(--muted);
  background: rgba(100, 116, 139, 0.08);
}

.button-row,
.chip-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.election-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.election-card {
  display: grid;
  gap: 0.9rem;
}

.primary-action,
.ghost-action,
.danger-action {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.68rem 0.86rem;
  font-weight: 850;
  transition: 160ms ease;
}

.primary-action {
  color: #ffffff;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  box-shadow: 0 12px 30px rgba(227, 47, 32, 0.22);
}

.primary-action:hover {
  transform: translateY(-1px);
}

.ghost-action {
  border-color: rgba(25, 25, 25, 0.14);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
}

.danger-action {
  border-color: rgba(227, 47, 32, 0.26);
  color: var(--red-deep);
  background: rgba(227, 47, 32, 0.08);
}

.table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.table-shell table {
  min-width: 46rem;
}

.progress-line {
  height: 0.62rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(25, 25, 25, 0.08);
}

.progress-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--yellow));
}

.timeline {
  display: grid;
  gap: 0.7rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: start;
}

.timeline-item::before {
  width: 0.62rem;
  height: 0.62rem;
  margin-top: 0.35rem;
  border-radius: 999px;
  background: var(--red);
  content: "";
}

.step-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.step-card {
  display: grid;
  gap: 0.48rem;
  align-content: start;
  min-height: 11rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  background: rgba(255, 255, 255, 0.78);
}

.step-card strong {
  font-size: 1rem;
}

.step-number {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--red);
  font-weight: 900;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 0.82rem;
}

.form-grid .wide,
.wide {
  grid-column: 1 / -1;
}

.form-grid > button,
.form-grid > .button-row {
  justify-self: start;
}

.form-grid > button.wide {
  width: auto;
}

.compact-field {
  max-width: 14rem;
}

.compact-field input,
.compact-field select {
  max-width: 10rem;
}

.form-error {
  min-height: 1.1rem;
  margin: 0;
  color: var(--red-deep);
  font-size: 0.86rem;
  font-weight: 700;
}

.form-info {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.form-info a {
  color: var(--primary);
  font-weight: 850;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--foreground);
  font-weight: 750;
}

.check-field input {
  width: 1rem;
  min-height: auto;
}

.link-action {
  border: 0;
  padding: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 850;
  text-align: left;
}

.credential-box {
  display: grid;
  gap: 0.48rem;
  margin-top: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: var(--secondary);
}

.credential-box code {
  display: block;
  overflow-wrap: anywhere;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.68rem;
  color: var(--foreground);
  background: var(--card);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
}

.vote-panel.locked {
  position: relative;
  overflow: hidden;
}

.vote-panel.locked .vote-form-content {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

.vote-lock-panel {
  border-color: color-mix(in srgb, var(--primary) 26%, var(--border));
}

.countdown-box {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.countdown-box span,
.countdown-box small {
  display: grid;
  place-items: center;
  min-height: 2.35rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--secondary);
}

.countdown-box span {
  color: var(--foreground);
  font-size: 1.55rem;
  font-weight: 900;
}

.countdown-box small {
  min-height: 1.75rem;
  color: var(--muted-foreground);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.code-field {
  max-width: 27rem;
}

.code-field small {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.code-control {
  display: flex;
  align-items: stretch;
  gap: 0.55rem;
  min-width: 0;
}

.code-control input {
  max-width: 9rem;
}

.code-control button {
  min-height: 2.65rem;
  white-space: nowrap;
}

.public-terminal-page {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 2rem);
  color: var(--foreground);
  background: #ffffff;
  text-align: center;
}

.public-terminal-page h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: 0;
  text-transform: none;
}

.public-terminal-page p {
  margin: 0.5rem 0 0;
  color: var(--muted-foreground);
}

.security-alert {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}

.question-block,
.result-block {
  display: grid;
  gap: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.95rem;
}

.question-block:first-child,
.result-block:first-child {
  border-top: 0;
  padding-top: 0;
}

.option-list {
  display: grid;
  gap: 0.5rem;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  border: 1px solid rgba(25, 25, 25, 0.1);
  border-radius: var(--radius);
  padding: 0.65rem 0.72rem;
  background: rgba(255, 255, 255, 0.72);
}

.option-row label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.option-row input[type="radio"],
.option-row input[type="checkbox"] {
  width: auto;
}

.option-row input[type="number"] {
  width: 8rem;
}

.hash-pill {
  max-width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-box {
  max-height: 16rem;
  overflow: auto;
  border: 1px solid rgba(25, 25, 25, 0.12);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: #111111;
  color: #f5f7fb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.empty-state {
  border: 1px dashed rgba(25, 25, 25, 0.22);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
}

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: grid;
  gap: 0.6rem;
}

.toast {
  min-width: min(24rem, calc(100vw - 2rem));
  border: 1px solid rgba(25, 25, 25, 0.12);
  border-radius: var(--radius);
  padding: 0.82rem 0.9rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.vote-success {
  width: min(100%, 42rem);
  margin: 12vh auto 0;
}

.public-vote-mode .app-shell {
  display: block;
  min-height: 100vh;
  padding: 1rem;
}

.public-vote-mode .sidebar,
.public-vote-mode .topbar {
  display: none;
}

.public-vote-mode .content {
  max-width: 980px;
  margin: 0 auto;
}

.mobile-nav-toggle,
.mobile-nav-backdrop {
  display: none;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(20rem, calc(100vw - 3rem));
    height: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-nav-backdrop {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: block;
    border: 0;
    background: rgba(25, 25, 25, 0.22);
  }

  .mobile-nav-toggle {
    display: grid;
    width: 2.6rem;
    height: 2.6rem;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
  }

  .mobile-nav-toggle span {
    display: block;
    width: 1.1rem;
    height: 2px;
    background: var(--ink);
  }

  .topbar {
    align-items: start;
  }

  .topbar-actions .select-field {
    width: min(100%, 28rem);
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 0.65rem;
  }

  .topbar {
    position: static;
    display: grid;
  }

  .topbar-actions,
  .section-heading,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-2,
  .grid-3,
  .election-grid,
  .step-grid,
  .metric-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .countdown-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .sidebar,
  .topbar,
  .toast-stack,
  .no-print {
    display: none !important;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .content {
    max-width: none;
  }

  .panel,
  .glass-panel {
    box-shadow: none;
  }
}

/* shadcn mode - flat token-based design system. */
:root {
  --background: #f8fafc;
  --foreground: #0f172a;
  --card: #ffffff;
  --card-foreground: #0f172a;
  --popover: #ffffff;
  --popover-foreground: #0f172a;
  --primary: #e32f20;
  --primary-foreground: #ffffff;
  --secondary: #f1f5f9;
  --secondary-foreground: #0f172a;
  --muted-surface: #f1f5f9;
  --muted-foreground: #64748b;
  --accent: #fff1f2;
  --accent-foreground: #9f1239;
  --destructive: #dc2626;
  --destructive-foreground: #ffffff;
  --success: #047857;
  --success-foreground: #ffffff;
  --border: #e2e8f0;
  --input: #cbd5e1;
  --ring: rgba(227, 47, 32, 0.24);
  --sidebar-background: #ffffff;
  --sidebar-accent: #f8fafc;
  --sidebar-accent-foreground: #0f172a;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --red: var(--primary);
  --red-deep: #b42318;
  --yellow: #f59e0b;
  --black: var(--foreground);
  --ink: var(--foreground);
  --muted: var(--muted-foreground);
  --muted-soft: #94a3b8;
  --line: var(--border);
  --panel: var(--card);
  --panel-strong: var(--card);
  --surface: var(--card);
  --wash: var(--background);
  --blue: #2563eb;
  --green: var(--success);
  color-scheme: light;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #111113;
  --card-foreground: #fafafa;
  --popover: #18181b;
  --popover-foreground: #fafafa;
  --primary: #ff4b3e;
  --primary-foreground: #ffffff;
  --secondary: #27272a;
  --secondary-foreground: #fafafa;
  --muted-surface: #27272a;
  --muted-foreground: #a1a1aa;
  --accent: #2b1716;
  --accent-foreground: #fecaca;
  --destructive: #ef4444;
  --destructive-foreground: #ffffff;
  --success: #10b981;
  --success-foreground: #052e16;
  --border: #27272a;
  --input: #3f3f46;
  --ring: rgba(255, 75, 62, 0.32);
  --sidebar-background: #111113;
  --sidebar-accent: #18181b;
  --sidebar-accent-foreground: #fafafa;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 18px 42px rgba(0, 0, 0, 0.28);
  --red-deep: #ff7a70;
  --muted-soft: #71717a;
  color-scheme: dark;
}

html,
body {
  background: var(--background);
}

body {
  color: var(--foreground);
  background: var(--background);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(227, 47, 32, 0.055), transparent 18rem),
    radial-gradient(circle at 100% 0%, rgba(37, 99, 235, 0.06), transparent 22rem);
  content: "";
}

html[data-theme="dark"] body::before {
  background:
    linear-gradient(180deg, rgba(255, 75, 62, 0.08), transparent 18rem),
    radial-gradient(circle at 100% 0%, rgba(96, 165, 250, 0.07), transparent 22rem);
}

.app-shell {
  gap: 1rem;
  padding: 1rem;
}

.glass-panel,
.panel,
.login-panel,
.topbar,
.metric-card,
.step-card,
.option-row,
.toast {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--card-foreground);
  background: var(--card);
  box-shadow: var(--shadow);
}

.glass-panel {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.glass-panel::before {
  display: none;
}

.sidebar {
  background: var(--sidebar-background);
}

.brand-lockup,
.brand-row,
.topbar h1,
.section-heading h2,
.panel-header h3,
.metric-card strong,
.step-card strong,
.option-row,
td,
input,
select,
textarea {
  color: var(--foreground);
}

.brand-lockup small,
.brand-row small,
.muted,
.metric-card span,
th,
.field span,
.select-field span,
.login-panel label span,
.nav-group summary,
.nav-group summary::after {
  color: var(--muted-foreground);
}

.topbar {
  top: 1rem;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar h1,
.section-heading h2,
.login-panel h1 {
  font-size: 1.75rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.panel-header h3 {
  font-size: 1.05rem;
  line-height: 1.25;
}

.eyebrow {
  color: var(--primary);
  letter-spacing: 0;
}

.nav-item {
  color: var(--muted-foreground);
  background: transparent;
}

.nav-item:hover {
  color: var(--sidebar-accent-foreground);
  background: var(--sidebar-accent);
}

.nav-item.active {
  color: var(--primary);
  background: var(--accent);
  box-shadow: none;
}

.sidebar-note {
  border-top-color: var(--border);
  color: var(--muted-foreground);
}

.app-version {
  border-color: var(--border);
  color: var(--muted-foreground);
  background: var(--secondary);
}

.status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 16%, transparent);
}

input,
select,
textarea {
  min-height: 2.5rem;
  border-color: var(--input);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

select[multiple] {
  min-height: 8rem;
}

th,
td {
  border-top-color: var(--border);
}

.table-shell {
  border-color: var(--border);
  background: var(--card);
}

.metric-card {
  background: var(--secondary);
}

.metric-card strong {
  font-size: 1.9rem;
}

.status-pill,
.role-pill,
.hash-pill {
  border-color: var(--border);
  color: var(--foreground);
  background: var(--secondary);
}

.status-pill.draft {
  border-color: color-mix(in srgb, var(--blue) 24%, var(--border));
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 10%, var(--card));
}

.status-pill.open {
  border-color: color-mix(in srgb, var(--success) 24%, var(--border));
  color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, var(--card));
}

.status-pill.closed,
.status-pill.tallied,
.status-pill.sealed {
  border-color: color-mix(in srgb, var(--primary) 26%, var(--border));
  color: var(--primary);
  background: var(--accent);
}

.status-pill.archived {
  border-color: var(--border);
  color: var(--muted-foreground);
  background: var(--secondary);
}

.primary-action,
.ghost-action,
.danger-action {
  min-height: 2.5rem;
  border-radius: calc(var(--radius) - 2px);
  box-shadow: none;
}

.primary-action {
  border-color: var(--primary);
  color: var(--primary-foreground);
  background: var(--primary);
}

.primary-action:hover {
  transform: none;
  background: color-mix(in srgb, var(--primary) 88%, #000000);
}

.ghost-action {
  border-color: var(--border);
  color: var(--foreground);
  background: var(--card);
}

.ghost-action:hover {
  background: var(--secondary);
}

.danger-action {
  border-color: color-mix(in srgb, var(--destructive) 28%, var(--border));
  color: var(--destructive);
  background: color-mix(in srgb, var(--destructive) 9%, var(--card));
}

.danger-action:hover {
  color: var(--destructive-foreground);
  background: var(--destructive);
}

.brand-mark {
  border-color: var(--card);
  background: var(--primary);
  box-shadow: none;
}

.login-screen {
  background: var(--background);
}

.login-panel {
  box-shadow: var(--shadow-lg);
}

.option-row,
.step-card,
.empty-state {
  background: var(--secondary);
}

.empty-state {
  border-color: var(--border);
  color: var(--muted-foreground);
}

.timeline-item::before,
.step-number {
  background: var(--primary);
}

.progress-line {
  background: var(--muted-surface);
}

.progress-line span {
  background: var(--primary);
}

.token-box {
  border-color: var(--border);
  color: var(--foreground);
  background: var(--popover);
}

.toast {
  color: var(--popover-foreground);
  background: var(--popover);
  box-shadow: var(--shadow-lg);
}

.theme-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem;
  min-width: 10.8rem;
  min-height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.18rem;
  color: var(--muted-foreground);
  background: var(--secondary);
}

.theme-toggle-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  min-height: 2rem;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
  transition: 160ms ease;
}

.theme-toggle svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.ui-icon {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-slot {
  display: inline-grid;
  place-items: center;
}

.button-icon,
.nav-item .button-icon {
  width: 1rem;
  height: 1rem;
  color: currentColor;
}

.primary-action.has-icon,
.ghost-action.has-icon,
.danger-action.has-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.nav-item.has-icon {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.62rem;
}

.nav-item.has-icon .button-icon {
  width: 1.05rem;
  height: 1.05rem;
}

.nav-item.has-icon:not(.active) .button-icon {
  color: var(--muted-foreground);
}

.metric-card {
  position: relative;
  display: grid;
  align-content: start;
  min-height: 7.2rem;
  padding-right: 4.2rem;
}

.metric-icon {
  position: absolute;
  top: 0.78rem;
  right: 0.78rem;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  border-radius: calc(var(--radius) - 2px);
  color: var(--primary);
  background: var(--accent);
}

.metric-icon .ui-icon {
  width: 1.08rem;
  height: 1.08rem;
}

.metric-card .metric-label {
  color: var(--muted-foreground);
}

.compact .metric-card {
  min-height: 5.7rem;
  padding-right: 3.5rem;
}

.compact .metric-icon {
  width: 1.9rem;
  height: 1.9rem;
}

html[data-theme="light"] .theme-toggle-sun,
html[data-theme="dark"] .theme-toggle-moon {
  color: var(--foreground);
  background: var(--card);
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .mobile-nav-toggle span {
  background: var(--foreground);
}

html[data-theme="dark"] .mobile-nav-backdrop {
  background: rgba(0, 0, 0, 0.52);
}

@media (max-width: 860px) {
  .theme-toggle {
    width: 100%;
  }

  .topbar h1,
  .section-heading h2,
  .login-panel h1 {
    font-size: 1.45rem;
  }
}

@media print {
  html,
  body {
    color: #111827;
    background: #ffffff;
  }

  .panel,
  .glass-panel,
  .metric-card,
  .step-card,
  .option-row {
    border-color: #d1d5db;
    color: #111827;
    background: #ffffff;
    box-shadow: none;
  }
}
