:root {
  --bg: #0b1118;
  --surface: #121b25;
  --surface-2: #182431;
  --surface-3: #223141;
  --text: #eef5f2;
  --muted: #91a29c;
  --line: #293947;
  --primary: #58d89b;
  --primary-dark: #1f8f63;
  --warning: #f3c568;
  --danger: #ff7b79;
  --radius: 18px;
  --shadow: 0 18px 50px rgb(0 0 0 / 24%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 90% -10%, rgb(42 99 75 / 24%), transparent 34rem), var(--bg); color: var(--text); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .4rem; font-size: clamp(1.75rem, 4vw, 2.55rem); line-height: 1.1; letter-spacing: -.035em; }
h2 { margin-bottom: .45rem; font-size: 1.15rem; }
p { line-height: 1.55; }

.topbar { position: sticky; z-index: 1000; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 70px; padding: 12px max(20px, calc((100vw - 1240px) / 2)); border-bottom: 1px solid rgb(255 255 255 / 7%); background: rgb(11 17 24 / 90%); backdrop-filter: blur(18px); }
.brand { display: flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark, .auth-logo { display: grid; place-items: center; color: #062316; background: linear-gradient(145deg, #7df0b9, #35b77b); font-weight: 900; box-shadow: 0 8px 24px rgb(58 210 143 / 20%); }
.brand-mark { width: 39px; height: 39px; border-radius: 12px; font-size: .9rem; }
.brand span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { margin-top: 3px; color: var(--muted); font-size: .7rem; }
.user-menu { display: flex; align-items: center; gap: 14px; }
.user-name { color: var(--muted); font-size: .9rem; }
.user-menu form { margin: 0; }
.project-nav { display: flex; gap: 5px; overflow-x: auto; padding: 10px max(20px, calc((100vw - 1240px) / 2)); border-bottom: 1px solid rgb(255 255 255 / 5%); background: rgb(11 17 24 / 74%); scrollbar-width: none; }
.project-nav a { flex: 0 0 auto; padding: 9px 14px; border-radius: 10px; color: var(--muted); font-size: .9rem; font-weight: 650; text-decoration: none; }
.project-nav a:hover, .project-nav a.active { color: var(--text); background: var(--surface-2); }

.page { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 72px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.page-heading .muted { margin-bottom: 0; }
.eyebrow { margin-bottom: .55rem; color: var(--primary); font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted, .hint { color: var(--muted); }
.hint { margin: -.2rem 0 .2rem; font-size: .82rem; }
.back-link { display: inline-block; margin-bottom: 15px; color: var(--muted); font-size: .9rem; text-decoration: none; }
.back-link:hover { color: var(--text); }
.required, .danger-text { color: var(--danger); }
.success-text { color: var(--primary); }
.warning-text { color: var(--warning); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 9px 17px; border: 1px solid transparent; border-radius: 11px; font-weight: 750; line-height: 1.1; text-decoration: none; cursor: pointer; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgb(88 216 155 / 35%); outline-offset: 2px; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button-primary { color: #062316; background: var(--primary); }
.button-primary:hover { background: #72e5ae; }
.button-secondary { color: var(--text); border-color: var(--line); background: var(--surface-2); }
.button-ghost { color: var(--muted); border-color: var(--line); background: transparent; }
.button-danger { color: #ffaaa7; border-color: rgb(255 123 121 / 32%); background: rgb(255 123 121 / 8%); }
.button-small { min-height: 34px; padding: 7px 11px; font-size: .82rem; }
.button-wide { width: 100%; }

.panel, .project-card, .stat-card { border: 1px solid var(--line); background: linear-gradient(145deg, rgb(24 36 49 / 88%), rgb(17 26 36 / 94%)); box-shadow: var(--shadow); }
.panel { padding: 24px; border-radius: var(--radius); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-heading p, .status-panel p, .quick-actions p { margin: 0; color: var(--muted); font-size: .9rem; }
.alert { margin: 0 0 20px; padding: 13px 16px; border: 1px solid; border-radius: 12px; line-height: 1.45; }
.alert-error { color: #ffd1cf; border-color: rgb(255 123 121 / 34%); background: rgb(255 123 121 / 10%); }
.alert-success { color: #b5f5d3; border-color: rgb(88 216 155 / 32%); background: rgb(88 216 155 / 10%); }

.auth-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, rgb(43 118 82 / 35%), transparent 40rem), var(--bg); }
.auth-page { width: 100%; padding: 0; }
.auth-card { width: min(440px, 100%); margin: auto; padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: rgb(18 27 37 / 94%); box-shadow: 0 28px 80px rgb(0 0 0 / 42%); }
.auth-card-wide { width: min(700px, 100%); }
.auth-logo { width: 54px; height: 54px; margin-bottom: 26px; border-radius: 16px; }
.auth-card h1 { font-size: 1.8rem; }

.form-stack { display: grid; gap: 17px; }
.form-grid { display: grid; gap: 15px; }
.form-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: #d8e3de; font-size: .84rem; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 45px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--text); background: #0d151e; }
textarea { min-height: 112px; resize: vertical; }
input::placeholder { color: #63736f; }
input:disabled, select:disabled, textarea:disabled { opacity: .72; cursor: default; }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: 18px; min-height: 18px; accent-color: var(--primary); }

.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.project-card { display: flex; align-items: center; gap: 16px; padding: 22px; border-radius: var(--radius); text-decoration: none; transition: border-color .15s, transform .15s; }
.project-card:hover { transform: translateY(-2px); border-color: rgb(88 216 155 / 50%); }
.project-icon { display: grid; flex: 0 0 48px; height: 48px; place-items: center; border-radius: 14px; color: #052014; background: var(--primary); font-size: 1.35rem; font-weight: 900; }
.project-card-copy { flex: 1; }
.project-card h2 { margin: 0 0 5px; }
.project-card p { margin: 0; color: var(--muted); font-size: .88rem; }
.arrow { color: var(--primary); font-size: 1.5rem; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 22px; }
.stat-card { display: grid; gap: 12px; min-height: 130px; align-content: space-between; padding: 20px; border-radius: 16px; }
.stat-card span { color: var(--muted); font-size: .86rem; }
.stat-card strong { font-size: 2.15rem; letter-spacing: -.04em; }
.quick-actions, .status-panel { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.quick-actions h2, .status-panel h2 { margin-bottom: 5px; }
.quick-actions-highlight { border-color: rgb(88 216 155 / 34%); background: linear-gradient(135deg, rgb(88 216 155 / 8%), var(--surface)); }

.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) 180px 220px auto; gap: 10px; margin-bottom: 16px; }
.filter-bar label { gap: 0; }
.data-table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 15px 17px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { color: var(--muted); background: #101923; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgb(255 255 255 / 2%); }
.data-table td small { display: block; margin-top: 5px; color: var(--muted); }
.table-action { width: 1%; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.badge-ok { color: #9bf0c4; background: rgb(88 216 155 / 12%); }
.badge-warning { color: #f7d997; background: rgb(243 197 104 / 12%); }
.badge-danger { color: #ffaaa7; background: rgb(255 123 121 / 12%); }
.badge-muted { color: #aebbb6; background: rgb(145 162 156 / 12%); }
.badge-large { padding: 8px 12px; font-size: .8rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 20px; color: var(--muted); }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(370px, .9fr); gap: 20px; align-items: start; }
.form-panel h2, .map-panel h2, .photos-panel h2 { margin-bottom: 18px; }
.map-panel { position: sticky; top: 145px; }
.map-panel .panel-heading h2, .photos-panel .panel-heading h2 { margin-bottom: 5px; }
.coordinate-map { height: 360px; margin: 18px -8px; border: 1px solid var(--line); border-radius: 14px; background: #18222d; }
.coordinate-fields { margin-top: 14px; }
.save-button { margin-top: 18px; }
.status-panel, .photos-panel { margin-top: 20px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin: 18px 0; }
.photo-card { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.photo-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-3); }
.photo-actions { display: flex; gap: 5px; padding: 9px; }
.photo-actions .button-danger { margin-left: auto; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: transparent; cursor: pointer; }
.upload-row { display: flex; align-items: end; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.file-field { flex: 1; }
.file-field span { color: var(--muted); }
.file-field input { padding: 8px; }

.import-panel { max-width: 760px; }
.drop-field { padding: 24px; border: 1px dashed #3b544b; border-radius: 14px; background: rgb(88 216 155 / 4%); }
.drop-field span { color: var(--muted); font-weight: 400; }
.drop-field input { margin-top: 7px; }
.info-panel { max-width: 760px; margin-top: 18px; }
.info-panel li { margin: 10px 0; color: var(--muted); line-height: 1.5; }
.confirm-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.confirm-bar p { margin: 0; color: var(--muted); }
.result-card { width: min(600px, 100%); margin: 50px auto; padding: 42px; border: 1px solid var(--line); border-radius: 24px; text-align: center; background: var(--surface); box-shadow: var(--shadow); }
.result-icon { display: grid; width: 62px; height: 62px; margin: 0 auto 22px; place-items: center; border-radius: 50%; color: #062316; background: var(--primary); font-size: 1.8rem; font-weight: 900; }
.result-icon-warning { color: #332307; background: var(--warning); }
.empty-state { padding: 55px 24px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }
.empty-state h1, .empty-state h2 { color: var(--text); }
.empty-state.compact { padding: 28px 16px; border: 0; }
.empty-state.compact p { margin: 0; }
code { color: #a8ecc9; }
.leaflet-control-attribution { color: #333; }

.geocoding-heading { max-width: 880px; }
.geocoding-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.geocoding-stat { display: grid; gap: 8px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.geocoding-stat span { color: var(--muted); font-size: .76rem; }
.geocoding-stat strong { font-size: 1.5rem; }
.geocoding-review { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(390px, .85fr); gap: 20px; align-items: start; }
.geocoding-worklist { display: grid; gap: 14px; min-width: 0; }
.geocoding-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.geocoding-toolbar h2, .geocoding-apply-bar h2 { margin-bottom: 4px; }
.geocoding-toolbar p, .geocoding-apply-bar p { margin: 0; font-size: .88rem; }
.geocoding-progress { display: grid; grid-column: 1 / -1; grid-template-columns: minmax(150px, 1fr) auto; gap: 12px; align-items: center; color: var(--muted); font-size: .8rem; }
.geocoding-progress[hidden] { display: none; }
.geocoding-progress progress { width: 100%; height: 8px; overflow: hidden; border: 0; border-radius: 999px; accent-color: var(--primary); background: var(--surface-3); }
.geocoding-rows { display: grid; gap: 12px; }
.geocoding-row { padding: 18px; transition: border-color .15s, opacity .15s; }
.geocoding-row.is-active { border-color: rgb(88 216 155 / 60%); box-shadow: 0 0 0 2px rgb(88 216 155 / 8%), var(--shadow); }
.geocoding-row.is-loading { opacity: .7; }
.geocoding-row.is-applied { border-color: rgb(88 216 155 / 30%); }
.geocoding-row-heading, .geocoding-row-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.geocoding-select-label { flex-direction: row; cursor: pointer; }
.geocoding-address { display: grid; width: 100%; gap: 4px; margin: 13px 0; padding: 0; border: 0; color: var(--text); text-align: left; background: transparent; cursor: pointer; }
.geocoding-address strong { font-size: 1rem; line-height: 1.4; }
.geocoding-address small { color: var(--muted); line-height: 1.35; }
.geocoding-candidates { display: grid; gap: 8px; margin: 12px 0 15px; }
.geocoding-candidate { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: rgb(8 14 20 / 44%); cursor: pointer; }
.geocoding-candidate:has(input:checked) { border-color: rgb(88 216 155 / 65%); background: rgb(88 216 155 / 7%); }
.geocoding-candidate.is-rejected { cursor: default; opacity: .74; }
.geocoding-candidate input { width: 17px; min-height: 17px; margin: 2px 0 0; accent-color: var(--primary); }
.geocoding-candidate span { display: grid; gap: 4px; min-width: 0; }
.geocoding-candidate strong { overflow-wrap: anywhere; font-size: .86rem; line-height: 1.35; }
.geocoding-candidate small { color: var(--muted); font-size: .74rem; line-height: 1.4; }
.geocoding-candidate.is-exact small:first-of-type { color: var(--primary); }
.geocoding-no-candidates { margin: 0; padding: 12px; border: 1px dashed var(--line); border-radius: 11px; color: var(--muted); font-size: .82rem; }
.geocoding-row-actions { justify-content: flex-start; }
.geocoding-row-message, .geocoding-map-message { min-height: 1.3em; margin: 10px 0 0; font-size: .78rem; }
.geocoding-map-panel { position: sticky; top: 145px; }
.geocoding-map { height: 430px; margin: 18px -8px 12px; border: 1px solid var(--line); border-radius: 14px; background: #18222d; }
.geocoding-map-hint { margin-bottom: 14px; }
.geocoding-manual-fields { margin-bottom: 12px; }
.geocoding-apply-bar { display: grid; grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.geocoding-result { grid-column: 1 / -1; }
.geocoding-result .alert { margin: 0; }
.geocoding-result-list { display: grid; gap: 5px; max-height: 210px; overflow: auto; margin: 12px 0 0; padding-left: 22px; font-size: .82rem; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .editor-layout { grid-template-columns: 1fr; }
  .map-panel { position: static; }
  .geocoding-stats { grid-template-columns: repeat(3, 1fr); }
  .geocoding-review { grid-template-columns: 1fr; }
  .geocoding-map-panel { position: static; grid-row: 1; }
  .geocoding-apply-bar { grid-column: auto; }
}

@media (max-width: 640px) {
  .topbar { min-height: 62px; padding: 10px 14px; }
  .brand small, .user-name { display: none; }
  .project-nav { padding: 8px 12px; }
  .page { width: min(100% - 24px, 1240px); padding: 24px 0 55px; }
  .page-heading { align-items: flex-start; }
  .page-heading > .button { flex: 0 0 auto; padding-inline: 13px; }
  h1 { font-size: 1.75rem; }
  .panel { padding: 18px; }
  .form-grid-two, .form-grid-three { grid-template-columns: 1fr; }
  .stats-grid { gap: 10px; }
  .stat-card { min-height: 108px; padding: 15px; }
  .stat-card strong { font-size: 1.7rem; }
  .quick-actions, .status-panel, .confirm-bar, .upload-row { align-items: stretch; flex-direction: column; }
  .filter-bar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .data-table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table thead { display: none; }
  .data-table tr { margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
  .data-table td { display: grid; grid-template-columns: 105px 1fr; gap: 10px; padding: 7px 5px; border: 0; }
  .data-table td::before { content: attr(data-label); color: var(--muted); font-size: .75rem; font-weight: 700; }
  .data-table td[colspan] { display: block; }
  .table-action { margin-top: 5px; }
  .table-action::before { display: none; }
  .table-action .button { width: 100%; }
  .coordinate-map { height: 310px; }
  .geocoding-stats { grid-template-columns: repeat(2, 1fr); }
  .geocoding-stat { padding: 12px; }
  .geocoding-toolbar, .geocoding-apply-bar { grid-template-columns: 1fr; align-items: stretch; }
  .geocoding-toolbar > .button, .geocoding-apply-bar > .button { width: 100%; }
  .geocoding-progress, .geocoding-result { grid-column: auto; }
  .geocoding-progress { grid-template-columns: 1fr; }
  .geocoding-map { height: 330px; }
  .geocoding-row-actions { align-items: stretch; flex-direction: column; }
  .geocoding-row-actions .button { width: 100%; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-actions { flex-wrap: wrap; }
  .photo-actions .button-danger { width: 100%; margin: 3px 0 0; }
  .auth-body { padding: 14px; }
  .auth-card { padding: 26px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
