/* =========================================================================
   Maps Scraper design system
   ========================================================================= */

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --surface-3: #eef0f6;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --border: #e5e7ef;
    --border-strong: #d4d8e3;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef0ff;
    --primary-text: #4338ca;

    --success: #059669;
    --success-soft: #e7f8f1;
    --warning: #b45309;
    --warning-soft: #fff5e6;
    --danger: #dc2626;
    --danger-soft: #fdeeee;
    --info: #2563eb;
    --info-soft: #eaf1ff;
    --violet: #7c3aed;
    --violet-soft: #f3edff;
    --neutral-soft: #f1f3f8;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
    --sidebar-w: 248px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0e14;
        --surface: #121620;
        --surface-2: #171c28;
        --surface-3: #1e2433;
        --text: #e8ebf2;
        --text-2: #c3c9d6;
        --muted: #8b94a7;
        --border: #232a3a;
        --border-strong: #2e3649;

        --primary: #7c74ff;
        --primary-hover: #948dff;
        --primary-soft: #1d1f3d;
        --primary-text: #a9a4ff;

        --success: #34d399;
        --success-soft: #0f2a21;
        --warning: #fbbf24;
        --warning-soft: #2c2210;
        --danger: #f87171;
        --danger-soft: #2e1515;
        --info: #60a5fa;
        --info-soft: #132238;
        --violet: #b39dff;
        --violet-soft: #241a40;
        --neutral-soft: #1b2130;

        --shadow-sm: none;
        --shadow: 0 1px 2px rgba(0, 0, 0, .35);
        --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- layout */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 14px;
    gap: 6px;
    z-index: 40;
}

.side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 16px;
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
    text-decoration: none !important;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #4f46e5 60%, #4338ca);
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .35);
}

.brand-mark .icon { width: 18px; height: 18px; stroke-width: 2.4; }

.side-cta { margin: 0 2px 10px; }
.side-cta .btn { width: 100%; justify-content: center; }

.side-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 12px 10px 6px;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; }

.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 500;
    text-decoration: none;
}

.side-nav a:hover { background: var(--surface-3); color: var(--text); }
.side-nav a.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.side-nav a.active .icon { stroke: var(--primary); }

.side-spacer { flex: 1; }

.side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-text);
    display: grid;
    place-items: center;
    font-weight: 700;
    text-transform: uppercase;
    flex: none;
}

.side-user .who { flex: 1; min-width: 0; }
.side-user .who b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .who span { font-size: 12px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.mobilebar { display: none; }

.page { width: 100%; max-width: 1320px; margin: 0 auto; padding: 28px 32px 48px; }
.page.narrow { max-width: 920px; }
.page.wizard-page { max-width: 1040px; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.page-head .sub { color: var(--muted); margin-top: 4px; max-width: 680px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 960px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }

    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim { display: block; }

    .scrim {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .35);
        z-index: 30;
    }

    .mobilebar {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 16px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 20;
        font-weight: 700;
    }

    .page { padding: 18px 16px 40px; }
}

/* ---------------------------------------------------------------- cards */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 20px; }
.card + .card { margin-top: 16px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 550;
    cursor: pointer;
    text-decoration: none !important;
    white-space: nowrap;
    transition: background .12s, border-color .12s, box-shadow .12s;
    box-shadow: var(--shadow-sm);
}

.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-icon { width: 32px; padding: 0; }

/* ---------------------------------------------------------------- forms */

input[type=text], input[type=number], input[type=search], input[type=password], input[type=email], select, textarea {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    transition: border-color .12s, box-shadow .12s;
}

textarea { height: auto; padding: 9px 12px; resize: vertical; line-height: 1.45; }
select { padding-right: 30px; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 700px) { .field-row, .field-row.three { grid-template-columns: 1fr; } }

label, .label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 500;
    cursor: pointer;
}

.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); flex: none; }

.form-stack { display: flex; flex-direction: column; gap: 16px; }

.search-input { position: relative; }
.search-input .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input input { padding-left: 36px; }

/* ---------------------------------------------------------------- alerts */

.error-message:not(:empty), .alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13.5px;
}

.error-message:not(:empty) { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-ok { background: var(--success-soft); color: var(--success); }
.alert-warn { background: var(--warning-soft); color: var(--warning); }

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000;
    background: var(--text);
    color: var(--surface);
    padding: 11px 16px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    font-size: 13.5px;
    animation: toast-in .18s ease-out;
}

.toast-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    cursor: pointer;
    transition: border-color .12s, box-shadow .12s;
}

.stat:hover { border-color: var(--border-strong); }
.stat.static { cursor: default; }
.stat.static:hover { border-color: var(--border); }
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }

.tone-primary { background: var(--primary-soft); color: var(--primary); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-neutral { background: var(--neutral-soft); color: var(--muted); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }

/* ---------------------------------------------------------------- toolbar */

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.toolbar .search-input { flex: 1; min-width: 200px; max-width: 360px; }
.toolbar select, .toolbar input[type=text] { width: auto; min-width: 140px; }
.toolbar .spacer { flex: 1; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }

th {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    background: var(--surface-2);
    white-space: nowrap;
}

tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

.cell-title { font-weight: 600; color: var(--text); }
.cell-title a { color: var(--text); }
.cell-title a:hover { color: var(--primary-text); }
.cell-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.cell-sub.clip { max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-error { color: var(--danger); font-size: 12.5px; margin-top: 4px; max-width: 460px; }
.num { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.right { text-align: right; }

.empty { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; margin-bottom: 10px; color: var(--border-strong); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.page-info { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- badges & chips */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-pending { background: var(--neutral-soft); color: var(--muted); }
.badge-working { background: var(--info-soft); color: var(--info); }
.badge-failed { background: var(--danger-soft); color: var(--danger); }
.badge-cancelled { background: var(--warning-soft); color: var(--warning); }
.badge-new { background: var(--primary); color: #fff; font-size: 10.5px; padding: 1px 8px; vertical-align: 1px; }

.badge-working::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 1.2s infinite ease-in-out;
}

@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none !important;
    cursor: pointer;
}

.chip:hover { border-color: var(--primary); color: var(--primary-text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-n { font-size: 11.5px; opacity: .75; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- dropdown */

.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 190px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: 6px;
}

.dropdown-menu a, .dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none !important;
    background: none;
    border: 0;
    font: inherit;
    cursor: pointer;
}

.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); }
.dropdown.up .dropdown-menu { top: auto; bottom: calc(100% + 6px); left: 0; right: auto; }

/* ---------------------------------------------------------------- spinner */

.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.htmx-request .spinner, .spinner.htmx-request { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- wizard */

.stepper {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}

.step-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    text-align: left;
    font: inherit;
    min-width: 0;
}

.step-tab .n {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--surface-3);
    color: var(--muted);
    font-weight: 700;
    font-size: 12.5px;
    flex: none;
}

.step-tab .t { min-width: 0; }
.step-tab .t b { display: block; color: var(--text-2); font-size: 13px; }
.step-tab .t span { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-tab.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.step-tab.active .n { background: var(--primary); color: #fff; }
.step-tab.done .n { background: var(--success-soft); color: var(--success); }

@media (max-width: 760px) {
    .stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .step-tab { flex-direction: column; text-align: center; padding: 10px 6px; }
    .step-tab .t span { display: none; }
}

.step-panel .card-body { min-height: 360px; }

.step-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
}

.step-foot .info { color: var(--muted); font-size: 13px; }

.picked {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 44px;
    padding: 8px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    margin-bottom: 16px;
    align-items: center;
}

.picked:empty::before { content: attr(data-empty); color: var(--muted); font-size: 13px; padding: 4px 6px; }

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 6px 0 12px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 550;
}

.tag button {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
}

.tag button:hover { background: rgba(255, 255, 255, .38); }
.tag .icon { width: 12px; height: 12px; stroke-width: 3; }

.add-row { display: flex; gap: 8px; margin-bottom: 18px; }
.add-row .search-input { flex: 1; }

.cat-group { margin-bottom: 18px; }
.cat-group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }

.option-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.opt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-2);
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    transition: all .1s;
}

.opt:hover { border-color: var(--primary); color: var(--primary-text); }
.opt.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.opt.on::before { content: "✓"; font-weight: 700; }

.list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
    max-height: 430px;
    overflow-y: auto;
    padding: 2px;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
    transition: all .1s;
}

.list-item:hover { border-color: var(--primary); }
.list-item small { color: var(--muted); font-size: 11.5px; }
.list-item.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.list-item .box {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1.5px solid var(--border-strong);
    display: grid;
    place-items: center;
    flex: none;
    color: #fff;
}

.list-item.on .box { background: var(--primary); border-color: var(--primary); }
.list-item .box .icon { width: 12px; height: 12px; stroke-width: 3.2; display: none; }
.list-item.on .box .icon { display: block; }

.list-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.list-tools .search-input { flex: 1; min-width: 200px; }

.summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

@media (max-width: 760px) { .summary { grid-template-columns: 1fr; } }

.summary-item { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.summary-item .k { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.summary-item .v { font-weight: 600; margin-top: 4px; word-break: break-word; }
.summary-total { display: flex; align-items: baseline; gap: 8px; }
.summary-total .big { font-size: 32px; font-weight: 800; color: var(--primary); line-height: 1; }

.preview-list { max-height: 160px; overflow-y: auto; font-size: 13px; color: var(--text-2); padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.preview-list div { padding: 2px 0; }

details.more {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 16px;
}

details.more > summary {
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 600;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "+"; color: var(--muted); font-size: 18px; font-weight: 400; }
details.more[open] > summary::after { content: "−"; }
details.more > .more-body { padding: 4px 14px 16px; display: flex; flex-direction: column; gap: 14px; }

/* ---------------------------------------------------------------- job detail */

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.kw-list { max-height: 340px; overflow-y: auto; }
.kw-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.kw-row:last-child { border-bottom: 0; }
.kw-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.kw-count.zero { color: var(--muted); font-weight: 400; }

.log-box {
    background: #0b0f17;
    color: #d6dbe4;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    border-radius: 10px;
    padding: 12px 14px;
    max-height: 440px;
    overflow-y: auto;
}

.log-line { padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.log-time { color: #6b7488; }
.log-warn { color: #fbbf24; }
.log-error { color: #f87171; }
.log-success { color: #34d399; }
.log-box .muted { color: #6b7488; }

/* ---------------------------------------------------------------- results & CRM */

.rating { color: #d97706; font-weight: 600; white-space: nowrap; }
.contact a { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addr { max-width: 320px; color: var(--text-2); }

.crm-status {
    width: auto;
    height: 30px;
    padding: 0 26px 0 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    border-color: transparent;
}

.crm-new { background: var(--neutral-soft); color: var(--text-2); }
.crm-to_call { background: var(--info-soft); color: var(--info); }
.crm-called { background: var(--warning-soft); color: var(--warning); }
.crm-interested { background: var(--violet-soft); color: var(--violet); }
.crm-not_interested { background: var(--danger-soft); color: var(--danger); }
.crm-customer { background: var(--success-soft); color: var(--success); }

.note-cell textarea { min-width: 180px; height: 34px; min-height: 34px; font-size: 12.5px; padding: 6px 9px; }
tr.saved { animation: saved 1.2s ease-out; }
@keyframes saved { from { background: var(--success-soft); } to { background: transparent; } }

.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline-form select { width: auto; height: 32px; }
.inline-form input { height: 32px; }

/* ---------------------------------------------------------------- login */

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, .14), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(79, 70, 229, .12), transparent 60%),
        var(--bg);
}

.auth-card { width: 100%; max-width: 400px; padding: 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.auth-card .side-brand { justify-content: center; padding-bottom: 8px; font-size: 17px; }
.auth-card h1 { font-size: 20px; text-align: center; margin-top: 6px; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 6px 0 22px; }
.auth-card .btn { width: 100%; }

/* ---------------------------------------------------------------- map modal */

.map-modal {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, .55);
    justify-content: center;
    align-items: center;
}

.map-modal-content {
    background: var(--surface);
    width: 92vw;
    height: 86vh;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.map-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.map-modal-header h2 { margin: 0; font-size: 16px; }
.map-modal-close { background: none; border: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.map-modal-body { flex: 1; display: flex; min-height: 0; }
#job-map { flex: 3; height: 100%; }
#job-places-list { flex: 1; min-width: 240px; max-width: 360px; overflow-y: auto; border-left: 1px solid var(--border); padding: 8px; }
.place-item { padding: 9px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
.place-item:hover { background: var(--surface-2); }
.place-title { font-weight: 600; }
.place-address { font-size: .85rem; color: var(--muted); }
.place-rating { font-size: .85rem; color: #d97706; }
.map-loading, .map-empty, .map-error { padding: 12px; color: var(--muted); }
.map-error { color: var(--danger); }

td .actions { flex-wrap: nowrap; }
.crm td:first-child, .crm th:first-child { min-width: 260px; }
.crm td:nth-child(5) { min-width: 120px; }

/* live progress */
.progress-card { margin-bottom: 16px; }
.progress-pct { font-size: 26px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.progress-bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #4f46e5); border-radius: 999px; transition: width .6s ease; }
.progress-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.progress-facts div { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.progress-facts b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.progress-facts span { color: var(--muted); font-size: 12px; }
.progress-facts .bad b { color: var(--danger); }
.kw-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--neutral-soft); color: var(--muted); }
.kw-running { background: var(--info-soft); color: var(--info); }
.kw-running::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }
.kw-listed { background: var(--success-soft); color: var(--success); }
.kw-failed { background: var(--danger-soft); color: var(--danger); }

/* social links */
.socials { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.soc { display: inline-flex !important; align-items: center; max-width: 220px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--neutral-soft); color: var(--text-2) !important; text-decoration: none !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soc-instagram { background: #fde8f3; color: #c1347a !important; }
.soc-facebook { background: #e7effe; color: #1d5fd1 !important; }
.soc-tiktok, .soc-twitter { background: var(--neutral-soft); color: var(--text) !important; }
.soc-youtube { background: #fdeaea; color: #c4302b !important; }
.soc-linkedin { background: #e6f0f8; color: #0a66c2 !important; }
.soc-whatsapp { background: #e5f8ec; color: #128c48 !important; }
@media (prefers-color-scheme: dark) {
    .soc-instagram { background: #3a1730; color: #f48ac2 !important; }
    .soc-facebook { background: #16243f; color: #7aa7f7 !important; }
    .soc-youtube { background: #3a1616; color: #f58a85 !important; }
    .soc-linkedin { background: #12263a; color: #6fb1f0 !important; }
    .soc-whatsapp { background: #11301f; color: #5fd896 !important; }
}

/* wizard v2 */
.stepper.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.step-tab.skip { opacity: .55; }
.step-tab.skip .n { background: var(--surface-3); }

.combo { position: relative; margin-bottom: 14px; }
.combo-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 60;
    padding: 6px;
    max-height: 340px;
    overflow-y: auto;
}

.combo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.combo-item small { color: var(--muted); font-size: 12px; }
.combo-item:hover, .combo-item.active { background: var(--primary-soft); color: var(--primary-text); }
.combo-item.add span { font-weight: 600; color: var(--primary-text); }

.upload-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.upload-row label.btn { cursor: pointer; }
.bulk { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border-radius: 10px;
    background: var(--surface-3);
    margin-bottom: 18px;
}

.seg-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    font: inherit;
    font-weight: 550;
    cursor: pointer;
}

.seg-btn .icon { width: 16px; height: 16px; }
.seg-btn.active { background: var(--surface); color: var(--primary-text); box-shadow: var(--shadow); }

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 28px 16px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    text-align: center;
    transition: border-color .12s, background .12s;
}

.dropzone .icon { width: 30px; height: 30px; color: var(--muted); margin-bottom: 4px; }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone label { cursor: pointer; }

.format-help {
    margin-top: 14px;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    background: var(--surface-3);
    padding: 1px 6px;
    border-radius: 5px;
}

.list-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; flex-wrap: wrap; }
.list-head .btn { margin-left: auto; }
#loc-picked { max-height: 260px; overflow-y: auto; }
.tag-loc { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.tag-loc button { background: var(--surface-3); color: var(--muted); }
.tag-loc button:hover { background: var(--danger-soft); color: var(--danger); }
.warn-list { font-size: 12.5px; color: var(--warning); display: flex; flex-direction: column; gap: 3px; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }

.field-opt {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    font-weight: 400;
    transition: border-color .1s, background .1s;
}

.field-opt:hover { border-color: var(--primary); }
.field-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.field-opt input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.field-opt b { display: block; color: var(--text); font-size: 14px; }
.field-opt small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.slow-tag {
    display: inline-block;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 11px;
    font-weight: 600;
    vertical-align: 1px;
}

@media (max-width: 760px) {
    .stepper.five { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
    .stepper.five .step-tab .t b { font-size: 11px; }
}

.when-box { margin-top: 18px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.when-box .seg { background: var(--surface-3); }
.when-box .chips .chip { height: 30px; font-size: 12.5px; }
input[type=datetime-local] { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; color-scheme: light dark; }
input[type=datetime-local]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
