/* AutoMapa Geocoder - styles (light / dark) */
:root {
  --bg: #f0f0f1; --surface: #fff; --surface-2: #f6f7f7; --surface-3: #f0f0f1; --text: #1d2327; --muted: #646970;
  --border: #c3c4c7; --border-soft: #dcdcde; --accent: #2271b1; --accent-hover: #135e96; --accent-text: #fff;
  --danger: #b32d2e; --danger-bg: #fcf0f1; --ok: #1a7f37; --ok-bg: #edfaef; --warn: #8a5a00; --warn-bg: #fcf9e8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .08); --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1d2327; --surface: #2c3338; --surface-2: #232a2e; --surface-3: #1d2327; --text: #f0f0f1; --muted: #a7aaad;
  --border: #50575e; --border-soft: #3c434a; --accent: #72aee6; --accent-hover: #9ec2e6; --accent-text: #0a1f33;
  --danger: #f86368; --danger-bg: #3a2022; --ok: #68de7c; --ok-bg: #1c3123; --warn: #f0c33c; --warn-bg: #36301a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5); color-scheme: dark; --filter: saturate(1.2) brightness(9); --filter-hover:brightness(7);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
main { flex: 1; width: 100%; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; width: 100%; }
h2 { font-size: 1.35rem; margin: 0 0 .5rem; font-weight: 600; }
h3 { font-size: 1.05rem; margin: 1rem 0 .5rem; font-weight: 600; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.info { border-left: solid 2px var(--warn); padding-left: .65rem; margin-left: .65rem}
.verysmall { font-size: .65rem; }

/* header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border-soft); box-shadow: var(--shadow); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-text { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: .2px; }
.logo-sub { color: var(--muted); font-size: .85rem; border-left: 1px solid var(--border); padding-left: 10px; }
.header-tools { display: flex; align-items: center; gap: 8px; }
.site-footer { border-top: 1px solid var(--border-soft); padding: 14px 0; color: var(--muted); text-align: center; margin-top: 24px; }
h1 a {text-decoration:none; color: var(--text);}

/* tabs (like nav-tab in WordPress) */
.tabs { display: flex; flex-wrap: wrap; gap: 0 4px; /*border-bottom: 1px solid var(--border);*/ margin-top: 20px; }
.tab {
  background: var(--surface-3); color: var(--muted); border: 0; border-bottom: 1px solid var(--border) ; border-radius: 4px 4px 0 0;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; font-size: 16px;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--bg); color: var(--text); border-color: var(--border); border-bottom: 4px solid var(--accent); }
.tab-panel { padding-top: 32px; outline: none; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 4px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card.sub { margin-top: 16px; }

/* forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 16px; margin-top: 12px; }
.form-footer { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .map-row > label { font-weight: 600; font-size: .9rem; }
.req { color: var(--danger); }
.field-hint { color: var(--muted); font-size: .8rem; }
.field-error { color: var(--danger); font-size: .82rem; }
input[type="text"], input[type="password"], input[type="number"], select, .input-wrap input {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); font: inherit;
}
select { padding-right: 24px; }
input.invalid { border-color: var(--danger); background: var(--danger-bg); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
input:disabled, select:disabled { opacity: 0; cursor: not-allowed; }
::placeholder { color: var(--muted); opacity: .8; }

input.snap-to-bld:disabled {
	opacity: .6;
}

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input { padding-right: 34px; }
.clear-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; display: none; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--muted); border-radius: 50%; cursor: pointer; padding: 0;
}
.clear-btn:hover { color: var(--text); background: var(--border-soft); }
.input-wrap.has-value:hover .clear-btn, .input-wrap.has-value:focus-within .clear-btn { display: flex; }

/* country picker */
.combo-wrap { position: relative; }
.combo-wrap .combo-input { padding-left: 48px; padding-right: 34px; }
.combo-badge { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.combo-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.combo-list {
  position: absolute; z-index: 30; top: calc(100% + 2px); left: 0; right: 0; max-height: 260px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
}
.combo-opt { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 3px; cursor: pointer; }
.combo-opt.active { background: var(--accent); color: var(--accent-text); }
.combo-opt.chosen { font-weight: 600; }
.code-badge {
  display: inline-block; min-width: 32px; text-align: center; padding: 1px 6px; border-radius: 3px; font: 700 .75rem/1.5 ui-monospace, Consolas, monospace;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
}
.combo-opt.active .code-badge { background: rgba(255, 255, 255, .25); color: inherit; border-color: transparent; }

/* buttons */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: 4px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--accent); text-decoration: none;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--accent); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); color: var(--accent-hover); }
.btn-sm { height: 28px; padding: 0 10px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { flex: none; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); cursor: pointer;}
.icon-btn:hover { background: var(--surface-2); }
.records-table .icon-btn { width: 30px; height: 30px; }

/* alerts */
.alert { margin-top: 14px; padding: 10px 14px; border-left: 4px solid var(--danger); background: var(--danger-bg); border-radius: 2px; }
.alert.success { border-color: var(--ok); background: var(--ok-bg); }
.alert.warning { border-color: var(--warn); background: var(--warn-bg); }
.alert.error { border-color: var(--danger); background: var(--danger-bg); }

/* tables */
.table-wrap { overflow-x: auto; margin-top: 10px; border: 1px solid var(--border-soft); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
.result-table tbody th { width: 240px; font-weight: 400; background: var(--surface-2); white-space: nowrap; }
.param-hint { display: block; color: var(--muted); font-size: .78rem; }
.result-table td { word-break: break-word; }
.result-table.compact th, .result-table.compact td { padding: 5px 9px; font-size: .88rem; white-space: nowrap; }
.raw summary { cursor: pointer; color: var(--accent); }
.raw pre { margin: 6px 0 0; max-height: 240px; overflow: auto; font-size: .8rem; background: var(--surface-2); padding: 8px; border-radius: 4px; }
tr.has-error td { background: var(--danger-bg); }

/* geocoding quality */
.q-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 26px; padding: 0 8px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, .25);
  font: 700 .9rem/1 ui-monospace, Consolas, monospace; color: #fff; cursor: pointer;
}
span.q-badge { cursor: default; }
.q9 { background: #17803a; } .q8 { background: #4a9a2c; } .q7 { background: #9cbf24; color: #1d2327; } .q6 { background: #e4c800; color: #1d2327; }
.q5 { background: #f0a000; color: #1d2327; } .q4 { background: #e8731a; } .q3 { background: #d9531e; } .q2 { background: #b3261e; }
.q1 { background: #2b2b2b; border-color: #8a8a8a; } .q0 { background: #000; border-color: #8a8a8a; }
.q-unknown { background: var(--surface-2); color: var(--text); border-color: var(--border); }
button.q-badge:focus-visible { box-shadow: var(--focus); }

.tooltip {
  position: fixed; z-index: 100; width: min(420px, calc(100vw - 16px)); padding: 12px; border-radius: 6px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .3); font-size: .85rem;
}
.legend-title { font-weight: 700; margin-bottom: 6px; }
.legend-row { display: flex; gap: 10px; align-items: flex-start; padding: 4px 6px; border-radius: 4px; }
.legend-row.current { background: var(--surface-2); outline: 1px solid var(--accent); }
.legend-row .q-badge { flex: none; }
.legend-text { flex: 1; }

/* switches (like components-form-toggle) */
.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle.disabled { cursor: not-allowed; opacity: .65; }
.toggle-input { position: absolute; opacity: 0; width: 36px; height: 18px; margin: 0; cursor: inherit; }
.toggle-track { width: 36px; height: 18px; background: #8c8f94; border-radius: 999px; transition: background .2s; flex: none; }
.toggle-thumb { position: absolute; left: 2px; width: 14px; height: 14px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.toggle-input:checked ~ .toggle-track { background: var(--accent); }
.toggle-input:checked ~ .toggle-thumb { transform: translateX(18px); }
.toggle-input:focus-visible ~ .toggle-track { box-shadow: var(--focus); }
.toggle-list { display: flex; flex-direction: column; margin-top: 8px; }
.toggle-row { display: flex; align-items: center; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .toggle { flex: 1 1 280px; }
.toggle-row code { color: var(--muted); }
.toggle-row select, .toggle-row input[type="number"] { width: 120px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.card > .field { max-width: 340px; margin-top: 12px; }

/* import */
.drop-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 14px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; min-height: 150px; padding: 18px;
  border: 2px dashed var(--border); border-radius: 6px; background: var(--surface-2); cursor: pointer; color: var(--text);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--surface); }
.dropzone.loaded { border-style: solid; border-color: var(--accent); cursor: default; }
.dropzone.disabled { opacity: .45; cursor: not-allowed; border-color: var(--border-soft); }
.dropzone.disabled:hover { background: var(--surface-2); border-color: var(--border-soft); }
.preview-table th, .preview-table td { padding: 4px 10px; font-size: .85rem; white-space: nowrap; }
.preview-table tr.is-header td { font-weight: 700; background: var(--surface-2); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px 20px; margin-top: 10px; }
.map-row { display: flex; flex-direction: column; gap: 4px; }
.records-table input { min-width: 110px; height: 30px; }
.records-table td { padding: 4px 8px; }
.records-table td.num { color: var(--muted); }
.records-table tr.skipped td { opacity: .5; }
.err-text { color: var(--danger); font-size: .82rem; } .ok-text { color: var(--ok); font-weight: 700; }
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.pill { padding: 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-soft); font-size: .85rem; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--danger-bg); color: var(--danger); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.run-actions { margin-top: 18px; }
progress { width: 220px; height: 14px; }

@media (max-width: 600px) {
  .logo-sub { display: none; }
  .card { padding: 14px; }
  .tab { padding: 8px 10px; font-size: .85rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* inline links */
.inline-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.inline-link:hover { color: var(--accent-hover); }

/* parameter names in result tables */
.param-label { display: block; font-weight: 600; }
.param-key { display: block; color: var(--muted); font-size: .75rem; font-weight: 400; }
.result-table tbody th { width: 260px; white-space: normal; }
.result-table th .param-key { font-weight: 400; }

/* row copy button */
.result-table .copy-col { width: 1%; white-space: nowrap; text-align: right; }
.copy-btn { opacity: 0; transition: opacity .12s; }
.result-table tr:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* nested data (extended) */
.nested-table { background: transparent; width: auto; }
.result-table .nested-table tbody th, .result-table .nested-table td, .nested-table th, .nested-table td { padding: 2px 10px 2px 0; border: 0; font-size: .85rem; background: transparent; width: auto; white-space: normal; }
.nested-table th { color: var(--muted); font-weight: 400; vertical-align: top; }
.nested-list { margin: 0; padding-left: 1.2rem; }
.nested-list > li + li { margin-top: 6px; }
.raw summary { cursor: pointer; color: var(--accent); }

/* drag-to-scroll tables */
.table-wrap.scrollable { cursor: grab; }
.table-wrap.dragging { cursor: grabbing; user-select: none; }
.table-wrap.scrollable a, .table-wrap.scrollable button, .table-wrap.scrollable input, .table-wrap.scrollable summary { cursor: pointer; }

/* import: quality summary and preview dialog */
.quality-summary { margin-top: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 8px 0 0; padding: 0; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 6px; border: 1px solid var(--border-soft); border-radius: 4px; background: var(--surface); }
.chip-none { padding-left: 12px; }
.chip-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.modal { width: min(1100px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(0, 0, 0, .4); }
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgba(0, 0, 0, .55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 8px 16px; overflow: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.sub-row { padding-left: 46px; }
.sub-row .row-label { flex: 1 1 240px; }

.card.flash { animation: flash 1.8s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }

/* header controls */
.header-tools select { width: auto; }
.theme-btn, .apps-btn { width: 36px; height: 36px; padding: 0; }

/* compact text tooltip (reuses .tooltip) */
.tooltip.tooltip-sm { width: auto; max-width: min(280px, calc(100vw - 16px)); padding: 6px 10px; font-size: .82rem; border-radius: 5px; }

/* apps popover */
.apps-menu {
  position: fixed; z-index: 120; width: min(300px, calc(100vw - 16px)); background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); overflow: hidden;
}
.apps-section { padding: 12px 14px; }
.apps-title { font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.apps-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.apps-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 6px; color: var(--text); text-decoration: none; font-weight: 600; }
.apps-item:hover, .apps-item:focus-visible { background: var(--surface-2); }
.apps-links { border-top: 1px solid var(--border-soft); background: var(--surface-2); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; font-size: .85rem; line-height: 1.4; text-align: center; }
.apps-sep { display: inline-flex; align-items: center; color: var(--muted); font-size: .6rem; line-height: 1; }

/* text with line breaks (e.g. import limits) */
.info { white-space: pre-line; }

/* about dialog */
.modal.modal-sm { width: min(520px, calc(100vw - 24px)); }
.about p { margin: 0 0 12px; }
.about-version { color: var(--muted); font-weight: 600;}
.about-donate { margin-top: 18px; padding-top: 24px; color: var(--muted);}
.donate-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; margin: 16px 0 8px; }
.donate-item { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-size: .85rem; }
.donate-img { display: flex; align-items: center; justify-content: center; padding: 10px 14px; transition: transform .18s ease; }
.donate-img img { display: block; height: 40px; width: auto; max-width: 220px; filter: var(--filter); opacity: .9; transition: filter .18s ease, opacity .18s ease; }
.donate-item:hover .donate-img, .donate-item:focus-visible .donate-img { transform: scale(1.08); filter: var(--filter-hover); }
.donate-item:hover img, .donate-item:focus-visible img { filter: saturate(1.2) brightness(1.05); opacity: 1; }
.about-thanks { text-align: center; font-weight: 700; margin: 12px 0 4px !important; padding: 24px 0; color: var(--muted);}
.apps-about { padding-top: 0; padding-bottom: 4px;}
.apps-about { border-top: 1px solid transparent; border-image: linear-gradient(to right, transparent 0px, var(--border-soft), transparent calc(100%)) 1;}
.apps-about-btn { display: block; width: 100%; border: 0; background: transparent; font: inherit; font-weight: 600; cursor: pointer; text-align: center;}

/* Home: apps list */
.home-title { margin: 32px 0 16px; font-size: 1.4rem; }
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.app-card { display: flex; align-items: center; gap: 14px; color: var(--text); text-decoration: none; font-weight: 600; margin-bottom: 0; }
.app-card:hover, .app-card:focus-visible { background: var(--surface-2); }
.muted { color: var(--muted); }

/* error pages (error.php) */
.error-page { text-align: center; padding-top: 56px; padding-bottom: 32px; }
.error-code { margin: 0; font-size: 5rem; font-weight: 700; line-height: 1; color: var(--muted); }
.error-page h2 { margin: 12px 0 8px; }
