/* ───────────── Theme tokens ───────────── */
:root {
    --bg: #fff7ed;
    --bg-2: #ffffff;
    --surface: #ffffff;
    --surface-2: #fdf1e3;
    --border: #f0dcc4;
    --text: #1c1917;
    --muted: #6b5f55;
    --brand: #f97316;
    --brand-2: #7c3aed;
    --brand-ink: #ffffff;
    --danger: #dc2626;
    --ok: #16a34a;
    --warn: #d97706;
    --shadow: 0 10px 30px rgba(60, 30, 0, .12);
    --radius: 14px;
    --topbar-h: 56px;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #130c1c;
    --bg-2: #1a1025;
    --surface: #1f1430;
    --surface-2: #2a1c3f;
    --border: #3b2a55;
    --text: #f3ecff;
    --muted: #b7a8cc;
    --brand: #ff8a2a;
    --brand-2: #a78bfa;
    --brand-ink: #1a0d00;
    --danger: #f87171;
    --ok: #4ade80;
    --warn: #fbbf24;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

/* ───────────── Base ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}
body.fullscreen { overflow: hidden; }
a { color: var(--brand-2); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* ───────────── Top bar ───────────── */
.topbar {
    position: sticky; top: 0; z-index: 1000;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 14px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
}
.topbar::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
    background: linear-gradient(90deg, var(--brand), var(--brand-2));
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.brand-icon { font-size: 1.4rem; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.nav-link { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; padding: 6px 10px; border-radius: 8px; }
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.theme-toggle {
    width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center;
}
.theme-toggle .ico-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: block; }
@media (max-width: 520px) {
    .brand-name { display: none; }
    .btn-lbl { display: none; }
    .btn-sm { padding: 8px 10px; }
}

/* ───────────── Buttons ───────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 700; font-size: .95rem; cursor: pointer; text-decoration: none;
    line-height: 1; white-space: nowrap; transition: transform .1s, opacity .15s;
}
.btn:hover { opacity: .92; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 8px 12px; font-size: .85rem; }
.btn-primary { background: linear-gradient(135deg, var(--brand), #fb923c); color: #1a0d00; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-oauth { background: var(--surface); color: var(--text); border-color: var(--border); width: 100%; }
.btn-oauth svg { width: 18px; height: 18px; }

/* ───────────── Layout ───────────── */
.main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
.main-full { flex: 1; position: relative; }
.main-wide { max-width: 1100px; }
.footer { border-top: 1px solid var(--border); background: var(--bg-2); }
.footer-inner { max-width: 760px; margin: 0 auto; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; font-size: .85rem; color: var(--muted); }
.footer nav { display: flex; gap: 14px; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title h2 { margin: 0; }
.auth-card { max-width: 420px; margin: 20px auto; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.stack { display: grid; gap: 10px; }

/* ───────────── Forms ───────────── */
.field { margin-bottom: 14px; }
.field label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="time"], input[type="date"],
input[type="number"], input[type="url"], select, textarea {
    width: 100%; padding: 11px 12px; font: inherit; color: var(--text);
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 100px; resize: vertical; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 480px) { .row { grid-template-columns: 1fr; } }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .95rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex-shrink: 0; }
.offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.offer-opt {
    display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; user-select: none;
}
.offer-opt input { accent-color: var(--brand); width: 18px; height: 18px; }
.offer-opt:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, var(--surface-2)); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.form-error { color: var(--danger); font-size: .9rem; margin-bottom: 12px; }

/* ───────────── Flashes ───────────── */
.flashes { position: fixed; top: calc(var(--topbar-h) + 10px); left: 50%; transform: translateX(-50%); z-index: 1100; width: min(560px, calc(100% - 24px)); display: grid; gap: 8px; }
.flash { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: .92rem; }
.flash-ok { border-color: var(--ok); }
.flash-error { border-color: var(--danger); }
.flash-warn { border-color: var(--warn); }
.flash-x { background: none; border: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; line-height: 1; }

/* ───────────── Map page ───────────── */
#map { position: absolute; inset: 0; background: var(--bg); }
.leaflet-container { font: inherit; }
.tiles-dark { filter: invert(1) hue-rotate(195deg) brightness(.85) contrast(.95) saturate(.7); }
.map-panel {
    position: absolute; z-index: 800; left: 10px; right: 10px; top: 10px;
    display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none;
}
.map-panel > * { pointer-events: auto; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border); color: var(--muted);
    font-size: .8rem; font-weight: 700; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.chip.on { color: var(--text); border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.map-intro {
    position: absolute; z-index: 850; left: 12px; bottom: 28px; width: min(380px, calc(100% - 24px));
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px;
    box-shadow: var(--shadow); font-size: .9rem;
}
.map-intro h1 { font-size: 1.05rem; margin: 0 24px 6px 0; }
.map-intro p { margin: 0 0 8px; color: var(--muted); }
.map-intro .intro-cta { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.intro-areas { font-size: .78rem; margin: 10px 0 0 !important; line-height: 1.7; }
.intro-areas span { color: var(--muted); }
.intro-areas a { margin-right: 8px; white-space: nowrap; }
.footer-areas { flex-wrap: wrap; gap: 4px 12px !important; width: 100%; }
.intro-x { position: absolute; top: 6px; right: 8px; background: none; border: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.map-intro.hidden { display: none; }
@media (max-width: 640px) {
    /* On phones the intro becomes a bottom sheet above the map controls; dismissing it reveals them */
    .map-intro { z-index: 1100; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 70vh; overflow-y: auto; }
}
.leaflet-bottom.leaflet-right .leaflet-control-zoom { margin-bottom: 36px; }
.map-fab {
    position: absolute; z-index: 800; right: 10px; bottom: 112px;
    width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center;
}
.map-empty {
    position: absolute; z-index: 800; left: 12px; bottom: 28px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px;
    font-size: .85rem; color: var(--muted); box-shadow: var(--shadow); max-width: min(380px, calc(100% - 80px));
}
.pin { background: none !important; border: none !important; }
.pin-inner {
    width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    background: var(--c); border: 2px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.35);
    display: grid; place-items: center;
}
.pin-inner span { transform: rotate(45deg); font-size: 17px; line-height: 1; }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--border); padding: 0; }
.leaflet-popup-content { margin: 0; width: min(300px, 80vw) !important; }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-close-button { color: var(--muted) !important; font-size: 22px !important; padding: 6px 8px 0 0 !important; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--bg) 80%, transparent) !important; color: var(--muted) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--brand-2) !important; }
.marker-cluster div { background: color-mix(in srgb, var(--brand) 85%, #000); color: #fff; font-weight: 800; }
.marker-cluster { background: color-mix(in srgb, var(--brand) 35%, transparent); }
.popup { overflow: hidden; border-radius: 14px; }
.popup-photo { width: 100%; height: 140px; object-fit: cover; display: block; }
.popup-body { padding: 12px 14px 14px; }
.popup-title { font-weight: 800; font-size: 1rem; margin: 0 0 2px; }
.popup-addr { font-size: .8rem; color: var(--muted); margin: 0 0 8px; }
.popup-when { font-size: .85rem; margin: 0 0 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.tag { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; color: #fff; background: var(--c); white-space: nowrap; }
.popup-notes { font-size: .85rem; color: var(--muted); margin: 0 0 8px; white-space: pre-wrap; }
.popup-links { display: flex; gap: 8px; }
.popup-links a { font-size: .8rem; font-weight: 700; }

/* ───────────── Location editor ───────────── */
.pick-map { height: 300px; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; position: relative; }
.addr-row { display: flex; gap: 8px; }
.addr-row input { flex: 1; }
.pick-hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.photo-box { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.photo-preview { width: 120px; height: 90px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.progress { height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 8px; display: none; }
.progress .bar { height: 100%; width: 0; background: var(--brand); transition: width .15s; }
.photo-status { font-size: .8rem; color: var(--muted); margin-top: 6px; }

/* ───────────── Lists / account ───────────── */
.loc-list { display: grid; gap: 10px; }
.loc-item { display: flex; gap: 12px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.loc-thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--surface); flex-shrink: 0; }
.loc-thumb.empty { display: grid; place-items: center; font-size: 1.4rem; }
.loc-info { flex: 1; min-width: 0; }
.loc-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-info span { font-size: .8rem; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-actions { display: flex; gap: 6px; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.badge-ok { color: var(--ok); border-color: var(--ok); }
.badge-warn { color: var(--warn); border-color: var(--warn); }
.badge-muted { opacity: .7; }
.empty { text-align: center; color: var(--muted); padding: 24px 10px; }

/* ───────────── Legal ───────────── */
.legal h2 { margin-top: 1.6em; }
.legal ul { padding-left: 1.2em; }

/* ───────────── Dash ───────────── */
.dash-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.dash-nav a { padding: 7px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700; text-decoration: none; color: var(--muted); border: 1px solid var(--border); background: var(--surface); }
.dash-nav a.active, .dash-nav a:hover { color: var(--text); border-color: var(--brand); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.stat b { display: block; font-size: 1.6rem; font-weight: 800; }
.stat span { font-size: .8rem; color: var(--muted); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tbl td .btn { margin-right: 4px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.toolbar input, .toolbar select { width: auto; padding: 8px 10px; }
.inline-form { display: inline; }
.settings-note { font-size: .85rem; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
code.inline { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; font-size: .85em; word-break: break-all; }
