/* Shared spacing and responsive presentation for the workspace. */
html .topbar { position: relative; height: 64px; padding-inline: 24px; gap: 20px; }
html .header-clock { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: var(--secondary); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: .02em; pointer-events: none; }
html .app-nav { width: 224px; min-width: 224px; padding: 18px 10px; }
html .app-nav > a { min-height: 44px; border-radius: 8px; }
html .app-nav > a[aria-current="page"] { box-shadow: inset 3px 0 var(--green); }
html .app-subnav { margin-left: 18px; padding-left: 10px; }
html .app-subnav a { min-height: 37px; gap: 8px; }
html .app-subnav [data-status-count] { font-variant-numeric: tabular-nums; }
html .nav-theme-footer { border-top: 1px solid var(--line); padding-top: 12px; }
html .app-shell > main { padding: 22px 28px 0; }
html .app-shell > .dashboard-view { padding-bottom: 28px; }
html .breadcrumb { margin-bottom: 14px; gap: 8px; font-size: 12px; flex-wrap: wrap; line-height: 1.6; }
html h1 { font-size: 26px; line-height: 1.35; letter-spacing: 0; }
html .page-heading { gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
html .heading-line { gap: 10px; flex-wrap: wrap; }
html .page-heading p { line-height: 1.7; }
html .heading-actions { flex-wrap: wrap; gap: 8px; }
html .heading-actions button, html .report-actions > button { min-height: 40px; border-radius: 8px; }

/* Compact summaries leave more room for records and reports. */
html .stats { gap: 14px; margin-bottom: 18px; }
html .dashboard-view .stat { padding: 18px 20px; border-radius: 10px; }
html .stat strong { font-size: 30px; font-variant-numeric: tabular-nums; }
html .today-cases { display: flex; align-items: center; gap: 16px; min-height: 92px; padding: 18px 22px; margin-bottom: 16px; border: 1px solid #385a75; border-radius: 12px; background: radial-gradient(circle at 95% 0%, #ffffff2b, transparent 35%), linear-gradient(110deg, #304a63, #4d718b); color: #fff; text-decoration: none; box-shadow: 0 8px 20px #243f5824; transition: transform .18s ease, box-shadow .18s ease, filter .18s ease; }
html .today-cases:hover { transform: translateY(-2px); filter: brightness(1.06); box-shadow: 0 12px 24px #243f5830; }
html .today-cases-icon { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border: 1px solid #ffffff42; border-radius: 11px; background: #ffffff24; color: #fff; }
html .today-cases-icon svg { width: 24px; height: 24px; }
html .today-cases-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
html .today-cases-copy strong { font-size: 17px; }
html .today-cases-copy small { color: #e0eaf1; font-size: 12px; white-space: nowrap; }
html .today-cases-total { display: flex; align-items: baseline; gap: 5px; margin-left: auto; color: #fff; white-space: nowrap; }
html .today-cases-total strong { font-size: 38px; line-height: 1; font-variant-numeric: tabular-nums; }
html .today-cases-total span { font-size: 13px; }
html .today-cases-action { display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: none; min-height: 34px; padding: 0 10px 0 13px; border: 1px solid #ffffff50; border-radius: 999px; background: #ffffff1d; color: #fff; font-size: 12px; white-space: nowrap; }
html .today-cases-action svg { width: 15px; height: 15px; }
html[data-theme="dark"] .today-cases { background: radial-gradient(circle at 95% 0%, #ffffff21, transparent 35%), linear-gradient(110deg, #395570, #52728b); border-color: #69859a; }
html .app-subnav a[data-status-link="today"]::before { content: ''; width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--green); }
html .app-subnav a[data-status-link="today"] [data-status-count] { color: var(--green); font-weight: 700; }
html #records-view .page-heading #record-scope { display: block; margin-top: 6px; color: var(--secondary); font-size: 13px; }
html .module-grid { gap: 14px; margin-bottom: 20px; }
html .module-card, html #admin-home-section .module-card { min-height: 112px; padding: 20px; gap: 14px; border-radius: 10px; }
html .module-card > div { min-width: 0; }
html .module-card h2 { font-size: 17px; line-height: 1.5; margin-bottom: 5px; }
html .module-card p { line-height: 1.6; margin-bottom: 6px; }
html .module-icon { width: 42px; height: 42px; border-radius: 10px; }
html .dashboard-panel, html .records-panel { border-radius: 10px; }
html .panel-heading { padding: 17px 20px; flex-wrap: wrap; }
html .panel-heading h2 { line-height: 1.5; }
html .panel-heading > div { flex-wrap: wrap; gap: 8px 14px; }
html .report-metric { padding-inline: 20px; }
html .report-metric strong, html .summary-table, html .monthly-table { font-variant-numeric: tabular-nums; }
html .summary-table td, html .monthly-table td { height: 54px; }

/* Keep search, filters and pagination readable at intermediate widths. */
html .tabs-row { min-height: 52px; padding-inline: 18px; gap: 8px; flex-wrap: wrap; }
html .tabs { height: 52px; gap: 20px; }
html .filter-row { flex-wrap: wrap; gap: 10px; padding: 14px 18px; }
html .filter-row .search { flex: 1 1 260px; width: auto; min-width: 180px; height: 40px; border-radius: 7px; }
html .filter-row > select { min-width: 130px; max-width: 230px; height: 40px; border-radius: 7px; }
html .select-box { height: 40px; border-radius: 7px; max-width: 100%; }
html .select-box select { min-width: 0; max-width: 100%; height: 38px; }
html .filter-spacer { display: none; }
html .field-total { font-size: 12px; margin-left: auto; }
html #records-table.records-summary td { height: 72px; padding: 10px 14px; font-size: 14px; line-height: 1.55; }
html #records-table.records-summary th { height: 44px; padding: 10px 14px; font-weight: 600; }
html #records-table .summary-record strong { font-size: 15px; font-weight: 600; }
html #records-table .summary-record small { margin-top: 3px; font-size: 12px; line-height: 1.5; }
html #records-table .summary-id { font-size: 13px; font-variant-numeric: tabular-nums; }
html .record-status { font-size: 12px; padding: 4px 8px; border-radius: 6px; }
html .table-footer { padding: 12px 18px; gap: 10px; flex-wrap: wrap; line-height: 1.6; }
html .pagination { margin-left: auto; gap: 7px; }
html .pagination .icon-button { min-width: 34px; min-height: 34px; border: 1px solid var(--line); border-radius: 7px; }
html .page-number { min-width: 32px; height: 32px; }
html .workspace-footer { padding-block: 12px; font-size: 12px; gap: 12px; }

/* Give long forms consistent groups and reachable actions. */
html .dialog-heading { padding: 18px 24px; }
html .dialog-heading h2 { font-size: 21px; line-height: 1.4; }
html .dialog-footer { padding: 14px 24px; flex-shrink: 0; align-items: center; }
html .dialog-footer button { min-height: 40px; border-radius: 7px; }
html .form-body { padding: 0 24px 24px; }
html .form-section { margin-top: 22px; }
html .form-section + .form-section { border-top: 1px solid var(--line); padding-top: 22px; }
html .form-grid { gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
html #record-dialog .form-grid label { min-width: 0; color: var(--secondary); line-height: 1.6; }
html #record-dialog .form-grid :is(input, select, textarea) { min-width: 0; min-height: 42px; border-radius: 7px; }
html .detail-grid { gap: 0 22px; }
html .detail-field { padding-block: 14px; }
html .detail-field dt { margin-bottom: 5px; }
html .detail-field dd { line-height: 1.7; }
html .account-edit-dialog form { max-height: calc(90dvh - 2px); }
html .account-edit-dialog .account-form-body { min-height: 0; overflow-y: auto; }
html .account-edit-dialog .dialog-heading { flex-shrink: 0; }

/* Field settings scroll within their panel; the save action stays below them. */
html .required-fields-list { max-height: max(240px, calc(100dvh - 340px)); overflow-y: auto; padding: 0 20px 12px; scrollbar-width: thin; }
html .required-grid { gap: 12px; }
html .field-setting { padding: 10px; border-radius: 8px; }
html .field-setting select { min-height: 40px; }
html .required-fields-footer { padding: 14px 20px; background: var(--surface-alt); }
html .required-fields-footer button { min-height: 40px; }
html .account-form-body { gap: 16px; }
html .account-row { gap: 14px; padding-block: 16px; }
html .account-row-main { gap: 5px; }
html .account-row-main small { line-height: 1.7; overflow-wrap: anywhere; }
html .account-row button { min-height: 36px; padding-inline: 12px; }
html :is(#import-dialog, #history-dialog) .upload-zone { position: relative; gap: 8px; padding: 24px 18px; border-color: var(--control-border); border-radius: 10px; background: var(--surface-alt); text-align: center; transition: background .15s, border-color .15s; }
html :is(#import-dialog, #history-dialog) .upload-zone:hover { border-color: var(--focus); background: var(--accent-soft); }
html :is(#import-dialog, #history-dialog) .upload-zone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
html :is(#import-dialog, #history-dialog) .upload-zone > span:first-child { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); }
html :is(#import-dialog, #history-dialog) .upload-zone strong { font-size: 15px; font-weight: 600; }
html :is(#import-dialog, #history-dialog) .upload-zone > span:not(:first-child) { font-size: 12px; line-height: 1.5; }
html :is(#import-file, #history-file) { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; opacity: 0; overflow: hidden; clip-path: inset(50%); }

@media (min-width: 601px) and (max-width: 1100px) {
  html .app-nav { width: 204px; min-width: 204px; }
  html .app-shell > main { padding-inline: 20px; }
  html .page-heading { align-items: flex-start; }
  html .heading-actions { width: 100%; }
  html .filter-row .field-total { flex-basis: 100%; }
  html .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html .month-range { width: 100%; flex-wrap: wrap; }
  html .month-range-title { flex-basis: 100%; }
  html .month-range .month-picker { flex: 1; min-width: 0; }
  html .month-range input { width: 100%; max-width: 160px; min-width: 0; }
  html .required-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html .module-grid { grid-template-columns: 1fr; }
  html #record-dialog .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html #record-dialog .form-grid .wide { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  html .today-cases { min-height: 78px; padding: 12px; gap: 10px; }
  html .today-cases-icon { width: 38px; height: 38px; }
  html .today-cases-icon svg { width: 20px; height: 20px; }
  html .today-cases-copy strong { font-size: 15px; }
  html .today-cases-copy small { font-size: 11px; }
  html .today-cases-total strong { font-size: 29px; }
  html .today-cases-action { width: 34px; min-height: 34px; padding: 0; }
  html .today-cases-action > span:first-child { display: none; }
  html .topbar { height: 57px; padding-inline: 14px; gap: 9px; position: sticky; top: 0; z-index: 91; }
  html .app-nav { width: min(280px, 85vw); min-width: 0; padding: 16px 10px; }
  html .app-shell > main { padding: 18px 14px 0; }
  html .app-shell > .dashboard-view { padding-bottom: 22px; }
  html h1, html .heading-line h1 { font-size: 24px; }
  html .breadcrumb { font-size: 11px; margin-bottom: 10px; }
  html .page-heading { gap: 14px; margin-bottom: 18px; }
  html .heading-actions { display: flex; width: 100%; gap: 7px; }
  html .heading-actions button { flex: 1 1 auto; min-height: 42px; padding: 9px 10px; font-size: 13px; }
  html .stats { gap: 10px; }
  html .dashboard-view .stat { padding: 14px; }
  html .stat strong { font-size: 28px; }
  html .stat-label { font-size: 13px; }
  html .module-grid { grid-template-columns: 1fr; gap: 10px; }
  html .module-card, html #admin-home-section .module-card { min-height: 102px; padding: 16px; gap: 12px; }
  html .module-card h2 { font-size: 16px; }
  html .module-card p { font-size: 13px; }
  html .panel-heading { padding: 15px 16px; gap: 10px; }
  html .month-range input { min-height: 42px; }
  html .tabs-row { padding-inline: 12px; }
  html .tabs { width: 100%; gap: 0; justify-content: space-between; }
  html #records-view .category-tabs { gap: 0; }
  html .tab { font-size: 12px; gap: 4px; }
  html .tab span { font-size: 11px; margin-left: 0; }
  html .filter-row { padding: 12px; gap: 8px; }
  html .filter-row .search { flex-basis: 100%; min-width: 0; height: 44px; }
  html .filter-row > select, html .filter-row .select-box { flex: 1 1 120px; min-width: 0; max-width: 100%; height: 44px; }
  html .select-box select { width: 100%; height: 42px; }
  html .filter-row .field-total { width: 100%; margin: 2px 0 0; font-size: 12px; }
  html .search input, html .filter-row select, html .month-picker input { font-size: 16px; }
  html #records-table.records-summary td { padding: 10px 8px; height: 78px; font-size: 14px; }
  html #records-table.records-summary th { padding: 10px 8px; font-size: 12px; }
  html #records-table.records-summary :is(th, td):nth-child(8) { padding-inline: 4px; }
  html #records-table .summary-id { font-size: 12px; }
  html .record-status { white-space: normal; font-size: 12px; padding: 4px 6px; }
  html .detail-open { min-width: 30px; min-height: 38px; padding: 5px; }
  html .table-wrap { height: min(58dvh, 480px); min-height: 240px; }
  html .table-footer { padding: 12px; font-size: 12px; }
  html .pagination { width: 100%; justify-content: flex-end; }
  html .pagination label { margin-right: auto; }
  html .pagination .icon-button { min-width: 40px; min-height: 40px; }
  html .workspace-footer { font-size: 11px; }
  html .dialog-heading, html .dialog-footer { padding: 16px; }
  html .dialog-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  html .dialog-footer button { min-height: 44px; }
  html .form-body { padding: 0 16px 20px; }
  html #record-dialog .form-grid { grid-template-columns: 1fr; gap: 14px; }
  html #record-dialog .form-grid .wide { grid-column: 1; }
  html #record-dialog .form-grid :is(input, select, textarea), html .account-form-body :is(input, select), html .field-setting :is(select, textarea), html .auth-card input { font-size: 16px; min-height: 44px; }
  html .required-fields-list { max-height: 54dvh; padding-inline: 14px; }
  html .required-grid { grid-template-columns: 1fr; }
  html .required-fields-footer { padding: 14px; gap: 10px; }
  html .required-fields-footer p:empty { display: none; }
  html .account-row { flex-wrap: nowrap; align-items: flex-start; }
  html .account-row-main { flex: 1; }
  html .account-row button { flex-shrink: 0; min-height: 40px; }
}

@media (max-width: 420px) {
  html .detail-grid { grid-template-columns: 1fr; }
  html .report-metric { padding-inline: 12px; }
  html .report-metric strong { font-size: 23px; }
  html .report-metric small { margin-left: 3px; }
}

@media (max-width: 760px) {
  html .topbar { height: 86px; flex-wrap: wrap; align-content: center; row-gap: 2px; padding-block: 6px; }
  html .header-clock { position: static; transform: none; order: 10; display: flex; justify-content: center; align-items: center; flex: 0 0 100%; height: 22px; font-size: 12px; }
  html .auth-view { min-height: calc(100dvh - 86px); }
}

@media (min-width: 601px) and (max-width: 760px) {
  html .today-cases { gap: 10px; padding-inline: 14px; }
  html .today-cases-icon { width: 40px; height: 40px; }
  html .today-cases-action { width: 34px; padding: 0; }
  html .today-cases-action > span:first-child { display: none; }
}

@media (max-width: 360px) {
  html .today-cases-icon { display: none; }
}

/* Cover placeholder records while the first data request is in progress. */
html .app-loading{position:fixed;z-index:30;inset:64px 0 0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;background:var(--canvas);color:var(--secondary);font-size:15px;font-weight:550;letter-spacing:.05em}
html .app-loading[hidden]{display:none}
.app-loading-spinner{width:48px;height:48px;border:3px solid var(--line);border-top-color:var(--green);border-radius:50%;animation:app-loading-spin .8s linear infinite}
@keyframes app-loading-spin{to{transform:rotate(360deg)}}
@media(max-width:760px){html .app-loading{top:86px}}
@media(prefers-reduced-motion:reduce){.app-loading-spinner{animation:none;border-top-color:var(--green);border-right-color:var(--green)}}

html .toast{top:auto;left:auto;right:24px;bottom:24px;margin:0;border:0;width:max-content;transform:none;max-width:calc(100vw - 32px);line-height:1.5}
html .toast.toast-enter{animation:toast-slide-in .32s cubic-bezier(.2,.8,.2,1) both}
@keyframes toast-slide-in{from{opacity:0;transform:translateX(32px)}to{opacity:1;transform:translateX(0)}}
@media(max-width:600px){html .toast{right:16px;bottom:16px}}
@media(prefers-reduced-motion:reduce){html .toast.toast-enter{animation:none}}
