:root {
    --bg: #f3f6f8;
    --bg-strong: #0e1a24;
    --panel: #ffffff;
    --panel-soft: #eef4f6;
    --text: #15232d;
    --muted: #6a7b87;
    --primary: #1d8f8a;
    --primary-dark: #156f6b;
    --danger: #b94545;
    --success: #287a52;
    --border: #d6e1e7;
    --shadow: 0 18px 48px rgba(11, 27, 38, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    overflow-x: hidden;
    font-family: "Segoe UI", Arial, sans-serif;
    background: linear-gradient(180deg, #f8fbfc 0%, var(--bg) 100%);
    color: var(--text);
}

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

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

.guest-main {
    width: min(100%, 460px);
}

.auth-card,
.panel-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.auth-card {
    padding: 32px;
}

.auth-card-header {
    margin-bottom: 24px;
}

.eyebrow {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 10px;
}

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

.field {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
}

.field input,
.field select {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 15px;
    color: var(--text);
}

.button {
    border: 0;
    border-radius: 14px;
    padding: 13px 18px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.button-primary {
    background: var(--primary);
    color: #fff;
}

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

.button-muted {
    background: var(--panel-soft);
    color: var(--text);
}

.button-block {
    width: 100%;
}

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid transparent;
}

.alert-error {
    background: #fff1f1;
    border-color: #f2cdcd;
    color: var(--danger);
}

.alert-success {
    background: #eefbf3;
    border-color: #cfe8d9;
    color: var(--success);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
    width: 100%;
    overflow-x: hidden;
}

.sidebar {
    padding: 28px;
    background: var(--bg-strong);
    color: #f2f6f8;
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-width: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #37c0ba, #1d8f8a);
    color: white;
    font-weight: 700;
}

.brand small,
.sidebar-footer small {
    color: #aac0cc;
}

.nav-links {
    display: grid;
    gap: 10px;
}

.nav-links a {
    padding: 12px 14px;
    border-radius: 12px;
    color: #dfeaf0;
}

.nav-links a.active,
.nav-links a:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 8px;
}

.content-area {
    padding: 28px;
    min-width: 0;
}

.page-header {
    margin-bottom: 22px;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
}

.panel-card {
    padding: 24px;
}

.metric {
    display: block;
    font-size: 38px;
    margin-bottom: 10px;
}

.dashboard-last-job {
    font-size: 28px;
}

.dashboard-welcome {
    margin-top: 18px;
}

.content-grid {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.content-grid > * {
    min-width: 0;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-heading h2 {
    margin: 0;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.table-wrap {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.data-table th,
.data-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 14px;
}

.data-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-pill {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-active {
    background: #e8f7ef;
    color: var(--success);
}

.status-inactive {
    background: #fff1f1;
    color: var(--danger);
}

.table-muted,
.table-empty {
    color: var(--muted);
}

.mining-console {
    gap: 18px;
}

.progress-shell {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
}

.progress-bar {
    height: 14px;
    border-radius: 999px;
    background: var(--panel-soft);
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #1d8f8a, #45b9ad);
}

.progress-status {
    color: var(--muted);
    margin: 12px 0 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.stat-box {
    background: var(--panel-soft);
    border-radius: 16px;
    padding: 16px;
}

.stat-box span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-box strong {
    font-size: 24px;
}

.channel-panel {
    margin-top: 20px;
    padding: 16px;
    border-radius: 16px;
    background: var(--panel-soft);
}

.channel-panel p {
    margin: 8px 0 0;
    color: var(--text);
    word-break: break-word;
}

.source-overview {
    overflow: hidden;
}

.source-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.source-card {
    background: linear-gradient(180deg, #f7fbfc, #edf5f6);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
}

.source-card strong {
    display: block;
    margin-bottom: 8px;
}

.source-card p,
.source-note {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.source-note {
    margin-top: 16px;
    padding: 16px;
    border-radius: 16px;
    background: #f8fafb;
    border: 1px dashed var(--border);
}

.filters-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.field-compact span {
    font-size: 12px;
}

.data-table-wide {
    min-width: 1500px;
}

.inline-details {
    min-width: 220px;
}

.inline-details summary {
    cursor: pointer;
    color: var(--primary-dark);
    font-weight: 600;
}

.detail-list {
    margin-top: 10px;
    display: grid;
    gap: 10px;
}

.detail-item {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fbfc;
}

.detail-item strong {
    font-size: 13px;
}

.detail-item span,
.detail-item a {
    font-size: 13px;
    color: var(--muted);
    word-break: break-word;
}

.map-card {
    overflow: hidden;
}

.map-counter {
    color: var(--primary-dark);
    font-size: 14px;
}

.lead-map {
    height: 420px;
    margin-top: 16px;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #f6fbfd, #e9f4f7);
}

.map-empty {
    margin: 14px 0 0;
}

.map-popup p {
    margin: 6px 0 0;
    font-size: 13px;
}

.leaflet-container {
    font: inherit;
}

.pagination-bar {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pagination-actions {
    display: flex;
    gap: 10px;
}

.modal-open {
    overflow: hidden;
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 24px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 21, 28, 0.55);
    backdrop-filter: blur(2px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 980px);
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 24px;
    border-radius: 24px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 24px 80px rgba(6, 18, 28, 0.28);
}

.modal-card textarea {
    width: 100%;
    resize: vertical;
    min-height: 120px;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 14px;
    color: var(--text);
    line-height: 1.55;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
}

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

    .sidebar {
        gap: 18px;
    }

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

    .lead-map {
        height: 320px;
    }
}

.field-compact {
    gap: 6px;
}

.field-compact input,
.field-compact select {
    padding: 11px 12px;
    min-width: 0;
}

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

    .sidebar {
        gap: 18px;
        padding: 22px;
    }

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

    .content-area {
        padding: 18px;
    }

    .data-table {
        min-width: 760px;
    }

    .pagination-bar,
    .modal-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
