:root {
    --primary: #C68642;
    --primary-dark: #8D5524;
    --secondary: #F5DEB3;
    --accent: #4CAF50;
    --accent-dark: #2E7D32;
    --danger: #D84315;
    --surface: rgba(255, 249, 241, 0.92);
    --surface-strong: rgba(255, 244, 227, 0.98);
    --text: #2E2418;
    --muted: #7D6B57;
    --line: rgba(141, 85, 36, 0.15);
    --shadow: 0 22px 60px rgba(94, 60, 28, 0.18);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --max-width: 1180px;
    --font-ui: "Segoe UI", "Trebuchet MS", "Tahoma", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-ui);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(245, 222, 179, 0.95), transparent 32%),
        radial-gradient(circle at top right, rgba(198, 134, 66, 0.22), transparent 24%),
        linear-gradient(180deg, #FFF9F2 0%, #F7E7CF 45%, #F4E0B8 100%);
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    z-index: 0;
    pointer-events: none;
    filter: blur(2px);
}

body::before {
    width: 240px;
    height: 240px;
    top: 6vh;
    inset-inline-start: -50px;
    background: radial-gradient(circle, rgba(198, 134, 66, 0.25), transparent 65%);
}

body::after {
    width: 320px;
    height: 320px;
    bottom: 6vh;
    inset-inline-end: -90px;
    background: radial-gradient(circle, rgba(76, 175, 80, 0.18), transparent 65%);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: 0;
}

img {
    max-width: 100%;
    display: block;
}

.hidden {
    display: none !important;
}

#app {
    position: relative;
    z-index: 1;
}

.shell {
    width: min(100%, var(--max-width));
    margin: 0 auto;
    padding: 1rem 1rem 6rem;
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.05em;
    box-shadow: 0 10px 22px rgba(141, 85, 36, 0.3);
}

.brand-copy h1,
.brand-copy p {
    margin: 0;
}

.brand-copy h1 {
    font-size: 1.1rem;
}

.brand-copy p {
    color: var(--muted);
    font-size: 0.9rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.hero {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card,
.glass-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.card {
    padding: 1.1rem;
}

.hero-card {
    padding: 1.35rem;
    display: grid;
    gap: 1rem;
    overflow: hidden;
    position: relative;
}

.hero-card::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: calc(var(--radius-xl) - 10px);
    border: 1px dashed rgba(141, 85, 36, 0.12);
    pointer-events: none;
}

.hero-title {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
}

.kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--primary-dark);
    font-size: 0.8rem;
    font-weight: 700;
}

.hero-copy h2,
.hero-copy p,
.section-head h2,
.section-head p,
.metric h3,
.metric p,
.page-title h2,
.page-title p,
.empty-state h3,
.empty-state p {
    margin: 0;
}

.hero-copy {
    display: grid;
    gap: 0.65rem;
}

.hero-copy h2,
.page-title h2,
.section-head h2 {
    font-size: clamp(1.5rem, 4.8vw, 2.4rem);
    line-height: 1.1;
}

.hero-copy p,
.page-title p,
.section-head p,
.muted,
.table-note,
.empty-state p {
    color: var(--muted);
}

.metric-grid,
.admin-grid,
.delivery-grid,
.plan-grid,
.data-grid,
.form-grid,
.list-grid,
.settings-grid {
    display: grid;
    gap: 1rem;
}

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

.metric {
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(255,255,255,0.56));
    border: 1px solid rgba(141, 85, 36, 0.1);
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 0.55rem;
}

.grid-two,
.grid-three {
    display: grid;
    gap: 1rem;
}

.page-title,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.9rem;
}

.page-title {
    margin-bottom: 1rem;
}

.action-row,
.inline-actions,
.filter-row,
.button-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.button,
.ghost-button,
.chip-button,
.nav-button {
    min-height: 44px;
    padding: 0.78rem 1rem;
    border-radius: 999px;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button,
.nav-button.is-active {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    box-shadow: 0 12px 24px rgba(141, 85, 36, 0.28);
}

.ghost-button,
.nav-button,
.chip-button {
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    border: 1px solid rgba(141, 85, 36, 0.12);
}

.button:hover,
.ghost-button:hover,
.chip-button:hover,
.nav-button:hover {
    transform: translateY(-1px);
}

.button:disabled,
.ghost-button:disabled,
.chip-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.42rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(255,255,255,0.7);
}

.status-pill.active,
.status-pill.delivered,
.status-pill.paid {
    color: var(--accent-dark);
    background: rgba(76, 175, 80, 0.14);
}

.status-pill.pending,
.status-pill.on_way {
    color: var(--primary-dark);
    background: rgba(198, 134, 66, 0.15);
}

.status-pill.paused,
.status-pill.failed {
    color: var(--danger);
    background: rgba(216, 67, 21, 0.12);
}

label,
.field {
    display: grid;
    gap: 0.45rem;
}

.field span,
label span {
    font-weight: 700;
    font-size: 0.92rem;
}

input,
select,
textarea {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid rgba(141, 85, 36, 0.16);
    padding: 0.9rem 1rem;
    background: rgba(255,255,255,0.9);
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(198, 134, 66, 0.12);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.form-card {
    display: grid;
    gap: 1rem;
}

.list-stack {
    display: grid;
    gap: 0.8rem;
}

.list-item,
.data-row,
.delivery-card,
.subscription-card,
.notification-card,
.user-card {
    border: 1px solid rgba(141, 85, 36, 0.12);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.68);
    padding: 1rem;
}

.list-item-header,
.data-row,
.delivery-head,
.subscription-head,
.notification-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 0.8rem;
}

.tag,
.small-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.38rem 0.65rem;
    border-radius: 999px;
    background: rgba(245, 222, 179, 0.55);
    font-size: 0.8rem;
    color: var(--primary-dark);
}

.price-tag {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-dark);
}

.bottom-nav {
    position: sticky;
    bottom: 1rem;
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
    padding: 0.7rem;
    background: rgba(255, 248, 237, 0.92);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(141, 85, 36, 0.12);
    backdrop-filter: blur(16px);
    box-shadow: 0 20px 50px rgba(94, 60, 28, 0.18);
}

.nav-button {
    min-height: 58px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
}

.auth-shell {
    min-height: 100vh;
    width: min(100%, 1160px);
    margin: 0 auto;
    padding: 1rem;
    display: grid;
    gap: 1rem;
    align-items: center;
}

.auth-hero,
.auth-panel {
    padding: 1.25rem;
}

.auth-hero {
    position: relative;
    overflow: hidden;
}

.auth-hero::before,
.auth-hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    opacity: 0.25;
}

.auth-hero::before {
    width: 220px;
    height: 220px;
    background: linear-gradient(135deg, var(--primary), transparent);
    top: -70px;
    inset-inline-end: -50px;
}

.auth-hero::after {
    width: 170px;
    height: 170px;
    background: linear-gradient(135deg, var(--accent), transparent);
    bottom: -60px;
    inset-inline-start: -30px;
}

.auth-layout {
    display: grid;
    gap: 1rem;
}

.demo-list {
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

.demo-button {
    width: 100%;
    text-align: start;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,0.72);
    border: 1px solid rgba(141, 85, 36, 0.12);
}

.demo-button strong,
.demo-button span,
.demo-button small {
    display: block;
}

.notice,
.toast {
    border-radius: var(--radius-lg);
    padding: 0.95rem 1rem;
    border: 1px solid transparent;
}

.notice {
    margin-bottom: 1rem;
}

.notice.success,
.toast.success {
    background: rgba(76, 175, 80, 0.12);
    color: var(--accent-dark);
    border-color: rgba(76, 175, 80, 0.22);
}

.notice.error,
.toast.error {
    background: rgba(216, 67, 21, 0.12);
    color: var(--danger);
    border-color: rgba(216, 67, 21, 0.2);
}

.notice.info,
.toast.info {
    background: rgba(198, 134, 66, 0.14);
    color: var(--primary-dark);
    border-color: rgba(198, 134, 66, 0.22);
}

.toast-host {
    position: fixed;
    inset-inline: 1rem;
    bottom: 1rem;
    z-index: 40;
}

.progress-bar {
    height: 8px;
    border-radius: 999px;
    background: rgba(141, 85, 36, 0.08);
    overflow: hidden;
}

.progress-bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-dark), var(--accent));
}

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

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

.data-table th,
.data-table td {
    text-align: start;
    padding: 0.9rem 0.8rem;
    border-bottom: 1px solid rgba(141, 85, 36, 0.1);
}

.data-table th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.media-proof {
    width: 100%;
    max-width: 180px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(141, 85, 36, 0.12);
    margin-top: 0.8rem;
}

.empty-state {
    padding: 1.4rem;
    border-radius: var(--radius-lg);
    border: 1px dashed rgba(141, 85, 36, 0.18);
    background: rgba(255,255,255,0.42);
    text-align: center;
}

.auth-footnote,
.footnote {
    font-size: 0.86rem;
    color: var(--muted);
}

@media (min-width: 720px) {
    .auth-layout,
    .grid-two,
    .settings-grid,
    .form-grid,
    .metric-grid,
    .plan-grid,
    .delivery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero {
        grid-template-columns: 1.35fr 0.95fr;
    }

    .grid-three,
    .admin-grid,
    .data-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 980px) {
    .shell {
        padding: 1.1rem 1.4rem 6.5rem;
    }

    .topbar {
        padding-top: 1.3rem;
    }

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

    .bottom-nav {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .auth-shell {
        padding: 1.5rem;
    }

    .auth-layout {
        grid-template-columns: 1.15fr 0.85fr;
    }
}

@media (max-width: 719px) {
    .topbar,
    .hero-title,
    .page-title,
    .section-head,
    .list-item-header,
    .delivery-head,
    .subscription-head,
    .notification-head,
    .data-row {
        flex-direction: column;
    }

    .topbar-actions {
        justify-content: stretch;
    }

    .topbar-actions > * {
        width: 100%;
    }

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

/* ── Extra status pills ──────────────────────────────────── */
.status-pill.skipped {
    color: var(--muted);
    background: rgba(125, 107, 87, 0.12);
}

.status-pill.cancelled {
    color: var(--danger);
    background: rgba(216, 67, 21, 0.1);
}

/* ── Toast slide-in animation ────────────────────────────── */
@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.toast {
    animation: toast-in 220ms ease forwards;
    margin-bottom: 0.45rem;
    cursor: default;
}

/* ── Loading spinner ─────────────────────────────────────── */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(255, 249, 241, 0.82);
    display: grid;
    place-items: center;
    backdrop-filter: blur(6px);
}

.spinner {
    width: 46px;
    height: 46px;
    border: 4px solid rgba(198, 134, 66, 0.18);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Proof image full-width on mobile ────────────────────── */
.media-proof {
    margin-top: 0.65rem;
    border-radius: var(--radius-md);
    max-width: 240px;
    width: 100%;
    border: 1px solid rgba(141, 85, 36, 0.12);
}

/* ── Agent on-way card highlight ─────────────────────────── */
.status-pill.on_way {
    color: #5c4200;
    background: rgba(255, 193, 7, 0.18);
}

/* ── Fix select inside inline-actions ───────────────────── */
.inline-actions select {
    width: auto;
    min-width: 160px;
    border-radius: var(--radius-sm);
}

/* ── 3-column bottom nav on tablet ──────────────────────── */
@media (min-width: 540px) and (max-width: 719px) {
    .bottom-nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ── Bar chart (financial report) ────────────────────────── */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 100px;
    padding: 0.5rem 0 0.3rem;
    overflow-x: auto;
}
.bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 18px;
    gap: 2px;
}
.bar-fill {
    width: 100%;
    min-height: 4px;
    background: linear-gradient(to top, var(--primary), rgba(198,134,66,.55));
    border-radius: 3px 3px 0 0;
    transition: height 0.4s ease;
}
.bar-col:hover .bar-fill { background: var(--primary-dark); }
.bar-label {
    font-size: 0.65rem;
    color: var(--muted);
    white-space: nowrap;
}

/* ── Mini progress bar (quality control) ─────────────────── */
.mini-progress-wrap {
    height: 6px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
    width: 70px;
    display: inline-block;
    vertical-align: middle;
    margin-inline-end: 0.3rem;
}
.mini-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent-dark));
    border-radius: 999px;
}

/* ── Score badge (agent leaderboard) ─────────────────────── */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.88rem;
    border: 2px solid currentColor;
}

/* ── Avatar circle (profile page) ────────────────────────── */
.avatar-circle {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.4rem;
    box-shadow: 0 4px 16px rgba(198,134,66,.28);
}

/* ── Admin grid (12-link overview) ───────────────────────── */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.65rem;
}

/* ── Toggle row (notification prefs) ─────────────────────── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    cursor: pointer;
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ── Notice variants ─────────────────────────────────────── */
.notice {
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin: 0.4rem 0;
}
.notice.success { background: rgba(0,128,0,.1);        color: #2d7a2d;             border: 1px solid rgba(0,128,0,.25); }
.notice.error   { background: rgba(216,67,21,.1);       color: var(--danger);       border: 1px solid rgba(216,67,21,.25); }
.notice.info    { background: rgba(198,134,66,.1);      color: var(--primary-dark); border: 1px solid rgba(198,134,66,.25); }

/* ── Responsive: admin grid on narrow screens ────────────── */
@media (max-width: 480px) {
    .admin-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .bar-chart { height: 80px; }
    .score-badge { width: 34px; height: 34px; font-size: 0.78rem; }
}