:root {
  color-scheme: light;
  --bg: #f8efe2;
  --bg-accent: #ffd54a;
  --surface: #fffaf2;
  --surface-rgb: 255, 250, 242;
  --surface-soft: #fffdf7;
  --ink: #171717;
  --muted: #5c584f;
  --red: #ff5d47;
  --green: #0c7c59;
  --line: #171717;
  --on-accent: #171717;
  --panel-bg: rgba(var(--surface-rgb), 0.96);
  --panel-accent: linear-gradient(180deg, #ffe59d 0%, #fff8e8 100%);
  --panel-danger: linear-gradient(180deg, #ffd8cf 0%, #fff8e8 100%);
  --input-bg: #fffdf7;
  --success-bg: #dff4df;
  --error-bg: #ffd8cf;
  --warning-bg: #ffe59d;
  --border-soft: rgba(23, 23, 23, 0.12);
  --border-table: rgba(23, 23, 23, 0.18);
  --grain-line: rgba(0, 0, 0, 0.8);
  --grain-opacity: 0.08;
  --body-bg:
    radial-gradient(circle at top left, rgba(255, 93, 71, 0.22), transparent 28%),
    radial-gradient(circle at right, rgba(255, 213, 74, 0.45), transparent 20%),
    linear-gradient(135deg, #f9ecdd 0%, #f4efe9 55%, #efe7db 100%);
  --shadow: 8px 8px 0 var(--line);
  --shadow-soft: 12px 12px 0 rgba(23, 23, 23, 0.08);
  --radius: 22px;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: "Trebuchet MS", "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121315;
  --bg-accent: #f2b84b;
  --surface: #1d2024;
  --surface-rgb: 29, 32, 36;
  --surface-soft: #24282d;
  --ink: #f6ead9;
  --muted: #c4b8a6;
  --red: #ff725f;
  --green: #58d097;
  --line: #050607;
  --on-accent: #150f0b;
  --panel-bg: rgba(var(--surface-rgb), 0.96);
  --panel-accent: linear-gradient(180deg, #4a3518 0%, #22262b 100%);
  --panel-danger: linear-gradient(180deg, #4b2722 0%, #22262b 100%);
  --input-bg: #15181c;
  --success-bg: #1e4a34;
  --error-bg: #55251f;
  --warning-bg: #5a421d;
  --border-soft: rgba(246, 234, 217, 0.16);
  --border-table: rgba(246, 234, 217, 0.2);
  --grain-line: rgba(255, 250, 242, 0.55);
  --grain-opacity: 0.06;
  --body-bg:
    radial-gradient(circle at top left, rgba(255, 114, 95, 0.2), transparent 30%),
    radial-gradient(circle at right, rgba(242, 184, 75, 0.2), transparent 22%),
    linear-gradient(135deg, #101113 0%, #171a1f 56%, #0c0d10 100%);
  --shadow-soft: 12px 12px 0 rgba(5, 6, 7, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--body-bg);
  font-family: var(--font-body);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image:
    linear-gradient(0deg, transparent 24%, var(--grain-line) 25%, transparent 26%),
    linear-gradient(90deg, transparent 24%, var(--grain-line) 25%, transparent 26%);
  background-size: 4px 4px;
}

.site-header,
main,
.site-footer {
  position: relative;
  z-index: 1;
}

.site-header {
  padding: 1.25rem 2rem;
}

.site-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
}

.site-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand,
.site-nav a,
.table-link {
  color: var(--ink);
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
}

.brand-mark {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 3px 3px 0 var(--line);
}

.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-nav form {
  margin: 0;
}

.theme-toggle {
  min-width: 8.5rem;
}

.button,
.nav-button,
button,
input,
textarea,
select {
  font: inherit;
}

.button,
.nav-button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.8rem 1.2rem;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--line);
}

.button.solid,
.nav-button.solid {
  background: var(--red);
  color: var(--on-accent);
}

.button.danger {
  background: var(--ink);
  color: var(--surface);
}

main {
  padding: 0 2rem 2rem;
}

.site-footer {
  padding: 0 2rem 2rem;
}

.site-footer-inner {
  padding-top: 0.5rem;
  text-align: center;
  color: var(--muted);
}

.legal-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 0.6rem;
}

.legal-links a,
.legal-card a,
.legal-consent a {
  color: var(--ink);
}

.site-footer-inner p {
  margin: 0;
}

.panel {
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  min-width: 0;
}

.panel.accent,
.panel-hero {
  background: var(--panel-accent);
}

.danger-panel {
  background: var(--panel-danger);
}

.form-panel {
  display: grid;
  align-content: start;
  gap: 0.95rem;
}

.form-panel .eyebrow,
.form-panel h1,
.form-panel h2,
.form-panel p,
.summary-panel .eyebrow,
.summary-panel h2,
.summary-panel p {
  margin: 0;
}

.form-panel button {
  justify-self: start;
  margin-top: 0.25rem;
}

.summary-panel {
  display: grid;
  align-content: start;
  gap: 0.85rem;
}

.summary-panel form {
  margin-top: 0.35rem;
}

.admin-detail-grid .adjustment-panel {
  grid-column: 1 / -1;
}

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

.adjustment-note {
  grid-column: 1 / -1;
}

.adjustment-note textarea {
  min-height: 110px;
}

.hero,
.dashboard-grid,
.two-col,
.admin-grid {
  display: grid;
  gap: 1.5rem;
}

.hero {
  width: min(100%, 1120px);
  margin: 0 auto;
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
  padding: 2rem 0 2.5rem;
}

.hero-copy h1,
.auth-card h1,
.timer-panel h1,
.panel h2,
.panel h1 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 0.95;
}

.hero-copy h1 {
  font-size: clamp(2.9rem, 6vw, 5.2rem);
  max-width: 11.5ch;
  margin: 0 auto;
  line-height: 0.9;
}

.hero-text,
.muted {
  color: var(--muted);
}

.hero-copy {
  min-height: min(68vh, 640px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem 2.5rem;
}

.hero-copy .eyebrow,
.hero-copy .hero-text {
  max-width: 44rem;
  margin-left: auto;
  margin-right: auto;
}

.hero-copy .hero-text {
  margin-top: 1.25rem;
  margin-bottom: 0;
  font-size: 1.08rem;
}

.hero-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}

.hero-actions {
  justify-content: center;
}

.stat-chip,
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 700;
}

.flash-stack {
  display: grid;
  gap: 0.75rem;
  padding: 0 0 1rem;
}

.flash {
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 0.85rem 1rem;
  background: var(--surface);
}

.flash-success {
  background: var(--success-bg);
}

.flash-error {
  background: var(--error-bg);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 520px);
  align-items: stretch;
  gap: 1.5rem;
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 4rem 0 3rem;
  min-height: auto;
}

.auth-card {
  display: grid;
  gap: 1rem;
  align-content: center;
}

.auth-aside {
  display: grid;
  align-content: center;
  min-height: 440px;
  padding: clamp(2rem, 5vw, 4rem);
}

.auth-aside h2 {
  margin: 0;
  max-width: 11ch;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 4.6rem);
  line-height: 0.9;
}

.auth-aside p {
  margin: 0;
}

.auth-aside .muted {
  max-width: 32rem;
  margin-top: 1.25rem;
  font-size: 1.03rem;
}

.page-shell {
  display: grid;
  padding: 1rem 0 2rem;
}

.section-card {
  width: min(100%, 680px);
  justify-self: center;
}

.settings-form {
  gap: 1.1rem;
  width: 100%;
}

.legal-card {
  display: grid;
  gap: 1rem;
  width: 100%;
}

.legal-card h2 {
  margin: 0.5rem 0 0;
  font-family: var(--font-display);
  line-height: 1;
}

.legal-card p,
.legal-card ul {
  margin: 0;
}

.legal-card ul {
  padding-left: 1.2rem;
}

.legal-card li + li {
  margin-top: 0.45rem;
}

.legal-consent {
  align-items: flex-start;
  font-size: 0.95rem;
  line-height: 1.35;
}

.settings-divider {
  height: 2px;
  background: var(--border-soft);
  border-radius: 999px;
}

.range-output {
  font-weight: 400;
}

.notification-permission {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 2px solid var(--border-soft);
  border-radius: 18px;
  background: var(--surface-soft);
}

.notification-permission p {
  margin: 0;
}

label {
  display: grid;
  gap: 0.45rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 0.85rem 1rem;
  background: var(--input-bg);
  color: var(--ink);
}

.dashboard-grid {
  width: 100%;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: start;
  min-width: 0;
}

.dashboard-shell {
  padding: 1rem 0 2rem;
}

.admin-shell {
  padding: 1rem 0 2rem;
}

.timer-panel {
  grid-column: 1 / -1;
}

.stats-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  min-width: 0;
}

.stat-panel {
  min-height: 100%;
}

.stat-panel h2,
.stat-panel p {
  overflow-wrap: anywhere;
}

.chart-panel {
  grid-column: span 3;
  min-width: 0;
}

.timer-clock {
  margin: 1rem 0;
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 1;
  font-family: var(--font-display);
}

.timer-alert {
  margin: 0 0 1rem;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 0.85rem 1rem;
  background: var(--warning-bg);
  font-weight: 700;
}

.bar-chart {
  display: flex;
  align-items: end;
  gap: 0.75rem;
  min-height: 260px;
  overflow-x: auto;
  padding-top: 1rem;
  padding-bottom: 0.25rem;
}

.bar-item {
  min-width: 72px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bar-track {
  height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: stretch;
  gap: 0.5rem;
}

.bar-value {
  min-height: 2.2em;
  display: inline-flex;
  align-items: end;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.bar-label {
  display: block;
  font-size: 0.74rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.bar {
  width: 100%;
  background: var(--red);
  border: 2px solid var(--line);
  border-radius: 14px 14px 0 0;
  box-shadow: 4px 4px 0 var(--line);
  min-height: 10%;
}

.bar.alt {
  background: var(--bg-accent);
}

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

.admin-grid {
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-header,
.table-panel {
  grid-column: 1 / -1;
}

.smtp-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 1.25rem;
}

.smtp-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1.5rem;
}

.smtp-panel-header h2,
.smtp-panel-header p {
  margin: 0;
}

.smtp-panel-header .muted {
  max-width: 46rem;
  margin-top: 0.65rem;
}

.smtp-status {
  flex: 0 0 auto;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  background: var(--warning-bg);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: 3px 3px 0 var(--line);
}

.smtp-status.is-ready {
  background: var(--success-bg);
}

.smtp-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.switch-row {
  border: 2px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.65rem 0.85rem;
  background: var(--surface-soft);
}

.smtp-field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.5fr) repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.smtp-field-grid .smtp-wide {
  grid-column: span 2;
}

.smtp-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 2px solid var(--border-soft);
  padding-top: 1rem;
}

.smtp-actions p {
  margin: 0;
}

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

th,
td {
  padding: 1rem 0.75rem;
  border-bottom: 1px solid var(--border-table);
  text-align: left;
  vertical-align: top;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.checkbox input {
  width: auto;
}

@media (max-width: 960px) {
  :root {
    --shadow: 5px 5px 0 var(--line);
  }

  .hero,
  .two-col,
  .admin-grid,
  .stats-grid,
  .dashboard-grid,
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .timer-panel,
  .stat-panel,
  .chart-panel {
    grid-column: auto;
  }

  .smtp-panel-header,
  .smtp-actions {
    display: grid;
  }

  .smtp-field-grid {
    grid-template-columns: 1fr;
  }

  .smtp-field-grid .smtp-wide {
    grid-column: auto;
  }

  .adjustment-field-grid {
    grid-template-columns: 1fr;
  }

  .bar-chart {
    min-height: 220px;
  }

  .bar-track {
    height: 180px;
  }

  main,
  .site-header,
  .site-footer,
  .flash-stack {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .dashboard-grid,
  .admin-grid,
  .auth-shell,
  .page-shell {
    padding-right: 5px;
    padding-bottom: 5px;
  }

  .auth-shell {
    padding-top: 1rem;
  }

  .auth-aside {
    min-height: auto;
  }

  .auth-aside h2 {
    max-width: 16ch;
  }
}
