:root {
    --page-background: #f4efe7;
    --surface: rgba(255, 252, 247, 0.88);
    --surface-strong: #fffdf8;
    --surface-border: rgba(26, 72, 64, 0.12);
    --text-primary: #143631;
    --text-secondary: #4f655f;
    --accent: #1d7a6d;
    --accent-strong: #135c52;
    --accent-soft: #daf1ec;
    --highlight: #ef7c4d;
    --shadow-soft: 0 18px 50px rgba(20, 54, 49, 0.1);
    --shadow-card: 0 20px 40px rgba(20, 54, 49, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", sans-serif;
    color: var(--text-primary);
    background:
        radial-gradient(circle at top left, rgba(239, 124, 77, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(29, 122, 109, 0.18), transparent 32%),
        linear-gradient(180deg, #f8f2e8 0%, var(--page-background) 48%, #efe6da 100%);
}

a {
    color: inherit;
}

code {
    font-family: Consolas, "Courier New", monospace;
}

.page-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
    background: rgba(248, 242, 232, 0.78);
    border-bottom: 1px solid rgba(20, 54, 49, 0.08);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.95rem;
    background: linear-gradient(135deg, var(--accent), var(--highlight));
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.08em;
    box-shadow: var(--shadow-soft);
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-copy strong {
    font-size: 1rem;
}

.brand-copy small {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-link:hover,
.nav-link:focus-visible,
.nav-link.is-active {
    color: var(--accent-strong);
    background: rgba(29, 122, 109, 0.12);
    transform: translateY(-1px);
}

.page-content {
    flex: 1;
    padding: 3.5rem 0 4rem;
}

.content-stack {
    display: grid;
    gap: 1.5rem;
}

.section-heading {
    max-width: 46rem;
}

.section-heading h1 {
    margin: 0.3rem 0 0.8rem;
    font-size: clamp(2.4rem, 5vw, 4rem);
    line-height: 1;
    letter-spacing: -0.04em;
}

.section-heading p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 1.05rem;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.9fr);
    gap: 1.5rem;
    align-items: stretch;
}

.hero-copy,
.hero-panel,
.feature-card,
.section-panel,
.alert,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    box-shadow: var(--shadow-card);
}

.hero-copy {
    padding: 3rem;
    border-radius: 2rem;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2.8rem, 6vw, 4.8rem);
    line-height: 0.98;
    letter-spacing: -0.04em;
}

.hero-text {
    max-width: 44rem;
    margin: 1.25rem 0 0;
    font-size: 1.12rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 2rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.9rem 1.35rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
}

.button-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    box-shadow: 0 18px 30px rgba(19, 92, 82, 0.25);
}

.button-secondary {
    background: rgba(29, 122, 109, 0.08);
    color: var(--accent-strong);
}

.hero-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem;
    border-radius: 1.8rem;
}

.panel-label {
    margin: 0 0 1rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.hero-panel code {
    display: block;
    padding: 1rem 1.1rem;
    border-radius: 1.2rem;
    background: #173d37;
    color: #eefbf6;
    line-height: 1.7;
    white-space: normal;
}

.route-callout {
    margin-top: 1.5rem;
    padding: 1rem 1.1rem;
    border-radius: 1.2rem;
    background: var(--surface-strong);
}

.route-callout span {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.route-callout a {
    color: var(--highlight);
    font-weight: 700;
    text-decoration: none;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.feature-card {
    padding: 1.75rem;
    border-radius: 1.6rem;
}

.feature-card h2 {
    margin-top: 0;
    margin-bottom: 0.8rem;
    font-size: 1.25rem;
}

.feature-card p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

.section-panel {
    padding: 1.75rem;
    border-radius: 1.8rem;
}

.panel-header {
    margin-bottom: 1.5rem;
}

.panel-header h2 {
    margin: 0 0 0.45rem;
    font-size: 1.45rem;
}

.panel-header p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

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

.field {
    display: grid;
    gap: 0.45rem;
    font-weight: 600;
}

.field span {
    font-size: 0.96rem;
}

.input {
    width: 100%;
    padding: 0.95rem 1rem;
    border: 1px solid rgba(20, 54, 49, 0.16);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-primary);
    font: inherit;
}

.input:focus {
    outline: 2px solid rgba(29, 122, 109, 0.22);
    border-color: rgba(29, 122, 109, 0.45);
}

.field-error {
    color: #a43d1f;
    font-size: 0.88rem;
    font-weight: 600;
}

.form-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.85rem;
}

.button {
    border: 0;
    cursor: pointer;
}

.alert,
.empty-state {
    padding: 1rem 1.15rem;
    border-radius: 1.2rem;
}

.alert-success {
    background: rgba(218, 241, 236, 0.92);
    color: var(--accent-strong);
}

.alert-error {
    background: rgba(239, 124, 77, 0.14);
    color: #8f3518;
}

.empty-state p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

.empty-state p + p {
    margin-top: 0.45rem;
}

.site-footer {
    margin-top: auto;
    border-top: 1px solid rgba(20, 54, 49, 0.08);
    background: rgba(255, 252, 247, 0.72);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 0 2rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.footer-inner p {
    margin: 0;
}

@media (max-width: 860px) {
    .header-inner,
    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero,
    .feature-grid {
        grid-template-columns: 1fr;
    }

    .hero-copy,
    .hero-panel {
        padding: 2rem;
    }

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

    .page-content {
        padding-top: 2rem;
    }
}

@media (max-width: 560px) {
    .container {
        width: min(100% - 1.25rem, 1120px);
    }

    .site-nav {
        width: 100%;
    }

    .nav-link {
        width: 100%;
        text-align: center;
    }

    .hero h1 {
        font-size: 2.5rem;
    }
}

/* ── Auth / Login ─────────────────────────────────────── */

.auth-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 0;
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    box-shadow: var(--shadow-card);
    border-radius: 2rem;
    padding: 2.5rem 2.5rem 2rem;
    display: grid;
    gap: 1.5rem;
}

.auth-card-header {
    display: grid;
    gap: 0.4rem;
}

.auth-card-title {
    margin: 0;
    font-size: 2rem;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.auth-card-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.97rem;
    line-height: 1.6;
}

.auth-form {
    display: grid;
    gap: 1.1rem;
}

.auth-remember {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.93rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.auth-remember input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
    cursor: pointer;
}

.auth-submit {
    width: 100%;
    justify-content: center;
    padding: 0.95rem;
    font-size: 1rem;
    margin-top: 0.25rem;
}

.auth-nav-form {
    display: inline;
    margin: 0;
    padding: 0;
}

.auth-nav-btn {
    background: none;
    border: none;
    padding: 0.7rem 1rem;
    font: inherit;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.auth-nav-btn:hover,
.auth-nav-btn:focus-visible {
    color: var(--accent-strong);
    background: rgba(29, 122, 109, 0.12);
    transform: translateY(-1px);
}

/* ── Page header ──────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-header h1 {
    margin: 0;
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.page-header-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.button-sm {
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
}

.button-danger {
    background: rgba(239, 124, 77, 0.14);
    color: #8f3518;
}

.button-danger:hover,
.button-danger:focus-visible {
    background: rgba(239, 124, 77, 0.28);
}

/* ── Alerts (flash) ───────────────────────────────────── */

.alert {
    margin-bottom: 1.25rem;
}

/* ── Badges ───────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: middle;
}

.badge-danger {
    background: rgba(239, 124, 77, 0.18);
    color: #8f3518;
}

.badge-warning {
    background: rgba(239, 200, 77, 0.22);
    color: #6b4a00;
}

.badge-success {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

/* ── Filter bar ───────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1.5rem;
}

.filter-bar .field {
    min-width: 160px;
}

/* ── Data table ───────────────────────────────────────── */

.table-responsive {
    overflow-x: auto;
    border-radius: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th {
    text-align: left;
    padding: 0.7rem 1rem;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--surface-border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--surface-border);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background: rgba(29, 122, 109, 0.035);
}

.data-table a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.data-table a:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}

.table-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: nowrap;
}

/* ── Inline form (for delete buttons in tables) ───────── */

.inline-form {
    display: inline;
    margin: 0;
    padding: 0;
}

/* ── Pagination ───────────────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--surface-border);
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    height: 2.2rem;
    padding: 0 0.6rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-secondary);
    transition: background-color 140ms, color 140ms;
}

.page-link:hover {
    background: rgba(29, 122, 109, 0.1);
    color: var(--accent-strong);
}

.page-link.is-active {
    background: var(--accent);
    color: #fff;
    pointer-events: none;
}

.pagination-meta {
    margin-left: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ── Detail list (show pages) ─────────────────────────── */

.detail-list {
    display: grid;
    grid-template-columns: 10rem 1fr;
    gap: 0.6rem 1.25rem;
    margin: 0;
}

.detail-list dt {
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    padding-top: 0.1rem;
}

.detail-list dd {
    margin: 0;
}

/* ── Checkbox label ───────────────────────────────────── */

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── Street chips ─────────────────────────────────────── */

.street-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ── Export checklist ─────────────────────────────────── */

.territory-checklist {
    display: grid;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.territory-item {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--surface-border);
    border-radius: 0.75rem;
    background: var(--surface-strong);
    font-weight: 400;
}

.territory-item:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* ── Utility ──────────────────────────────────────────── */

.text-secondary {
    color: var(--text-secondary);
}

select.input {
    appearance: auto;
    cursor: pointer;
}

textarea.input {
    resize: vertical;
    min-height: 80px;
}

@media (max-width: 860px) {
    .detail-list {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }

    .detail-list dt {
        margin-top: 0.75rem;
    }

    .detail-list dt:first-child {
        margin-top: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
