:root {
  --bg: #10161d;
  --panel: #17212b;
  --panel-2: #1e2b38;
  --line: #2d3d4d;
  --text: #e7eef5;
  --muted: #93a4b5;
  --accent: #3ecf8e;
  --danger: #ef5b5b;
  --warn: #e8a317;
  --ok: #3ecf8e;
  --paper: #f7f4ee;
  --ink: #1c2430;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", Candara, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { height: 100%; }

body.mod-eds { --accent: #3ecf8e; }
body.mod-eds-sa { --accent: #5aa8ff; }
body.mod-enh { --accent: #f0a202; }

.home {
  min-height: 100%;
  padding: 36px 48px 48px;
  background:
    linear-gradient(180deg, rgba(16, 22, 29, 0.2), rgba(16, 22, 29, 0.94)),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(255, 255, 255, 0.035) 28px),
    repeating-linear-gradient(90deg, transparent, transparent 27px, rgba(255, 255, 255, 0.035) 28px),
    #10161d;
}
.home-head { max-width: 1100px; margin: 0 auto 28px; }
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 36px; height: 36px; border: 1.5px solid var(--accent); display: grid; place-items: center;
  font-weight: 700; letter-spacing: -0.04em; color: var(--accent);
}
.brand h1 { font-size: 28px; margin: 0; letter-spacing: -0.03em; font-weight: 650; }
.lede { max-width: 720px; color: var(--muted); line-height: 1.5; margin: 10px 0 0; }
.cards { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card {
  background: rgba(23, 33, 43, 0.92); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  padding: 18px 18px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
}
.card h2 { margin: 0; font-size: 18px; }
.card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; flex: 1; }
.card ul { margin: 0; padding-left: 18px; color: var(--text); font-size: 13px; line-height: 1.45; }
.card-actions { display: flex; gap: 8px; margin-top: 8px; }
.recent { max-width: 1100px; margin: 28px auto 0; }
.recent h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; }
.proj-row {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); background: rgba(23, 33, 43, 0.8); margin-bottom: 6px;
}
.proj-row b { font-weight: 600; }
.muted { color: var(--muted); }
.fine { font-size: 12px; color: var(--muted); line-height: 1.45; max-width: 1100px; margin: 22px auto 0; }
.badge {
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; border: 1px solid var(--line);
  padding: 2px 6px; color: var(--accent);
}

.btn, .tool, .tab, .menu > button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 2px; padding: 7px 10px;
}
.btn.primary { background: var(--accent); color: #102017; border-color: transparent; font-weight: 650; }
.btn.ghost { background: transparent; }
.btn.warn { background: transparent; color: var(--danger); border-color: #5a3030; }
.btn:hover, .tool:hover, .tab:hover, .menu > button:hover { border-color: #4c6276; }
.btn.small { padding: 4px 8px; font-size: 12px; }

.workspace {
  height: 100%;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 372px;
  grid-template-rows: 54px minmax(0, 1fr) 28px;
  grid-template-areas: "top top top" "tools stage side" "status status status";
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 8px; padding: 0 10px;
  border-bottom: 1px solid var(--line); background: #141c25;
  position: relative; z-index: 30;
}
.topbar .name {
  background: transparent; border: 1px solid transparent; padding: 6px 8px; min-width: 180px; font-weight: 650;
}
.topbar .name:hover, .topbar .name:focus { border-color: var(--line); outline: none; }
.spacer { flex: 1; }
.menu { position: relative; }
.menu-pop {
  display: none; position: absolute; top: 36px; left: 0; min-width: 230px; z-index: 30;
  background: #1b2632; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 4px;
}
.menu.open .menu-pop { display: block; }
.menu-pop button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 8px 10px; color: var(--text);
}
.menu-pop button:hover { background: #243444; }

.tools { grid-area: tools; overflow: auto; border-right: 1px solid var(--line); background: #141c25; padding: 6px 0; position: relative; z-index: 20; }
.tool {
  width: 100%; border: 0; border-left: 3px solid transparent; border-radius: 0; background: transparent;
  color: var(--muted); display: flex; flex-direction: column; align-items: flex-start; padding: 7px 10px; font-size: 12px;
}
.tool.on { color: var(--text); background: #223140; border-left-color: var(--accent); }
.tool small { font-size: 10px; color: var(--muted); }

.stage { grid-area: stage; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.map-wrap { position: relative; flex: 1; min-height: 180px; display: flex; flex-direction: column; }
#map { flex: 1; min-height: 180px; background: #d5dde6; position: relative; z-index: 0; isolation: isolate; }
#profile { display: none; height: 250px; border-top: 1px solid var(--line); background: var(--paper); }
body.mod-enh #profile { display: block; }
.legend {
  position: absolute; z-index: 5; left: 10px; bottom: 10px; background: rgba(16, 22, 29, 0.88);
  border: 1px solid var(--line); padding: 8px 10px; font-size: 11px; display: grid; gap: 4px; max-width: 220px;
}
.sw { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 50%; }
.hint {
  position: absolute; z-index: 4; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(16, 22, 29, 0.9); border: 1px solid var(--line); padding: 8px 12px; font-size: 13px; pointer-events: none;
}

.side { grid-area: side; overflow: auto; border-left: 1px solid var(--line); background: var(--panel); position: relative; z-index: 20; }
.tabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #141c25; z-index: 2; }
.tab { flex: 1; border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 10px 4px; font-size: 12px; }
.tab.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.pane { padding: 12px; display: grid; gap: 10px; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { background: var(--panel-2); border: 1px solid var(--line); padding: 8px; }
.metric b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.metric span { color: var(--muted); font-size: 11px; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, .modal input, .modal select, .modal textarea {
  width: 100%; background: #101920; border: 1px solid var(--line); padding: 7px 8px; color: var(--text);
}
.note, .warn-line, .ok-line {
  font-size: 12.5px; line-height: 1.4; padding: 8px; border: 1px solid var(--line); background: #121a22;
}
.warn-line { border-color: #6a5420; background: #2a230f; }
.ok-line { border-color: #1e4d38; }
.sugg { display: grid; gap: 4px; padding: 8px; border: 1px solid var(--line); font-size: 12.5px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { border-bottom: 1px solid var(--line); padding: 5px 4px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.total { font-size: 15px; font-weight: 700; }

.status {
  grid-area: status; display: flex; gap: 14px; align-items: center; padding: 0 10px;
  border-top: 1px solid var(--line); background: #121920; color: var(--muted); font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.status b { color: var(--text); font-weight: 600; }

.modal-back {
  position: fixed; inset: 0; background: rgba(6, 10, 14, 0.62); z-index: 4000;
  display: grid; place-items: center; padding: 24px;
}
.modal { width: min(560px, 100%); background: #18222d; border: 1px solid var(--line); padding: 16px; box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 12px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.form-grid { display: grid; gap: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }

.report-view {
  position: fixed; inset: 0; z-index: 5000; background: #d9d3c7; overflow: auto; padding: 24px;
}
.paper {
  width: min(980px, 100%); margin: 0 auto; background: var(--paper); color: var(--ink);
  padding: 28px 32px 40px; box-shadow: var(--shadow);
}
.paper h1 { margin: 0; font-size: 22px; }
.paper h2 { font-size: 16px; margin: 22px 0 8px; border-bottom: 1px solid #d9d0c3; padding-bottom: 4px; }
.antet { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid #1c2430; padding-bottom: 10px; }
.paper table th, .paper table td { border-bottom: 1px solid #e4dccf; }
.paper .muted { color: #5c6b7a; }
.report-bar { width: min(980px, 100%); margin: 0 auto 12px; display: flex; gap: 8px; }

.leaflet-div-icon.pin { background: transparent; border: none; }
.pin i {
  display: block; width: 12px; height: 12px; margin: 5px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
.pin.on i { box-shadow: 0 0 0 3px #f0a202; }
.pin.eski i { opacity: 0.8; outline: 1px dashed #fff; }
.pin b {
  display: none; position: absolute; left: 20px; top: 0; background: rgba(255, 255, 255, 0.92);
  color: #14202b; font: 11px Consolas, monospace; padding: 0 3px; white-space: nowrap;
}
.leaflet-container.show-labels .pin b { display: block; }

#toast {
  position: fixed; bottom: 36px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: #102017; color: #d9ffe9; border: 1px solid #1e4d38; padding: 8px 12px; opacity: 0;
  pointer-events: none; transition: 0.2s ease; z-index: 6000;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1100px) {
  .home { padding: 20px; }
  .cards { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: 86px minmax(0, 1fr); grid-template-rows: 54px minmax(280px, 52vh) minmax(240px, 1fr) 28px; grid-template-areas: "top top" "tools stage" "side side" "status status"; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  body.mod-enh .legend { bottom: 10px; }
}
@media print {
  body > *:not(#report-view) { display: none !important; }
  #report-view { position: static; background: white; padding: 0; overflow: visible; }
  .report-bar { display: none !important; }
  .paper { box-shadow: none; width: auto; }
}
