:root {
  font-family: "Arial", "Segoe UI", sans-serif;
  color: #172e2c;
  background: #f5f7f5;
  font-synthesis: none;
  --ink: #172e2c;
  --muted: #627774;
  --line: #e3ebe7;
  --green: #18735f;
  --dark: #143d38;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid #3b9b81; outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
svg { width: 19px; height: 19px; flex: none; vertical-align: middle; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.sidebar { position: fixed; inset: 0 0 0 auto; z-index: 5; width: 226px; background: var(--dark); color: #f1fffa; display: flex; flex-direction: column; padding: 31px 17px 23px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 12px; margin-bottom: 47px; }
.brand-mark { width: 44px; height: 44px; border-radius: 13px; background: #d6f1df; color: #1b6555; display: grid; place-items: center; }
.brand-mark svg { width: 24px; height: 24px; stroke-width: 2.5; }
.brand strong { display: block; font-size: 25px; line-height: 1; }
.brand small { display: block; margin-top: 6px; color: #b7d2c9; font-size: 12px; }
nav { display: grid; gap: 6px; }
nav a { display: flex; align-items: center; gap: 12px; padding: 12px 13px; color: #d1e6df; font-size: 14px; min-height: 45px; border-radius: 9px; }
nav a:hover { background: #20534b; }
nav a[aria-current] { color: white; font-weight: 700; background: #286358; box-shadow: inset -3px 0 #a5dfbc; }
nav a b { margin-inline-start: auto; font-size: 11px; background: #d6f1df; color: #184d41; padding: 2px 6px; border-radius: 1em; }
.sidebar-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid #39615a; font-size: 12px; color: #c5dcd5; }
.sidebar-foot i { display: inline-block; width: 7px; height: 7px; margin-inline-end: 7px; border-radius: 50%; background: #a0dbb5; }
.workspace { margin-inline-start: 226px; min-width: 0; }
.topbar { height: 68px; padding: 0 clamp(20px, 3vw, 46px); display: flex; justify-content: space-between; align-items: center; background: #fff; border-bottom: 1px solid var(--line); }
.breadcrumb, .top-actions { display: flex; align-items: center; gap: 13px; color: var(--muted); font-size: 13px; }
.breadcrumb strong { color: var(--ink); font-weight: 700; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; background: #e3f1e8; color: #216452; border-radius: 50%; font-weight: bold; }
.icon-button { position: relative; background: #fff; border: 1px solid var(--line); color: #416660; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; }
.icon-button:hover { background: #f0f6f2; }
.notification-dot { width: 8px; height: 8px; background: #df875c; border: 1px solid white; border-radius: 50%; position: absolute; top: 5px; right: 6px; }
main { max-width: 1670px; margin: auto; padding: 30px clamp(20px, 3vw, 46px) 44px; outline: none; }
.loading { padding: 20px; color: var(--muted); }
#save-status { font-size: 11px; color: #486f5b; }
#connection-status { padding: 12px 20px; background: #fff1d5; color: #6c4c20; font-size: 13px; }
.backup-summary { padding: 20px; }
.backup-summary h2 { font-size: 20px; margin-bottom: 12px; }
.backup-summary p { font-size: 14px; line-height: 1.7; margin-top: 8px; color: #526d61; }
.backup-actions { display: flex; gap: 7px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 25px; }
.page-heading h1 { font-size: clamp(28px,3vw,38px); line-height: 1.16; letter-spacing: -.8px; margin-bottom: 8px; }
.page-heading p { color: var(--muted); font-size: 14px; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 39px; min-width: 74px; border: 1px solid transparent; padding: 8px 13px; border-radius: 8px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.button svg { width: 16px; height: 16px; }
.primary { background: #166c59; color: white; border-color: #166c59; box-shadow: 0 2px 4px #12493924; }
.primary:hover { background: #0f5949; }
.secondary { background: white; color: #244741; border-color: #dfe8e3; }
.secondary:hover { background: #eff6f1; }
.notice { background: #fff3dc; color: #78511e; padding: 13px; margin-bottom: 14px; border-radius: 9px; }

.stats { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; margin-bottom: 20px; }
.stat { position: relative; display: flex; align-items: center; text-align: right; gap: 12px; min-height: 98px; padding: 15px 13px; border: 1px solid var(--line); color: var(--ink); background: white; border-radius: 13px; box-shadow: 0 3px 8px #1d403205; }
.stat:hover { border-color: #9bbbaf; }
.metric-icon, .card-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; background: #e5f2e9; color: #216f5c; }
.metric-icon.blue { background: #e8f0fb; color: #406f9b; }
.metric-icon.violet { background: #f1eafa; color: #7962a6; }
.metric-icon.amber { background: #f9f0e1; color: #886530; }
.metric-copy { display: grid; gap: 5px; }
.metric-copy span { color: var(--muted); font-size: 12px; }
.metric-copy strong { font-size: 29px; line-height: 1; }
.metric-arrow { margin-inline-start: auto; color: #657f78; opacity: .72; }
.metric-arrow svg { width: 14px; height: 14px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.52fr) minmax(0,1fr); gap: 17px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; min-width: 0; margin-bottom: 18px; box-shadow: 0 3px 8px #1d403205; }
.card-head { display: flex; gap: 11px; align-items: center; padding: 17px; min-height: 72px; }
.card-head .card-icon { width: 36px; height: 36px; border-radius: 9px; }
.card-icon svg { width: 18px; height: 18px; }
.card-head h2 { font-size: 17px; }
.card-head p:not(:empty) { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card-head :is(.text-link,select) { margin-inline-start: auto; flex: none; }
.text-link { padding: 6px 0; color: #176954; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.text-link:hover { text-decoration: underline; }
.text-link svg { width: 14px; height: 14px; }
.map-layout { padding: 0 14px 14px; }
.map { position: relative; min-height: 306px; border-radius: 9px; overflow: hidden; isolation: isolate; background: #e9eee2; }
.map canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.compass { display: grid; place-items: center; position: absolute; top: 11px; left: 11px; width: 27px; height: 29px; color: #395f5b; background: #fff; border-radius: 7px; font-weight: bold; box-shadow: 0 1px 5px #163b3620; }
.sea { position: absolute; left: 2.8%; top: 44%; font-size: 11px; color: #4b777c; writing-mode: vertical-rl; }
.map-key { position: absolute; left: 8px; bottom: 8px; padding: 4px 7px; border-radius: 5px; background: #ffffffe8; color: #395e55; font-size: 10px; }
.pin { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%,-46%); display: grid; justify-items: center; gap: 2px; padding: 0; background: transparent; border: 0; z-index: 1; color: #27453e; }
.pin:hover, .pin:focus-visible { z-index: 2; }
.pin b { min-width: 21px; height: 21px; color: #fff; background: #5f8e79; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 2px 3px #18392c35; font-size: 10px; }
.pin.medium b { width: 26px; height: 26px; background: #43856c; }
.pin.large b { width: 34px; height: 34px; background: #176b57; box-shadow: 0 0 0 5px #24755d21, 0 3px 7px #163c363d; font-size: 13px; }
.pin:hover b, .pin:focus-visible b { background: #123f36; }
.pin span { padding: 1px 4px; border-radius: 4px; color: #27453e; background: #f9fcf4d9; font-weight: 700; font-size: 9px; white-space: nowrap; }
.expanded .map-layout { display: grid; grid-template-columns: 3fr minmax(160px,1fr); gap: 13px; }
.expanded .map { min-height: 455px; }
.expanded .pin span { font-size: 11px; }
.map-cities { max-height: 455px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; padding: 11px; }
.map-cities h3 { margin: 3px 6px 8px; font-size: 15px; }
.map-cities h3 span { color: var(--muted); font-size: 12px; margin-inline-start: 4px; }
.map-cities button { display: flex; justify-content: space-between; align-items: center; text-align: start; width: 100%; padding: 8px; border: 0; background: white; border-radius: 6px; color: var(--ink); font-size: 13px; }
.map-cities button:hover { background: #eaf3ec; }
.map-cities button b { color: var(--green); }
.unmapped { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 0 14px 14px; font-size: 12px; }
.unmapped .button { min-height: 28px; padding: 5px 7px; font-size: 11px; }

.chart-legend { display: flex; gap: 15px; margin: 6px 19px 12px; color: #526d66; font-size: 12px; }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; background: #1f8a70; }
.chart-legend span + span i { background: #b5b6ed; }
.chart { height: 249px; display: flex; gap: 9px; padding: 2px 17px 18px; align-items: stretch; }
.axis { display: flex; flex-direction: column; justify-content: space-between; color: #637970; padding: 0 0 25px 0; font-size: 11px; text-align: end; min-width: 17px; }
.chart-viewport { min-width: 0; width: 100%; overflow-x: auto; }
.plot { height: 100%; min-width: calc(var(--months) * 35px); display: grid; grid-template-columns: repeat(var(--months),1fr); background: repeating-linear-gradient(to top, #e4ece7 0 1px, transparent 1px 25%); background-clip: content-box; padding: 5px 0 29px; border-radius: 0; }
.month { height: 100%; position: relative; text-align: center; min-width: 0; }
.month > span { color: #62756d; font-size: 10px; position: absolute; bottom: -21px; left: 0; width: 100%; }
.bars { height: 100%; display: flex; align-items: end; justify-content: center; gap: 3px; }
.bars i { background: #1f8a70; height: var(--height); width: min(29%,25px); border-radius: 4px 4px 0 0; }
.bars i + i { background: #b5b6ed; }
.month:hover .bars { background: #eff5f086; }
.chart-card select { padding: 5px 8px; font-size: 11px; min-height: 30px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px; }
.search { min-width: min(245px,100%); display: flex; gap: 8px; align-items: center; padding: 0 10px; border: 1px solid #dae6df; border-radius: 8px; }
.search svg { color: #6b837b; width: 16px; }
.search input { border: none; background: transparent; padding: 9px 0; min-width: 100px; width: 100%; color: var(--ink); }
#row-count { margin-inline-start: auto; white-space: nowrap; color: var(--muted); font-size: 12px; }
input, select, textarea { color: var(--ink); }
select { min-height: 36px; border-radius: 8px; border: 1px solid #dae6df; background: white; padding: 6px 9px; font-size: 13px; }
.table-scroll { max-width: 100%; overflow: auto; }
table { border-spacing: 0; width: 100%; font-size: 13px; }
th, td { padding: 11px 15px; text-align: start; border-bottom: 1px solid #edf1ee; }
th { white-space: nowrap; color: #4d675f; font-size: 12px; background: #f1f6f3; }
td { color: #314d45; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fbf9; }
.case-table { max-height: min(68vh, 720px); }
.case-table td { min-width: 110px; max-width: 240px; overflow-wrap: anywhere; }
.case-table .wide { min-width: 250px; white-space: pre-wrap; }
.case-table th { position: sticky; top: 0; z-index: 2; }
.case-table :is(td,th):first-child { position: sticky; inset-inline-start: 0; min-width: 164px; border-inline-end: 1px solid var(--line); }
.case-table th:first-child { z-index: 3; }
.case-table td:first-child { background: white; z-index: 1; }
.table-link { border: none; padding: 2px 0; background: transparent; color: #1b6553; font-weight: 700; text-align: start; }
.table-link:hover { text-decoration: underline; }
.name { display: inline-flex; gap: 8px; align-items: center; }
.initials { display: grid; place-items: center; flex: none; width: 29px; height: 29px; background: #e8f2eb; color: #426c5d; border-radius: 8px; font-size: 11px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 20px; white-space: nowrap; font-size: 11px; background: #e8effb; color: #375c88; }
.badge i { width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.badge.active { background: #e1f4e9; color: #22684d; }
.badge.closed { background: #f6eddc; color: #7d5d27; }
.badge.expired { background: #fae9e6; color: #913f3b; }
.empty { min-height: 165px; display: grid; justify-items: center; align-content: center; gap: 12px; padding: 25px; color: var(--muted); text-align: center; }

dialog { max-width: min(680px,calc(100vw - 28px)); width: 100%; max-height: 88vh; padding: 0; border: 1px solid #d6e4dc; border-radius: 16px; color: var(--ink); box-shadow: 0 15px 65px #102e3155; }
dialog::backdrop { background: #142e2c78; }
.dialog-head, .dialog-foot { position: sticky; z-index: 2; background: #fff; padding: 15px 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-head { top: 0; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 23px; }
.dialog-head p { display: flex; gap: 9px; align-items: center; margin-top: 6px; }
.detail-city { color: var(--muted); font-size: 13px; }
.dialog-foot { justify-content: flex-start; flex-wrap: wrap; bottom: 0; border-top: 1px solid var(--line); }
.form-message { width: 100%; padding: 8px 10px; background: #fae9e6; color: #833630; border-radius: 7px; font-size: 13px; }
.form-grid, .detail-grid { margin: 0; padding: 17px 20px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; }
.field { display: grid; gap: 6px; font-size: 13px; }
.field span, dt { color: #4b665d; font-weight: 700; font-size: 12px; }
.field input, .field textarea { background: #fbfcfb; border: 1px solid #dbe6df; border-radius: 7px; padding: 8px; min-width: 0; min-height: 36px; }
.field textarea { resize: vertical; }
.form-grid .full, .detail-grid .full { grid-column: 1/-1; }
.detail-grid > div { padding: 10px; background: #f5f8f6; border-radius: 8px; overflow-wrap: anywhere; }
dd { margin: 6px 0 0; font-size: 14px; white-space: pre-wrap; }
.form-note { color: var(--muted); font-size: 13px; line-height: 1.5; }
#toast { display: none; }
#toast.visible { display: block; position: fixed; bottom: 17px; left: 17px; z-index: 10; max-width: calc(100% - 34px); border-radius: 9px; padding: 13px 18px; background: #133e35; color: white; font-size: 14px; box-shadow: 0 5px 17px #163f4144; }
#toast.error { background: #87372e; }

@media (max-width: 1150px) {
  .sidebar { width: 185px; padding-inline: 12px; }
  .workspace { margin-inline-start: 185px; }
  .metric-arrow { display: none; }
  .dashboard-grid { grid-template-columns: minmax(0,1.37fr) minmax(0,1fr); }
  .map-card:not(.expanded) .pin span { font-size: 8px; }
}
@media (max-width: 960px) {
  .dashboard-grid { grid-template-columns: 1fr; gap: 0; }
  .stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .expanded .map-layout { grid-template-columns: 1fr; }
  .map-cities { display: grid; grid-template-columns: repeat(2,1fr); }
  .map-cities h3 { grid-column: 1/-1; }
}
@media (max-width: 650px) {
  .sidebar { width: 58px; padding: 13px 6px; }
  .brand { padding: 0; justify-content: center; margin-bottom: 20px; }
  .brand-mark { width: 35px; height: 35px; }
  .brand > span + span, nav a span, .sidebar-foot { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  nav a { justify-content: center; padding: 10px 0; position: relative; }
  nav a b { position: absolute; top: 3px; left: 1px; }
  .workspace { margin-inline-start: 58px; }
  .topbar { padding-inline: 12px; height: 52px; }
  main { padding-inline: 10px; padding-top: 21px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .stat { padding: 9px 7px; min-height: 73px; gap: 6px; }
  .stats { gap: 6px; }
  .metric-icon { width: 30px; height: 30px; border-radius: 7px; }
  .metric-icon svg { width: 15px; }
  .metric-copy strong { font-size: 22px; }
  .card-head { padding: 12px; gap: 8px; }
  .card-head .card-icon { display: none; }
  .card-head p:not(:empty) { font-size: 11px; }
  .card-head h2 { font-size: 15px; }
  .map-layout { padding: 0 8px 8px; }
  .expanded .map { min-height: 360px; }
  .expanded .pin span { font-size: 8px; }
  .pin span { font-size: 8px; }
  .table-scroll th, .table-scroll td { padding-inline: 10px; }
}
