/* Email Dashboard — Notion-inspired, compact */

:root {
    --bg-page: #ffffff;
    --bg-secondary: #f7f6f3;
    --bg-card: #ffffff;
    --bg-hover: #f1f1ef;
    --text-primary: #37352f;
    --text-secondary: #6b6b6b;
    --text-muted: #9b9a97;
    --text-link: #2383e2;
    --border: rgba(55, 53, 47, 0.09);
    --border-heavy: rgba(55, 53, 47, 0.16);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --accent: #2383e2;
    --accent-light: #e8f0fe;
    --success: #0f7b6c;
    --error: #e03e3e;
    --error-light: #fce4e4;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --ga4-color: #2383e2;
    --af-color: #d4854a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.5;
}

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

/* Navigation */
.nav {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.nav-brand { font-weight: 600; font-size: 15px; }
.nav-links { flex: 1; display: flex; gap: 4px; }
.nav-links a {
    padding: 6px 12px; border-radius: 6px;
    text-decoration: none; color: var(--text-secondary);
    font-weight: 500;
}
.nav-links a:hover { background: var(--bg-hover); }
.nav-links a.active { background: var(--accent-light); color: var(--accent); }
.nav-user { display: flex; align-items: center; gap: 12px; }
.btn-logout {
    padding: 4px 10px; border-radius: 4px;
    font-size: 12px; text-decoration: none;
    color: var(--text-secondary);
    border: 1px solid var(--border-heavy);
}
.btn-logout:hover { background: var(--bg-hover); }

/* Main container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

h1 { font-size: 22px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 16px; margin: 28px 0 12px; font-weight: 600; }

/* Filters */
.filters {
    display: flex;
    gap: 14px;
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 6px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filters label {
    display: flex; flex-direction: column;
    font-size: 12px; color: var(--text-secondary);
    gap: 4px;
}
.filters input, .filters select {
    font-family: inherit; font-size: 13px;
    padding: 6px 8px;
    border: 1px solid var(--border-heavy);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-primary);
    min-width: 140px;
}
.filters select[multiple] { min-width: 160px; }
.filters button {
    padding: 7px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    font-size: 13px;
}
.filters button:hover { background: #1a6fc5; }

/* KPI row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 20px 0;
}
.kpi {
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 12px 16px;
}
.kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.kpi-value { font-size: 22px; font-weight: 600; margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Chart */
.chart-wrap {
    height: 340px;
    margin: 12px 0 24px;
    position: relative;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
th, td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    position: sticky; top: 0;
    cursor: pointer;
    user-select: none;
}
th:hover { background: var(--bg-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:nth-child(even):not(.total-row) { background: var(--bg-secondary); }
tr.row-clickable { cursor: pointer; }
tr.row-clickable:hover { background: var(--bg-hover) !important; }
tr.total-row { font-weight: 600; background: #ecebe7; }

/* Tags */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.tag-ga4 { background: rgba(35, 131, 226, 0.1); color: var(--ga4-color); }
.tag-af { background: rgba(212, 133, 74, 0.12); color: var(--af-color); }
.brand-dot {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-secondary);
    margin-right: 6px;
}

.breadcrumb {
    margin-bottom: 12px;
    font-size: 13px;
}
.breadcrumb a { color: var(--text-link); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.campaign-header {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.campaign-meta { display: flex; gap: 8px; align-items: center; }
.campaign-name {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 18px;
    word-break: break-all;
    margin: 0;
}
.brand-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    background: var(--accent-light);
    color: var(--accent);
    letter-spacing: 0.4px;
}

/* Login page */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-secondary);
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 32px;
    width: 340px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.login-card h1 { margin: 0; }
.login-card label {
    display: flex; flex-direction: column;
    gap: 4px; font-size: 12px; color: var(--text-secondary);
}
.login-card input {
    padding: 8px 10px;
    border: 1px solid var(--border-heavy);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}
.login-card button {
    margin-top: 8px;
    padding: 10px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    font-size: 14px;
}
.login-card button:hover { background: #1a6fc5; }

.alert {
    padding: 10px 12px;
    background: var(--error-light);
    color: var(--error);
    border-radius: 4px;
    font-size: 13px;
}
/* Generic hidden — any element with .hidden is removed from layout. */
.hidden { display: none !important; }

.empty {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

.scroll-x {
    overflow-x: auto;
}
.scroll-x table { min-width: max-content; }

.benchmark-panel {
    margin: 24px 0;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border);
}
.benchmark-panel h2 { font-size: 14px; }
.benchmark-panel table { font-size: 12px; }
.benchmark-panel th { font-size: 11px; }

.delta-up { color: var(--success); font-weight: 600; }
.delta-down { color: var(--error); font-weight: 600; }
.bench-warn { color: var(--warning, #c77d2e); cursor: help; }

.seg-link {
    margin-left: 8px;
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.seg-link:hover { text-decoration: underline; }

.filter-banner {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 4px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.filter-banner a { color: var(--accent); text-decoration: none; font-weight: 600; }
.filter-banner a:hover { text-decoration: underline; }

.sent-weekend {
    color: var(--error);
    font-weight: 600;
}
.sent-holiday {
    color: var(--warning, #c77d2e);
    font-weight: 600;
    cursor: help;
    border-bottom: 1px dotted var(--warning, #c77d2e);
}

.metrics-legend-row {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin: 24px 0 8px;
}
.metrics-legend > summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 12px;
    list-style: none;
    user-select: none;
}
.metrics-legend > summary::-webkit-details-marker { display: none; }
.metrics-legend[open] > summary { color: var(--text-secondary); }
.metrics-legend-table {
    margin-top: 8px;
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 4px 0;
    font-size: 12px;
    line-height: 1.5;
    border-collapse: collapse;
}
.metrics-legend-table th {
    text-align: left;
    padding: 8px 14px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 12px;
    width: 130px;
    vertical-align: top;
    background: transparent;
    cursor: default;
}
.metrics-legend-table td {
    padding: 8px 14px 8px 0;
    color: var(--text-secondary);
    vertical-align: top;
}
.metrics-legend-table th:hover { background: transparent; }

/* Heatmap grid — single column, never overflowing the panel */
.heatmap-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 16px;
    max-width: 100%;
    min-width: 0;
}
.heatmap-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 16px;
    /* min-width:0 lets flex/grid children shrink; max-width prevents overflow */
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.heatmap-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.heatmap-card-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}
.heatmap-table-wrap {
    overflow-x: auto;
}
.heatmap-table {
    width: max-content;
    border-collapse: separate;
    border-spacing: 2px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.heatmap-table th, .heatmap-table td {
    padding: 0;
    border: none;
}
.heatmap-table thead th {
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 10px;
    padding: 2px 4px;
    text-align: center;
    cursor: default;
    position: static;
}
.heatmap-table thead th:hover { background: transparent; }
.heatmap-table .brand-col {
    text-align: left;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 11px;
    padding: 4px 8px 4px 4px;
    white-space: nowrap;
    background: transparent;
}
.heatmap-table .day-col.weekend { color: var(--warning, #c77d2e); }
.heatmap-table .total-col {
    text-align: right;
    font-weight: 600;
    padding: 4px 8px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border-radius: 3px;
    white-space: nowrap;
}
.heatmap-table .cell {
    /* width / font-size set inline by JS based on dataset size & viewport */
    text-align: center;
    border-radius: 2px;
    line-height: 1;
    vertical-align: middle;
    cursor: default;
    transition: outline 0.1s;
    overflow: hidden;
    padding: 0;
}
.heatmap-table .cell:hover {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    z-index: 1;
}
.heatmap-table tbody tr:nth-child(even) { background: transparent; }
.heatmap-table tbody tr:hover { background: transparent; }

/* Brand summary cards */
.ms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.ms-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.1s, box-shadow 0.1s;
}
.ms-card:hover {
    border-color: var(--border-heavy);
    box-shadow: var(--shadow-sm);
}
.ms-card-total {
    background: linear-gradient(135deg, #f7f6f3 0%, #fff 100%);
    border-color: var(--accent-light);
    grid-column: 1 / -1;
}
.ms-card-total .ms-revenue-value { color: var(--accent); }
.ms-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.ms-brand {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--text-primary);
}
.ms-share {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}
.ms-revenue {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.ms-revenue-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
.ms-revenue-delta {
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.ms-bar {
    height: 4px;
    background: var(--bg-hover);
    border-radius: 2px;
    overflow: hidden;
}
.ms-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}
.ms-card-total .ms-bar-fill { background: var(--success); }
.ms-tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 4px;
}
.ms-tile {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.ms-tile-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 500;
}
.ms-tile-value {
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
.ms-tile-delta {
    font-size: 10px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.delta-flat { color: var(--text-muted); }

/* Draft loader (countdown ring) */
.loader-card {
    text-align: center;
    padding: 40px 20px;
    max-width: 480px;
    margin: 24px auto;
}
.loader-ring {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
}
.loader-ring svg {
    transform: rotate(-90deg);
}
.loader-ring-bg {
    fill: none;
    stroke: var(--bg-hover);
    stroke-width: 6;
}
.loader-ring-fg {
    fill: none;
    stroke: var(--accent);
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.4s linear;
}
.loader-arc-overtime {
    stroke: var(--warning, #c77d2e) !important;
    animation: arc-pulse 1.4s ease-in-out infinite;
}
@keyframes arc-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}
.loader-countdown {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.loader-card h2 {
    font-size: 18px;
    margin: 0 0 6px;
    font-weight: 600;
}
.loader-tips {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    transition: opacity 0.2s;
    min-height: 18px;
}

/* Composer refine blocks (feedback / corrections) */
.refine-block {
    margin: 16px 0;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border-left: 3px solid var(--accent);
}
.refine-block label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.refine-block textarea {
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid var(--border-heavy);
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
}

/* Knowledge file pills in library detail */
.kn-files { display: inline-flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
.kn-file {
    text-decoration: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}
.kn-file code { background: transparent; padding: 0; }
.kn-file:hover { border-color: var(--accent); background: var(--accent-light); }

/* Draft generator */
.draft-step {
    margin-top: 16px;
}
.draft-step h2 { font-size: 16px; margin: 0 0 12px; }
.draft-step.hidden { display: none; }
.draft-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 6px;
    align-items: start;
}
.draft-form label.full { grid-column: 1 / -1; }
.draft-form label {
    display: flex; flex-direction: column; gap: 4px;
    font-size: 12px; color: var(--text-secondary);
}
.draft-form input, .draft-form textarea, .draft-form select {
    font-family: inherit; font-size: 13px;
    padding: 8px 10px;
    border: 1px solid var(--border-heavy);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-primary);
}
.draft-form textarea { resize: vertical; min-height: 80px; }
.draft-form .btn-primary { grid-column: 1 / -1; justify-self: end; }

.btn-primary {
    padding: 9px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}
.btn-primary:hover:not(:disabled) { background: #1a6fc5; }
.btn-primary:disabled { opacity: 0.5; cursor: wait; }
.btn-secondary {
    padding: 8px 14px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-heavy);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }
.btn-secondary:disabled { opacity: 0.5; }

.proposal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 12px;
    display: grid;
    gap: 8px;
}
.proposal-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.proposal-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
}
.proposal-num {
    font-weight: 700;
    color: var(--accent);
    font-size: 13px;
}
.proposal-angle {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 13px;
}
.proposal-subject {
    font-size: 14px;
    font-weight: 500;
}
.proposal-sketch {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}
.proposal-card .btn-pick { justify-self: start; }

.draft-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.draft-preview-meta {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 13px;
}
.draft-preview-meta input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-heavy);
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    margin-top: 2px;
}

.draft-refs {
    margin-top: 24px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
}
.draft-refs.hidden { display: none; }
.draft-refs summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}
.refs-table {
    width: 100%;
    margin-top: 8px;
    font-size: 12px;
}
.refs-table th, .refs-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
}

.saved-warning {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(199, 125, 46, 0.10);
    border-left: 3px solid var(--warning, #c77d2e);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-primary);
}

/* Confirm step — danger button + safety callout */
.btn-danger {
    padding: 9px 18px;
    background: var(--error);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}
.btn-danger:hover:not(:disabled) { background: #b32f2f; }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }

.confirm-safe {
    background: var(--success-light);
    border-left: 4px solid var(--success);
    padding: 14px 18px;
    border-radius: 4px;
}
.confirm-danger {
    background: var(--error-light);
    border-left: 4px solid var(--error);
    padding: 14px 18px;
    border-radius: 4px;
    animation: alert-pulse 1.5s ease-in-out infinite;
}
@keyframes alert-pulse {
    0%, 100% { background: var(--error-light); }
    50% { background: rgba(224, 62, 62, 0.18); }
}
.confirm-headline {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.confirm-checks {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    line-height: 1.7;
}
.confirm-checks code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}
#confirm-payload {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px;
    font-size: 11px;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 400px;
    margin: 8px 0;
}

/* Daily recap */
.recap-row-today {
    background: rgba(35, 131, 226, 0.10) !important;
    box-shadow: inset 4px 0 0 var(--accent);
}
.recap-row-today td {
    font-weight: 600;
}
.recap-row-today td:first-child {
    padding-left: 14px;
}
.recap-subject {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 480px;
}
.recap-cid {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    font-weight: 600;
}

/* Draft library */
.badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.badge-saved { background: var(--success-light); color: var(--success); }
.badge-local { background: var(--bg-hover); color: var(--text-muted); }
.library-detail-header {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 12px; justify-content: space-between;
}
.library-detail-actions {
    display: flex; gap: 8px;
}
#library-confirm.hidden { display: none; }
#library-confirm-payload {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px;
    font-size: 11px;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 400px;
    margin: 8px 0;
}
#btn-save-to-gr.hidden { display: none; }
.library-detail-card {
    background: var(--bg-secondary);
    padding: 14px 18px;
    border-radius: 6px;
    margin-bottom: 12px;
}
.library-meta {
    margin: 0; padding-left: 18px;
    font-size: 12px; line-height: 1.7;
}
.library-meta code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
}
#library-detail.hidden, #library-list.hidden { display: none; }

/* Brand profile */
.brand-header { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.brand-header h1 { margin: 0; }
.composer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 4px;
}
.composer-header h1 { margin: 0; }
.composer-header .btn-secondary { text-decoration: none; }
.brand-picker {
    font-family: inherit;
    font-size: 18px;
    font-weight: 700;
    padding: 6px 12px;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    cursor: pointer;
}
.brand-charts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 16px;
}
@media (min-width: 1100px) {
    .brand-charts { grid-template-columns: 1fr 1fr; }
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 16px;
}
.chart-card h3 {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.chart-card .chart-wrap { height: 260px; }

.segment-legend {
    margin: 12px 0 4px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    font-size: 12px;
}
.seg-legend-title {
    font-weight: 600;
    color: var(--text-primary);
}
.seg-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.seg-swatch {
    width: 12px; height: 12px;
    border-radius: 2px;
    display: inline-block;
}
.seg-legend-label {
    color: var(--text-secondary);
}
.seg-flipped {
    margin-left: auto;
    color: var(--warning, #c77d2e);
    font-size: 11px;
    font-style: italic;
}

/* Segment include-filter — pill toggles per segment, matches filter row height */
.filter-segs {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}
.filter-label-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: help;
    position: relative;
    font-size: 13px;
    line-height: 1;
    user-select: none;
}
.info-icon:hover { color: var(--accent); }
.info-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #2a2a28;
    color: #fff;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.5;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
    z-index: 30;
    box-shadow: var(--shadow-md);
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    min-width: 200px;
}
.info-tooltip::after {
    /* Little arrow pointing down at the icon */
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #2a2a28;
}
.info-icon:hover .info-tooltip,
.info-icon:focus-visible .info-tooltip { opacity: 1; pointer-events: auto; }
.info-tooltip-title {
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 11px;
    color: #fff;
}
.info-tooltip-row {
    display: flex;
    gap: 10px;
    align-items: baseline;
    line-height: 1.4;
}
.info-tooltip-letter {
    font-weight: 700;
    min-width: 14px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.info-tooltip-note {
    margin-top: 6px;
    color: #f0c87a;
    font-size: 10px;
    border-top: 1px solid rgba(255,255,255,0.15);
    padding-top: 6px;
    white-space: normal;
}
.seg-toggles {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 30px;
}
.seg-toggle {
    --seg-color: #888;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    padding: 0 9px;
    border-radius: 13px;
    border: 1.5px solid var(--seg-color);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    background: transparent;
    color: var(--seg-color);
    transition: opacity 0.12s, transform 0.12s, background 0.12s, color 0.12s;
}
.seg-toggle.on {
    background: var(--seg-color);
    color: #fff;
}
.seg-toggle.off {
    opacity: 0.45;
}
.seg-toggle:hover {
    opacity: 1;
    transform: translateY(-1px);
}
.seg-toggle:focus-visible {
    outline: 2px solid var(--seg-color);
    outline-offset: 2px;
}
.seg-toggles-row {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
.seg-quick-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
    height: 22px;
}
/* Override `.filters button` (accent blue) for these tertiary inline links. */
.filters .seg-quick {
    background: transparent;
    border: none;
    box-shadow: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    border-radius: 3px;
    height: auto;
    min-width: 0;
}
.filters .seg-quick:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Health check */
.health-summary { margin: 16px 0 24px; }
.health-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.health-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);
    border-radius: 6px;
    padding: 12px 16px;
}
.health-card-good { border-left-color: var(--success); }
.health-card-warn { border-left-color: var(--warning, #c77d2e); }
.health-card-bad  { border-left-color: var(--error); }
.health-card-neutral { border-left-color: var(--text-muted); }
.health-card-name { font-weight: 600; font-size: 13px; }
.health-card-pct {
    font-size: 22px; font-weight: 700; margin-top: 4px;
    font-variant-numeric: tabular-nums;
}
.health-card-meta { font-size: 11px; margin-top: 2px; }

.health-source {
    margin: 24px 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 16px;
}
.health-source-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.health-source-header h2 { margin: 0; font-size: 14px; }
.health-source-meta { font-size: 11px; }
.health-discrete-tag {
    background: var(--bg-secondary);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    margin-left: 6px;
}
.health-source-note {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 8px 12px;
    border-radius: 4px;
    margin: 4px 0 10px;
}
.health-table-wrap { overflow-x: auto; }
.health-table {
    border-collapse: separate;
    border-spacing: 2px;
    font-size: 10px;
}
.health-table th, .health-table td { border: none; padding: 0; }
.health-table thead th {
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 9px;
    padding: 2px 3px;
    text-align: center;
    cursor: default;
}
.health-table thead th:hover { background: transparent; }
.health-table .brand-col {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px 2px 4px;
    white-space: nowrap;
    color: var(--text-primary);
}
.health-table .day-col.weekend { color: var(--warning, #c77d2e); }
.health-cell {
    width: 18px; min-width: 18px; max-width: 18px;
    height: 18px;
    border-radius: 3px;
    cursor: default;
}
.health-cell.ok { background: rgba(15, 123, 108, 0.85); }
.health-cell.missing { background: rgba(224, 62, 62, 0.7); }
.health-cell.discrete-empty {
    background: rgba(155, 154, 151, 0.18);
    border: 1px dashed rgba(155, 154, 151, 0.4);
}
.health-cell:hover { outline: 2px solid var(--accent); outline-offset: -1px; }
.health-table .total-col {
    text-align: right;
    padding: 2px 6px 2px 8px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-size: 11px;
}
.health-table .total-col.all-ok { color: var(--success); }
.health-table .total-col.all-missing { color: var(--error); }
.health-table .total-col.partial { color: var(--warning, #c77d2e); }

/* Open rate / CTOR matrices */
.orm-wrap {
    overflow-x: auto;
    margin-bottom: 24px;
}
.orm-table {
    border-collapse: separate;
    border-spacing: 4px;
}
.orm-table th, .orm-table td { border: none; padding: 0; }
.orm-table thead th { background: transparent; cursor: default; }
.orm-table thead th:hover { background: transparent; }
.orm-brand {
    font-weight: 600;
    font-size: 12px;
    padding: 6px 10px 6px 4px;
    white-space: nowrap;
    color: var(--text-primary);
}
.orm-seg {
    font-size: 11px;
    text-align: center;
    color: var(--text-muted);
    padding: 4px 8px;
    min-width: 90px;
}
.orm-seg-label {
    display: block;
    font-size: 9px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}
.orm-cell {
    width: 90px;
    height: 56px;
    text-align: center;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
    cursor: default;
    transition: outline 0.1s;
    padding: 4px 0;
}
.orm-cell .orm-value {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}
.orm-cell .orm-delta {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.1;
    margin-top: 2px;
    opacity: 0.92;
}
/* Delta pills — readable on both light AND dark heatmap cells.
   Background ensures contrast regardless of cell intensity. */
.orm-delta {
    display: inline-flex;
    justify-content: center;
}
.orm-delta-up,
.orm-delta-down,
.orm-delta-na {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
    line-height: 1.2;
    backdrop-filter: blur(2px);
}
.orm-delta-up {
    color: #0a5e3a;
    background: rgba(220, 252, 231, 0.92);
}
.orm-delta-down {
    color: #8a1a1a;
    background: rgba(254, 226, 226, 0.92);
}
.orm-delta-na {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.55);
}
.orm-cell:hover {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}
.orm-cell.empty {
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
}

/* Segmented control (e.g. chart metric switcher) */
.chart-mode-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0 6px;
}
.chart-mode-label {
    font-size: 12px;
    color: var(--text-muted);
}
.seg-control {
    display: inline-flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}
.seg-btn {
    background: transparent;
    border: none;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
    transition: background 0.1s, color 0.1s;
}
.seg-btn:hover { color: var(--text-primary); }
.seg-btn.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

/* Skeleton loaders */
@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}
.skeleton {
    background: linear-gradient(90deg,
        var(--bg-hover) 0%,
        var(--bg-secondary) 50%,
        var(--bg-hover) 100%);
    background-size: 200% 100%;
    animation: skeleton-shine 1.4s ease-in-out infinite;
    border-radius: 4px;
}
@keyframes skeleton-shine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-kpi {
    height: 76px;
}
.skeleton-bench {
    height: 220px;
    margin: 16px 0;
}
.skeleton-chart {
    height: 340px;
    margin: 12px 0 24px;
}
.chart-wrap { position: relative; }
.chart-skeleton-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.skeleton-table {
    height: 200px;
}
.skeleton-preview {
    height: 48px;
    margin: 16px 0;
}
.loading-dot::after {
    content: "";
    display: inline-block;
    width: 6px; height: 6px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: skeleton-pulse 1s ease-in-out infinite;
    vertical-align: middle;
}

/* Email preview panel */
.preview-panel {
    margin: 16px 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    overflow: hidden;
}
.preview-panel > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 16px;
    font-size: 13px;
    background: var(--bg-secondary);
    user-select: none;
}
.preview-panel > summary::before {
    content: "▶ ";
    color: var(--text-muted);
    font-size: 10px;
    margin-right: 4px;
}
.preview-panel[open] > summary::before { content: "▼ "; }
.preview-panel > summary::-webkit-details-marker { display: none; }
.preview-body {
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.preview-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    font-size: 12px;
}
.preview-alt {
    font-size: 11px;
    padding: 6px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
}
.preview-iframe {
    width: 100%;
    height: 50vh;
    min-height: 360px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #ffffff;
}
