:root {
  color-scheme: light;
  --ink: #301e23;
  --muted: #66544c;
  --line: #eadbb8;
  --accent: #781b3d;
  --accent-dark: #59132d;
  --tint: #f8ebcd;
  --canvas: #fcf7eb;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; display: grid; grid-template-columns: 285px minmax(0, 1fr); min-height: 100vh; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { color: var(--accent-dark); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 3vw, 2.35rem); letter-spacing: -.045em; line-height: 1.16; }
h2 { font-size: 1.1rem; line-height: 1.35; }
h3 { font-size: 1rem; margin-top: 1.2rem; }
p { margin-block: .55rem; }
.sidebar {
  background: #f5e6bf; color: #5b1731; border-right: 1px solid var(--line); padding: 27px 18px;
  display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand strong { display: block; letter-spacing: .13em; line-height: 1.2; }
.brand small { display: block; color: var(--muted); font-size: .74rem; }
.monogram {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px;
  background: var(--accent); color: white; font: bold 26px Georgia, serif;
}
.sidebar .brand, .sidebar nav a { color: #5b1731; }
.sidebar .brand small { color: #694d3b; }
.sidebar :focus-visible { outline-color: #781b3d; }
.sidebar .logout .secondary { background: transparent; color: #5b1731; border-color: #b79b63; }
.sidebar .logout .secondary:hover { background: #ead5a4; }
nav { display: grid; gap: 4px; }
nav a { min-width: 0; overflow-wrap: anywhere; padding: 10px 12px; border-radius: 7px; text-decoration: none; color: var(--ink); font-size: .94rem; }
.sidebar nav a:hover, .sidebar nav a[aria-current] { color: #ffffff; background: #781b3d; }
nav a[aria-current] { font-weight: 650; }
.logout { margin-top: auto; }
main { width: 100%; min-width: 0; max-width: 1320px; padding: 36px clamp(16px, 4vw, 54px); margin-inline: auto; }
.page-heading, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-heading { margin: 0 0 22px; }
.page-heading p { margin-bottom: 0; color: var(--muted); }
.section-heading { margin-bottom: 16px; }
.section-heading > a { font-size: .9rem; }
.panel, .metric {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: clamp(14px, 2.4vw, 24px); min-width: 0; overflow-wrap: anywhere;
}
.panel { margin-bottom: 18px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { display: flex; flex-direction: column; justify-content: space-between; gap: 12px; color: var(--ink); text-decoration: none; }
.metric span { color: var(--muted); font-size: .86rem; }
.metric strong { font-size: 2rem; line-height: 1; }
.metric.danger { background: #fff1f2; color: #8b1527; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
  padding: 7px 13px; font: 650 .88rem/1.3 system-ui, sans-serif; border-radius: 7px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; text-decoration: none; cursor: pointer;
}
button:hover, .button:hover { background: var(--accent-dark); color: white; }
.secondary { background: white; color: var(--accent); border-color: var(--line); }
.secondary:hover { background: var(--tint); color: var(--accent); }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: .9rem; }
td, th { overflow-wrap: anywhere; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th:first-child, td:first-child { padding-left: 3px; }
thead th { white-space: nowrap; color: var(--muted); font-size: .8rem; }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { min-width: 140px; }
tbody th a { color: var(--ink); text-decoration: none; }
tbody th a:hover { text-decoration: underline; }
.row-actions { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
td .row-actions { gap: 6px; }
.row-actions > :is(button, .button) { max-width: 100%; overflow-wrap: anywhere; text-align: center; }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; border-radius: 50px; padding: 3px 9px; background: #f6ebd3; color: #654929; font-size: .78rem; white-space: nowrap; }
.overdue { background: #fbe8ee; color: #8b1b40; }
.filed { background: #e8f4ec; color: #235b38; }
.empty, .helptext, .documents { color: var(--muted); }
.alerts { list-style: none; padding: 0; margin: 0; }
.alerts li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.alerts li:last-child { border-bottom: 0; padding-bottom: 0; }
.alerts li span { font-size: .85rem; }
.filters { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; padding-bottom: 16px; }
.filters label:first-child { flex: 1 1 180px; }
label { display: block; font-size: .9rem; font-weight: 650; }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px; border: 1px solid #b8a782;
  border-radius: 7px; color: var(--ink); background: white; font: inherit; font-size: .93rem;
}
textarea { resize: vertical; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
form p:has(input[type=checkbox]) { display: flex; align-items: center; gap: 8px; }
.form-panel, .login-card { max-width: 680px; }
.form-panel form p, .login-card form p { margin: 0 0 16px; }
form p label, .filters label input, .filters label select { margin-bottom: 4px; }
.helptext { display: block; font-size: .8rem; margin-top: 4px; }
.errorlist { padding-left: 18px; color: #8b1b40; }
.message { background: var(--tint); color: var(--accent-dark); border-radius: 7px; padding: 9px 13px; margin: 0 0 16px; }
.detail-grid, .presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.presets { grid-template-columns: repeat(auto-fit, minmax(min(235px, 100%), 1fr)); }
.presets .panel { display: flex; flex-direction: column; align-items: start; gap: 6px; }
.presets .button { margin-top: auto; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: .92rem; }
dt { color: var(--muted); }
dd { margin: 0; }
.documents { padding-left: 18px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.weekday { text-align: center; color: var(--muted); font-size: .82rem; }
.day { overflow-wrap: anywhere; min-width: 0; min-height: 86px; border: 1px solid var(--line); border-radius: 6px; padding: 5px; }
.calendar-blank { background: var(--canvas); }
.day time { display: inline-block; font-size: .8rem; padding: 2px 5px; }
.day time[aria-current] { border-radius: 5px; color: white; background: var(--accent); }
.calendar-item { display: block; font-size: .79rem; margin-top: 3px; padding: 3px 5px; border-radius: 4px; }
.calendar-item:focus-visible { outline-offset: -2px; }
.mobile-date, .calendar-empty { display: none; }
.login-page { display: grid; grid-template-columns: 1fr; place-items: center; }
.login-page main { max-width: 460px; }
.login-card .brand { margin-bottom: 22px; }
.login-card h1 { margin-bottom: 16px; }
@media (max-width: 900px) {
  body { grid-template-columns: 225px minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  body { display: block; }
  .sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; overflow: visible; }
  .sidebar nav { display: flex; flex-wrap: wrap; grid-row: 2; grid-column: 1 / -1; gap: 2px; }
  nav a { padding: 7px; font-size: .84rem; }
  .logout { margin: 0; align-self: start; }
  main { padding: 20px 14px; }
  .detail-grid, .calendar-grid { display: block; }
  .calendar-grid .weekday, .calendar-grid .day:not(.has-items), .desktop-date { display: none; }
  .calendar-grid .day { min-height: 0; margin-bottom: 6px; }
  .mobile-date { display: inline; }
  .calendar-grid:not(:has(.has-items)) .calendar-empty { display: block; color: var(--muted); }
  .filters label { flex: 1 1 9rem; min-width: 0; }
  #compliances table, #compliances tbody { display: block; }
  #compliances thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #compliances tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 3px; }
  #compliances tbody tr + tr { border-top: 1px solid var(--line); }
  #compliances tbody tr > * { min-width: 0; border: 0; padding: 0; }
  #compliances tbody th, #compliances tbody td:last-child { grid-column: 1 / -1; }
  #compliances tbody td:nth-child(3) { justify-self: end; }
  #compliances .badge { white-space: normal; }
}


dialog { width:min(460px, calc(100% - 32px)); border:1px solid var(--line); border-radius:12px; padding:24px; }
dialog::backdrop { background:rgb(32 32 39 / 48%); }
dialog .row-actions { margin-top:12px; }

.filing-checklist { margin-block: .35rem; }
.checklist-step { display: flex; align-items: start; gap: .35rem; font-weight: normal; }
.checklist-step input { flex: 0 0 auto; }

#backup hr { border:0; border-top:1px solid var(--line); margin:1.25rem 0; }
#calendar .calendar-empty { grid-column:1 / -1; }
@media (min-width: 681px) { #calendar .calendar-empty { display:block; } }

.calendar-legend { display:flex; flex-wrap:wrap; gap:.45rem; padding:0; margin:0 0 1rem; list-style:none; }
.calendar-legend li { padding:.2rem .55rem; border-radius:.3rem; font-size:.8rem; }
.calendar-due { background:#fbe3e6; color:#8b1527; }
.calendar-soon { background:#ffeccf; color:#804000; }
.calendar-upcoming { background:#dff2e6; color:#175832; }
.calendar-filed { background:#eeedf0; color:#514b56; }

.login-page { background: #f8edcf; }
.login-card h2 { margin-block: .75rem; }

.company-heading { margin-bottom: 1.25rem; }
.sidebar .brand { flex-direction: column; align-items: start; gap: .25rem; }
.company-logo { display: block; position: relative; overflow: hidden; width: min(100%, 190px); aspect-ratio: 2.5; }
.company-logo img { width: 118%; height: auto; max-width: none; position: absolute; left: -10%; top: -107%; }
.brand-caption { color: var(--muted); font-size: .8rem; }
@media (max-width: 680px) { .company-logo { width: min(100%, 130px); } }
.company-heading p { color: var(--accent-dark); font-weight: 700; font-size: clamp(.95rem, 2vw, 1.15rem); margin: .3rem 0 0; }

.badge.upcoming { background:#dff2e6; color:#175832; }
.badge.due-today { background:#fbe3e6; color:#8b1527; }

.login-card #access { display: grid; gap: .85rem; }
.login-card #access p { margin: 0; }
.login-card #access label { display: grid; gap: .3rem; }
.login-card #unlock { width: 100%; min-height: 44px; }
.login-card #access-options { margin-top: 1rem; align-items: stretch; }
.login-card #access-options > button { flex: 1 1 9rem; }
.login-card #gate-error:empty { display: none; }

#entry { display:grid; gap:.9rem; }
#entry > label { display:grid; gap:.35rem; }
#entry > p { margin:0; }
#entry > .row-actions { margin-top:.25rem; }
#compliances .filters { gap:12px; padding-bottom:20px; }
#compliances th, #compliances td { padding-block:16px; }
#compliances td .row-actions { gap:8px; }
@media (max-width:680px) {
  #compliances tbody tr { padding-block:16px; row-gap:10px; }
  #compliances tbody tr > * { padding-block:0; }
}

#report .metrics { margin-top: 1rem; }
@media print {
  body:has(#workspace[data-active-view="report"]:not([hidden])) { display: block; background: white; }
  body:has(#workspace[data-active-view="report"]:not([hidden])) #navigation,
  body:has(#workspace[data-active-view="report"]:not([hidden])) .report-controls { display: none; }
  #workspace[data-active-view="report"] { max-width: none; padding: 0; }
  #report { border: 0; padding: 0; }
  #report .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #report .table-scroll { overflow: visible; }
  #report tr { break-inside: avoid; }
}

#filing-history .history-record { flex: 1 1 15rem; min-width: 0; }
#filing-history .alerts li { padding-block: .85rem; }
#history-message:empty { display: none; }

.health-summary { display:flex; align-items:center; flex-wrap:wrap; gap:1rem 1.5rem; }
.health-ring { width:7rem; aspect-ratio:1; border-radius:50%; position:relative; display:grid; place-content:center; justify-items:center; isolation:isolate; background:conic-gradient(#237b4b var(--score), var(--line) 0); }
.health-ring::before { content:""; position:absolute; inset:.55rem; background:#fff; border-radius:50%; z-index:-1; }
.health-ring strong { font-size:1.6rem; }
.health-ring span { font-size:.75rem; }
.health-breakdown { flex:1 1 12rem; grid-template-columns:minmax(0,1fr) auto; }
.health-breakdown dd { text-align:right; font-weight:650; margin:0; }
#penalty-history { margin-top:.85rem; }
.penalty-months { list-style:none; padding:0; }
.penalty-months li { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin-block:.35rem; }
.penalty-months li > span { min-width:5.5rem; }
.penalty-bar { flex:1 1 5rem; min-width:0; }

.certificate-form { display:grid; gap:.9rem; }
.certificate-form p { margin:0; }
.certificate-fields { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,14rem),1fr)); gap:.75rem 1rem; }
.certificate-form label { overflow-wrap:anywhere; }
#certificate-details { max-height:calc(100dvh - 2rem); overflow:auto; }
#certificate-details-body dd { overflow-wrap:anywhere; white-space:pre-wrap; }
#certificate-details-body { margin-bottom:1rem; }
#certificate-attachments:empty, #certificate-error:empty { display:none; }

.dashboard-section-title { margin: 1.25rem 0 .85rem; }
.calendar-record-type { display:block; font-size:.72em; text-decoration:none; }

#admin-form .row-actions { margin-top:1rem; }
#admin-error:empty { display:none; }
#admin-fields label { overflow-wrap:anywhere; }

#admin-metrics { display:contents; }
#office-expenses { gap:.45rem; }
#office-expenses dl { grid-template-columns:minmax(0, 1fr) auto; margin:0; gap:.2rem .55rem; }
#office-expenses dd { font-weight:650; }
#office-expenses .helptext { margin:0; }
@media (max-width:410px) { #admin-summary { grid-template-columns:1fr; } }


.workspace-heading { display:grid; grid-template-columns:minmax(0, 1fr) auto; align-items:start; }
.theme-toggle { width:42px; height:42px; padding:0; border-radius:50%; }
.theme-toggle .theme-sun, [data-theme="dark"] .theme-toggle .theme-moon { display:none; }
[data-theme="dark"] .theme-toggle .theme-sun { display:block; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #fff4f3;
  --muted: #e1cbd0;
  --line: #67464f;
  --accent: #f2a8c1;
  --accent-dark: #ffccdf;
  --tint: #442331;
  --canvas: #21171b;
}
[data-theme="dark"] .sidebar, [data-theme="dark"] .login-page { background: #2e1b23; color: var(--ink); }
[data-theme="dark"] .sidebar .brand, [data-theme="dark"] .sidebar nav a { color: var(--ink); }
[data-theme="dark"] .sidebar :focus-visible { outline-color: var(--accent); }
[data-theme="dark"] .sidebar nav a:hover, [data-theme="dark"] .sidebar nav a[aria-current] { background: #753453; color: #fff; }
[data-theme="dark"] .sidebar .logout .secondary { color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .sidebar .logout .secondary:hover { background: var(--tint); }
[data-theme="dark"] .company-logo { background: #f5e6bf; border-radius: .35rem; }
[data-theme="dark"] :is(.panel, .metric, dialog) { background: #31222a; color: var(--ink); }
[data-theme="dark"] .health-ring::before { background: #31222a; }
[data-theme="dark"] :is(input:not([type=checkbox]), select, textarea) { background: #251a20; border-color: #84636d; color: var(--ink); }
[data-theme="dark"] :is(button, .button, .day time[aria-current]) { color: #291924; }
[data-theme="dark"] :is(button, .button):not(.secondary):hover { color: #291924; }
[data-theme="dark"] .secondary { background: #352631; color: var(--accent); border-color: var(--line); }
[data-theme="dark"] .secondary:hover { background: var(--tint); color: var(--accent-dark); }
[data-theme="dark"] .badge { background: #523923; color: #ffe2a9; }
[data-theme="dark"] :is(.metric.danger, .badge.overdue, .badge.due-today, .calendar-due) { background: #582430; color: #ffc3cc; }
[data-theme="dark"] :is(.badge.upcoming, .badge.filed, .calendar-upcoming) { background: #1e4635; color: #b7f0cf; }
[data-theme="dark"] .calendar-soon { background: #583914; color: #ffd494; }
[data-theme="dark"] .calendar-filed { background: #473e48; color: #e9ddea; }
[data-theme="dark"] .errorlist,
[data-theme="dark"] [role="alert"] { color: #ffc3cc; }
[data-theme="dark"] :is(input, textarea)::placeholder { opacity: 1; color: #cfb7bf; }
[data-theme="dark"] :is(input, select, textarea):disabled { opacity: 1; color: #d4bbc4; -webkit-text-fill-color: #d4bbc4; }
[data-theme="dark"] select :is(option, optgroup) { background: #251a20; color: #fff4f3; }
[data-theme="dark"] select option:checked { background: #753453; color: #fff4f3; }
[data-theme="dark"] input[type="file"]::file-selector-button {
  background: #523244; color: #fff4f3; border: 1px solid #9a7181; border-radius: 4px; margin-inline-end: .7rem;
}
[data-theme="dark"] :is(button, .button):disabled { background: #493541; color: #dfc4ce; border-color: #9a7181; opacity: 1; }
[data-theme="dark"] :is(.alert, .metric.danger) :is(.helptext, span) { color: inherit; }
[data-theme="dark"] .calendar-record-type { color: inherit; opacity: 1; }
@media print {
  [data-theme="dark"] body:has(#workspace[data-active-view="report"]:not([hidden])) { color: #301e23; background: white; }
  [data-theme="dark"] #report, [data-theme="dark"] #report .metric { color: #301e23; background: white; border-color: #bbb; }
  [data-theme="dark"] #report :is(.metric span, th, .helptext) { color: #66544c; }
}
