:root {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --ink: #1c2420;
  --muted: #657068;
  --line: #d9dedb;
  --accent: #176b3a;
  --accent-hover: #10552d;
  --danger: #b42318;
  --soft: #edf3ef;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; letter-spacing: 0; }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; letter-spacing: 0; }
button, .primary { min-height: 38px; border: 1px solid var(--line); border-radius: 5px; padding: 8px 14px; background: var(--surface); color: var(--ink); cursor: pointer; }
.button-link { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 5px; padding: 8px 14px; background: var(--surface); color: var(--ink); white-space: nowrap; }
.button-link:hover { border-color: #aeb8b1; }
button:hover { border-color: #aeb8b1; }
button.primary, .primary { border-color: var(--accent); background: var(--accent); color: white; }
button.primary:hover { background: var(--accent-hover); }
.topbar { height: 68px; padding: 10px clamp(18px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand img { width: 176px; height: auto; display: block; }
.account { display: flex; gap: 20px; align-items: center; color: var(--muted); }
.account form { margin: 0; }
.admin-navigation { display: flex; align-items: center; gap: 20px; }
.admin-navigation a { padding: 7px 0 5px; border-bottom: 2px solid transparent; }
.admin-navigation a:hover { border-color: #aeb8b1; }
.admin-navigation a.active { border-color: var(--accent); color: var(--ink); font-weight: 650; }
.link-button { border: 0; padding: 0; min-height: auto; color: var(--accent); background: transparent; }
main { width: min(1500px, 100%); margin: 0 auto; padding: 32px clamp(18px, 4vw, 56px) 56px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(28px, 4vw, 42px); margin-bottom: 8px; font-weight: 650; }
h2 { font-size: 18px; }
.eyebrow { margin-bottom: 8px; text-transform: uppercase; font-size: 12px; font-weight: 700; color: var(--accent); }
.muted { color: var(--muted); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 24px; }
.page-heading.compact { align-items: center; }
.time-zone-control { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 14px; }
.time-zone-control .check-label { font-size: 14px; }
.time-zone-control small { flex-basis: 100%; }
.back-link { display: inline-block; margin-bottom: 12px; }
.project-list { border-top: 1px solid var(--line); }
.project-row, .user-row { min-height: 78px; display: grid; grid-template-columns: minmax(220px, 1fr) 100px minmax(190px, auto) 24px; align-items: center; gap: 20px; padding: 14px 8px; border-bottom: 1px solid var(--line); color: var(--ink); }
.project-row:hover, .user-row:hover { background: var(--surface); }
.project-row small, .user-row small, .access-row small { display: block; margin-top: 4px; color: var(--muted); }
.project-date { color: var(--muted); }
.project-date small { margin: 0 0 4px; }
.row-arrow { font-size: 28px; color: var(--muted); }
.login-shell { min-height: calc(100vh - 150px); display: grid; place-items: center; }
.login-panel { width: min(420px, 100%); }
.form-stack { display: grid; gap: 16px; }
label { display: grid; gap: 6px; font-weight: 600; }
label small { font-weight: 400; color: var(--muted); }
.check-label { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.check-label input { width: 18px; min-height: 18px; margin: 0; }
input, select { width: 100%; min-height: 42px; border: 1px solid #bfc8c2; border-radius: 5px; background: var(--surface); padding: 8px 10px; color: var(--ink); }
input:focus, select:focus { outline: 3px solid #b9ddc8; border-color: var(--accent); }
.alert { padding: 10px 12px; margin-bottom: 16px; border-left: 3px solid; background: var(--surface); }
.alert.error { border-color: var(--danger); color: var(--danger); }
.alert.success { border-color: var(--accent); color: var(--accent); }
.alert.warning { border-color: #a15c00; color: #734200; }
.system-notice { width: min(1500px, calc(100% - 36px)); margin: 16px auto 0; }
.view-tabs { display: inline-flex; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: var(--surface); }
.view-tabs { max-width: 100%; overflow-x: auto; }
.view-tabs a { min-width: 120px; padding: 8px 14px; border-right: 1px solid var(--line); color: var(--ink); text-align: center; }
.view-tabs a:last-child { border-right: 0; }
.view-tabs a:hover { background: var(--soft); }
.view-tabs a.active { background: var(--accent); color: white; }
.project-view-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.project-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; min-height: 480px; }
.map-column { min-width: 0; }
.map { width: 100%; height: 480px; border: 1px solid var(--line); background: #e5e7e6; }
.map.maplibregl-map { font: inherit; }
.map .maplibregl-canvas-container, .map .maplibregl-control-container { transition: opacity 100ms ease-out; }
.map.map-view-pending .maplibregl-canvas-container, .map.map-view-pending .maplibregl-control-container, .map.map-view-pending .map-time-legend { opacity: 0; }
.map-time-legend { position: absolute; z-index: 2; left: 12px; bottom: 12px; width: min(360px, calc(100% - 72px)); padding: 10px 12px; border: 1px solid rgb(28 36 32 / 18%); background: rgb(255 255 255 / 92%); box-shadow: 0 1px 5px rgb(28 36 32 / 18%); pointer-events: none; }
.map-time-legend strong { display: block; margin-bottom: 7px; font-size: 13px; }
.map-time-gradient { height: 9px; }
.map-time-labels { display: flex; justify-content: space-between; gap: 16px; margin-top: 5px; color: var(--muted); font-size: 11px; }
.map-time-labels span:last-child { text-align: right; }
.maplibregl-ctrl-group { border-radius: 5px; box-shadow: 0 1px 4px rgb(28 36 32 / 18%); }
.maplibregl-ctrl-group button { min-height: 0; }
.maplibregl-popup-content { border-radius: 5px; padding: 12px 30px 12px 14px; box-shadow: 0 2px 10px rgb(28 36 32 / 22%); }
.maplibregl-popup-close-button { min-height: 0; padding: 4px 8px; font-size: 20px; line-height: 1; }
.map-note { min-height: 20px; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.map-time-scale-toggle { width: fit-content; margin-top: 4px; font-size: 13px; }
.map-time-scale-toggle[hidden] { display: none; }
.scan-point-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 4px; font-size: 13px; }
.scan-point-controls .map-time-scale-toggle { margin: 0 0 0 10px; }
.time-palette-control { display: flex; grid-template-columns: none; flex-direction: row; align-items: center; gap: 7px; font-weight: 500; }
.time-palette-control[hidden] { display: none; }
.time-palette-control select { width: auto; min-height: 34px; padding: 4px 28px 4px 8px; font-size: 13px; }
.map-layer-controls { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.map-layer-controls h2 { margin-bottom: 10px; font-size: 15px; }
.map-layer-options { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.map-layer-option { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.map-layer-option > input { width: 18px; min-height: 18px; margin: 0; }
.map-layer-option > label { display: block; font-weight: 400; cursor: pointer; }
.layer-swatch { width: 16px; height: 16px; min-height: 0; flex: 0 0 16px; border: 1px solid rgb(28 36 32 / 25%); border-radius: 2px; padding: 0; }
.layer-style-trigger:hover, .layer-style-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.layer-style-dialog { width: min(420px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 6px; padding: 0; color: var(--ink); background: var(--surface); box-shadow: 0 12px 40px rgb(28 36 32 / 28%); }
.layer-style-dialog::backdrop { background: rgb(28 36 32 / 42%); }
.layer-style-dialog-form { display: grid; gap: 16px; padding: 20px; }
.layer-style-dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.layer-style-dialog-heading small { color: var(--muted); }
.layer-style-dialog-heading h2 { margin: 2px 0 0; font-size: 20px; }
.dialog-close { width: 34px; min-height: 34px; padding: 0; font-size: 24px; line-height: 1; }
.range-input { display: grid; grid-template-columns: minmax(0, 1fr) 48px; align-items: center; gap: 10px; }
.range-input input { min-height: 28px; padding: 0; }
.range-input output { color: var(--muted); text-align: right; }
.layer-point-style-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.scan-color-style-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.layer-point-style-fields[hidden] { display: none; }
.layer-style-dialog-actions { display: flex; justify-content: space-between; gap: 12px; padding-top: 4px; }
.status-panel { border-left: 1px solid var(--line); padding-left: 24px; }
.status-panel h2 small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 500; }
.status-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.table-section { margin-top: 36px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; }
.section-heading span { color: var(--muted); }
.table-wrap { overflow: auto; border: 1px solid var(--line); background: var(--surface); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e6e9e7; text-align: left; }
th { position: sticky; top: 0; background: #f0f2f1; font-size: 13px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 20px; padding: 18px; }
.empty-state { min-height: 360px; display: grid; align-content: center; justify-items: center; text-align: center; color: var(--muted); }
.scan-filter-panel { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)) auto; gap: 12px; align-items: end; padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.scan-filter-panel label { min-width: 0; font-size: 13px; }
.scan-filter-actions { display: flex; gap: 8px; }
.scan-filter-actions > * { flex: 1; }
.admin-scan-map-section { margin-top: 24px; }
.admin-scan-map { height: min(52vh, 620px); min-height: 380px; }
.scan-database-table { margin-top: 24px; }
.scan-database-table .table-wrap { max-height: calc(100vh - 390px); min-height: 320px; }
.scan-database-table th { z-index: 1; }
.scan-comment-cell { min-width: 220px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.scan-table-empty { height: 280px; color: var(--muted); text-align: center; }
.admin-grid { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 48px; }
.admin-form { padding-right: 36px; border-right: 1px solid var(--line); }
.user-row { grid-template-columns: minmax(240px, 1fr) 90px 86px 20px; }
.state { border-radius: 999px; padding: 5px 8px; text-align: center; font-size: 12px; font-weight: 700; }
.state.active { background: #dff3e6; color: #176b3a; }
.state.inactive { background: #eceeed; color: #657068; }
.access-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 400px); gap: 48px; }
.access-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.access-actions { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.access-actions form { margin: 0; }
.preview-banner { display: flex; align-items: center; gap: 14px; margin: -8px 0 20px; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--soft); }
.preview-banner span { color: var(--muted); }
.danger-text { color: var(--danger); background: transparent; border-color: transparent; }
.grant-panel { padding-left: 36px; border-left: 1px solid var(--line); }
.status-grant-fieldset { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 5px; }
.status-grant-fieldset legend { padding: 0 6px; font-weight: 600; }
.status-options { display: grid; gap: 9px; }
.status-options .check-label { font-size: 14px; }
.password-reset { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--line); }
.settings-panel { width: min(560px, 100%); }
.settings-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.settings-summary div { min-width: 0; }
.settings-summary dt { color: var(--muted); font-size: 0.84rem; }
.settings-summary dd { margin: 4px 0 0; overflow-wrap: anywhere; }
.layer-admin-layout { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 48px; }
.layer-upload-panel { padding-right: 36px; border-right: 1px solid var(--line); }
.layer-list { border-top: 1px solid var(--line); }
.layer-row { display: grid; grid-template-columns: minmax(260px, 1fr) 72px auto auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.layer-row small { display: block; margin-top: 4px; color: var(--muted); }
.layer-row form { margin: 0; }
.layer-style-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; padding: 14px; border: 1px solid var(--line); }
.layer-style-fields legend { padding: 0 5px; font-weight: 700; }
.layer-style-fields label { min-width: 0; align-self: start; align-content: start; font-size: 14px; white-space: nowrap; }
.layer-style-fields label small { white-space: normal; }
.layer-style-fields label:first-of-type { grid-column: 1 / -1; }
.layer-style-fields input[type="color"] { width: 100%; padding: 4px; }
.unit-input { position: relative; }
.unit-input input { padding-right: 52px; }
.unit-input span { position: absolute; top: 50%; right: 30px; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.layer-style-summary { display: flex !important; align-items: center; gap: 6px; }
.layer-statistics-config { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--line); }
.layer-statistics-config summary { width: fit-content; cursor: pointer; color: var(--accent); font-weight: 650; }
.layer-statistics-form { display: grid; gap: 12px; max-width: 520px; padding: 14px 0 4px; }
.layer-statistics-form p { margin: 0; }
.map-layer-statistics { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.map-layer-statistics h2 { margin-bottom: 12px; font-size: 15px; }
.map-layer-statistics-list { display: grid; gap: 14px; }
.layer-statistics-card { padding: 14px; border: 1px solid var(--line); background: var(--surface); }
.layer-statistics-heading, .layer-statistics-labels { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; }
.layer-statistics-heading { margin-bottom: 14px; }
.layer-statistics-heading h3 { margin: 0; font-size: 15px; }
.layer-statistics-heading span { color: var(--muted); font-size: 13px; }
.layer-statistics-row + .layer-statistics-row { margin-top: 12px; }
.layer-statistics-labels { margin-bottom: 5px; font-size: 13px; }
.statistics-track { height: 7px; overflow: hidden; background: #e6e9e7; }
.statistics-track span { display: block; height: 100%; }
.monitor-body { overflow: hidden; }
.monitor-page { position: fixed; inset: 0; width: 100%; max-width: none; margin: 0; padding: 0; }
.monitor-map { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.monitor-header, .monitor-side-panel { position: absolute; z-index: 3; border: 1px solid rgb(28 36 32 / 18%); background: rgb(255 255 255 / 92%); box-shadow: 0 2px 12px rgb(28 36 32 / 20%); backdrop-filter: blur(5px); }
.monitor-header { top: 16px; left: 16px; width: min(760px, calc(100vw - 440px)); padding: 14px; }
.monitor-header img { width: 160px; height: auto; display: block; }
.monitor-header h1 { margin: 10px 0 2px; font-size: 24px; }
.monitor-header p { margin: 0 0 12px; color: var(--muted); }
.monitor-header .view-tabs { width: 100%; margin: 0; }
.monitor-header .view-tabs a { min-width: max-content; flex: 1; }
.monitor-side-panel { top: 16px; right: 16px; bottom: 16px; width: 390px; overflow: auto; padding: 14px; }
.monitor-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.monitor-actions button { min-height: 34px; padding: 6px 10px; }
.monitor-side-panel .status-panel { padding: 0; border: 0; }
.monitor-time-controls { display: grid; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.monitor-time-controls small { margin-top: -6px; }
.monitor-filter-summary { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.monitor-filter-summary h2 { font-size: 15px; }
.monitor-filter-summary strong { max-width: 220px; overflow-wrap: anywhere; text-align: right; }
.monitor-side-panel .map-layer-options { display: grid; gap: 10px; }
.monitor-side-panel .map-layer-statistics { margin-top: 18px; }
.monitor-side-panel .layer-statistics-card { padding: 10px; }
.monitor-map-note { position: absolute; z-index: 3; left: 16px; bottom: 10px; max-width: calc(100vw - 450px); margin: 0; padding: 4px 7px; background: rgb(255 255 255 / 88%); }
.monitor-page .maplibregl-ctrl-top-right { right: 408px; }
@media (max-width: 800px) {
  .topbar { height: auto; align-items: flex-start; }
  .brand img { width: 142px; }
  .account { flex-wrap: wrap; justify-content: flex-end; gap: 10px 14px; }
  .account-name { flex-basis: 100%; text-align: right; }
  .admin-navigation { flex-wrap: wrap; justify-content: flex-end; gap: 6px 14px; }
  main { padding-top: 24px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .view-tabs { display: flex; width: 100%; }
  .view-tabs a { flex: 1; min-width: 0; }
  .project-row { grid-template-columns: 1fr 72px 20px; }
  .project-date { display: none; }
  .project-workspace, .admin-grid, .access-layout, .layer-admin-layout { grid-template-columns: 1fr; }
  .scan-filter-panel { grid-template-columns: 1fr 1fr; }
  .scan-filter-actions { grid-column: 1 / -1; }
  .status-panel, .admin-form, .grant-panel, .layer-upload-panel { border: 0; padding: 0; }
  .access-row { align-items: flex-start; flex-direction: column; }
  .layer-row { grid-template-columns: minmax(0, 1fr) auto; }
  .map { height: min(58vh, 480px); }
  .user-row { grid-template-columns: 1fr 70px 20px; }
  .user-row .state { display: none; }
  .project-view-toolbar { align-items: stretch; flex-direction: column; }
  .monitor-header { width: calc(100vw - 32px); }
  .monitor-header img { width: 130px; }
  .monitor-header h1 { font-size: 20px; }
  .monitor-side-panel { top: auto; left: 16px; width: auto; max-height: 42vh; }
  .monitor-page .maplibregl-ctrl-top-right { right: 0; top: 185px; }
  .monitor-map-note { max-width: calc(100vw - 32px); bottom: 43vh; }
}
