:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #eef4f8;
    --text: #17202a;
    --muted: #6b7785;
    --line: #dfe7ef;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --teal: #0f766e;
    --shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.auth-page {
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.12), transparent 36%),
        linear-gradient(225deg, rgba(15, 118, 110, 0.12), transparent 40%),
        var(--bg);
}

.home-page {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.15), transparent 34%),
        radial-gradient(circle at bottom right, rgba(15, 118, 110, 0.16), transparent 34%),
        var(--bg);
}

.home-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.home-panel {
    width: min(100%, 520px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
    padding: 38px;
    text-align: center;
}

.home-logo {
    width: min(240px, 72vw);
    height: auto;
    object-fit: contain;
    image-rendering: auto;
    margin: 0 auto 18px;
}

.home-panel p {
    margin: 0 0 24px;
    color: var(--muted);
    font-weight: 700;
}

.home-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.auth-panel {
    width: min(100%, 430px);
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
}

.brand-mark {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: var(--radius);
    background: var(--text);
    color: #fff;
    font-weight: 800;
}

.brand-logo,
.auth-logo {
    display: block;
    height: auto;
    image-rendering: auto;
    object-fit: contain;
}

.brand-logo {
    width: 58px;
    max-height: 58px;
    border-radius: var(--radius);
}

.auth-logo {
    width: min(210px, 70vw);
    max-height: 120px;
    margin-bottom: 14px;
}

.auth-panel h1,
.topbar h1 {
    margin: 14px 0 6px;
    font-size: 30px;
    line-height: 1.1;
}

.auth-panel p,
.eyebrow {
    margin: 0 0 24px;
    color: var(--muted);
}

.eyebrow {
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.form-stack,
.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
}

.upload-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
    display: grid;
    gap: 7px;
    min-width: 0;
}

label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    outline: none;
    padding: 10px 12px;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 0;
    accent-color: var(--blue);
    cursor: pointer;
    padding: 0;
}

input:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn,
.status-btn,
.icon-btn {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.btn:hover,
.status-btn:hover,
.icon-btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--blue);
    color: #fff;
    padding: 0 18px;
}

.btn-primary:hover {
    background: var(--blue-dark);
}

.btn-soft {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    padding: 0 16px;
}

.btn-danger,
.btn-mini-danger {
    background: #fee2e2;
    color: #991b1b;
}

.btn-danger {
    padding: 0 16px;
}

.btn-mini-danger {
    min-height: 34px;
    padding: 0 12px;
}

.btn-danger:hover,
.btn-mini-danger:hover {
    background: #fecaca;
}

.auth-link {
    display: inline-flex;
    margin-top: 20px;
    color: var(--blue);
    font-weight: 800;
}

.alert {
    margin-bottom: 18px;
    border-radius: var(--radius);
    padding: 12px 14px;
    font-weight: 700;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.app-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid var(--line);
    background: #101820;
    color: #fff;
    padding: 22px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    text-decoration: none;
}

.sidebar .brand-mark {
    background: #fff;
    color: #101820;
}

.nav-list {
    display: grid;
    gap: 8px;
}

.nav-list a {
    border-radius: var(--radius);
    color: rgba(255, 255, 255, 0.72);
    font-weight: 800;
    padding: 12px 14px;
}

.nav-form {
    margin: 0;
}

.mobile-menu-cache {
    display: none;
}

.nav-action {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    font-weight: 800;
    padding: 12px 14px;
    text-align: left;
}

.nav-action:hover {
    background: rgba(255, 255, 255, 0.11);
    color: #fff;
}

.nav-icon-action {
    justify-content: center;
    width: 44px;
    font-size: 18px;
    padding: 0;
}

.nav-list a.active,
.nav-list a:hover {
    background: rgba(255, 255, 255, 0.11);
    color: #fff;
}

.main-panel {
    min-width: 0;
    padding: 28px;
}

.menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 22px;
    font-weight: 900;
    margin-bottom: 14px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.topbar h1 {
    margin: 0;
}

.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.cache-form {
    display: inline-flex;
}

.cache-btn {
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.cache-btn:hover {
    border-color: var(--blue);
    background: #eff6ff;
    transform: translateY(-1px);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric,
.panel-card,
.data-row {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 8px 26px rgba(23, 32, 42, 0.04);
}

.metric {
    padding: 18px;
}

.metric span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

.split-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.panel-card {
    margin-bottom: 18px;
    padding: 18px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.section-title h2 {
    margin: 0;
    font-size: 18px;
}

.title-actions {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.with-pager {
    flex-wrap: wrap;
}

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

.compact-scroll {
    max-height: 560px;
    overflow: auto;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.checkbox-cell {
    width: 46px;
    text-align: center;
}

.checkbox-cell input {
    margin: 0 auto;
}

.inline-form {
    display: inline-flex;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font-size: 22px;
}

.icon-btn.disabled {
    pointer-events: none;
    opacity: 0.38;
}

.pager {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-weight: 900;
}

.pager-note {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}

.pill {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 900;
}

.pill-green,
.status-called {
    background: #dcfce7;
    color: #166534;
}

.pill-gray,
.status-new {
    background: #e5e7eb;
    color: #374151;
}

.status-unreachable {
    background: #fee2e2;
    color: #991b1b;
}

.status-offered {
    background: #ffedd5;
    color: #9a3412;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.city-filter-form {
    margin-left: auto;
    min-width: min(100%, 230px);
}

.filter-chip {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-weight: 900;
    padding: 8px 14px;
}

.filter-chip.active,
.filter-chip:hover {
    border-color: var(--blue);
    background: #eff6ff;
    color: var(--blue);
}

.data-list {
    display: grid;
    max-height: 650px;
    overflow: auto;
    gap: 12px;
    padding-right: 4px;
}

.data-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 16px;
}

.data-main {
    min-width: 0;
}

.data-main h3 {
    overflow-wrap: anywhere;
    margin: 10px 0 6px;
    font-size: 18px;
}

.phone-link {
    color: var(--blue);
    font-weight: 900;
}

.city-badge {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: 12px;
    font-weight: 900;
    margin-left: 6px;
    padding: 4px 10px;
}

.status-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(112px, 1fr));
    gap: 8px;
}

.status-btn {
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--text);
    padding: 0 12px;
}

.status-btn.selected {
    border-color: var(--teal);
    background: #ccfbf1;
    color: #115e59;
}

.empty-state {
    color: var(--muted);
    font-weight: 800;
    padding: 24px 10px;
    text-align: center;
}

.is-loading {
    opacity: 0.68;
    pointer-events: none;
}

@media (max-width: 820px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 50;
        top: 0;
        left: 0;
        width: min(82vw, 300px);
        height: 100vh;
        padding: 18px;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: 18px 0 40px rgba(16, 24, 32, 0.2);
    }

    .sidebar-brand {
        margin-bottom: 18px;
    }

    .nav-list {
        display: grid;
        overflow: visible;
        padding-bottom: 0;
    }

    .mobile-menu-cache {
        display: flex;
        padding-left: 14px;
    }

    .topbar-cache,
    .topbar-logout {
        display: none;
    }

    body.menu-open .sidebar {
        transform: translateX(0);
    }

    body.menu-open::after {
        content: "";
        position: fixed;
        z-index: 40;
        inset: 0;
        background: rgba(16, 24, 32, 0.42);
    }

    .menu-toggle {
        display: inline-flex;
        position: sticky;
        top: 10px;
        z-index: 30;
    }

    .main-panel {
        padding: 18px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .metric-grid,
    .split-grid,
    .form-grid,
    .upload-form {
        grid-template-columns: 1fr;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .data-row {
        grid-template-columns: 1fr;
    }

    .status-actions {
        grid-template-columns: 1fr;
    }

    .city-filter-form {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 520px) {
    .home-panel {
        padding: 26px;
    }

    .home-actions {
        grid-template-columns: 1fr;
    }

    .auth-panel {
        padding: 22px;
    }

    .main-panel {
        padding: 14px;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .btn,
    .btn-primary,
    .btn-soft {
        width: 100%;
    }

    .topbar-actions {
        display: flex;
    }
}
