:root {
    color-scheme: light;
    --bg: #f7f8fb;
    --panel: #ffffff;
    --panel-soft: #f1f5f9;
    --text: #18202f;
    --muted: #677084;
    --line: #e3e7ee;
    --track: #e2e8f0;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --success: #0f9f6e;
    --danger: #d64545;
    --warning: #c47a00;
    --shadow: 0 14px 36px rgba(24, 32, 47, 0.08);
    --chart-tick: #64748b;
    --chart-grid: rgba(148, 163, 184, 0.28);
}

html[data-theme="light"] {
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1218;
    --panel: #171b24;
    --panel-soft: #222833;
    --text: #f3f6fb;
    --muted: #c5cddc;
    --line: #343b4a;
    --track: #2c3342;
    --primary: #7eb6ff;
    --primary-strong: #9ec7ff;
    --shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
    --chart-tick: #e8edf5;
    --chart-grid: rgba(215, 222, 234, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
    font-feature-settings: "tnum" 1, "lnum" 1;
    font-variant-numeric: tabular-nums lining-nums;
}

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

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

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    background: var(--panel);
    border-right: 1px solid var(--line);
}

.brand,
.sidebar-head,
.nav a,
.topbar,
.topbar-start,
.panel-head,
.topbar-actions {
    display: flex;
    align-items: center;
}

.brand {
    gap: 10px;
    font-weight: 800;
}

.sidebar-head {
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    margin-bottom: 34px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #0f9f6e);
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a {
    min-height: 42px;
    padding: 0 12px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 650;
}

.nav a.active,
.nav a:hover {
    color: var(--text);
    background: var(--panel-soft);
}

.store-analytics-note {
    max-width: 720px;
    margin: 8px 0 0;
    line-height: 1.6;
}

.store-status.is-empty {
    border-color: rgba(196, 122, 0, .35);
}

.store-status-compact {
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 16px;
    min-height: 0;
    padding: 14px 18px;
    margin-bottom: 14px;
}

.store-status-compact .store-status-heading,
.store-status-compact .store-status-summary {
    min-width: 0;
}

.store-status-compact .store-status-heading h2 {
    margin: 0;
    font-size: 24px;
}

.store-status-summary {
    display: flex;
    align-items: center;
    gap: 9px;
}

.store-status-summary p {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.store-status-indicator {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(15, 159, 110, .12);
}

.store-status[data-state="loading"] .store-status-indicator {
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.store-status[data-state="error"] .store-status-indicator {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(214, 69, 69, .12);
}

.store-status[data-state="partial"] .store-status-indicator,
.store-status[data-state="empty"] .store-status-indicator {
    background: var(--warning);
    box-shadow: 0 0 0 4px rgba(196, 122, 0, .12);
}

.store-status[data-state="error"] {
    border-color: rgba(190, 45, 45, .5);
}

.store-status[data-state="partial"] {
    border-color: rgba(196, 122, 0, .5);
}

.store-lifecycle {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin: 18px 0 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.store-lifecycle-step {
    position: relative;
    display: grid;
    flex: 1 1 0;
    gap: 6px;
    min-width: 145px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background:
        linear-gradient(135deg, rgba(126, 182, 255, .14), rgba(15, 159, 110, .05)),
        var(--panel);
    box-shadow: var(--shadow);
}

.store-lifecycle-step.no-data {
    background: var(--panel);
    opacity: .72;
}

.store-lifecycle-index {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(126, 182, 255, .16);
    color: #9fc8ff;
    font-weight: 850;
    font-size: 13px;
}

.store-lifecycle-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.store-lifecycle-step strong {
    color: var(--text);
    font-size: clamp(22px, 3vw, 30px);
    line-height: 1.1;
}

.store-lifecycle-step small {
    color: var(--muted);
}

.store-lifecycle-arrow {
    display: grid;
    place-items: center;
    min-width: 14px;
    color: var(--muted);
    font-weight: 900;
}

.store-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 0 16px;
}

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

.store-story-card {
    min-height: 360px;
}

.store-story-card canvas,
.store-chart-grid canvas {
    min-height: 270px;
}

.chart-empty {
    display: grid;
    place-items: center;
    min-height: 220px;
    border: 1px dashed var(--line);
    border-radius: 10px;
    color: var(--muted);
    text-align: center;
    padding: 18px;
}

.chart-empty[hidden] {
    display: none;
}

.chart-data-details {
    margin-top: 12px;
    color: var(--muted);
    font-size: 12px;
}

.chart-data-details summary {
    cursor: pointer;
    font-weight: 750;
}

.chart-data-table {
    width: 100%;
    margin-top: 8px;
    border-collapse: collapse;
}

.chart-data-table th,
.chart-data-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
}

.chart-data-table th:first-child,
.chart-data-table td:first-child {
    text-align: left;
}

.store-kpi-grid {
    margin-top: 4px;
}

.store-analytics .metric-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.store-analytics .metric-card .metric-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
}

.store-analytics .metric-card strong {
    font-size: clamp(24px, 3.3vw, 34px);
    line-height: 1.1;
}

.store-analytics .metric-card small {
    color: var(--muted);
}

.store-analytics .store-kpi-all-time {
    display: block;
    margin-top: 3px;
    color: var(--text);
    font-size: 12px;
    font-weight: 750;
}

.store-analytics .store-kpi-period {
    display: block;
}

.store-lifecycle-step .store-kpi-all-time {
    font-size: 12px;
}

.store-analytics .metric-card.no-data strong {
    color: var(--muted);
    font-size: 20px;
}

.store-tab {
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
    font-weight: 700;
}

.store-tab.is-active,
.store-tab:hover {
    color: var(--text);
    background: var(--panel-soft);
}

.store-tab:focus-visible,
.store-grain-toggle button:focus-visible,
.store-analytics button:focus-visible,
.store-analytics select:focus-visible,
.store-analytics input:focus-visible {
    outline: 3px solid var(--accent, #2563eb);
    outline-offset: 2px;
}

.store-chart-grid .chart-panel {
    min-height: 360px;
}

.chart-grain-group {
    display: flex;
    align-items: center;
    gap: 10px;
    align-self: end;
}

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

.store-grain-toggle {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-soft);
}

.store-grain-toggle button {
    min-width: 64px;
    min-height: 34px;
    padding: 0 12px;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    color: var(--muted);
    background: transparent;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.store-grain-toggle button:last-child {
    border-right: 0;
}

.store-grain-toggle button:hover {
    color: var(--text);
    background: var(--panel);
}

.store-grain-toggle button.is-active {
    color: #fff;
    background: var(--primary);
}

.cron-action-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 12px;
}

.cron-action-card {
    display: grid;
    align-content: start;
    gap: 10px;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.cron-action-card h3,
.cron-action-card p {
    margin: 0;
}

.cron-action-card label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
}

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

    .store-lifecycle {
        align-items: stretch;
    }

    .store-lifecycle-step {
        flex-basis: 180px;
        min-width: 180px;
    }

    .store-status-compact {
        grid-template-columns: 150px minmax(0, 1fr);
    }

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

@media (max-width: 720px) {
    .store-status-compact {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 12px 14px;
    }

    .store-status-compact .store-status-heading {
        display: flex;
        align-items: baseline;
        gap: 8px;
    }

    .store-status-compact .store-status-heading h2 {
        font-size: 20px;
    }

    .cron-action-grid {
        grid-template-columns: 1fr;
    }
}

.logout-form {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 20px;
}

.main {
    min-width: 0;
    overflow-x: clip;
    padding: 28px;
}

.app-shell.sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
}

.app-shell.sidebar-collapsed .sidebar {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 60;
    display: block;
    width: 44px;
    height: 44px;
    padding: 3px;
    border: 0;
    background: transparent;
    overflow: visible;
    pointer-events: none;
}

.app-shell.sidebar-collapsed .sidebar-head {
    width: 44px;
    height: 44px;
    margin: 0;
    pointer-events: auto;
}

.app-shell.sidebar-collapsed .sidebar .brand,
.app-shell.sidebar-collapsed .sidebar .nav,
.app-shell.sidebar-collapsed .sidebar .logout-form {
    display: none;
}

.topbar-start {
    min-width: 0;
    gap: 12px;
}

.sidebar-toggle {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--muted);
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    color: var(--text);
    background: var(--panel-soft);
}

.nav-toggle,
.sidebar-overlay {
    display: none !important;
}

.topbar {
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.topbar h1,
.analysis-band h2,
.chart-panel h3,
.settings-panel h2,
.table-panel h2,
.table-panel h3 {
    margin: 0;
}

.topbar h1 {
    font-size: clamp(24px, 3vw, 34px);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.topbar-actions {
    gap: 10px;
}

.user-pill,
.status {
    padding: 7px 10px;
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 13px;
}

.decision-board {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.decision-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.decision-hero-compact h2 {
    margin: 0;
    font-size: 22px;
}

.decision-hero h2 {
    margin: 0 0 8px;
    font-size: 28px;
}

.decision-hero p,
.decision-grid p {
    margin: 0;
    color: var(--muted);
}

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

.decision-grid article {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.decision-grid span {
    grid-row: span 2;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    color: #fff;
    background: var(--primary);
    font-size: 13px;
    font-weight: 850;
}

.decision-grid strong {
    font-size: 14px;
}

.decision-grid p {
    font-size: 12px;
}

.ai-panel {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    max-height: none;
    overflow: visible;
}

.ai-history-panel {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
}

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

.ai-history-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
}

.ai-history-row.has-delete {
    grid-template-columns: minmax(0, 1fr) 44px;
}

.ai-history-item {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.ai-history-item:hover {
    border-color: var(--primary);
}

.ai-history-delete {
    display: inline-grid;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    cursor: pointer;
}

.ai-history-delete:hover {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.14);
}

.ai-history-delete svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.demographic-section {
    margin-top: 24px;
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
}

.geo-section {
    margin-top: 18px;
}

.geo-grid {
    align-items: stretch;
}

.geo-delivery-card {
    margin-bottom: 16px;
}

.geo-delivery-card .geo-delivery-list {
    max-height: 280px;
    overflow: auto;
}

.geo-access-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}

.geo-access-grid > .demographic-card > .panel-head,
.geo-grid > .demographic-card > .panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

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

.geo-delivery-list {
    display: grid;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
}

.geo-delivery-row {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.geo-delivery-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.geo-delivery-head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.geo-platform-badge {
    flex: 0 0 auto;
    min-width: 52px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}

.geo-delivery-countries {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.geo-access-breakdown {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 12px;
}

.geo-access-breakdown h5 {
    margin: 0 0 8px;
    font-size: 13px;
}

@media (max-width: 900px) {
    .geo-access-breakdown {
        grid-template-columns: 1fr;
    }
}

.geo-legend {
    display: grid;
    gap: 4px;
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    font-size: 12px;
    line-height: 1.45;
}

.geo-legend strong {
    color: var(--text);
    font-weight: 700;
}

.geo-access-detail {
    margin: 0 0 10px;
    font-size: 12px;
    line-height: 1.45;
}

.geo-view-toggle {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.geo-view-btn {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.geo-view-btn.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.geo-view-panel[hidden] {
    display: none !important;
}

.geo-pie-wrap {
    position: relative;
    height: 320px;
}

.geo-map {
    height: 360px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--panel);
}

.geo-map .leaflet-container {
    width: 100%;
    height: 100%;
    font: inherit;
}

.geo-map .leaflet-tile-pane img.leaflet-tile,
.geo-map img.leaflet-tile {
    max-width: none !important;
    max-height: none !important;
}

.geo-map-note {
    margin: 8px 0 0;
    font-size: 12px;
}

.demographic-head {
    align-items: flex-start;
    gap: 24px;
}

.demographic-head h3,
.demographic-card h4 {
    margin: 0;
    color: var(--text);
}

.demographic-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    min-width: min(100%, 360px);
}

.demographic-controls label {
    display: grid;
    gap: 6px;
    min-width: 160px;
    color: var(--muted);
    font-weight: 700;
}

.demographic-controls select {
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    color: var(--text);
}

.demographic-status {
    margin: 16px 0;
}

.demographic-overview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.demographic-overview-card {
    min-width: 0;
    padding: 15px 16px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.demographic-overview-card span,
.demographic-overview-card small {
    display: block;
    color: var(--muted);
}

.demographic-overview-card strong {
    display: block;
    margin: 5px 0 3px;
    overflow: hidden;
    color: var(--text);
    font-size: 1.18rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demographic-bars {
    display: grid;
    gap: 13px;
    min-height: 80px;
}

.demographic-ranking-insight {
    margin: 0 0 18px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.demographic-insight-title {
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.demographic-insight-content {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    color: var(--text);
}

.demographic-insight-chip {
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--panel);
    color: var(--text);
    font-size: 0.86rem;
    font-variant-numeric: tabular-nums;
}

.demographic-insight-chip strong,
.demographic-insight-main strong {
    color: var(--text);
}

.demographic-insight-main {
    padding-left: 14px;
    border-left: 2px solid color-mix(in srgb, var(--primary), transparent 45%);
    font-size: 0.88rem;
}

.demographic-insight-main em {
    margin-left: 5px;
    color: var(--primary);
    font-style: normal;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.demographic-bar-row {
    min-width: 0;
}

.demographic-bar-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text);
    font-size: 0.88rem;
}

.demographic-bar-name {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    gap: 8px;
}

.demographic-bar-name-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demographic-media-badge {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 23px;
    height: 23px;
    border-radius: 6px;
    color: #fff;
    font-size: 0.74rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
}

.demographic-media-meta {
    background: #2563eb;
}

.demographic-media-google {
    background: #c47a00;
}

.demographic-bar-label > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demographic-bar-label strong {
    flex: 0 0 auto;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.demographic-bar-track {
    height: 10px;
    margin-top: 5px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--track);
}

.demographic-bar-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #0f9f6e);
}

.demographic-bar-row small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.75rem;
}

.demographic-ad-detail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 14px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.demographic-ad-detail > span {
    white-space: nowrap;
}

.demographic-ad-detail strong {
    color: var(--text);
    font-weight: 800;
}

.demographic-ad-strongest {
    padding-left: 12px;
    border-left: 2px solid color-mix(in srgb, var(--primary), transparent 45%);
}

.demographic-ad-strongest em {
    margin-left: 4px;
    color: var(--primary);
    font-style: normal;
    font-weight: 800;
}

.demographic-details {
    margin-top: 15px;
}

.demographic-details summary {
    color: var(--primary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
}

.demographic-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 16px;
}

.demographic-subgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 16px;
}

.demographic-card {
    min-width: 0;
    padding: 16px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.demographic-card .panel-head > * {
    min-width: 0;
}

.demographic-card .panel-head h4 {
    overflow-wrap: anywhere;
}

.demographic-cross-ad-card {
    grid-column: 1 / -1;
}

.demographic-cross-ad-card .panel-head {
    align-items: flex-start;
}

.demographic-cross-ad-card h5 {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.demographic-cross-ad-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.demographic-insight-badge {
    flex: 0 0 auto;
    padding: 6px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary), transparent 82%);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
}

.demographic-card .panel-head {
    margin-bottom: 12px;
}

.compact-scroll {
    max-height: 360px;
}

.demographic-card table {
    width: 100%;
    border-collapse: collapse;
}

.demographic-card th,
.demographic-card td {
    padding: 9px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.demographic-card th {
    color: var(--muted);
    font-size: 0.82rem;
}

.demographic-card td:first-child {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.demographic-card .numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.demographic-media-cell {
    white-space: nowrap;
}

.demographic-media-cell .demographic-media-badge {
    margin-right: 8px;
    vertical-align: middle;
}

.demographic-media-cell > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.demographic-heatmap-wrap {
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.demographic-heatmap {
    min-width: 520px;
}

.demographic-heatmap th,
.demographic-heatmap td {
    text-align: center;
}

.demographic-heatmap .demographic-cell {
    background: rgba(37, 99, 235, var(--heat));
    color: var(--text);
    cursor: default;
    font-variant-numeric: tabular-nums;
}

.demographic-heatmap .demographic-cell:focus {
    outline: 3px solid var(--warning);
    outline-offset: -3px;
}

.demographic-empty {
    padding: 28px 12px;
    text-align: center;
}

.demographic-google-note {
    margin-bottom: 14px;
    padding: 12px 14px;
    background: var(--panel-soft);
    border-left: 3px solid var(--primary);
    color: var(--muted);
}

.demographic-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.demographic-tab {
    padding: 10px 16px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
}

.demographic-tab.is-active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}

@media (max-width: 900px) {
    .demographic-grid,
    .demographic-subgrid,
    .demographic-cross-ad-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .demographic-section {
        padding: 16px;
    }

    .demographic-ad-detail {
        align-items: flex-start;
        gap: 4px 10px;
        font-size: 0.76rem;
    }

    .demographic-ad-strongest {
        width: 100%;
        padding-left: 0;
        border-top: 1px solid #dbeafe;
        border-left: 0;
        padding-top: 4px;
    }

    .demographic-head {
        display: grid;
    }

    .demographic-controls {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .demographic-controls label,
    .demographic-controls select {
        width: 100%;
    }

    .demographic-controls select {
        min-height: 44px;
        font-size: 16px;
    }

    .demographic-more-link {
        min-height: 40px;
    }

    .demographic-grid,
    .demographic-subgrid {
        grid-template-columns: 1fr;
    }

    .demographic-cross-ad-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

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

    .demographic-card {
        padding: 12px;
    }
}

@media (max-width: 420px) {
    .demographic-overview {
        grid-template-columns: 1fr;
    }
}

.ai-history-item span,
.ai-history-item small {
    color: var(--muted);
}

.ai-text {
    max-height: 70vh;
    padding-right: 8px;
    color: var(--text);
    line-height: 1.75;
    overflow-y: auto;
    overflow-wrap: anywhere;
    white-space: normal;
    word-break: normal;
}

.ai-text p {
    margin: 0 0 12px;
}

.ai-text h4 {
    margin: 18px 0 8px;
    font-size: 18px;
}

.ai-text ul,
.ai-text ol {
    display: grid;
    gap: 8px;
    margin: 0 0 14px;
    padding-left: 22px;
}

.ai-text li {
    padding-left: 2px;
}

.analysis-band {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 22px;
    align-items: center;
    padding: 22px;
    margin-bottom: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.analysis-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.analysis-list li {
    padding: 12px;
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    font-size: 14px;
}

.filter-bar {
    position: sticky;
    top: 12px;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(112px, 150px);
    gap: 12px;
    align-items: stretch;
    min-width: 0;
    padding: 14px;
    margin-bottom: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.filter-section {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 9px;
    min-width: 0;
    padding: 10px 12px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.filter-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    min-height: 18px;
    color: var(--text);
    font-size: 13px;
    font-weight: 900;
}

.filter-section-head small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    overflow-wrap: anywhere;
    text-align: right;
}

.filter-group {
    display: grid;
    gap: 10px;
    align-items: end;
    min-width: 0;
}

.period-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.condition-group {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 0.8fr) minmax(0, 1.35fr);
}

.condition-group .ad-performance-campaign-field {
    min-width: 0;
}

.filter-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-content: stretch;
    min-width: 0;
}

.filter-bar-summary {
    display: none;
}

.filter-bar-body {
    display: contents;
}

label {
    display: grid;
    gap: 7px;
    min-width: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
}

select[multiple] {
    min-height: 40px;
    max-height: 58px;
}

.campaign-select select {
    min-width: 0;
    min-height: 45px;
    max-height: 45px;
    padding-top: 7px;
    padding-bottom: 7px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
    display: inline-grid;
    place-items: center;
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

.primary-button {
    padding: 0 16px;
    color: #fff;
    background: var(--primary);
}

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

.primary-button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.secondary-button,
.ghost-button {
    padding: 0 14px;
    color: var(--text);
    background: var(--panel-soft);
}

.icon-button {
    width: 40px;
    color: var(--muted);
    background: var(--panel-soft);
}

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

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

.clarity-page-intro {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    min-width: 0;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.clarity-page-intro h2 {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.2;
}

.clarity-page-intro-meta {
    display: grid;
    gap: 10px;
    justify-items: end;
    flex: 0 0 auto;
}

.clarity-status {
    margin: 0;
    min-height: 1.4em;
}

.clarity-status[hidden] {
    display: none;
}

.clarity-chart-wrap {
    position: relative;
    height: 240px;
}

.clarity-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.clarity-table-panel {
    min-width: 0;
}

.clarity-page {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.metric-card,
.chart-panel,
.table-panel,
.clarity-section {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.clarity-section,
.settings-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric-card {
    padding: 18px;
}

.metric-card .label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.metric-card .value {
    margin: 8px 0 10px;
    font-size: clamp(24px, 4vw, 34px);
    font-weight: 850;
}

.metric-card .changes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 12px;
}

.change-up {
    color: var(--success);
}

.change-down {
    color: var(--danger);
}

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

.chart-panel {
    min-height: 340px;
    padding: 16px;
}

.chart-panel.wide {
    grid-column: 1 / -1;
}

.panel-head {
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.chart-panel canvas {
    width: 100%;
    max-height: 270px;
}

.demographic-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.demographic-more-link {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid #c8d8f5;
    border-radius: 7px;
    color: var(--primary);
    background: #eff6ff;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.demographic-more-link:hover {
    border-color: var(--primary);
    background: #dbeafe;
}

.ad-performance-page {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.ad-performance-intro,
.ad-performance-filters {
    min-width: 0;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.ad-performance-intro {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.ad-performance-intro h2 {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.ad-performance-intro p:last-child {
    margin: 0;
}

.ad-performance-filters {
    position: sticky;
    top: 12px;
    z-index: 10;
}

.ad-performance-filter-grid {
    display: grid;
    grid-template-columns:
        minmax(104px, 0.85fr)
        minmax(118px, 1fr)
        minmax(118px, 1fr)
        minmax(96px, 0.8fr)
        minmax(168px, 1.7fr)
        minmax(108px, 0.95fr)
        96px;
    gap: 12px;
    align-items: end;
}

.ad-performance-filter-grid label,
.ad-performance-filter-grid .ad-performance-campaign-field,
.ad-performance-table-meta label {
    min-width: 0;
    overflow: hidden;
}

.ad-performance-filter-grid > .primary-button {
    width: 100%;
    min-height: 40px;
    padding-inline: 12px;
}

.ad-performance-campaign-field {
    display: grid;
    gap: 7px;
    align-content: end;
    min-width: 0;
}

.ad-performance-campaign-label {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ad-performance-campaign-button {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 40px;
    padding-inline: 10px;
    overflow: hidden;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
}

.ad-performance-campaign-button .ad-performance-campaign-button-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ad-performance-campaign-button .filter-count {
    flex: 0 0 auto;
    margin-left: 0;
}

.ad-performance-campaign-modal {
    width: min(560px, calc(100vw - 28px));
}

.ad-performance-campaign-modal .modal-head {
    margin-bottom: 12px;
}

.ad-performance-campaign-modal .modal-head > div:first-child {
    display: grid;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}

.ad-performance-campaign-modal .modal-head h3 {
    font-size: 1.15rem;
    line-height: 1.3;
}

.ad-performance-campaign-modal-lead {
    margin: 0 0 12px;
    font-size: 12.5px;
    line-height: 1.5;
}

.ad-performance-campaign-modal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.ad-performance-campaign-modal-toolbar .ghost-button {
    min-height: 34px;
    padding: 0 12px;
    font-size: 12.5px;
}

.ad-performance-campaign-modal-toolbar strong {
    margin-left: auto;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.ad-performance-campaign-list {
    display: grid;
    gap: 2px;
    max-height: min(38vh, 280px);
    overflow: auto;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(241, 245, 249, 0.45);
}

.ad-performance-campaign-search {
    width: 100%;
    min-height: 38px;
    margin: 0 0 10px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font-size: 13.5px;
}

.ad-performance-campaign-search:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent);
    outline-offset: 1px;
}

.ad-performance-campaign-option.is-hidden {
    display: none;
}

.ad-performance-campaign-search-empty {
    margin: 8px 6px;
}

html[data-theme="dark"] .ad-performance-campaign-list {
    background: rgba(32, 37, 48, 0.55);
}

.ad-performance-campaign-option {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    margin: 0;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.ad-performance-campaign-option:hover {
    background: rgba(59, 130, 246, 0.08);
}

.ad-performance-campaign-option input {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--primary);
}

.ad-performance-campaign-option span {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 13.5px;
    line-height: 1.4;
    font-weight: 600;
}

.ad-performance-campaign-modal .campaign-filter-footer {
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
}

.ad-performance-campaign-modal .campaign-filter-footer .muted {
    flex: 1 1 160px;
    font-size: 12px;
    line-height: 1.45;
}

.ad-performance-campaign-modal .campaign-filter-footer > div {
    flex: 0 0 auto;
    margin-left: auto;
}

.ad-performance-campaign-modal .campaign-filter-footer .ghost-button,
.ad-performance-campaign-modal .campaign-filter-footer .primary-button {
    min-height: 38px;
    font-size: 13px;
}

.ad-performance-filter-note {
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 1.55;
}

.ad-performance-status {
    min-height: 20px;
    margin: -2px 0;
}

.ad-performance-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    min-width: 0;
}

.ad-performance-summary-card {
    display: grid;
    gap: 7px;
    min-width: 0;
    min-height: 92px;
    padding: 13px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.ad-performance-summary-card .label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.ad-performance-summary-card strong {
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: clamp(16px, 1.35vw, 22px);
    line-height: 1.25;
    font-weight: 800;
}

.ad-performance-summary-card small {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ad-performance-demo-panel {
    min-width: 0;
    padding: 18px 18px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.ad-performance-demo-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.ad-performance-demo-head h3 {
    margin: 0 0 4px;
    font-size: 18px;
}

.ad-performance-demo-head p {
    margin: 0;
}

.ad-performance-demo-controls select {
    min-width: 140px;
}

.ad-performance-demo-status {
    min-height: 1.4em;
    margin: 0 0 8px;
    font-size: 13px;
}

.ad-performance-demo-chart-wrap {
    position: relative;
    height: 300px;
    margin-bottom: 8px;
}

.ad-performance-demo-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.ad-performance-demo-legend {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    padding: 8px 8px 4px;
}

.ad-performance-demo-legend-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 140px;
}

.ad-performance-demo-swatch {
    width: 12px;
    height: 12px;
    margin-top: 4px;
    border-radius: 3px;
    flex: 0 0 auto;
}

.ad-performance-demo-legend-item strong {
    display: block;
    font-size: 14px;
}

.ad-performance-demo-legend-item span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.ad-performance-demo-legend-item small {
    display: block;
    margin-top: 2px;
    color: var(--text);
    font-size: 12px;
}

.ad-performance-google-demo {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.ad-performance-google-demo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.ad-performance-google-demo h4 {
    margin: 0 0 8px;
    font-size: 14px;
}

.ad-performance-demo-note {
    margin: 10px 0 0;
    font-size: 12px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ad-performance-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    min-width: 0;
}

.ad-performance-chart-panel {
    min-width: 0;
    min-height: 0;
    padding: 14px;
}

.ad-performance-chart-wrap {
    position: relative;
    height: 230px;
    min-width: 0;
}

.ad-performance-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: none;
}

.ad-performance-chart-state {
    min-height: 230px;
    display: grid;
    place-items: center;
    padding: 20px;
    text-align: center;
}

.ad-performance-chart-state[hidden] {
    display: none;
}

.ad-performance-table-panel {
    min-width: 0;
    margin-top: 0;
}

.ad-performance-table-head {
    align-items: flex-start;
}

.ad-performance-table-head h3 {
    margin: 0 0 6px;
}

.ad-performance-table-head p {
    margin: 0;
    font-size: 12px;
}

.ad-performance-table-meta {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 12px;
    min-width: 0;
}

.ad-performance-table-meta label {
    width: 110px;
}

.ad-performance-table-scroll {
    max-width: 100%;
}

#adPerformanceTable {
    min-width: 1180px;
}

#adPerformanceTable th,
#adPerformanceTable td {
    padding: 11px 10px;
    vertical-align: middle;
    white-space: nowrap;
}

#adPerformanceTable th {
    color: var(--muted);
    font-size: 12px;
    text-align: left;
    user-select: none;
}

#adPerformanceTable th[data-sort]:hover {
    color: var(--text);
}

#adPerformanceTable td.numeric,
#adPerformanceTable th.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#adPerformanceTable td:nth-child(2) {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#adPerformanceTable td:nth-child(6) {
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#adPerformanceTable td:first-child,
#adPerformanceTable th:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--panel);
    box-shadow: 6px 0 10px rgba(24, 32, 47, 0.06);
}

.ad-performance-entity-name {
    display: block;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#adPerformanceTable td:nth-child(2) small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.ad-performance-thumb-col,
.ad-performance-thumb-cell {
    width: 52px;
    text-align: center;
    vertical-align: middle;
}

.ad-performance-thumb {
    display: block;
    width: 36px;
    height: 64px;
    margin: 0 auto;
    object-fit: cover;
    border-radius: 6px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
}

.ad-performance-thumb-placeholder {
    display: block;
    width: 36px;
    height: 64px;
    margin: 0 auto;
    border-radius: 6px;
    background: var(--panel-soft);
    border: 1px dashed var(--line);
}

.ad-performance-selected-value {
    font-weight: 800;
}

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

.ad-performance-pagination > div {
    display: flex;
    gap: 8px;
}

.ad-performance-pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.table-empty {
    padding: 28px 12px !important;
    color: var(--muted);
    text-align: center !important;
}

.weekday-heatmap {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.heat-cell {
    min-height: 86px;
    padding: 12px;
    border-radius: 8px;
    background: var(--panel-soft);
}

.heat-cell strong {
    display: block;
    margin-bottom: 8px;
}

.heat-cell span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.table-panel {
    margin-top: 16px;
    padding: 16px;
}

.plan-toolbar,
.plan-current-banner,
.plan-card-grid,
.plan-chart-grid {
    margin-top: 16px;
}

.plan-toolbar {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) auto auto;
    gap: 20px;
    align-items: end;
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.plan-toolbar h2 {
    margin: 0 0 6px;
    font-size: 32px;
    line-height: 1.2;
    white-space: nowrap;
    word-break: keep-all;
}

.plan-toolbar .eyebrow {
    margin: 0 0 5px;
}

.plan-toolbar > div:first-child {
    min-width: 0;
}

.plan-toolbar-fields {
    display: grid;
    grid-template-columns: minmax(180px, 1.5fr) 150px 90px;
    gap: 10px;
    align-items: end;
    min-width: 0;
}

.plan-save-button {
    min-width: 130px;
}

.plan-current-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-left: 4px solid var(--primary);
    background: var(--panel-soft);
}

.plan-actual-note {
    margin: 10px 2px 0;
    color: var(--muted);
    font-size: 12px;
}

.plan-effectiveness-panel {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.plan-effectiveness-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.plan-effectiveness-head .eyebrow {
    margin: 0 0 4px;
}

.plan-effectiveness-head h3 {
    margin: 0;
    font-size: 20px;
}

.plan-effectiveness-head p:not(.eyebrow) {
    margin: 5px 0 0;
    font-size: 12px;
}

.plan-effectiveness-baseline {
    flex: 0 0 auto;
    padding: 6px 9px;
    border: 1px solid rgba(37, 99, 235, 0.22);
    border-radius: 6px;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    font-size: 12px;
    font-weight: 800;
}

.plan-effectiveness-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: end;
    gap: 8px;
    max-width: 640px;
}

.plan-effectiveness-controls label {
    display: grid;
    gap: 5px;
    min-width: 104px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.plan-effectiveness-controls label:first-child {
    min-width: 136px;
}

.plan-effectiveness-controls select {
    width: 100%;
    min-height: 36px;
    padding: 7px 28px 7px 9px;
    font-size: 13px;
}

.plan-effectiveness-controls .secondary-button {
    min-height: 36px;
    padding: 7px 14px;
}

.plan-effectiveness-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.plan-effectiveness-card {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.plan-effectiveness-card .plan-card-heading .label {
    min-height: 0;
}

.plan-effectiveness-ratio {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}

.plan-effectiveness-ratio span,
.plan-effectiveness-equivalent span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.plan-effectiveness-ratio strong {
    padding: 2px 5px;
    font-size: 26px;
    line-height: 1.1;
}

.plan-effectiveness-card .plan-card-progress {
    margin-top: 12px;
    background: var(--panel);
}

.plan-effectiveness-equivalent {
    display: grid;
    gap: 4px;
    margin-top: 14px;
}

.plan-effectiveness-equivalent strong {
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.45;
}

.plan-effectiveness-equivalent b {
    padding: 0 3px;
    color: var(--muted);
    font-size: 12px;
}

.plan-ai-section {
    display: grid;
    gap: 14px;
    margin-top: 16px;
    background: var(--panel);
}

.plan-ai-section > .panel-head {
    align-items: end;
}

.plan-ai-section h4 {
    margin: 0 0 8px;
    font-size: 15px;
}

.plan-ai-controls {
    display: grid;
    grid-template-columns: minmax(180px, 240px) auto;
    gap: 10px;
    align-items: end;
}

.plan-ai-controls label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.plan-ai-controls select {
    width: 100%;
}

.plan-ai-section .ai-panel {
    background: var(--panel-soft);
}

.plan-ai-history {
    display: grid;
    gap: 8px;
}

.plan-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.plan-card {
    min-width: 0;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.plan-card .label {
    min-height: 2.7em;
    line-height: 1.35;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.plan-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.plan-card-status {
    flex: 0 0 auto;
    padding: 4px 7px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.plan-card-values {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    margin-top: 14px;
}

.plan-card-values span,
.plan-card-values strong {
    display: block;
}

.plan-card-values > div {
    min-width: 0;
}

.plan-card-values span {
    color: var(--muted);
    font-size: 12px;
}

.plan-card-values strong {
    margin-top: 4px;
    overflow: hidden;
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-card-values strong.plan-card-actual {
    background: transparent;
}

.plan-card-progress {
    position: relative;
    height: 9px;
    margin-top: 16px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--panel-soft);
}

.plan-card-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--muted);
}

.plan-card-progress i {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 2px;
    background: var(--text);
    opacity: 0.45;
}

.plan-card-progress.status-good span {
    background: var(--success);
}

.plan-card-progress.status-watch span {
    background: var(--warning);
}

.plan-card-progress.status-bad span {
    background: var(--danger);
}

.plan-card-progress-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.plan-card-progress-meta strong {
    color: var(--text);
    font-size: 14px;
}

.plan-card-difference {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    font-weight: 800;
}

.plan-card-difference strong {
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.plan-chart-grid .chart-panel {
    min-height: 310px;
}

.plan-chart-grid .chart-panel.wide {
    grid-column: 1 / -1;
}

.plan-chart-grid .plan-combo-chart {
    min-height: 380px;
}

.plan-chart-grid .chart-panel > .panel-head p {
    margin: 5px 0 0;
    font-size: 12px;
}

.plan-media-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-soft);
}

.plan-media-toggle button {
    min-width: 64px;
    min-height: 34px;
    padding: 0 12px;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    color: var(--muted);
    background: transparent;
    font-size: 13px;
    font-weight: 800;
}

.plan-media-toggle button:last-child {
    border-right: 0;
}

.plan-media-toggle button:hover {
    color: var(--text);
    background: var(--panel);
}

.plan-media-toggle button.is-active {
    color: #fff;
    background: var(--primary);
}

.plan-legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
    font-weight: 800;
}

.plan-legend span {
    padding: 4px 8px;
    border-radius: 6px;
}

.status-good {
    color: var(--success);
    background: rgba(15, 159, 110, 0.10);
}

.status-watch {
    color: var(--warning);
    background: rgba(196, 122, 0, 0.12);
}

.status-bad {
    color: var(--danger);
    background: rgba(214, 69, 69, 0.10);
}

.status-missing,
.status-neutral {
    color: var(--muted);
    background: var(--panel-soft);
}

.plan-table-panel {
    overflow: hidden;
}

.plan-table-panel > .panel-head {
    align-items: flex-start;
}

.plan-table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.plan-category-action {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
}

.plan-table-panel .table-scroll {
    max-height: calc(100vh - 230px);
    overflow: auto;
}

.plan-table {
    min-width: 1500px;
}

.plan-table th,
.plan-table td {
    white-space: nowrap;
}

.plan-table tbody td {
    text-align: right;
}

.plan-table tbody td:nth-child(2) {
    text-align: center;
}

.plan-table th:first-child,
.plan-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 4;
    width: 270px;
    min-width: 270px;
    background: var(--panel);
}

.plan-table th:nth-child(2),
.plan-table td:nth-child(2) {
    position: sticky;
    left: 270px;
    z-index: 4;
    width: 72px;
    min-width: 72px;
    background: var(--panel);
}

.plan-table thead th:first-child,
.plan-table thead th:nth-child(2) {
    z-index: 7;
    background: var(--panel);
}

.plan-table thead tr:first-child th {
    position: sticky;
    top: 0;
    z-index: 8;
    background: var(--panel-soft);
}

.plan-table thead tr:first-child th:first-child,
.plan-table thead tr:first-child th:nth-child(2) {
    background: var(--panel);
}

.plan-table thead tr:nth-child(2) th {
    position: sticky;
    top: 62px;
    z-index: 8;
    background: var(--panel);
}

.plan-table tbody .plan-category-row th {
    background: var(--panel-soft);
}

.plan-table tbody .plan-category-row .plan-category-label,
.plan-table tbody .plan-category-row .plan-category-unit {
    position: sticky;
    z-index: 6;
    background: var(--panel-soft);
}

.plan-table tbody .plan-category-row .plan-category-label {
    left: 0;
}

.plan-table tbody .plan-category-row .plan-category-unit {
    left: 270px;
    box-shadow: 8px 0 12px rgba(24, 32, 47, 0.06);
}

.plan-category-toggle,
.plan-category-static {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
}

.plan-category-toggle {
    cursor: pointer;
}

.plan-category-static {
    cursor: default;
}

.plan-category-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

.plan-category-chevron {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    color: var(--text);
    font-size: 17px;
    line-height: 1;
}

.plan-table thead th {
    text-align: center;
}

.plan-table thead th:first-child,
.plan-table thead th:nth-child(2),
.plan-table tbody th {
    text-align: left;
}

.plan-month-head {
    min-width: 280px;
    background: var(--panel-soft);
    border-left: 3px solid var(--line);
    border-right: 1px solid var(--line);
    box-shadow: inset 0 3px 0 rgba(100, 116, 139, 0.18);
    font-size: 15px;
}

.plan-month-head.current-month {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.10);
    border-left-color: var(--primary);
    box-shadow: inset 0 3px 0 var(--primary), inset 0 -3px 0 rgba(37, 99, 235, 0.24);
}

.plan-month-ai-trigger {
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 56px;
    padding: 4px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
}

.plan-month-ai-trigger:hover,
.plan-month-ai-trigger:focus-visible {
    background: rgba(37, 99, 235, 0.10);
    outline: none;
}

.plan-month-head small,
.plan-table tbody th small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.plan-subhead th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.plan-table thead tr:nth-child(2) th:nth-child(4n + 3),
.plan-table tbody tr:not(.plan-category-row) td:nth-child(4n + 3) {
    border-left: 3px solid var(--line);
}

.plan-table thead tr:nth-child(2) th:nth-child(4n + 6),
.plan-table tbody tr:not(.plan-category-row) td:nth-child(4n + 6) {
    border-right: 1px solid var(--line);
}

.plan-category-row th {
    padding-top: 16px;
    color: var(--primary);
    background: var(--panel-soft);
    font-size: 12px;
}

.plan-input-cell input,
.plan-actual-cell input {
    width: 105px;
    min-height: 34px;
    padding: 6px 8px;
    text-align: right;
}

.plan-actual-cell {
    font-weight: 800;
}

.plan-effectiveness-cell {
    display: grid;
    gap: 2px;
    min-width: 126px;
    margin-left: auto;
    text-align: right;
}

.plan-effectiveness-cell strong {
    font-size: 15px;
}

.plan-effectiveness-cell small {
    color: inherit;
    font-size: 10px;
    font-weight: 700;
    opacity: 0.78;
}

.plan-cv-editor {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    min-width: 148px;
    margin-left: auto;
}

.plan-cv-value {
    display: inline-block;
}

.plan-cv-source {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.plan-cv-editor.has-override .plan-cv-source {
    color: var(--primary);
}

.plan-cv-editor.is-editing .plan-cv-value {
    display: none;
}

.plan-cv-editor .plan-cv-override-input {
    width: 88px;
    min-height: 32px;
}

.plan-cv-editor .icon-button {
    width: 28px;
    min-height: 28px;
    padding: 0;
    font-size: 15px;
}

.campaign-table-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    margin-left: 7px;
    padding: 0 6px;
    border-radius: 50%;
    color: #fff;
    background: var(--primary);
    font-size: 12px;
}

.campaign-period {
    white-space: nowrap;
}

.campaign-period span {
    margin: 0 5px;
    color: var(--muted);
}

.clarity-section {
    margin-top: 16px;
    padding: 16px;
}

.clarity-section .chart-grid {
    margin-bottom: 16px;
}

.url-cell {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
    /* Edge shadows hint that the table scrolls horizontally: the first two
       layers scroll with the content and mask the shadow once an edge is
       reached, so it only appears while there is more content to reveal. */
    background:
        linear-gradient(to right, var(--panel) 30%, rgba(0, 0, 0, 0)),
        linear-gradient(to left, var(--panel) 30%, rgba(0, 0, 0, 0)) 100% 0,
        radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0)),
        radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 30px 100%, 30px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}

#campaignTable {
    min-width: 1180px;
}

#clarityPagesTable {
    min-width: 850px;
}

#campaignTable th:first-child,
#campaignTable td:first-child,
#clarityPagesTable th:first-child,
#clarityPagesTable td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--panel);
    box-shadow: 6px 0 10px rgba(24, 32, 47, 0.06);
}

#campaignTable th:first-child,
#campaignTable td:first-child {
    width: 220px;
    min-width: 220px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#clarityPagesTable th:first-child,
#clarityPagesTable td:first-child {
    width: 280px;
    min-width: 280px;
}

#campaignTable thead th:first-child,
#clarityPagesTable thead th:first-child {
    z-index: 3;
}

#clarityPagesTable th[data-sort]:hover {
    color: var(--text);
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
}

th.sorted-asc,
th.sorted-desc {
    color: var(--text);
}

th.sorted-asc::after,
th.sorted-desc::after {
    display: inline-block;
    margin-left: 5px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 900;
}

th.sorted-asc::after {
    content: "↑";
}

th.sorted-desc::after {
    content: "↓";
}

.muted {
    color: var(--muted);
}

.info-tooltip {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--muted);
    cursor: help;
    font-size: 12px;
    font-weight: 850;
    line-height: 1;
    vertical-align: middle;
}

.tooltip-panel {
    position: absolute;
    z-index: 20;
    left: 50%;
    bottom: calc(100% + 10px);
    width: min(280px, calc(100vw - 48px));
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--text);
    color: var(--panel);
    box-shadow: var(--shadow);
    font-size: 12px;
    font-weight: 650;
    line-height: 1.55;
    opacity: 0;
    pointer-events: none;
    text-align: left;
    transform: translate(-50%, 4px);
    transition: opacity 0.14s ease, transform 0.14s ease;
    white-space: normal;
}

.info-tooltip .tooltip-panel {
    display: none;
}

.tooltip-portal {
    position: fixed;
    z-index: 10000;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--text);
    color: var(--panel);
    box-shadow: var(--shadow);
    font-size: 12px;
    font-weight: 650;
    line-height: 1.55;
    pointer-events: none;
    text-align: left;
    white-space: normal;
}

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

.settings-panel {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.notice {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    font-weight: 750;
}

.notice.success {
    border-color: color-mix(in srgb, var(--success), var(--line) 68%);
    color: var(--success);
}

.notice.error {
    border-color: color-mix(in srgb, var(--danger, #d64545), var(--line) 68%);
    color: var(--danger, #d64545);
}

.settings-mail-test {
    display: grid;
    gap: 10px;
    align-items: end;
    grid-template-columns: minmax(0, 1fr) auto;
}

@media (max-width: 760px) {
    .settings-mail-test {
        grid-template-columns: 1fr;
    }
}

.saved-badge {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    min-height: 22px;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--success), transparent 86%);
    color: var(--success);
    font-size: 12px;
    font-weight: 800;
    vertical-align: middle;
}

.saved-badge.empty {
    background: var(--panel-soft);
    color: var(--muted);
}

.masked-value {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    min-height: 22px;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--panel-soft);
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0;
    vertical-align: middle;
}

.settings-panel.narrow {
    max-width: 720px;
    margin-top: 16px;
}

.account-profile-page {
    max-width: 640px;
}

.account-profile-card {
    display: grid;
    gap: 18px;
    padding: 22px 22px 20px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.account-profile-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.account-profile-kicker {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.account-profile-card h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
}

.account-profile-lead {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

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

.account-profile-fieldset {
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-soft);
    min-inline-size: 0;
}

.account-profile-fieldset-password {
    background: var(--panel);
}

.account-profile-legend {
    padding: 0 4px;
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
}

.account-profile-hint {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.account-profile-email {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
}

.account-profile-email-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.account-profile-email-value {
    font-size: 14px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.account-profile-field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.account-profile-field label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.account-profile-field input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
}

.account-profile-field input:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary), transparent 55%);
    outline-offset: 2px;
    border-color: var(--primary);
}

.account-profile-field input:user-invalid {
    border-color: var(--danger, #d64545);
}

.account-profile-field-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.account-profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.account-profile-actions .primary-button {
    min-width: 128px;
}

@media (max-width: 760px) {
    .account-profile-card {
        padding: 16px;
    }

    .account-profile-fieldset {
        padding: 14px;
    }

    .account-profile-field-row {
        grid-template-columns: 1fr;
    }

    .account-profile-actions .primary-button {
        width: 100%;
    }
}

.notifications-page {
    max-width: 640px;
}

.notifications-card {
    display: grid;
    gap: 18px;
    padding: 22px 22px 20px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.notifications-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.notifications-kicker {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.notifications-card h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
}

.notifications-schedule {
    flex: 0 0 auto;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.notifications-lead {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.notifications-email {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-soft);
}

.notifications-email-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.notifications-email-value {
    font-size: 14px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

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

.notifications-options {
    display: grid;
    gap: 10px;
}

.notifications-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.notifications-option:hover {
    border-color: color-mix(in srgb, var(--primary), var(--line) 55%);
    background: var(--panel-soft);
}

.notifications-option:has(input:checked) {
    border-color: color-mix(in srgb, var(--primary), var(--line) 40%);
    background: color-mix(in srgb, var(--primary), transparent 94%);
}

.notifications-option.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.notifications-option input {
    width: 18px;
    min-height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
}

.notifications-option-body {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.notifications-option-title {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.35;
}

.notifications-option-desc {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

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

.notifications-actions .primary-button,
.notifications-actions .secondary-button {
    min-height: 42px;
    padding: 0 18px;
}

@media (max-width: 760px) {
    .notifications-card {
        padding: 18px 16px 16px;
    }

    .notifications-card-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

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

    .notifications-actions .primary-button,
    .notifications-actions .secondary-button {
        width: 100%;
    }
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-row input {
    width: auto;
    min-height: auto;
}

.status.success {
    color: var(--success);
}

.status.failed {
    color: var(--danger);
}

.chart-modal {
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
    width: min(1400px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    height: min(900px, calc(100vh - 24px));
    max-height: calc(100vh - 24px);
    margin: auto;
    padding: 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
}

.chart-modal[open] {
    display: grid;
}

.chart-modal::backdrop {
    background: rgba(24, 32, 47, 0.48);
    backdrop-filter: blur(4px);
}

.campaign-filter-modal {
    width: min(860px, calc(100vw - 36px));
    max-width: calc(100vw - 36px);
    max-height: calc(100vh - 48px);
    padding: 0;
    overflow: auto;
    border: 1px solid rgba(227, 231, 238, 0.82);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--text);
    box-shadow: 0 28px 80px rgba(24, 32, 47, 0.24);
    backdrop-filter: blur(18px);
}

html[data-theme="dark"] .campaign-filter-modal {
    border-color: rgba(42, 48, 59, 0.9);
    background: rgba(24, 27, 34, 0.94);
}

.campaign-filter-modal::backdrop {
    background: rgba(24, 32, 47, 0.38);
    backdrop-filter: blur(3px);
}

.campaign-filter-modal form {
    padding: 22px;
}

.campaign-filter-modal h3,
.campaign-filter-modal .eyebrow {
    margin: 0;
}

.campaign-filter-modal .modal-head {
    margin-bottom: 20px;
}

.campaign-filter-grid {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 14px;
}

.filter-fieldset {
    min-width: 0;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(241, 245, 249, 0.58);
}

html[data-theme="dark"] .filter-fieldset {
    background: rgba(32, 37, 48, 0.68);
}

.filter-fieldset legend {
    padding: 0 6px;
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
}

.metrics-filter-fieldset {
    grid-column: 1 / -1;
}

.filter-field-grid {
    display: grid;
    gap: 12px;
}

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

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

.campaign-filter-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.campaign-filter-footer > div {
    display: flex;
    gap: 10px;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    margin-bottom: 0;
}

.modal-head h3 {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.modal-head > div {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}

.chart-modal-body {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.chart-modal canvas {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.guest-body {
    display: grid;
    place-items: center;
    padding: 28px;
}

.login-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 420px);
    gap: 36px;
    align-items: center;
    width: min(980px, 100%);
}

.login-copy h1 {
    margin: 0 0 14px;
    font-size: clamp(34px, 6vw, 58px);
    line-height: 1.05;
}

.login-copy p:last-child {
    color: var(--muted);
    font-size: 17px;
    line-height: 1.8;
}

.login-card {
    display: grid;
    gap: 16px;
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.form-error {
    margin: 0;
    padding: 10px;
    border-radius: 8px;
    color: var(--danger);
    background: rgba(214, 69, 69, 0.1);
}

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

    .sidebar {
        position: static;
        height: auto;
        display: flex;
        gap: 14px;
        align-items: center;
        overflow-x: auto;
    }

    .app-shell.sidebar-collapsed .sidebar {
        display: block;
    }

    .brand {
        margin: 0;
    }

    .sidebar-head {
        flex: 0 0 auto;
        margin: 0;
    }

    .nav {
        display: flex;
    }

    .logout-form {
        position: static;
        margin-left: auto;
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }

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

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

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

    .period-group,
    .condition-group {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .decision-grid,
    .analysis-band {
        grid-template-columns: 1fr 1fr;
    }

    .analysis-list {
        grid-template-columns: 1fr 1fr;
    }
}

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

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

    .plan-toolbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .plan-toolbar-fields {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .plan-save-button {
        justify-self: start;
    }

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

    .ad-performance-filter-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .ad-performance-campaign-field {
        grid-column: span 2;
    }

    .ad-performance-filter-grid > .primary-button {
        grid-column: 1 / -1;
        width: min(180px, 100%);
        justify-self: end;
    }

    .ad-performance-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1280px) and (min-width: 1081px) {
    .ad-performance-filter-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .ad-performance-campaign-field {
        grid-column: span 2;
    }

    .ad-performance-filter-grid > .primary-button {
        grid-column: span 1;
        width: 100%;
        justify-self: stretch;
    }
}

@media (max-width: 760px) {
    .main {
        padding: 14px 12px 24px;
    }

    /* Keep form controls at (or above) 16px to stop iOS Safari from
       auto-zooming the page on focus, and give buttons/links a touch
       target close to the recommended 44px minimum. */
    input,
    select,
    textarea {
        font-size: 16px;
    }

    .primary-button,
    .secondary-button,
    .ghost-button,
    .icon-button {
        min-height: 44px;
    }

    .icon-button {
        width: 44px;
    }

    .info-tooltip {
        width: 22px;
        height: 22px;
        font-size: 13px;
    }

    .topbar,
    .decision-hero,
    .login-panel {
        align-items: stretch;
        flex-direction: column;
        grid-template-columns: 1fr;
    }

    .topbar-start {
        align-items: center;
        gap: 10px;
    }

    /* Horizontal scrollable nav on small screens (no hamburger drawer). */
    .app-shell,
    .app-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .sidebar,
    .app-shell.sidebar-collapsed .sidebar {
        position: static;
        z-index: auto;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        width: auto;
        height: auto;
        padding: 12px 14px;
        overflow-x: auto;
        overflow-y: hidden;
        box-shadow: none;
        transform: none;
        pointer-events: auto;
    }

    .brand,
    .app-shell.sidebar-collapsed .sidebar .brand {
        display: flex;
        flex: 0 0 auto;
        margin: 0;
    }

    .app-shell.sidebar-collapsed .sidebar .brand > span:last-child {
        display: inline;
    }

    .sidebar-head,
    .app-shell.sidebar-collapsed .sidebar-head {
        flex: 0 0 auto;
        width: auto;
        height: auto;
        margin: 0;
        pointer-events: auto;
    }

    .sidebar-toggle {
        display: none;
    }

    .nav,
    .app-shell.sidebar-collapsed .sidebar .nav {
        display: flex;
        flex: 1 1 auto;
        flex-direction: row;
        gap: 4px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .nav a {
        flex: 0 0 auto;
        width: auto;
        min-height: 40px;
        padding: 0 12px;
        font-size: 14px;
        white-space: nowrap;
    }

    .logout-form,
    .app-shell.sidebar-collapsed .sidebar .logout-form {
        display: block;
        position: static;
        flex: 0 0 auto;
        width: auto;
        margin: 0 0 0 auto;
    }

    .logout-form .ghost-button {
        width: auto;
        min-height: 40px;
    }

    .topbar {
        gap: 10px;
        margin-bottom: 16px;
    }

    .topbar h1 {
        font-size: 24px;
        line-height: 1.25;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .user-pill {
        min-width: 0;
        max-width: calc(100% - 50px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .decision-board {
        gap: 12px;
        margin-bottom: 14px;
        padding: 14px;
    }

    .decision-hero h2 {
        font-size: 22px;
        line-height: 1.35;
    }

    .decision-hero .primary-button {
        width: 100%;
        min-height: 44px;
    }

    .decision-grid {
        gap: 8px;
    }

    .decision-grid article {
        padding: 10px;
    }

    .analysis-band {
        gap: 12px;
        margin-bottom: 14px;
        padding: 14px;
    }

    .analysis-list li {
        padding: 10px;
        font-size: 13px;
    }

    .filter-bar,
    .period-group,
    .condition-group,
    .decision-grid,
    .analysis-band,
    .analysis-list,
    .card-grid,
    .card-grid.compact,
    .chart-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .weekday-heatmap {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .heat-cell {
        flex: 0 0 130px;
    }

    .chart-panel {
        min-height: 290px;
        padding: 12px;
    }

    .chart-panel h3 {
        font-size: 16px;
        line-height: 1.3;
    }

    .chart-panel canvas {
        max-height: 240px;
    }

    .chart-panel .icon-button {
        width: 40px;
        min-height: 40px;
    }

    .ad-performance-intro,
    .ad-performance-table-head,
    .ad-performance-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .ad-performance-intro,
    .ad-performance-filters,
    .ad-performance-table-panel {
        padding: 14px;
    }

    .ad-performance-intro .secondary-button {
        width: 100%;
    }

    .ad-performance-filters {
        top: 8px;
    }

    .ad-performance-filter-grid,
    .ad-performance-summary,
    .ad-performance-chart-grid,
    .ad-performance-google-demo-grid {
        grid-template-columns: 1fr;
    }

    .ad-performance-demo-head {
        flex-direction: column;
    }

    .ad-performance-demo-chart-wrap {
        height: 260px;
    }

    .ad-performance-demo-legend {
        gap: 20px;
    }

    .ad-performance-campaign-field,
    .ad-performance-filter-grid > .primary-button {
        grid-column: auto;
        width: 100%;
        justify-self: stretch;
    }

    .ad-performance-campaign-label {
        white-space: normal;
    }

    .ad-performance-summary-card {
        min-height: 88px;
    }

    .ad-performance-summary-card strong,
    .ad-performance-summary-card small {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .ad-performance-campaign-modal-toolbar strong {
        margin-left: 0;
        width: 100%;
    }

    .ad-performance-chart-panel {
        min-height: 0;
        padding: 12px;
    }

    .ad-performance-chart-wrap,
    .ad-performance-chart-state {
        min-height: 220px;
        height: 220px;
    }

    .ad-performance-table-meta,
    .ad-performance-pagination > div {
        justify-content: stretch;
        width: 100%;
    }

    .ad-performance-table-meta {
        align-items: stretch;
        flex-direction: column;
    }

    .ad-performance-table-meta label,
    .ad-performance-pagination button {
        width: 100%;
    }

    .ad-performance-pagination > div {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .filter-bar {
        top: 8px;
        gap: 12px;
        margin-bottom: 14px;
        padding: 12px;
    }

    .filter-group {
        gap: 10px;
    }

    .filter-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        min-width: 0;
    }

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

    .filter-bar-summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-height: 40px;
    }

    .filter-bar-summary-text {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        font-size: 13px;
        font-weight: 700;
        color: var(--text);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .filter-bar-toggle {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        gap: 4px;
        min-height: 36px;
        padding: 6px 14px;
        font-size: 13px;
        font-weight: 700;
        color: var(--text);
        background: var(--panel-soft);
        border: 1px solid var(--line);
        border-radius: 999px;
    }

    .filter-bar-toggle span[aria-hidden] {
        display: inline-block;
        transition: transform 0.15s ease;
    }

    .is-expanded .filter-bar-toggle span[aria-hidden] {
        transform: rotate(180deg);
    }

    .filter-bar-body {
        display: none;
    }

    .is-expanded > .filter-bar-body {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-top: 12px;
    }

    .table-panel,
    .clarity-section,
    .clarity-page-intro,
    .clarity-table-panel {
        margin-top: 14px;
        padding: 12px;
    }

    .clarity-page-intro {
        flex-direction: column;
    }

    .clarity-page-intro-meta {
        justify-items: start;
        width: 100%;
    }

    .table-panel > .panel-head,
    .clarity-section > .panel-head {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .campaign-table-tools {
        align-items: stretch;
        width: 100%;
        gap: 7px;
    }

    .campaign-table-tools .secondary-button {
        width: 100%;
    }

    #campaignTable th:first-child,
    #campaignTable td:first-child {
        width: 170px;
        min-width: 170px;
        max-width: 170px;
    }

    #clarityPagesTable th:first-child,
    #clarityPagesTable td:first-child {
        width: 220px;
        min-width: 220px;
    }

    .chart-modal {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        height: calc(100dvh - 16px);
        max-height: calc(100dvh - 16px);
        padding: 12px;
    }

    .chart-modal .modal-head {
        align-items: flex-start;
    }

    .chart-modal .modal-head h3 {
        min-width: 0;
        overflow-wrap: anywhere;
        font-size: 18px;
    }

    .campaign-filter-modal {
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        max-height: calc(100dvh - 20px);
    }

    .campaign-filter-modal form {
        padding: 14px;
    }

    .campaign-filter-modal .modal-head {
        margin-bottom: 14px;
    }

    .campaign-filter-footer {
        gap: 12px;
    }

    .campaign-filter-footer > div {
        gap: 8px;
    }

    .campaign-filter-footer .ghost-button,
    .campaign-filter-footer .primary-button {
        min-height: 42px;
        padding: 0 8px;
        font-size: 12px;
    }

    .campaign-table-tools,
    .campaign-filter-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .campaign-table-tools {
        width: 100%;
    }

    .campaign-filter-grid,
    .filter-field-grid.two-columns,
    .filter-field-grid.three-columns {
        grid-template-columns: 1fr;
    }

    .metrics-filter-fieldset {
        grid-column: auto;
    }

    .campaign-filter-footer > div {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .plan-toolbar,
    .plan-current-banner {
        align-items: stretch;
        flex-direction: column;
    }

    .plan-toolbar {
        gap: 14px;
        padding: 14px;
    }

    .plan-toolbar h2 {
        font-size: 22px;
        line-height: 1.3;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .plan-toolbar-fields {
        gap: 8px;
    }

    .plan-save-button {
        width: 100%;
        justify-self: stretch;
    }

    .plan-current-banner {
        gap: 6px;
        padding: 12px 14px;
    }

    .plan-current-banner strong {
        line-height: 1.45;
    }

    .plan-current-banner .muted,
    .plan-actual-note {
        line-height: 1.55;
    }

    .plan-effectiveness-panel {
        padding: 14px;
    }

    .plan-effectiveness-head {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .plan-effectiveness-baseline {
        align-self: flex-start;
    }

    .plan-effectiveness-controls {
        justify-content: stretch;
        width: 100%;
    }

    .plan-effectiveness-controls label,
    .plan-effectiveness-controls label:first-child {
        flex: 1 1 130px;
        min-width: 0;
    }

    .plan-effectiveness-controls select {
        min-height: 44px;
        font-size: 16px;
    }

    .plan-effectiveness-controls .secondary-button,
    .plan-effectiveness-controls .plan-effectiveness-baseline {
        flex: 1 1 100%;
    }

    .plan-effectiveness-controls .secondary-button {
        min-height: 44px;
    }

    .plan-effectiveness-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .plan-effectiveness-ratio strong {
        font-size: 23px;
    }

    .plan-ai-section > .panel-head {
        align-items: stretch;
    }

    .plan-ai-controls {
        grid-template-columns: 1fr;
    }

    .plan-card-grid {
        gap: 10px;
    }

    .plan-card {
        padding: 14px;
    }

    .plan-card .label {
        min-height: 0;
        font-size: 14px;
    }

    .plan-card-values strong,
    .plan-card-difference strong {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .plan-card-values strong {
        font-size: 19px;
    }

    .plan-toolbar-fields,
    .plan-card-grid,
    .plan-chart-grid {
        grid-template-columns: 1fr;
    }

    .plan-table-panel > .panel-head {
        align-items: stretch;
        flex-direction: column;
    }

    .plan-table-actions {
        justify-content: flex-start;
    }

    .plan-category-action {
        flex: 1 1 140px;
        min-height: 44px;
    }

    .plan-legend {
        flex-basis: 100%;
    }

    .plan-chart-grid {
        gap: 12px;
    }

    .plan-chart-grid .chart-panel,
    .plan-chart-grid .plan-combo-chart {
        min-height: 290px;
    }

    .plan-chart-grid .chart-panel canvas {
        max-height: 240px;
    }

    .plan-chart-grid .plan-combo-chart .panel-head {
        align-items: stretch;
        flex-direction: column;
    }

    .plan-media-toggle {
        width: 100%;
    }

    .plan-media-toggle button {
        flex: 1 1 0;
        min-height: 44px;
    }

    .plan-input-cell input,
    .plan-actual-cell input {
        min-height: 40px;
        font-size: 16px;
    }

    .plan-table-panel {
        padding: 10px;
    }

    .plan-table-panel .table-scroll {
        max-height: calc(100dvh - 300px);
    }

    .plan-table th,
    .plan-table td {
        padding: 10px 8px;
    }

    .plan-table th:first-child,
    .plan-table td:first-child {
        width: 190px;
        min-width: 190px;
    }

    .plan-table th:nth-child(2),
    .plan-table td:nth-child(2) {
        left: 190px;
        width: 52px;
        min-width: 52px;
    }

    .plan-table tbody th:first-child,
    .plan-table tbody th:first-child small {
        white-space: normal;
        overflow-wrap: anywhere;
        line-height: 1.35;
    }

    .plan-table tbody .plan-category-row .plan-category-unit {
        left: 190px;
    }

    .plan-chart-grid .chart-panel.wide {
        grid-column: auto;
    }
}

@media (max-width: 420px) {
    .brand > span:last-child {
        display: none;
    }

    .main {
        padding-right: 10px;
        padding-left: 10px;
    }

    .plan-card-values {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

.cron-error-info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--danger, #dc2626);
    border-radius: 50%;
    background: transparent;
    color: var(--danger, #dc2626);
    font-size: 12px;
    font-weight: 800;
    font-style: italic;
    line-height: 1;
    cursor: pointer;
}

.cron-error-info-button:hover,
.cron-error-info-button:focus-visible {
    background: var(--danger, #dc2626);
    color: #fff;
}

.cron-error-dialog {
    width: min(640px, calc(100vw - 28px));
    max-height: calc(100vh - 48px);
    padding: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 28px 80px rgba(24, 32, 47, 0.24);
}

.cron-error-dialog::backdrop {
    background: rgba(24, 32, 47, 0.38);
    backdrop-filter: blur(3px);
}

.cron-error-dialog-form {
    display: grid;
    gap: 12px;
    padding: 20px;
}

.cron-error-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cron-error-dialog-head h3 {
    margin: 0;
    font-size: 1.05rem;
}

.cron-error-dialog-meta {
    display: grid;
    gap: 6px;
    margin: 0;
    font-size: 12.5px;
}

.cron-error-dialog-meta > div {
    display: flex;
    gap: 8px;
}

.cron-error-dialog-meta dt {
    flex: 0 0 72px;
    color: var(--muted);
    font-weight: 700;
}

.cron-error-dialog-meta dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.cron-error-dialog-message {
    margin: 0;
    padding: 12px;
    max-height: 45vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-soft);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}
