:root {
  --bg: #f4f6f5;
  --card: #fff;
  --ink: #16211c;
  --muted: #5d6b64;
  --line: #e1e7e4;
  --brand: #0f5132;
  --brand-2: #157347;
  --brand-soft: #e7f2ec;
  --gold: #b8872b;
  --danger: #b42318;
  --warn: #b54708;
  --st-available: #22a06b;
  --st-reserved: #e2a100;
  --st-allocated: #1d63d8;
  --st-withheld: #8a8f98;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,20,.05), 0 1px 3px rgba(16,24,20,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
small, .muted { color: var(--muted); }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: #0c2b1f; color: #cfe0d7; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 19px; font-weight: 600; padding: 4px 8px 14px; text-decoration: none !important; }
.brand b { color: #e3b75a; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #1f8a5a, #0f5132); display: inline-flex; align-items: center; justify-content: center; flex: none; font-weight: 700; font-size: 14px; letter-spacing: -.5px; border: 1px solid rgba(255,255,255,.15); }
.logo span { color: #e3b75a; }
.estate-chip { margin: 0 6px 14px; padding: 9px 12px; border-radius: 10px; background: rgba(255,255,255,.06); color: #fff; font-weight: 600; font-size: 13px; }
.estate-chip { display: block; text-decoration: none !important; }
.side nav a .badge, .badge { margin-left: auto; background: #e3b75a; color: #0c2b1f; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.estate-chip small { display: block; color: #9fb8ab; font-weight: 400; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: #cfe0d7; font-weight: 500; text-decoration: none; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.on { background: #1a4a35; color: #fff; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7f9a8c; padding: 16px 12px 6px; }
.me { border-top: 1px solid rgba(255,255,255,.08); padding: 12px 8px 0; font-size: 13px; }
.me b { color: #fff; display: block; }
.me small { color: #9fb8ab; display: block; margin-bottom: 6px; }
.me a { color: #e3b75a; }
.main { padding: 0 28px 40px; min-width: 0; }
.top { display: flex; align-items: center; gap: 16px; padding: 18px 0; }
.top h1 { font-size: 21px; margin: 0; flex: 1; }
.search input { width: 340px; max-width: 100%; }
.burger { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; }
.bare { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #1f6b47 0, #0c2b1f 55%); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .burger { display: block; }
  .main { padding: 0 16px 30px; }
  .top { flex-wrap: wrap; }
  .search, .search input { width: 100%; }
}

/* ---------- components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card > h2:first-child { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.kpi { padding: 16px 18px; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.kpi .l { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .bar { height: 4px; border-radius: 4px; background: var(--line); margin-top: 10px; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; }

.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: #f7f9f8; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--danger); border-color: #f1c7c3; }
.btn.danger:hover { background: #fef3f2; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input, select, textarea { font: inherit; color: inherit; border: 1px solid #cfd8d3; border-radius: 9px; padding: 8px 11px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd3b8; border-color: var(--brand-2); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } .form-grid .wide { grid-column: auto; } }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 2px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfa; }
.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:hover td { background: #fafcfb; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef1f0; color: #445; }
.pill-available { background: #dcf5e9; color: #0e6b43; }
.pill-reserved { background: #fdf1cc; color: #8a5a00; }
.pill-allocated, .pill-active { background: #dfeafc; color: #1446a0; }
.pill-withheld { background: #ececef; color: #555a63; }
.pill-revoked { background: #fde4e1; color: #a1251a; }
.pill-transferred { background: #efe5fb; color: #5b2c9a; }
.pill-admin { background: #fdf1cc; color: #8a5a00; }

.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: #dcf5e9; color: #0e6b43; }
.flash-err { background: #fde4e1; color: #a1251a; }
.flash-warn { background: #fdf1cc; color: #7a4f00; }
.empty { text-align: center; padding: 30px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; }
.filters input, .filters select { width: auto; min-width: 140px; }
.pager { display: flex; gap: 6px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--brand-soft); display: inline-grid; place-items: center; font-weight: 600; color: var(--brand); flex: none; }
.avatar.lg { width: 110px; height: 130px; border-radius: 10px; font-size: 32px; }
.who { display: flex; align-items: center; gap: 10px; }
.who small { display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- map */
.map-wrap { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; height: calc(100vh - 150px); min-height: 480px; touch-action: none; cursor: grab; }
.map-wrap.drag { cursor: grabbing; }
.map-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-wrap:focus { outline: 2px solid #9fd3b8; outline-offset: -2px; }
.map-wrap .ground { fill: #f6f5ef; }
.map-wrap .nohit { pointer-events: none; }
.map-wrap path.plot { stroke: rgba(15,61,43,.55); stroke-width: .7; vector-effect: non-scaling-stroke; cursor: pointer; fill-opacity: .34; transition: fill-opacity .12s; }
.map-wrap path.plot:hover { fill-opacity: .7; }
.map-wrap path.plot.dim { fill-opacity: .06; }
.map-wrap .available { fill: var(--st-available); }
.map-wrap .reserved { fill: var(--st-reserved); }
.map-wrap .allocated { fill: var(--st-allocated); }
.map-wrap .withheld, .map-wrap .taken { fill: var(--st-withheld); }
.map-wrap .sel-outline { fill: rgba(255,255,255,.25); stroke: #111; stroke-width: 3; vector-effect: non-scaling-stroke; }
#label-layer text { font-family: Inter, system-ui, sans-serif; font-weight: 600; fill: #0b3d27; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: rgba(255,255,255,.9); stroke-width: .16em; stroke-linejoin: round; }
#street-layer text { font-family: Inter, system-ui, sans-serif; font-weight: 700; letter-spacing: .08em; fill: #7e1f86; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: #fff; stroke-width: .3em; stroke-linejoin: round; }
.map-wrap.mode-streets #street-layer { pointer-events: auto; }
.map-wrap.mode-streets #street-layer text { cursor: move; }
#street-layer text.on { fill: #c2410c; }
#street-layer text.sel { fill: #c2410c; stroke: #fde68a; }
.map-wrap path.plot.st-mine { fill: #f97316; fill-opacity: .7; }
.map-wrap path.plot.st-other { fill: #94a3b8; fill-opacity: .25; }
.map-wrap path.plot.st-none { fill: #ef4444; fill-opacity: .45; }
.street-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.street-list button { display: flex; justify-content: space-between; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: #fff; padding: 8px 12px; font: inherit; cursor: pointer; text-align: left; }
.street-list button:hover { background: #f7f9f8; }
.street-list button.on { background: #fff4e6; font-weight: 600; }
.street-list small { color: var(--muted); }
.label-row { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 8px; }
.label-row.sel { border-color: #f97316; background: #fff7ed; }
.label-row input[type=range] { width: 100%; padding: 0; }
.hintbox { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 9px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px; }
#label-layer .owner { display: none; font-weight: 500; fill: #1446a0; }
#label-layer.show-owner .owner { display: inline; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; cursor: pointer; }
.toggle input { width: auto; }
.map-tools { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
.map-tools button { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-size: 18px; cursor: pointer; box-shadow: var(--shadow); }
.map-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.map-bar #find { width: 200px; }
.map-bar .legend label { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; }
@media (max-width: 1000px) { .map-layout { grid-template-columns: 1fr; } .map-wrap { height: 70vh; } }
.panel { position: sticky; top: 12px; }
.tip { position: fixed; pointer-events: none; background: #0c2b1f; color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12.5px; z-index: 60; display: none; white-space: nowrap; }

/* ---------- auth */
.auth { width: 380px; max-width: 100%; background: #fff; border-radius: 16px; padding: 30px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth .brand { color: var(--ink); padding: 0 0 6px; }
.auth p { color: var(--muted); margin-top: 0; }

/* ---------- letter preview */
.letter-frame { width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-2); }
.bars .row { display: grid; grid-template-columns: 38px 1fr 90px; gap: 10px; align-items: center; margin-bottom: 7px; font-size: 13px; }
.stack { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--line); }
.stack i { display: block; height: 100%; }
@media print { .side, .top, .btns, .no-print { display: none !important; } .shell { display: block; } .card { box-shadow: none; } }
