:root {
  color-scheme: light;
  --primary: #dc2626;
  --primary-soft: #fef2f2;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --card: #18181b;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --border: #3f3f46;
  --primary: #ef4444;
  --primary-soft: #3f171b;
  --sidebar: #111113;
  --danger: #f87171;
  --danger-soft: #40191d;
  --warning: #fbbf24;
  --warning-soft: #3b2a12;
  --success: #4ade80;
  --success-soft: #143522;
  --info: #60a5fa;
  --info-soft: #172d4d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

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

.login-page {
  background: linear-gradient(135deg, #f8fafc, #fef2f2);
}

.btn-primary:hover {
  background: #b91c1c;
}

.form-control:focus,
select:focus,
textarea:focus,
input:focus {
  border-color: #f87171;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.theme-toggle {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.theme-toggle .theme-sun,
html[data-theme="dark"] .theme-toggle .theme-moon {
  display: none;
}

html[data-theme="dark"] .theme-toggle .theme-sun {
  display: inline;
}

.login-theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
}

html[data-theme="dark"] .topbar {
  background: rgba(24, 24, 27, .94);
}

html[data-theme="dark"] .nav-link {
  color: #d4d4d8;
}

html[data-theme="dark"] .nav-link:hover,
html[data-theme="dark"] .btn:hover {
  background: #27272a;
}

html[data-theme="dark"] .nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}

html[data-theme="dark"] .avatar {
  background: #3f3f46;
}

html[data-theme="dark"] .btn,
html[data-theme="dark"] .form-control,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] .table,
html[data-theme="dark"] .login-card {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

html[data-theme="dark"] .table th {
  background: #202023;
}

html[data-theme="dark"] .table a {
  color: var(--text);
}

html[data-theme="dark"] .badge-neutral {
  background: #27272a;
  color: #d4d4d8;
}

html[data-theme="dark"] .badge-emergency {
  background: #4c1823;
  color: #fda4af;
}

.badge-future {
  background: #f1f5f9;
  color: #475569;
}

html[data-theme="dark"] .badge-future {
  background: #29313d;
  color: #cbd5e1;
}

html[data-theme="dark"] .login-page {
  background: linear-gradient(135deg, #09090b, #2a1014);
}

html[data-theme="dark"] .login-card {
  box-shadow: 0 20px 40px rgba(0, 0, 0, .35);
}

@media (max-width: 420px) {
  .top-actions .theme-toggle {
    font-size: 18px;
  }

  .top-actions .theme-toggle::after {
    content: none;
  }
}

.settings-grid > .card {
  min-width: 0;
}

.settings-table {
  min-width: 0;
}

.service-types-table {
  min-width: 700px;
}

.service-types-table input[name="name"] {
  min-width: 170px;
}

.settings-row-actions {
  align-items: center;
  min-width: 250px;
}

.settings-in-use {
  font-size: 12px;
}

.inline-delete {
  display: inline-block;
}

.inline-delete > summary {
  list-style: none;
}

.inline-delete > summary::-webkit-details-marker {
  display: none;
}

.inline-delete > summary.is-disabled {
  pointer-events: none;
}

.inline-delete > form {
  width: 210px;
  margin-top: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  box-shadow: 0 10px 25px rgba(0,0,0,.14);
}

.inline-delete > form span {
  display: block;
  margin-bottom: 9px;
  font-size: 13px;
}

.service-status-card .inline-delete > form {
  width: min(430px, calc(100vw - 60px));
}

.destructive-confirmation > form {
  width: min(520px, calc(100vw - 60px));
}

.danger-zone-card {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

.settings-add-form > input[name="name"] {
  flex: 1 1 220px;
  min-width: 0;
}

.settings-type-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.optional-field-settings {
  max-width: 760px;
}

.users-table {
  min-width: 1320px;
}

.users-table input,
.users-table select {
  min-width: 150px;
}

.user-chip span {
  display: block;
  margin: 1px 0;
  color: var(--muted);
  font-size: 11px;
}

.user-access-note {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

.current-user-label {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.user-row-actions {
  min-width: 335px;
}

.password-reset > form {
  width: min(330px, calc(100vw - 60px));
}

.password-reset label {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
}

.password-reset input {
  margin-top: 5px;
}

.user-add-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.user-add-form .actions {
  margin-top: 14px;
}

.optional-field-setting {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

.optional-field-setting strong,
.optional-field-setting small {
  display: block;
}

.optional-field-setting small {
  color: var(--muted);
  margin-top: 4px;
}

.optional-field-setting input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.history-notes {
  min-width: 220px;
  max-width: 420px;
  white-space: normal;
}

.property-note-history {
  margin-top: 24px;
  padding: 0;
  overflow: hidden;
}

.note-history-header {
  padding: 18px 20px;
  margin: 0;
}

.note-history-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.note-history-filter select {
  width: auto;
  min-width: 170px;
  min-height: 36px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.note-history-scroll {
  max-height: 560px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding: 0 20px;
}

.note-history-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.note-history-item:last-child {
  border-bottom: 0;
}

.note-history-item[hidden],
.note-filter-empty[hidden] {
  display: none;
}

.note-history-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.note-history-heading > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.note-history-heading small,
.note-history-heading time,
.note-history-meta {
  color: var(--muted);
  font-size: 12px;
}

.note-history-heading time {
  flex: 0 0 auto;
}

.note-history-text {
  margin-top: 11px;
  line-height: 1.55;
  white-space: normal;
}

.note-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 11px;
}

.note-history-meta a {
  color: var(--primary);
  font-weight: 650;
  text-decoration: none;
}

@media (max-width: 1200px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .settings-table th,
  .settings-table td {
    padding: 11px 10px;
  }

  .settings-add-form > input[name="name"],
  .settings-add-form > .btn {
    flex-basis: 100%;
    width: 100%;
  }

  .settings-type-form {
    grid-template-columns: 1fr;
  }

  .settings-type-form .btn {
    width: 100%;
  }

  .note-history-header,
  .note-history-scroll {
    padding-left: 14px;
    padding-right: 14px;
  }

  .note-history-header {
    align-items: stretch;
    flex-direction: column;
  }

  .note-history-filter,
  .note-history-filter select {
    width: 100%;
  }

  .note-history-heading {
    display: block;
  }

  .note-history-heading time {
    display: block;
    margin-top: 8px;
  }
}

.inspection-hero { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 14px; }
.inspection-jump { margin-bottom: 18px; }
.inspection-section, #checklist { scroll-margin-top: 90px; }
.inspection-record { min-width: 0; margin: 0 0 16px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; }
.inspection-record legend { padding: 0 6px; font-weight: 700; }
.inspection-record .form-grid { margin-bottom: 12px; }
.result-option input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 3px; }
.inspection-hero h2 { margin: 8px 0 4px; font-size: 22px; }
.inspection-hero p { margin: 0; color: var(--muted); }
.inspection-back { text-decoration: none; font-size: 13px; }
.inspection-summary { min-width: 150px; display: grid; justify-items: end; gap: 4px; }
.inspection-summary strong { font-size: 22px; }
.inspection-summary small { color: var(--muted); }
.inspection-progress { height: 7px; border-radius: 99px; background: var(--border); overflow: hidden; margin: 0 2px 18px; }
.inspection-progress span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.inspection-form { padding-bottom: 92px; }
.inspection-section { margin-bottom: 18px; }
.inspection-items { display: grid; gap: 12px; }
.inspection-item { border: 1px solid var(--border); border-radius: 11px; padding: 14px; display: grid; grid-template-columns: minmax(240px,1fr) auto; gap: 14px; }
.inspection-item.has-failure { border-color: #fca5a5; background: var(--danger-soft); }
.inspection-question { display: flex; gap: 11px; align-items: flex-start; }
.inspection-question strong,.inspection-question small { display: block; }
.inspection-question small { color: var(--muted); margin-top: 4px; }
.inspection-code { flex: 0 0 auto; min-width: 42px; padding: 4px 7px; border-radius: 7px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 800; text-align: center; }
.result-options { display: flex; gap: 6px; }
.result-option input { position: absolute; opacity: 0; pointer-events: none; }
.result-option span { min-width: 58px; min-height: 38px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); display: grid; place-items: center; font-size: 13px; font-weight: 700; cursor: pointer; }
.result-pass input:checked + span { color: var(--success); border-color: #86efac; background: var(--success-soft); }
.result-fail input:checked + span { color: var(--danger); border-color: #fca5a5; background: var(--danger-soft); }
.result-na input:checked + span { color: var(--muted); border-color: #a1a1aa; background: #f4f4f5; }
.inspection-details { grid-column: 1/-1; display: grid; grid-template-columns: 180px 180px minmax(260px,1fr); gap: 12px; }
.inspection-comments { grid-column: -2/-1; }
.inspection-details textarea { min-height: 68px; }
.fail-required { display: none; color: var(--danger); font-weight: 500; }
.has-failure .fail-required { display: inline; }
.system-warning { margin: 16px 0 0; }
.inspection-savebar { position: fixed; z-index: 15; left: 268px; right: 20px; bottom: 18px; max-width: 1210px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--card) 94%, transparent); box-shadow: 0 10px 30px rgba(15,23,42,.15); backdrop-filter: blur(10px); }
.inspection-savebar strong,.inspection-savebar small { display: block; }
.inspection-savebar small { color: var(--muted); margin-top: 3px; }
@media(max-width:900px){.inspection-item{grid-template-columns:1fr}.result-options{grid-column:1}.inspection-details{grid-template-columns:1fr 1fr}.inspection-comments{grid-column:1/-1}.inspection-savebar{left:20px}}
@media(max-width:600px){.inspection-hero{align-items:flex-start}.inspection-summary{min-width:auto}.inspection-item{padding:12px}.result-option{flex:1}.result-option span{min-width:0}.inspection-details{grid-template-columns:1fr}.inspection-comments{grid-column:auto}.inspection-savebar{left:10px;right:10px;bottom:10px}.inspection-savebar div{display:none}}

.dashboard-stats {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 22px;
}

.dashboard-stats .stat-card {
  color: var(--text);
  text-decoration: none;
  border-top: 3px solid var(--border);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.dashboard-stats .stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
}

.dashboard-stats .stat-danger { border-top-color: var(--danger); }
.dashboard-stats .stat-primary { border-top-color: var(--primary); }
.dashboard-stats .stat-warning { border-top-color: var(--warning); }
.dashboard-stats .stat-emergency { border-top-color: #e11d48; }
.dashboard-stats .stat-info { border-top-color: var(--info); }
.dashboard-stats .stat-billing { border-top-color: #9333ea; }

.badge-info {
  background: var(--info-soft);
  color: var(--info);
}

.badge-billing {
  background: #f3e8ff;
  color: #7e22ce;
}

.badge-ready {
  background: var(--primary-soft);
  color: var(--primary);
}

html[data-theme="dark"] .badge-billing {
  background: #35164b;
  color: #d8b4fe;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  align-items: end;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: span 2;
}

.dashboard-work-list {
  margin-top: 18px;
}

.dashboard-active-work {
  margin-bottom: 18px;
}

.active-work-toolbar select {
  max-width: 220px;
}

.job-action-card {
  margin-top: 18px;
}

.job-field-notes {
  margin-top: 18px;
}

.job-site-information {
  margin-top: 18px;
}

.field-notes-editor {
  min-height: 150px;
}

.field-notes-display {
  line-height: 1.55;
  white-space: normal;
}

.field-notes-display[hidden],
.field-notes-edit-form[hidden],
#editFieldNotesButton[hidden] {
  display: none;
}

.field-notes-edit-form small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

.field-notes-edit-form .actions {
  margin-top: 12px;
}

.field-notes-readonly {
  line-height: 1.55;
  white-space: normal;
}

.field-notes-help {
  margin: 10px 0 0;
  font-size: 13px;
}

.field-note-audit {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.field-note-audit summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.field-note-audit-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.field-note-audit-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 14px;
  border-left: 3px solid var(--border);
  padding: 4px 0 4px 11px;
  font-size: 13px;
}

.field-note-audit-item span {
  color: var(--muted);
}

.completion-correction {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.completion-correction .form-group {
  flex: 1 1 220px;
}

.report-checklist {
  display: grid;
  gap: 14px;
}

.report-requirement,
.report-check,
.report-recipient {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.report-requirement .report-check {
  border: 0;
  padding: 0;
}

.requirement-date {
  margin: 12px 0 0 29px;
  max-width: 240px;
}

.report-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.report-check input {
  width: 19px;
  height: 19px;
  margin-top: 1px;
}

.report-check span,
.report-check strong,
.report-check small {
  display: block;
}

.report-check small {
  color: var(--muted);
  margin-top: 3px;
}

.report-recipient > .checkbox-row {
  margin-bottom: 10px;
  font-weight: 650;
}

.btn.is-disabled {
  opacity: .48;
  filter: grayscale(.35);
  cursor: not-allowed;
}

.requirement-missing {
  border-color: var(--danger) !important;
  background: var(--danger-soft);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

.closeout-message {
  margin-top: 18px;
  margin-bottom: 0;
}

.closeout-message[hidden] {
  display: none;
}

.reopen-message {
  margin: 18px 0 0;
}

.reopen-message[hidden] {
  display: none;
}

.reopen-message p {
  margin: 5px 0 12px;
}

html[data-theme="dark"] .dashboard-stats .stat-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}

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

  .filter-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 900px) {
  .dashboard-stats,
  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .dashboard-stats,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    grid-column: auto;
  }

  .filter-actions .btn {
    flex: 1 1 auto;
  }

  .active-work-toolbar select,
  .active-work-toolbar .btn {
    max-width: none;
    width: 100%;
  }
}

/* Shared visual polish */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #202124;
  --muted: #6b7280;
  --border: #e2e5e9;
  --sidebar: #fbfbfc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .035);
}

html[data-theme="dark"] {
  --bg: #0c0c0f;
  --card: #19191d;
  --border: #34343b;
  --sidebar: #121216;
  --shadow: 0 1px 2px rgba(0, 0, 0, .28), 0 10px 28px rgba(0, 0, 0, .18);
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { line-height: 1.45; }
::selection { background: var(--primary-soft); color: var(--text); }

.sidebar {
  overflow-y: auto;
  box-shadow: 1px 0 0 rgba(15, 23, 42, .02);
}

.brand-mark,
.login-logo {
  background: linear-gradient(145deg, #ef4444, #b91c1c);
  box-shadow: 0 7px 18px rgba(220, 38, 38, .2);
}

.brand strong { letter-spacing: -.01em; }
.nav-link { position: relative; transition: color .15s ease, background .15s ease, transform .15s ease; }
.nav-link:hover { transform: translateX(2px); }
.nav-link.active { box-shadow: inset 3px 0 0 var(--primary); }

.user-chip a:hover,
.table a:hover,
.note-history-meta a:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.topbar { height: 74px; box-shadow: 0 1px 0 rgba(15, 23, 42, .025); }
.topbar h1 { font-size: 19px; letter-spacing: -.015em; }
.content { width: 100%; max-width: 1560px; margin: 0 auto; padding: 30px; }
.card, .stat-card { border-color: var(--border); }
.card { padding: 22px; }
.card-header { align-items: flex-start; margin-bottom: 18px; }

.card-header h2,
.card-header h3,
.section-title h2 { letter-spacing: -.012em; }

.card-header p,
.section-title p { line-height: 1.45; }
.section-title { margin-top: 30px; margin-bottom: 13px; }

.btn {
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .08s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { box-shadow: 0 3px 10px rgba(220, 38, 38, .16); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn:focus-visible,
.nav-link:focus-visible,
.icon-btn:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(239, 68, 68, .25);
  outline-offset: 2px;
}

.form-control,
select,
textarea,
input:not([type]),
input[type="date"],
input[type="datetime-local"],
input[type="email"],
input[type="text"],
input[type="password"],
input[type="number"],
input[type="tel"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d1d5db;
  border-radius: 9px;
  background: var(--card);
  padding: 9px 11px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

textarea { min-height: 108px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #9ca3af; }

html[data-theme="dark"] input:not([type]),
html[data-theme="dark"] input[type="datetime-local"],
html[data-theme="dark"] .form-control,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="tel"] {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

.form-group label { color: var(--text); letter-spacing: .005em; }
.form-group small { line-height: 1.4; }
.checkbox-row { line-height: 1.35; }

.checkbox-row input,
.report-check input,
.optional-field-setting input { accent-color: var(--primary); }

.table-wrap { border-radius: 12px; background: var(--card); }
.table th { height: 43px; color: #68707d; font-size: 11px; font-weight: 750; letter-spacing: .055em; }
.table td { line-height: 1.4; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #fafafa; }
html[data-theme="dark"] .table th { color: #a1a1aa; }
html[data-theme="dark"] .table tbody tr:hover { background: #202026; }
.badge { min-height: 23px; align-items: center; letter-spacing: .01em; }
.alert { line-height: 1.45; box-shadow: inset 3px 0 0 currentColor; }

.stat-card {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.dashboard-stats .stat-card strong { letter-spacing: -.035em; }
.detail-item { min-width: 0; }
.detail-item strong { display: block; overflow-wrap: anywhere; line-height: 1.4; }
.empty { line-height: 1.5; }

.login-page {
  background: radial-gradient(circle at 15% 15%, rgba(239, 68, 68, .1), transparent 34%), linear-gradient(135deg, #f8fafc, #fff7f7);
}

html[data-theme="dark"] .login-page {
  background: radial-gradient(circle at 15% 15%, rgba(239, 68, 68, .13), transparent 34%), linear-gradient(135deg, #09090b, #1f0d10);
}

.login-card { border-radius: 18px; box-shadow: 0 24px 60px rgba(15, 23, 42, .11); }
.login-card h1 { letter-spacing: -.025em; }
html[data-theme="dark"] .login-card { box-shadow: 0 24px 60px rgba(0, 0, 0, .38); }

.coverage-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 18px;
}

.coverage-settings-card { display: flex; flex-direction: column; gap: 16px; }
.coverage-settings-card .card-header { margin-bottom: 0; }
.coverage-rule-list { display: grid; gap: 12px; flex: 1; }
.coverage-rule {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.coverage-rule legend { padding: 0 6px; font-size: 13px; font-weight: 700; color: var(--text); }
.coverage-checks, .interval-check-grid { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.coverage-checks .checkbox-row, .interval-check-grid .checkbox-row { min-width: 120px; }
.interval-requirements { margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: 10px; }
.interval-requirements legend { padding: 0 6px; font-weight: 700; }

.interval-date-options {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  gap: 10px;
}
.interval-date-options legend { padding: 0 6px; font-size: 13px; font-weight: 700; }
.interval-date-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
}
.interval-date-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.interval-date-option input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }
.interval-date-option strong, .interval-date-option small { display: block; }
.interval-date-option small { color: var(--muted); margin-top: 3px; line-height: 1.4; }
.custom-interval-date { padding: 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--card); }
.closeout-custom-interval { margin-bottom: 16px; }

@media (max-width: 760px) {
  .sidebar { width: min(300px, 86vw); box-shadow: 16px 0 40px rgba(0, 0, 0, .16); }
  .topbar { height: 66px; }
  .topbar h1 { font-size: 17px; }
  .content { padding: 18px 14px 28px; }
  .card { padding: 18px; }
  .card-header { gap: 10px; }
  .section-title { align-items: flex-start; }
  .btn { min-height: 42px; }
}

@media (max-width: 520px) {
  .login-page { padding: 18px; }
  .login-card { padding: 24px; }
  .card-header { flex-wrap: wrap; }
  .actions > .btn, .actions > form:only-child .btn { min-width: 0; }
  .stat-card { min-height: 104px; }
}
