:root {
    color-scheme: light;
    --bg: #f3f0e8;
    --bg-2: #ebe6da;
    --surface: rgba(255, 252, 244, 0.82);
    --surface-solid: #fffcf4;
    --surface-muted: #f7f1e5;
    --ink: #181713;
    --ink-muted: #6d675c;
    --ink-soft: #9a9182;
    --line: rgba(31, 29, 24, 0.11);
    --line-strong: rgba(31, 29, 24, 0.18);
    --accent: #0f8f6f;
    --accent-dark: #096a53;
    --accent-soft: #d8f1e8;
    --danger: #b3402c;
    --danger-soft: #ffe1d9;
    --warning: #9a6a00;
    --warning-soft: #fff0bf;
    --shadow: 0 24px 70px rgba(43, 37, 25, 0.12);
    --shadow-soft: 0 12px 34px rgba(43, 37, 25, 0.08);
    --shadow-card: 0 18px 42px rgba(43, 37, 25, 0.075);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 15px;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --sans: "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--sans);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    background:
        radial-gradient(circle at 12% -10%, rgba(15, 143, 111, 0.18), transparent 34rem),
        radial-gradient(circle at 88% 10%, rgba(189, 124, 43, 0.13), transparent 31rem),
        linear-gradient(135deg, var(--bg), var(--bg-2));
    font-variant-numeric: tabular-nums;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.42;
    background-image:
        linear-gradient(rgba(24, 23, 19, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(24, 23, 19, 0.025) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(to bottom, black, transparent 80%);
}

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

a { color: inherit; }

/* Legacy mobile auth templates kept functional */
.phone-screen { width: min(100vw, 430px); min-height: 100vh; background: var(--surface-solid); overflow: hidden; box-shadow: var(--shadow); }
.hero { min-height: 170px; padding: 16px 20px 0; background: var(--accent); color: white; }
.status-bar { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.status-icons { font-size: 11px; opacity: .86; }
h1 { margin: 34px 0 0; font-size: clamp(36px, 7vw, 58px); line-height: .98; letter-spacing: -0.045em; text-wrap: balance; }
.panel { min-height: calc(100% - 170px); background: var(--surface-solid); border-radius: 36px 36px 0 0; padding: 24px 20px 32px; }

/* Login */
.login-body { display: grid; place-items: center; padding: 28px; }
.login-shell { width: min(100%, 1080px); display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 20px; align-items: stretch; }
.login-brief, .login-card { border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.login-brief { min-height: 560px; padding: clamp(30px, 5vw, 56px); border-radius: 38px; background: linear-gradient(145deg, #17231f, #0d3a2e); color: #fffaf0; display: flex; flex-direction: column; justify-content: flex-end; position: relative; overflow: hidden; }
.login-brief::before { content: ""; position: absolute; inset: 24px; border: 1px solid rgba(255,255,255,.12); border-radius: 28px; }
.login-brief .brand-mark { position: absolute; top: 42px; left: 42px; }
.login-brief h1 { margin: 16px 0; max-width: 12ch; font-size: clamp(48px, 7vw, 86px); }
.login-brief p:not(.eyebrow) { max-width: 56ch; color: rgba(255,250,240,.72); font-size: 17px; line-height: 1.7; }
.login-card { align-self: center; padding: clamp(26px, 4vw, 42px); border-radius: 30px; background: var(--surface); }
.login-heading h2 { margin: 0; font-size: 30px; letter-spacing: -0.04em; }
.login-heading p { margin: 8px 0 22px; color: var(--ink-muted); line-height: 1.55; }

/* App shell */
.app-body { display: block; }
.app-chrome { width: min(100% - 28px, 1480px); margin: 14px auto 52px; }
.topbar { position: sticky; top: 14px; z-index: 20; display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; min-height: 76px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 26px; background: rgba(255, 252, 244, 0.78); backdrop-filter: blur(20px); box-shadow: var(--shadow-soft); }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; min-width: max-content; }
.brand-mark { width: 46px; height: 46px; display: inline-grid; place-items: center; border-radius: 15px; background: #17231f; color: #fffaf0; font-weight: 800; letter-spacing: -0.08em; text-transform: lowercase; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 15px; letter-spacing: -0.02em; }
.brand-copy small { color: var(--ink-muted); font-size: 12px; font-weight: 600; }
.topnav { justify-self: center; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; justify-content: center; }
.nav-link, .utility-link { text-decoration: none; color: var(--ink-muted); font-size: 13px; font-weight: 760; border-radius: 999px; transition: color .2s ease, background .2s ease, transform .2s ease; }
.nav-link { padding: 10px 12px; letter-spacing: -0.01em; }
.nav-link:hover, .utility-link:hover { color: var(--ink); background: rgba(24,23,19,.055); }
.nav-link.active { color: #fffaf0; background: #17231f; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.utility-link { padding: 9px 10px; }
.content-shell { padding: 42px clamp(4px, 2vw, 18px) 0; }
.page-hero { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin: 0 auto 24px; }
.page-hero h1 { margin: 0; color: var(--ink); font-size: clamp(42px, 5.4vw, 74px); max-width: 980px; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.header-actions form, .topbar-actions form { margin: 0; }
.eyebrow { margin: 0 0 10px; color: var(--accent-dark); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

/* Components */
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-grid.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-grid.three-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-grid.four-cols { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card, .panel-card { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-soft); backdrop-filter: blur(18px); }
.metric-card { min-height: 154px; padding: 22px; border-radius: 24px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 120px; height: 120px; right: -60px; top: -60px; border-radius: 50%; background: rgba(15,143,111,.08); }
.metric-card strong { display: block; margin: 12px 0 8px; font-family: var(--mono); font-size: clamp(30px, 3.4vw, 46px); line-height: 1; letter-spacing: -0.045em; }
.metric-card .metric-word { font-family: var(--sans); font-size: 27px; letter-spacing: -0.04em; }
.metric-card p, .panel-card p, .data-table small { color: var(--ink-muted); line-height: 1.55; }
.metric-card.muted { background: rgba(247, 241, 229, 0.72); }
.metric-label { color: var(--ink-muted); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .105em; }
.panel-card { padding: clamp(18px, 2.5vw, 28px); border-radius: var(--radius-xl); margin-bottom: 16px; }
.narrow-card { max-width: 760px; }
.section-title-row, .table-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
h2 { margin: 0 0 5px; font-size: 24px; letter-spacing: -0.032em; }

/* Forms */
.form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--line); outline: none; border-radius: 15px; background: rgba(255,255,255,.56); padding: 12px 14px; color: var(--ink); transition: border .2s ease, box-shadow .2s ease, background .2s ease; }
input, select { min-height: 46px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: rgba(15,143,111,.55); box-shadow: 0 0 0 4px rgba(15,143,111,.12); background: #fffdf7; }
input::placeholder, textarea::placeholder { color: var(--ink-soft); }
.form-actions, .filter-row, .export-grid { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.filter-form { display: grid; grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(150px, 1fr)) auto; gap: 10px; margin-bottom: 18px; }
.dashboard-filter-form { grid-template-columns: repeat(3, minmax(150px, 1fr)) repeat(2, minmax(140px, 1fr)) auto; margin-bottom: 0; }
.credential-box { display: grid; gap: 12px; margin: 8px 0; padding: 18px; border: 1px dashed var(--line-strong); border-radius: 20px; background: rgba(247,241,229,.58); }
.credential-box h2, .credential-box p { margin: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; text-decoration: none; font-weight: 800; letter-spacing: -0.02em; cursor: pointer; transition: transform .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary { background: var(--accent); color: #fffaf0; box-shadow: 0 10px 24px rgba(15,143,111,.2); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: rgba(24,23,19,.07); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-small { min-height: 38px; padding-inline: 13px; font-size: 13px; }
.text-btn, .table-link, .table-actions a { color: var(--accent-dark); font-weight: 800; text-decoration: none; }
.text-btn:hover, .table-link:hover, .table-actions a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 20px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th, .data-table td { padding: 14px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { color: var(--ink-muted); font-size: 11px; letter-spacing: .11em; text-transform: uppercase; white-space: nowrap; }
.data-table td { font-size: 14px; }
.data-table tbody tr { transition: background .18s ease; }
.data-table tbody tr:hover { background: rgba(255,255,255,.38); }
.data-table small { display: block; margin-top: 4px; font-size: 12px; }
.table-actions { display: flex; gap: 12px; justify-content: flex-end; }
.empty-state { color: var(--ink-muted); text-align: center !important; padding: 30px !important; }

/* Status */
.status-pill, .chip { display: inline-flex; align-items: center; border-radius: 999px; font-weight: 800; }
.status-pill { padding: 6px 10px; font-size: 12px; }
.chip { padding: 8px 12px; background: rgba(24,23,19,.06); color: var(--ink-muted); text-decoration: none; font-size: 13px; }
.chip.active, .chip:hover { background: #17231f; color: #fffaf0; }
.status-active, .status-connected, .status-success, .status-info { background: var(--accent-soft); color: var(--accent-dark); }
.status-inactive, .status-archived, .status-untested, .status-not_configured, .status-paused, .status-idle { background: var(--warning-soft); color: var(--warning); }
.status-failed, .status-disconnected, .status-critical, .status-danger { background: var(--danger-soft); color: var(--danger); }
.status-warning { background: var(--warning-soft); color: var(--warning); }
.growth-text { color: var(--accent-dark) !important; font-weight: 800; }
.growth-text.negative { color: var(--danger) !important; }

/* Charts and detail */
.bar-chart { display: flex; align-items: end; gap: 10px; min-height: 240px; overflow-x: auto; padding: 12px 4px 0; }
.bar-item { display: grid; align-items: end; justify-items: center; gap: 8px; min-width: 44px; height: 220px; }
.bar-track { position: relative; width: 34px; height: 170px; border-radius: 999px; background: rgba(24,23,19,.06); overflow: hidden; }
.bar-track span { position: absolute; left: 0; right: 0; bottom: 0; min-height: 3px; border-radius: 999px 999px 0 0; background: linear-gradient(180deg, #1f9f7e, #0b614e); }
.bar-item small { color: var(--ink-muted); font-size: 11px; font-weight: 800; white-space: nowrap; writing-mode: vertical-rl; rotate: 180deg; }
.detail-list { display: grid; margin: 0; }
.detail-list div { display: grid; grid-template-columns: 190px 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.detail-list dt { color: var(--ink-muted); font-weight: 800; }
.detail-list dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.live-feed { display: grid; gap: 10px; }
.live-order { display: grid; grid-template-columns: 220px 1fr 1fr 120px; gap: 12px; align-items: center; padding: 14px; border-radius: 16px; background: rgba(255,255,255,.42); border: 1px solid var(--line); }

/* Flash */
.flash-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.flash { border-radius: 16px; padding: 12px 14px; font-weight: 800; border: 1px solid transparent; }
.flash-success { background: var(--accent-soft); color: var(--accent-dark); border-color: rgba(15,143,111,.18); }
.flash-error, .flash-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(179,64,44,.16); }
.flash-warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(154,106,0,.16); }

/* Legacy utility bits */
.password-row { position: relative; }
.password-row input { padding-right: 52px; }
.password-row span { position: absolute; right: 16px; top: 50%; translate: 0 -50%; color: var(--ink-muted); }
.fingerprint-link, .meta-link, .tiny-label, .helper-text, .centered { text-align: center; }
.social-row, .pin-row { display: flex; justify-content: center; gap: 14px; }
.social, .pin-digit { display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--line-strong); }
.social { width: 38px; height: 38px; }
.pin-digit { width: 42px; height: 42px; font-weight: 800; }
.body-copy { color: var(--ink-muted); }

@media (max-width: 1180px) {
    .topbar { grid-template-columns: 1fr; align-items: start; }
    .topnav { justify-self: stretch; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .topbar-actions { justify-content: space-between; }
    .metric-grid, .metric-grid.four-cols, .dashboard-filter-form, .filter-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
    .app-chrome { width: min(100% - 16px, 1480px); margin-top: 8px; }
    .content-shell { padding-top: 28px; }
    .page-hero, .section-title-row, .table-toolbar { flex-direction: column; align-items: stretch; }
    .page-hero h1 { font-size: 44px; }
    .login-shell { grid-template-columns: 1fr; }
    .login-brief { min-height: 360px; }
    .metric-grid, .metric-grid.two-cols, .metric-grid.three-cols, .metric-grid.four-cols, .dashboard-filter-form, .filter-form, .detail-list div, .live-order { grid-template-columns: 1fr; }
    .brand-copy { display: none; }
    .panel-card { border-radius: 22px; }
}

.dashboard-filters .filter-hint {
    margin: 12px 2px 0;
    color: var(--ink-muted);
    font-size: 13px;
    font-weight: 650;
}

.dashboard-filters:not(.is-custom) .custom-date,
.dashboard-filters:not(.is-custom) .custom-apply {
    display: none;
}

.dashboard-filters:not(.is-custom) .dashboard-filter-form {
    grid-template-columns: minmax(180px, .8fr) minmax(190px, 1fr) minmax(190px, 1fr);
    max-width: 980px;
}

.dashboard-filters.is-custom .dashboard-filter-form {
    grid-template-columns: minmax(160px, .8fr) minmax(170px, .9fr) minmax(170px, .9fr) minmax(145px, .8fr) minmax(145px, .8fr) auto;
}

@media (max-width: 1180px) {
    .dashboard-filters:not(.is-custom) .dashboard-filter-form,
    .dashboard-filters.is-custom .dashboard-filter-form {
        grid-template-columns: 1fr 1fr;
        max-width: none;
    }
}

@media (max-width: 760px) {
    .dashboard-filters:not(.is-custom) .dashboard-filter-form,
    .dashboard-filters.is-custom .dashboard-filter-form {
        grid-template-columns: 1fr;
    }
}

.orders-table {
    min-width: 1080px;
}

.product-summary {
    max-width: 460px;
    color: var(--ink-muted);
    line-height: 1.45;
}

.order-items {
    display: grid;
    gap: 14px;
}

.order-item-card {
    display: grid;
    grid-template-columns: 112px 1fr;
    gap: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255,255,255,.38);
}

.order-item-card img,
.item-image-placeholder {
    width: 112px;
    height: 112px;
    border-radius: 18px;
    object-fit: cover;
    background: rgba(24,23,19,.06);
}

.item-image-placeholder {
    display: grid;
    place-items: center;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 800;
}

.order-item-card h3 {
    margin: 2px 0 6px;
    font-size: 19px;
    letter-spacing: -0.03em;
    text-wrap: pretty;
}

.order-item-card p {
    margin: 0 0 12px;
}

.order-item-card dl {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.order-item-card dt {
    color: var(--ink-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.order-item-card dd {
    margin: 3px 0 0;
    font-family: var(--mono);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.live-order {
    color: inherit;
    text-decoration: none;
}

.live-order small {
    display: block;
    color: var(--ink-muted);
    margin-top: 3px;
}

@media (max-width: 760px) {
    .order-item-card,
    .order-item-card dl {
        grid-template-columns: 1fr;
    }
}

.analytics-table {
    min-width: 1120px;
}

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

.funnel-card {
    overflow: hidden;
}

.funnel-card.is-muted {
    opacity: .72;
}

.funnel-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.funnel-head h2 {
    margin: 6px 0 0;
    font-size: clamp(25px, 2.5vw, 34px);
    line-height: .98;
    letter-spacing: -0.045em;
}

.funnel-head p {
    margin: 7px 0 0;
    font-size: 14px;
    font-weight: 650;
}

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

.conversion-summary strong {
    display: block;
    margin-top: 4px;
    font-family: var(--mono);
    font-size: 50px;
    line-height: 1;
    letter-spacing: -0.08em;
}

.summary-pairs {
    display: grid;
    gap: 6px;
    color: var(--ink-muted);
    font-family: var(--mono);
    font-size: 12px;
    text-align: right;
}

.funnel-viz {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 72px 1fr 72px 1fr 72px 1fr;
    gap: 0;
    align-items: end;
    min-height: 280px;
    padding: 18px 4px 0;
}

.funnel-shade {
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 54px;
    height: 170px;
    background: linear-gradient(100deg, rgba(246, 188, 54, .15), rgba(24, 23, 19, .035));
    clip-path: polygon(0 8%, 36% 38%, 68% 45%, 100% 72%, 100% 100%, 0 100%);
    pointer-events: none;
}

.funnel-stage {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    gap: 10px;
}

.funnel-bar-wrap {
    display: flex;
    align-items: end;
    height: 190px;
    width: 100%;
    justify-content: center;
    border-bottom: 2px solid var(--line-strong);
}

.funnel-bar {
    position: relative;
    width: min(58px, 68%);
    min-height: 6px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    border-radius: 9px 9px 3px 3px;
    background: linear-gradient(180deg, #f7c74b, #efad2f);
    box-shadow: 0 14px 24px rgba(239, 173, 47, .2);
}

.funnel-bar b {
    position: absolute;
    top: -25px;
    color: #6f4a12;
    font-family: var(--mono);
    font-size: 14px;
}

.funnel-stage span {
    min-height: 40px;
    color: var(--ink-muted);
    font-size: 12px;
    font-weight: 850;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: .035em;
}

.funnel-rate {
    position: relative;
    z-index: 2;
    align-self: center;
    margin-bottom: 44px;
    height: 34px;
    display: grid;
    place-items: center;
}

.funnel-rate span {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-width: 68px;
    height: 30px;
    padding: 0 12px;
    background: #ffe4a5;
    border: 1px solid #f3c35e;
    color: #7c5516;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 800;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
}

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

@media (max-width: 760px) {
    .conversion-summary {
        flex-direction: column;
        align-items: flex-start;
    }
    .summary-pairs {
        text-align: left;
    }
    .funnel-viz {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    .funnel-rate,
    .funnel-shade {
        display: none;
    }
}

.dashboard-main-grid {
    display: grid;
    grid-template-columns: minmax(420px, .9fr) minmax(560px, 1.1fr);
    gap: 16px;
    align-items: start;
}

.dashboard-main-grid > .panel-card {
    min-width: 0;
}

.compact-chart {
    min-height: 330px;
}

.dashboard-funnel-panel .funnel-grid {
    grid-template-columns: 1fr;
    margin-bottom: 0;
}

.dashboard-funnel-panel .funnel-card {
    box-shadow: none;
    background: rgba(255,255,255,.36);
}

.dashboard-funnel-panel .funnel-viz {
    min-height: 240px;
}

.dashboard-funnel-panel .funnel-bar-wrap {
    height: 160px;
}

.dashboard-funnel-panel .conversion-summary strong {
    font-size: 44px;
}

@media (max-width: 1280px) {
    .dashboard-main-grid {
        grid-template-columns: 1fr;
    }
}

.team-chip {
    display: inline-flex;
    width: fit-content;
    margin: 0 !important;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(24,23,19,.06);
    color: var(--ink-muted) !important;
    font-size: 12px;
    font-weight: 850;
}

.funnel-scoreboard {
    display: grid;
    grid-template-columns: 1.1fr .75fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.score-block {
    padding: 15px;
    border-radius: 20px;
    background: rgba(255,255,255,.46);
    border: 1px solid var(--line);
}

.score-block strong {
    display: block;
    margin: 7px 0 4px;
    font-family: var(--mono);
    font-size: 28px;
    line-height: 1;
    letter-spacing: -0.035em;
}

.primary-score strong,
.conversion-score strong {
    font-size: clamp(32px, 3vw, 40px);
}

.score-block small {
    color: var(--ink-muted);
    font-weight: 750;
}

.inline-pairs {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 16px;
    text-align: right;
}

.inline-pairs span {
    padding: 6px 9px;
    border-radius: 999px;
    background: #ffe4a5;
    color: #7c5516;
}

@media (max-width: 760px) {
    .funnel-scoreboard {
        grid-template-columns: 1fr;
    }
    .inline-pairs {
        justify-content: flex-start;
        text-align: left;
    }
}

/* Team grouped dashboard funnel */
.team-funnel-stack {
    display: grid;
    gap: 18px;
}

.team-lane {
    position: relative;
    padding: 18px;
    border: 1px solid color-mix(in srgb, var(--team-color) 28%, transparent);
    border-left: 7px solid var(--team-color);
    border-radius: 32px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--team-soft) 50%, transparent), rgba(255,252,244,.5));
    box-shadow: var(--shadow-card);
}

.team-lane-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}

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

.team-title-wrap h2 {
    margin: 1px 0 0;
    color: var(--team-ink);
    font-size: clamp(30px, 3vw, 42px);
    line-height: .95;
    letter-spacing: -0.045em;
}

.team-dot {
    width: 18px;
    height: 52px;
    border-radius: 999px;
    background: var(--team-color);
    box-shadow: 0 10px 24px color-mix(in srgb, var(--team-color) 28%, transparent);
}

.team-lane-metrics {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.team-lane-metrics span {
    min-width: 98px;
    padding: 10px 12px;
    border-radius: 18px;
    background: rgba(255,255,255,.58);
    border: 1px solid color-mix(in srgb, var(--team-color) 16%, transparent);
}

.team-lane-metrics b,
.team-lane-metrics small {
    display: block;
}

.team-lane-metrics b {
    color: var(--team-ink);
    font-family: var(--mono);
    font-size: 17px;
    letter-spacing: -0.025em;
}

.team-lane-metrics small {
    margin-top: 2px;
    color: var(--ink-muted);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.team-lane .funnel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 0;
}

.team-lane .funnel-card {
    border-top: 5px solid var(--team-color);
    background:
        radial-gradient(circle at 92% 8%, color-mix(in srgb, var(--team-soft) 66%, transparent), transparent 12rem),
        rgba(255,252,244,.8);
    box-shadow: 0 14px 32px rgba(43, 37, 25, 0.06);
}

.shop-name-highlight {
    display: inline;
    padding: 0 .1em;
    border-radius: 10px;
    background: linear-gradient(to top, color-mix(in srgb, var(--team-color) 22%, transparent) 40%, transparent 40%);
    color: var(--ink);
}

.team-chip {
    background: var(--team-soft) !important;
    color: var(--team-ink) !important;
    border: 1px solid color-mix(in srgb, var(--team-color) 24%, transparent);
}

.score-block {
    border-color: color-mix(in srgb, var(--team-color) 13%, var(--line));
}

.primary-score strong,
.conversion-score strong,
.score-block strong {
    color: var(--team-ink);
}

.inline-pairs span,
.funnel-rate span {
    background: color-mix(in srgb, var(--team-soft) 78%, #fff7df);
    border-color: color-mix(in srgb, var(--team-color) 34%, #f3c35e);
    color: var(--team-ink);
}

.funnel-bar {
    background: linear-gradient(180deg, color-mix(in srgb, var(--team-color) 70%, #ffd95a), var(--team-color));
    box-shadow: 0 14px 24px color-mix(in srgb, var(--team-color) 22%, transparent);
}

.funnel-bar b {
    color: var(--team-ink);
}

.funnel-shade {
    background: linear-gradient(100deg, color-mix(in srgb, var(--team-soft) 62%, transparent), rgba(24, 23, 19, .035));
}

.failed-card-body {
    display: grid;
    grid-template-columns: minmax(210px, .45fr) 1fr;
    gap: 12px;
    align-items: stretch;
}

.failed-card-body .empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    margin: 0;
    border-radius: 20px;
    background: rgba(255,255,255,.44);
}

@media (max-width: 1180px) {
    .team-lane .funnel-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .team-lane-head,
    .failed-card-body {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }
    .team-lane-metrics {
        justify-content: flex-start;
    }
}

.card-status-stack {
    display: grid;
    justify-items: end;
    gap: 7px;
}

.sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.sync-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
}

.sync-fresh {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.sync-stale {
    background: var(--warning-soft);
    color: var(--warning);
}

.sync-note {
    display: block;
    margin-top: 6px;
    color: var(--ink-muted);
    font-style: normal;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
}

.sync-note.is-stale {
    color: var(--warning);
}

@media (max-width: 760px) {
    .card-status-stack {
        justify-items: start;
    }
}

.sync-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    max-width: 100%;
    margin-bottom: 12px;
    padding: 9px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,.48);
    border: 1px solid var(--line);
    color: var(--ink-muted);
}

.sync-strip strong {
    color: var(--ink);
    font-size: 13px;
}

.sync-strip small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 750;
}

.sync-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 5px rgba(15,143,111,.1);
}

.sync-strip.is-running .sync-dot {
    animation: syncPulse 1s ease-in-out infinite;
}

.sync-strip.is-error .sync-dot {
    background: var(--danger);
    box-shadow: 0 0 0 5px rgba(179,64,44,.1);
}

@keyframes syncPulse {
    0%, 100% { transform: scale(1); opacity: .65; }
    50% { transform: scale(1.45); opacity: 1; }
}

/* Taste pass: typography polish and visual hierarchy */
.data-table td,
.data-table th,
.filter-hint,
.sync-strip small {
    letter-spacing: -0.005em;
}

.metric-card,
.panel-card {
    box-shadow: var(--shadow-card);
}

.dashboard-funnel-panel {
    padding: clamp(16px, 2vw, 24px);
}

.dashboard-funnel-panel > .section-title-row h2 {
    font-size: clamp(28px, 3vw, 40px);
    line-height: 1;
    letter-spacing: -0.045em;
}

.dashboard-funnel-panel > .section-title-row p {
    max-width: 760px;
    font-size: 14px;
}

.funnel-card.panel-card {
    padding: clamp(20px, 2.2vw, 28px);
}

.status-pill {
    letter-spacing: -0.01em;
}

.score-block .metric-label,
.team-lane-metrics small {
    color: color-mix(in srgb, var(--team-ink) 55%, var(--ink-muted));
}

.inline-pairs span {
    font-size: 12px;
    font-weight: 850;
    letter-spacing: -0.015em;
}

.funnel-rate span {
    justify-content: center;
    font-weight: 850;
    letter-spacing: -0.02em;
}

.funnel-bar {
    border-radius: 11px 11px 4px 4px;
}

.funnel-bar b {
    font-size: 13px;
    letter-spacing: -0.02em;
}

@media (max-width: 760px) {
    .page-hero h1 {
        font-size: 42px;
    }
    .team-lane {
        padding: 14px;
    }
    .funnel-card.panel-card {
        padding: 18px;
    }
}

/* Mobile UX pass */
@media (max-width: 760px) {
    body::before {
        opacity: .24;
        background-size: 26px 26px;
    }

    .app-chrome {
        width: min(100% - 10px, 1480px);
        margin: 5px auto 28px;
    }

    .topbar {
        top: 5px;
        gap: 10px;
        min-height: 0;
        padding: 9px;
        border-radius: 20px;
    }

    .brand-mark {
        width: 40px;
        height: 40px;
        border-radius: 13px;
    }

    .topnav {
        margin: 0 -4px;
        padding: 2px 4px 7px;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
    }

    .topnav::-webkit-scrollbar {
        display: none;
    }

    .nav-link {
        flex: 0 0 auto;
        padding: 9px 11px;
        scroll-snap-align: start;
    }

    .topbar-actions {
        gap: 8px;
    }

    .content-shell {
        padding: 22px 0 0;
    }

    .page-hero {
        margin-bottom: 14px;
    }

    .page-hero h1 {
        font-size: 38px;
        line-height: .96;
    }

    .eyebrow {
        margin-bottom: 7px;
        font-size: 11px;
    }

    .panel-card,
    .metric-card {
        border-radius: 20px;
    }

    .dashboard-filters {
        padding: 13px;
    }

    .sync-strip {
        width: 100%;
        align-items: flex-start;
        border-radius: 16px;
    }

    .sync-strip small {
        white-space: normal;
        line-height: 1.35;
    }

    .metric-grid.four-cols {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .metric-card {
        min-height: 126px;
        padding: 15px;
    }

    .metric-card strong {
        font-size: clamp(26px, 8vw, 34px);
        letter-spacing: -0.035em;
    }

    .metric-card p {
        margin: 0;
        font-size: 12px;
        line-height: 1.35;
    }

    .dashboard-funnel-panel {
        padding: 12px;
    }

    .dashboard-funnel-panel > .section-title-row {
        margin-bottom: 12px;
    }

    .dashboard-funnel-panel > .section-title-row h2 {
        font-size: 28px;
    }

    .team-funnel-stack {
        gap: 14px;
    }

    .team-lane {
        padding: 12px;
        border-left-width: 1px;
        border-top: 6px solid var(--team-color);
        border-radius: 24px;
    }

    .team-lane-head {
        gap: 12px;
        margin-bottom: 12px;
    }

    .team-title-wrap {
        align-items: flex-start;
        gap: 10px;
    }

    .team-dot {
        width: 11px;
        height: 42px;
    }

    .team-title-wrap h2 {
        font-size: 31px;
    }

    .team-lane-metrics {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .team-lane-metrics span {
        min-width: 0;
        padding: 9px 10px;
        border-radius: 15px;
    }

    .team-lane-metrics b {
        font-size: 14px;
    }

    .team-lane-metrics small {
        font-size: 10px;
    }

    .team-lane .funnel-grid {
        gap: 12px;
    }

    .funnel-card.panel-card {
        padding: 15px;
        border-radius: 22px;
    }

    .funnel-head {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 10px;
        margin-bottom: 14px;
    }

    .funnel-head h2 {
        font-size: 28px;
    }

    .funnel-head p:not(.team-chip) {
        max-width: 100%;
        font-size: 12px;
        overflow-wrap: anywhere;
    }

    .team-chip,
    .status-pill,
    .sync-badge {
        font-size: 10px;
        padding: 5px 8px;
    }

    .card-status-stack {
        justify-items: end;
    }

    .funnel-scoreboard {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .funnel-scoreboard .primary-score {
        grid-column: 1 / -1;
    }

    .score-block {
        padding: 11px;
        border-radius: 16px;
    }

    .score-block strong {
        font-size: 25px;
    }

    .primary-score strong,
    .conversion-score strong {
        font-size: 31px;
    }

    .score-block small,
    .sync-note {
        font-size: 11px;
    }

    .inline-pairs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        margin-bottom: 10px;
    }

    .inline-pairs span {
        justify-content: center;
        padding: 6px 5px;
        font-size: 10.5px;
        white-space: nowrap;
    }

    .funnel-viz {
        grid-template-columns: repeat(4, minmax(60px, 1fr));
        min-height: 174px;
        padding-top: 8px;
        gap: 6px;
    }

    .dashboard-funnel-panel .funnel-viz {
        min-height: 174px;
    }

    .funnel-bar-wrap,
    .dashboard-funnel-panel .funnel-bar-wrap {
        height: 108px;
    }

    .funnel-bar {
        width: min(42px, 66%);
    }

    .funnel-bar b {
        top: -21px;
        font-size: 12px;
    }

    .funnel-stage {
        gap: 7px;
    }

    .funnel-stage span {
        min-height: 34px;
        font-size: 10px;
        line-height: 1.2;
        letter-spacing: .01em;
    }

    .failed-card-body {
        gap: 8px;
    }
}

@media (max-width: 420px) {
    .metric-grid.four-cols,
    .team-lane-metrics {
        grid-template-columns: 1fr;
    }

    .inline-pairs {
        grid-template-columns: 1fr;
    }

    .funnel-head {
        grid-template-columns: 1fr;
    }

    .card-status-stack {
        justify-items: start;
        display: flex;
        flex-wrap: wrap;
    }
}
