/* ============================================================
   flack.marziale.tech — Themed Styles
   Light / Dark / System · Blue Accent
   ============================================================ */

/* ============================================================
   Fonts
   ============================================================ */
@font-face {
    font-family: 'Autograf';
    src: url('../static/fonts/AutografPersonalUseOnly-mOBm.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

.brand-rho {
    font-style: italic;
}

/* ============================================================
   Theme Variables
   ============================================================ */
:root {
    --brand-mark-font: 'STIX Two Text', 'Cambria Math', 'Latin Modern Math', Georgia, serif;

    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-dim: #f1f5f9;
    --surface-hover: rgba(0, 0, 0, 0.03);

    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --accent: #1d4ed8;
    --accent-dim: #1e3a8a;
    --accent-glow: rgba(29, 78, 216, 0.08);
    --accent-surface: rgba(29, 78, 216, 0.06);

    --logo-filter: brightness(0) saturate(100%) invert(22%) sepia(89%) saturate(2476%) hue-rotate(213deg) brightness(93%) contrast(96%);

    --rules-accent: #7c3aed;
    --rules-accent-surface: rgba(124, 58, 237, 0.1);
    --rules-accent-pending-bg: #ddd6fe;
    --rules-accent-pending-text: #4c1d95;

    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --success: #16a34a;

    --fill: #16a34a;
    --fill-dim: #15803d;
    --fill-glow: rgba(34, 197, 94, 0.08);
    --fill-surface: rgba(34, 197, 94, 0.06);

    --sched-filled-tint: color-mix(in srgb, #16a34a 26%, var(--surface));
    --sched-partial-tint: color-mix(in srgb, #ca8a04 28%, var(--surface));
    --sched-unfilled-tint: color-mix(in srgb, #dc2626 22%, var(--surface));
    --sched-filled-tint-hour: color-mix(in srgb, #16a34a 22%, var(--surface));
    --sched-unfilled-tint-hour: color-mix(in srgb, #dc2626 18%, var(--surface));
    --sched-filled-tint-hover: color-mix(in srgb, #16a34a 34%, var(--surface));
    --sched-partial-tint-hover: color-mix(in srgb, #ca8a04 36%, var(--surface));
    --sched-unfilled-tint-hover: color-mix(in srgb, #dc2626 30%, var(--surface));

    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;

    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);

    --input-bg: #ffffff;
    --input-border: #d1d5db;

    --modal-overlay: rgba(0, 0, 0, 0.3);
    --modal-bg: #ffffff;

    --scrollbar-thumb: rgba(0, 0, 0, 0.15);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.25);

    --skeleton: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-raised: #1e293b;
    --surface-dim: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.05);

    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;

    --border: #334155;
    --border-light: rgba(255, 255, 255, 0.06);

    --accent: #60a5fa;
    --accent-dim: #3b82f6;
    --accent-glow: rgba(96, 165, 250, 0.12);
    --accent-surface: rgba(96, 165, 250, 0.08);

    --logo-filter: brightness(0) saturate(100%) invert(71%) sepia(46%) saturate(1234%) hue-rotate(186deg) brightness(101%) contrast(101%);

    --rules-accent: #a78bfa;
    --rules-accent-surface: rgba(167, 139, 250, 0.14);
    --rules-accent-pending-bg: color-mix(in srgb, var(--rules-accent) 46%, #312e81);
    --rules-accent-pending-text: #ede9fe;

    --danger: #f87171;
    --warning: #fbbf24;
    --info: #60a5fa;
    --success: #4ade80;

    --fill: #22c55e;
    --fill-dim: #16a34a;
    --fill-glow: rgba(34, 197, 94, 0.12);
    --fill-surface: rgba(34, 197, 94, 0.08);

    --sched-filled-tint: color-mix(in srgb, #4ade80 32%, var(--surface));
    --sched-partial-tint: color-mix(in srgb, #facc15 34%, var(--surface));
    --sched-unfilled-tint: color-mix(in srgb, #f87171 28%, var(--surface));
    --sched-filled-tint-hour: color-mix(in srgb, #4ade80 28%, var(--surface));
    --sched-unfilled-tint-hour: color-mix(in srgb, #f87171 24%, var(--surface));
    --sched-filled-tint-hover: color-mix(in srgb, #4ade80 40%, var(--surface));
    --sched-partial-tint-hover: color-mix(in srgb, #facc15 42%, var(--surface));
    --sched-unfilled-tint-hover: color-mix(in srgb, #f87171 36%, var(--surface));

    --sidebar-bg: rgba(15, 23, 42, 0.98);
    --sidebar-border: #334155;

    --card-bg: #1e293b;
    --card-border: #334155;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);

    --input-bg: rgba(255, 255, 255, 0.05);
    --input-border: #475569;

    --modal-overlay: rgba(0, 0, 0, 0.6);
    --modal-bg: #1e293b;

    --scrollbar-thumb: rgba(255, 255, 255, 0.12);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.2);

    --skeleton: rgba(255, 255, 255, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --bg: #0f172a;
        --surface: #1e293b;
        --surface-raised: #1e293b;
        --surface-dim: rgba(255, 255, 255, 0.04);
        --surface-hover: rgba(255, 255, 255, 0.05);

        --text: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --text-subtle: #64748b;

        --border: #334155;
        --border-light: rgba(255, 255, 255, 0.06);

        --accent: #60a5fa;
        --accent-dim: #3b82f6;
        --accent-glow: rgba(96, 165, 250, 0.12);
        --accent-surface: rgba(96, 165, 250, 0.08);

    --logo-filter: brightness(0) saturate(100%) invert(71%) sepia(46%) saturate(1234%) hue-rotate(186deg) brightness(101%) contrast(101%);

        --rules-accent: #a78bfa;
        --rules-accent-surface: rgba(167, 139, 250, 0.14);
        --rules-accent-pending-bg: color-mix(in srgb, var(--rules-accent) 46%, #312e81);
        --rules-accent-pending-text: #ede9fe;

        --danger: #f87171;
        --warning: #fbbf24;
        --info: #60a5fa;
        --success: #4ade80;

    --fill: #22c55e;
    --fill-dim: #16a34a;
    --fill-glow: rgba(34, 197, 94, 0.12);
    --fill-surface: rgba(34, 197, 94, 0.08);

        --sched-filled-tint: color-mix(in srgb, #4ade80 32%, var(--surface));
        --sched-partial-tint: color-mix(in srgb, #facc15 34%, var(--surface));
        --sched-unfilled-tint: color-mix(in srgb, #f87171 28%, var(--surface));
        --sched-filled-tint-hour: color-mix(in srgb, #4ade80 28%, var(--surface));
        --sched-unfilled-tint-hour: color-mix(in srgb, #f87171 24%, var(--surface));
        --sched-filled-tint-hover: color-mix(in srgb, #4ade80 40%, var(--surface));
        --sched-partial-tint-hover: color-mix(in srgb, #facc15 42%, var(--surface));
        --sched-unfilled-tint-hover: color-mix(in srgb, #f87171 36%, var(--surface));

        --sidebar-bg: rgba(15, 23, 42, 0.98);
        --sidebar-border: #334155;

        --card-bg: #1e293b;
        --card-border: #334155;
        --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);

        --input-bg: rgba(255, 255, 255, 0.05);
        --input-border: #475569;

        --modal-overlay: rgba(0, 0, 0, 0.6);
        --modal-bg: #1e293b;

        --scrollbar-thumb: rgba(255, 255, 255, 0.12);
        --scrollbar-thumb-hover: rgba(255, 255, 255, 0.2);

        --skeleton: rgba(255, 255, 255, 0.05);
    }
}

/* ============================================================
   Theme Bridge — remap Tailwind dark-specific utilities to
   CSS variables so page templates work in both themes without
   needing per-file edits. The `body` parent provides the
   specificity bump needed to beat Tailwind CDN's utilities.
   ============================================================ */

/* Backgrounds */
body.bg-black,
body .bg-black {
    background-color: var(--bg);
}

/* Primary text */
body .text-white {
    color: var(--text);
}
body .text-gray-200 {
    color: var(--text);
}
body .text-gray-500 {
    color: var(--text-muted);
}

/* White-opacity text → semantic text tiers */
body .text-white\/30 {
    color: var(--text-subtle);
}
body .text-white\/40 {
    color: var(--text-muted);
}
body .text-white\/50 {
    color: var(--text-muted);
}
body .text-white\/60 {
    color: var(--text-secondary);
}
body .text-white\/70 {
    color: var(--text-secondary);
}

/* Surface / skeleton backgrounds */
body .bg-white\/5,
body .bg-white\/\[0\.04\],
body .bg-white\/\[0\.06\] {
    background-color: var(--surface-dim);
}
body .bg-white\/10 {
    background-color: var(--surface-dim);
}

/* Hover surface (used in interactive rows) */
body .hover\:bg-white\/\[0\.03\]:hover,
body .hover\:bg-white\/\[0\.04\]:hover,
body .hover\:bg-white\/\[0\.06\]:hover,
body .hover\:bg-white\/10:hover {
    background-color: var(--surface-hover);
}

/* Very subtle text (20%, 80%) */
body .text-white\/20 {
    color: var(--text-subtle);
}
body .text-white\/80 {
    color: var(--text);
}

/* Hover text overrides */
body .hover\:text-white:hover {
    color: var(--text);
}
body .hover\:text-white\/60:hover,
body .hover\:text-white\/70:hover {
    color: var(--text-secondary);
}

/* Border overrides */
body .border-white\/10,
body .border-white\/\[0\.08\] {
    border-color: var(--border);
}

/* Accent text/bg/border — use theme variable */
body .text-accent {
    color: var(--accent);
}
body .bg-accent {
    background-color: var(--accent);
}
body .border-accent {
    border-color: var(--accent);
}
body .hover\:text-accent-dim:hover {
    color: var(--accent-dim);
}
body .border-b-2.border-accent {
    border-color: var(--accent);
}
body .bg-accent\/10 { background-color: color-mix(in srgb, var(--accent) 10%, transparent); }
body .bg-accent\/20 { background-color: color-mix(in srgb, var(--accent) 20%, transparent); }
body .bg-accent\/30 { background-color: color-mix(in srgb, var(--accent) 30%, transparent); }
body .hover\:bg-accent\/10:hover { background-color: color-mix(in srgb, var(--accent) 10%, transparent); }
body .hover\:bg-accent\/30:hover { background-color: color-mix(in srgb, var(--accent) 30%, transparent); }
body .border-accent\/20 { border-color: color-mix(in srgb, var(--accent) 20%, transparent); }
body .border-accent\/30 { border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
body .border-accent\/50 { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
body .hover\:border-accent\/50:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

/* Black/white overlay backgrounds used in mobile */
body .bg-black\/80 {
    background-color: var(--surface);
}

/* ============================================================
   Base / Typography
   ============================================================ */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background-color 0.2s ease, color 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
input,
textarea,
select,
[contenteditable="true"],
.allow-text-select,
.allow-text-select * {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

/* ============================================================
   Scrollbar — hidden globally; scroll still works via wheel,
   trackpad, touch, and keyboard. Same pattern as Community
   Events (.ce-col-body).
   ============================================================ */
* {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
*::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* ============================================================
   Schedule — full-day list
   ============================================================ */
.sch-day-list {
    display: flex;
    flex-direction: column;
}
.sch-hour-divider {
    display: block;
}
.sch-hour-sep {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 4px 12px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
}
.is-sched-filled::after {
    background-color: var(--sched-filled-tint);
}
.is-sched-partial::after {
    background-color: var(--sched-partial-tint);
}
.is-sched-unfilled::after {
    background-color: var(--sched-unfilled-tint);
}
.planner-gcal-cell.is-sched-filled::after {
    background-color: var(--sched-filled-tint-hour);
}
.planner-gcal-cell.is-sched-unfilled::after {
    background-color: var(--sched-unfilled-tint-hour);
}
.planner-month-cell.is-sched-filled:hover::after {
    background-color: var(--sched-filled-tint-hover);
}
.planner-month-cell.is-sched-partial:hover::after {
    background-color: var(--sched-partial-tint-hover);
}
.planner-month-cell.is-sched-unfilled:hover::after {
    background-color: var(--sched-unfilled-tint-hover);
}
.sch-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 0;
    border-bottom: 1px solid var(--border-light);
    min-height: 28px;
    font-size: 0.75rem;
    transition: background 0.15s;
    --live-progress: 0%;
}
.sch-row:hover {
    background: var(--surface-hover);
}
.sch-row-arrow {
    width: 20px;
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sch-arrow-icon {
    width: 12px;
    height: 10px;
    color: #ef4444;
    animation: sch-arrow-pulse 1.5s ease-in-out infinite;
}
@keyframes sch-arrow-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.sch-row-now {
    background: linear-gradient(
        90deg,
        rgba(239, 68, 68, 0.18) 0 var(--live-progress),
        rgba(239, 68, 68, 0.06) var(--live-progress) 100%
    );
}
.sch-row-now:hover {
    background: linear-gradient(
        90deg,
        rgba(239, 68, 68, 0.22) 0 var(--live-progress),
        rgba(239, 68, 68, 0.10) var(--live-progress) 100%
    );
}
.sch-row-time {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.6875rem;
    color: var(--text-muted);
    min-width: 172px;
    flex-shrink: 0;
}
.sch-row-color {
    width: 4px;
    height: 16px;
    border-radius: 2px;
    flex-shrink: 0;
}
.sch-row-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    font-size: 0.75rem;
}
.sch-row-client {
    font-size: 0.6875rem;
    color: var(--accent);
    flex-shrink: 0;
    white-space: nowrap;
}
/* Rotation tier + decade badge (Phase 3a) */
.sch-row-rot {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.625rem;
    color: var(--text-subtle);
    background: var(--surface-2, rgba(255,255,255,0.06));
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    padding: 1px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
/* Rotation Rules panel (Phase 3b) — daypart cards */
.sch-daypart-card {
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 96px;
}
.sch-daypart-card:hover {
    border-color: var(--border);
}
/* Phase 3d — special override variant */
.sch-override-card {
    border-style: dashed;
    border-color: rgba(168, 85, 247, 0.45);
}
.sch-override-card:hover {
    border-color: rgba(168, 85, 247, 0.75);
}
.sch-daypart-card-disabled {
    opacity: 0.45;
}
.sch-daypart-edit {
    background: transparent;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    flex-shrink: 0;
}
.sch-daypart-edit:hover {
    color: var(--text);
    background: var(--surface-hover);
}
.sch-daypart-edit svg {
    width: 14px;
    height: 14px;
}
.sch-rot-kind {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.625rem;
    color: var(--text-subtle);
    background: var(--surface-dim);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    letter-spacing: 0.02em;
}
/* Rotation Rules panel header + New menu */
.rules-root {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0.35rem;
    --rules-tree-line: color-mix(in srgb, var(--text-subtle) 58%, transparent);
    --rules-tree-cover: var(--bg);
    --rules-tree-gutter: 0.42rem;
    --rules-tree-indent: 0.88rem;
    --rules-tree-elbow-y: 0.62em;
}
.rules-tree-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 0.1rem;
}
.rules-tree-head-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0.12rem 0.1rem;
    border: none;
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
    color: inherit;
    border-radius: 0.25rem;
}
.rules-tree-head-toggle:hover {
    background: var(--surface-hover);
}
.rules-tree-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.01em;
}
.rules-tree-add-wrap {
    position: relative;
    flex-shrink: 0;
}
.rules-tree-add {
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.rules-tree-add:hover:not(:disabled) {
    color: var(--accent);
    background: var(--surface-hover);
}
.rules-tree-add:disabled {
    opacity: 0.35;
    cursor: default;
}
.rules-tree-body {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--text-muted);
}
.rules-tree-section + .rules-tree-section {
    margin-top: 0.15rem;
}
.rules-tree-section-head {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
    margin: 0 0 0.15rem;
    padding: 0.12rem 0.1rem;
    border: none;
    background: none;
    text-align: left;
    font: inherit;
    cursor: pointer;
    color: inherit;
    border-radius: 0.25rem;
}
.rules-tree-section-head:hover {
    background: var(--surface-hover);
}
.rules-tree-section-chev {
    width: 0.75rem;
    height: 0.75rem;
    flex-shrink: 0;
    color: var(--text-subtle);
    transform: rotate(0deg);
    transition: transform 0.15s ease;
}
.rules-tree-section-chev.is-open {
    transform: rotate(90deg);
}
.rules-tree-section-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-subtle);
}
.rules-tree-section.is-collapsed .rules-tree-section-body {
    display: none;
}
.rules-tree-count {
    margin-left: 0.35rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}
.rules-tree-branch-list {
    margin: 0.05rem 0 0 var(--rules-tree-gutter);
    padding: 0;
    border-left: 1px solid var(--rules-tree-line);
}
.rules-tree-node-row {
    position: relative;
    padding-left: var(--rules-tree-indent);
}
.rules-tree-node-row::before {
    content: '';
    position: absolute;
    left: 0;
    top: var(--rules-tree-elbow-y);
    width: var(--rules-tree-indent);
    height: 1px;
    background: var(--rules-tree-line);
}
.rules-tree-node.is-last > .rules-tree-node-row::after {
    content: '';
    position: absolute;
    left: -1px;
    top: calc(var(--rules-tree-elbow-y) + 1px);
    bottom: 0;
    width: 1px;
    background: var(--rules-tree-cover);
}
.rules-tree-node.is-group > .rules-tree-branch-list.is-nested {
    position: relative;
    margin-left: var(--rules-tree-indent);
    margin-top: calc(-1 * var(--rules-tree-elbow-y) - 0.12rem);
    padding-top: calc(var(--rules-tree-elbow-y) + 0.12rem);
    border-left: 1px solid var(--rules-tree-line);
}
.rules-tree-node.is-group > .rules-tree-branch-list.is-nested::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--rules-tree-indent) - 1px);
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--rules-tree-cover);
    pointer-events: none;
}
.rules-tree-item {
    display: block;
    width: 100%;
    padding: 0.12rem 0;
    border: none;
    background: none;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
}
.rules-tree-item:hover .rules-tree-label {
    color: var(--text);
}
.rules-tree-item.is-selected .rules-tree-label {
    color: var(--rules-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.rules-tree-label {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rules-tree-group-head {
    padding: 0.12rem 0;
    font-weight: 500;
    color: var(--text-secondary);
}
.rules-tree-empty-nested {
    padding-left: 0.35rem;
}
.rules-inherit-block + .rules-inherit-block {
    margin-top: 0.65rem;
}
.rules-inherit-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1rem;
}
.rules-inherit-opt {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    cursor: pointer;
}
.rules-inherit-opt input {
    margin: 0;
}
.rules-inherit-target:disabled {
    opacity: 0.45;
}
.rules-override-hour-row {
    display: grid;
    grid-template-columns: 2.75rem 1fr;
    gap: 0.35rem;
    align-items: center;
}
.rules-override-hour-label {
    font-size: 0.68rem;
    color: var(--text-subtle);
}
.rules-override-hour-controls {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 0.25rem;
}
.rules-inline-link {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.rules-inline-link:hover {
    color: var(--rules-accent, #a855f7);
}
.rules-tree-empty {
    padding: 0.1rem 0 0.1rem 0.65rem;
    font-size: 0.68rem;
    color: var(--text-subtle);
    font-style: italic;
}
.rules-tree-muted {
    color: var(--text-subtle);
    font-style: normal;
}
.rules-popover .sch-rot-detail-empty {
    min-height: 0;
    padding: 0.5rem 0;
    border: none;
    background: transparent;
    font-size: 0.8rem;
}
.rules-popover {
    position: fixed;
    z-index: 45;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    border-radius: 0.55rem;
    border: 1px solid color-mix(in srgb, var(--rules-accent) 62%, var(--border));
    background: var(--surface-raised);
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.18), 0 0 0 1px color-mix(in srgb, var(--rules-accent) 18%, transparent);
    pointer-events: auto;
}
.rules-popover.is-hidden {
    display: none;
}
.rules-popover.is-dragging,
.rules-popover.is-resizing {
    user-select: none;
}
.rules-popover.is-minimized .rules-popover-body,
.rules-popover.is-minimized .rules-popover-resize-layer {
    display: none;
}
.rules-popover.is-minimized .rules-popover-dragbar {
    border-bottom: none;
}
.rules-popover-shell {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
}
.rules-popover-resize-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}
.rules-popover-resize {
    position: absolute;
    pointer-events: auto;
    touch-action: none;
}
.rules-popover-resize.is-n {
    top: -4px;
    left: 12px;
    right: 12px;
    height: 8px;
    cursor: n-resize;
}
.rules-popover-resize.is-s {
    bottom: -4px;
    left: 12px;
    right: 12px;
    height: 8px;
    cursor: s-resize;
}
.rules-popover-resize.is-e {
    right: -4px;
    top: 12px;
    bottom: 12px;
    width: 8px;
    cursor: e-resize;
}
.rules-popover-resize.is-w {
    left: -4px;
    top: 12px;
    bottom: 12px;
    width: 8px;
    cursor: w-resize;
}
.rules-popover-resize.is-ne {
    top: -5px;
    right: -5px;
    width: 12px;
    height: 12px;
    cursor: ne-resize;
}
.rules-popover-resize.is-nw {
    top: -5px;
    left: -5px;
    width: 12px;
    height: 12px;
    cursor: nw-resize;
}
.rules-popover-resize.is-se {
    bottom: -5px;
    right: -5px;
    width: 12px;
    height: 12px;
    cursor: se-resize;
}
.rules-popover-resize.is-sw {
    bottom: -5px;
    left: -5px;
    width: 12px;
    height: 12px;
    cursor: sw-resize;
}
.rules-popover-dragbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.45rem 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
    min-width: 10rem;
}
.rules-popover.is-dragging .rules-popover-dragbar {
    cursor: grabbing;
}
.rules-popover-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rules-popover-path {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-subtle);
}
.rules-popover-name {
    text-transform: none;
    letter-spacing: normal;
}
.rules-popover-title-muted {
    font-weight: 500;
    color: var(--text-subtle);
}
.rules-popover-actions {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    flex-shrink: 0;
}
.rules-popover-minimize,
.rules-popover-close {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    border-radius: 0.35rem;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.rules-popover-minimize:hover,
.rules-popover-close:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.rules-popover-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}
.rules-popover .sch-rot-detail-pane {
    width: max-content;
    max-width: calc(100vw - 2rem);
    min-width: 0;
    padding: 0.85rem 1rem 1rem;
    box-sizing: border-box;
}
.rules-popover .sch-rot-detail-head {
    margin-bottom: 0.35rem;
}
.rules-popover .sch-rot-detail-pane.rules-program-pane {
    width: max-content;
    min-width: min(22rem, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
}
.rules-program-form-fields {
    min-width: min(22rem, calc(100vw - 2rem));
}
.rules-program-form-fields .pf-rec-field {
    display: none;
}
.rules-popover .sch-rot-detail-pane.rules-daypart-pane {
    width: max-content;
    max-width: calc(100vw - 2rem);
    min-width: 0;
}
.rules-daypart-split {
    display: grid;
    grid-template-columns: minmax(17rem, max-content) minmax(14rem, max-content);
    gap: 0.75rem;
    align-items: start;
    width: max-content;
    max-width: calc(100vw - 2rem);
}
.rules-daypart-split-meta {
    min-width: 0;
}
.rules-daypart-split-hours {
    min-width: 0;
}
.rules-daypart-hours-card {
    padding: 10px;
    max-height: min(480px, 62vh);
    overflow-y: auto;
}
@media (max-width: 640px) {
    .rules-daypart-split {
        grid-template-columns: 1fr;
        width: 100%;
    }
}
.rules-popover .sch-rot-detail-pane.rules-hour-plan-pane {
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 0.85rem 1rem 1rem;
    box-sizing: border-box;
}
.rules-popover .rules-hour-plan-timeline {
    margin-bottom: 0.75rem;
    min-height: 4rem;
    width: 100%;
}
.rules-popover .rules-hour-inspector.planner-inspector {
    display: grid;
    grid-template-columns: minmax(10.5rem, 32%) minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
}
.rules-popover .rules-hour-inspector .planner-inspector-items {
    min-width: 0;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border);
}

/* Planner fill/clear busy overlays (shared mini calendar lives across Studio tabs) */
.planner-busy-overlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    pointer-events: auto;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
}
.planner-busy-overlay.is-active { display: flex; }
.planner-busy-overlay.is-scrim-only .planner-busy-overlay-panel {
    display: none;
}
.planner-busy-overlay-panel {
    max-width: 18rem;
    width: min(18rem, 82%);
    padding: 0;
    text-align: center;
    background: transparent;
    border: none;
    box-shadow: none;
}
.planner-busy-overlay-label {
    margin: 0 0 0.85rem;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}
.planner-busy-overlay-progress {
    height: 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text) 14%, transparent);
    overflow: hidden;
}
.planner-busy-overlay-progress > div {
    height: 100%;
    width: 100%;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.25s ease, background 0.15s ease;
}
.planner-busy-overlay.is-clear-busy .planner-busy-overlay-progress > div {
    background: var(--danger);
}
[data-theme="dark"] .planner-busy-overlay {
    background: color-mix(in srgb, #020617 74%, transparent);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .planner-busy-overlay {
        background: color-mix(in srgb, #020617 74%, transparent);
    }
}
[data-theme="dark"] .planner-busy-overlay-label {
    color: #f8fafc;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .planner-busy-overlay-label {
        color: #f8fafc;
    }
}
[data-theme="dark"] .planner-busy-overlay-progress {
    background: rgba(255, 255, 255, 0.2);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .planner-busy-overlay-progress {
        background: rgba(255, 255, 255, 0.2);
    }
}
.planner-main-pane.is-busy .planner-toolbar,
.planner-main-pane.is-busy .planner-main-body {
    pointer-events: none;
    user-select: none;
}
.planner-mini-shell.is-busy,
.planner-rail-rules-shell.is-busy {
    pointer-events: none;
    user-select: none;
}

/* FlackConfirm — shared ✓/✕ confirm controls + dialog overlay */
.fk-confirm-overlay {
    z-index: 12000;
}
.fk-confirm-panel {
    max-width: 22rem;
    text-align: center;
    gap: 0.65rem;
}
.fk-confirm-panel.is-danger .fk-confirm-message {
    color: var(--danger);
}
.fk-confirm-message {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
    white-space: pre-wrap;
}
.fk-confirm-detail {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--text-muted);
    white-space: pre-wrap;
}
.fk-confirm-dialog-actions,
.fk-confirm-actions {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.35rem;
}
.fk-confirm-dialog-actions {
    display: flex;
    justify-content: center;
    margin-top: 0.15rem;
}
.fk-confirm-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.35rem;
}
.fk-confirm-row.is-confirming .fk-confirm-actions {
    display: flex;
}
.fk-confirm-row.is-confirming .fk-confirm-trigger {
    flex: 1 1 auto;
    min-width: 0;
}
.fk-confirm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    background: var(--surface-raised);
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.fk-confirm-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.fk-confirm-btn.is-yes {
    color: var(--success, #10b981);
    border-color: color-mix(in srgb, var(--success, #10b981) 45%, var(--border));
}
.fk-confirm-btn.is-yes:hover {
    background: color-mix(in srgb, var(--success, #10b981) 12%, var(--surface-raised));
}
.fk-confirm-btn.is-no:hover {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}

.sch-rot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.sch-rot-new-wrap {
    position: relative;
    flex-shrink: 0;
}
.sch-rot-new-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 168px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 50;
    overflow: hidden;
}
.sch-rot-new-option {
    display: block;
    width: 100%;
    padding: 8px 14px;
    text-align: left;
    font-size: 12px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.sch-rot-new-option:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.sch-rot-sections {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sch-rot-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 280px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-dim);
}
/* Rotation rules in the Planner left rail — stacked nav over detail */
.planner-rail-rules .sch-rot-rail-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}
.planner-rail-rules .sch-rot-rail-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-top: 0.5rem;
}
.planner-rail-rules .sch-rot-split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(140px, 38%) minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.planner-rail-rules .sch-rot-nav {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
}
.planner-rail-rules .sch-rot-detail {
    max-height: none;
    min-height: 0;
}
@media (max-width: 768px) {
    .sch-rot-split {
        grid-template-columns: 1fr;
    }
    .sch-rot-nav {
        border-right: none !important;
        border-bottom: 1px solid var(--border);
        max-height: 240px !important;
    }
}
.sch-rot-nav {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    max-height: 420px;
}
.sch-rot-detail {
    overflow-y: auto;
    max-height: 420px;
    background: var(--card-bg, var(--surface));
}
.sch-rot-nav-group + .sch-rot-nav-group {
    border-top: 1px solid var(--border);
}
.sch-rot-nav-group-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: background .15s;
}
.sch-rot-nav-group-head:hover {
    background: var(--surface-hover);
}
.sch-rot-nav-children {
    padding-bottom: 4px;
}
.sch-rot-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 7px 12px 7px 28px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: background .15s, color .15s;
    font-size: 12px;
}
.sch-rot-nav-item.is-nested {
    padding-left: 40px;
}
.sch-rot-nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.sch-rot-nav-item.is-selected {
    background: var(--accent-glow, rgba(59, 130, 246, 0.12));
    color: var(--text);
    box-shadow: inset 3px 0 0 var(--accent);
}
.sch-rot-nav-item-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sch-rot-nav-item-meta {
    flex-shrink: 0;
    font-size: 10px;
    color: var(--text-subtle);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}
.sch-rot-nav-empty {
    padding: 8px 12px 10px 28px;
    font-size: 11px;
    color: var(--text-subtle);
    font-style: italic;
}
.sch-rot-nav-subgroup {
    margin-top: 4px;
    border-top: 1px dashed var(--border);
}
.sch-rot-nav-subgroup-head {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px 8px 20px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sch-rot-nav-subgroup-head:hover {
    background: var(--surface-hover);
}
.sch-rot-detail-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    padding: 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-subtle);
}
.sch-rot-detail-pane {
    padding: 14px 16px;
}
.sch-rot-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.sch-rot-detail-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
}
.sch-rot-inline-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.sch-rot-inline-card {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-dim);
}
.sch-rot-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-dim);
}
.sch-rot-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: background .15s;
}
.sch-rot-section-head:hover {
    background: var(--surface-hover);
}
.sch-rot-section-chev {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform .15s;
    color: var(--text-subtle);
}
.sch-rot-section-chev.is-open {
    transform: rotate(90deg);
}
.sch-rot-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
}
.sch-rot-section-summary {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-subtle);
    font-weight: 400;
}
.sch-rot-section-body {
    padding: 0 12px 12px;
    border-top: 1px solid var(--border);
    background: var(--card-bg, var(--surface));
}
.sch-rot-subhead {
    margin-bottom: 8px;
}
/* Rotation Rules panel — two-column layout (Clocks | Dayparts + Specials) */
.sch-rot-cols {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 1024px) {
    .sch-rot-cols {
        grid-template-columns: 280px 1fr;
        align-items: flex-start;
    }
}
.sch-rot-col-clocks {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.sch-rot-col-right {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.sch-rot-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.sch-rot-col-title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
}
.sch-rot-empty {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    padding: 8px 0;
}
.sch-rot-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 8px;
}
@media (min-width: 640px) {
    .sch-rot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
    .sch-rot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
    .sch-rot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
    .sch-rot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1536px) {
    .sch-rot-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Compact clock row in the left column. Visually distinct from
   .sch-daypart-card so that clocks read as a different kind of
   thing (a reusable template) rather than a daypart variant. */
.sch-clock-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sch-clock-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--surface-dim);
    border: 1px solid transparent;
}
.sch-clock-row:hover {
    background: var(--surface-hover);
    border-color: var(--border);
}
.sch-clock-row-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.sch-clock-row-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Monochrome tier mix bar — proportional segments labeled A/B/C/D.
   Uses theme text color at varying opacity so it won't be confused
   with schedule category colors. */
.sch-clock-mix-bar {
    display: flex;
    width: 100%;
    height: 14px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 3px;
    overflow: hidden;
    gap: 1px;
}
.sch-mix-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2px;
    height: 100%;
}
.sch-mix-seg-a { background: color-mix(in srgb, var(--text) 72%, transparent); }
.sch-mix-seg-b { background: color-mix(in srgb, var(--text) 54%, transparent); }
.sch-mix-seg-c { background: color-mix(in srgb, var(--text) 36%, transparent); }
.sch-mix-seg-d { background: color-mix(in srgb, var(--text) 20%, transparent); }
.sch-mix-lbl {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 8px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    color: var(--surface-raised);
    text-shadow: 0 0 2px color-mix(in srgb, var(--text) 40%, transparent);
    pointer-events: none;
    user-select: none;
}
.sch-clock-usage {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sch-clock-usage-unused {
    color: var(--text-subtle);
    font-style: italic;
}

/* Phase 3c — per-slot swap popover + lock indicator */
.sch-row-name-swap {
    cursor: pointer;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.15s;
}
.sch-row-name-swap:hover {
    border-bottom-color: var(--border-strong, rgba(255, 255, 255, 0.20));
}
.sch-row-lock {
    font-size: 11px;
    line-height: 1;
    opacity: 0.7;
    flex-shrink: 0;
    margin-left: 2px;
}

/* Plan B Phase 5: Rockstar live-operator panel */
.rs-rockstar-status {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.rs-rockstar-status-live {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.rs-rockstar-breaks {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rs-rockstar-break {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    font-size: 12px;
}
.rs-rockstar-break-idx {
    width: 18px; height: 18px;
    line-height: 18px;
    text-align: center;
    background: var(--accent-glow);
    color: var(--accent);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
}
.rs-rockstar-break-time {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    min-width: 70px;
}
.rs-rockstar-break-label { flex: 1; color: rgba(255,255,255,0.8); }
.rs-rockstar-break-dur {
    color: rgba(255,255,255,0.4);
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* Plan B Phase 4: Programming attention banner */
.programming-status-banner {
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
}
.programming-status-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.programming-status-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    background: #f59e0b;
    color: #1a1a1a;
    border-radius: 50%;
    font-weight: 700;
    font-size: 12px;
}
.programming-status-title {
    color: #fbbf24;
    font-weight: 600;
    font-size: 13px;
}
.programming-status-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.programming-status-section { padding-top: 4px; }
.programming-status-heading {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.5);
    margin-bottom: 4px;
}
.programming-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text, #fff);
    font-size: 12px;
    transition: background 0.1s;
}
.programming-status-item:hover { background: rgba(255,255,255,0.05); }
.programming-status-tag {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}
.programming-status-tag.tag-live { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.programming-status-tag.tag-broken { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.programming-status-text { color: rgba(255,255,255,0.8); }

/* Plan A: cascade-overflow badge */
.sch-row-bumped {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.625rem;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.25);
    padding: 1px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-left: 4px;
}
.sch-row-locked {
    border-left: 2px solid var(--accent, rgba(96, 165, 250, 0.6));
}
.sch-swap-edit {
    position: fixed;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    width: 360px;
    max-width: calc(100vw - 16px);
}
.sch-swap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.sch-swap-close {
    background: transparent;
    border: none;
    color: var(--text-subtle);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.sch-swap-close:hover { color: var(--text); }
.sch-swap-list {
    margin-top: 6px;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
}
.sch-swap-loading {
    padding: 12px;
    text-align: center;
    font-size: 11px;
    color: var(--text-subtle);
}
.sch-swap-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    font-size: 11px;
    color: var(--text-soft, rgba(255,255,255,0.75));
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.sch-swap-item:last-child { border-bottom: none; }
.sch-swap-item:hover { background: rgba(255, 255, 255, 0.04); }
.sch-swap-item-selected {
    background: rgba(96, 165, 250, 0.12) !important;
    color: var(--text);
}
.sch-swap-item-current {
    border-left: 2px solid var(--accent, rgba(96, 165, 250, 0.6));
}
.sch-swap-tier {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-subtle);
    flex-shrink: 0;
    letter-spacing: 0.02em;
    width: 60px;
    text-align: center;
}
.sch-swap-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sch-swap-hint {
    font-size: 9px;
    color: var(--text-subtle);
    background: rgba(255, 255, 255, 0.04);
    padding: 1px 4px;
    border-radius: 3px;
    flex-shrink: 0;
}
.sch-swap-age {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 9px;
    color: var(--text-subtle);
    flex-shrink: 0;
    min-width: 28px;
    text-align: right;
}
.sch-swap-age-fresh { color: rgb(74, 222, 128); }
.sch-swap-lock {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-soft, rgba(255,255,255,0.75));
    margin-top: 8px;
    cursor: pointer;
}
.sch-swap-lock input { margin: 0; }
.sch-row-dur {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.625rem;
    color: var(--text-subtle);
    flex-shrink: 0;
    min-width: 36px;
    text-align: right;
}

/* Schedule — drag handle */
.sch-row-grip {
    width: 16px;
    min-width: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: var(--text-subtle);
    opacity: 0.2;
    user-select: none;
    flex-shrink: 0;
}
.sch-row-grip svg { width: 10px; height: 14px; }
.sch-row:hover .sch-row-grip { opacity: 0.6; }
.sch-row-grip:active { cursor: grabbing; }

/* Schedule — drag feedback */
.sch-row.sch-dragging { opacity: 0.25; background: var(--surface-dim); }
.sch-row.sch-drop-before { box-shadow: inset 0 2px 0 0 var(--accent); }
.sch-row.sch-drop-after { box-shadow: inset 0 -2px 0 0 var(--accent); }

/* Schedule — row selection */
.sch-row-selected { background: var(--accent-glow); }
.sch-row-selected:hover { background: var(--accent-surface); }

/* Schedule — editable time */
.sch-row-time { cursor: pointer; border-radius: 3px; padding: 1px 3px; margin: -1px -3px; }
.sch-row-time:hover { color: var(--accent); background: var(--surface-hover); }
.schedule-page .sch-row-time {
    cursor: default;
    padding: 0;
    margin: 0;
}
.schedule-page .sch-row-time:hover {
    color: var(--text-muted);
    background: transparent;
}

/* Schedule — time edit popover */
.sch-time-edit {
    position: fixed;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    min-width: 150px;
}

/* Schedule — overlap dialog */
.sch-overlap-dialog {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sch-overlap-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}
.sch-overlap-content {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    max-width: 380px;
    width: 90%;
}

/* Schedule — row action buttons */
.sch-row-preview-btn,
.sch-row-download-btn,
.sch-row-order-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: var(--text-subtle);
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.sch-row-preview-btn svg,
.sch-row-download-btn svg,
.sch-row-order-btn svg { width: 14px; height: 14px; }
.sch-row:hover .sch-row-preview-btn,
.sch-row:hover .sch-row-download-btn,
.sch-row:hover .sch-row-order-btn { opacity: 0.6; }
.sch-row-preview-btn:hover,
.sch-row-download-btn:hover,
.sch-row-order-btn:hover { opacity: 1 !important; color: var(--accent); background: var(--surface-hover); }
.sch-row-preview-btn-active { opacity: 1 !important; color: var(--accent); background: var(--accent-glow); }

/* ============================================================
   Live grid — marquee (back-and-forth)
   ============================================================ */
.slot-marquee {
    overflow: hidden;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}
.slot-marquee-inner {
    display: inline-block;
    white-space: nowrap;
    animation: slot-marquee-pingpong 8s ease-in-out infinite;
    padding-right: 1rem;
}
@keyframes slot-marquee-pingpong {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-50%); }
}

/* ============================================================
   App frame + top bar (replaces the old sidebar)
   ============================================================ */
:root {
    --player-footer-h: 3.5rem;
    --topbar-h: 52px;
}

.app-main.is-viewport-locked {
    overflow: hidden;
}
.app-main.is-viewport-locked > #main-content {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.app-main.is-viewport-locked > #main-content.page-pad {
    padding: 0;
}

/* Reusable shell: main pane + action footer above the live player bar */
.page-stack {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}
.page-stack-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    position: relative;
}
.page-stack-main > .ce-columns {
    height: 100%;
}
.page-action-footer {
    flex: 0 0 auto;
    flex-shrink: 0;
    position: relative;
    z-index: 25;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.app-frame {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* App shell: scroll only inside .app-main (never the document under the player footer). */
html:has(#app .app-frame) {
    height: 100%;
}
body:has(#app .app-frame) {
    height: 100dvh;
    overflow: hidden;
}
#app:has(.app-frame) {
    height: 100%;
}

#app-topbar,
.login-header {
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 0.75rem 0 0.5rem;
    background: var(--sidebar-bg);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
    text-decoration: none;
}
.topbar-logo {
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    display: block;
}
.topbar-logo-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: var(--logo-filter);
    transition: filter 0.2s ease;
}
.topbar-version {
    display: inline-flex;
    align-items: baseline;
    font-family: var(--brand-mark-font);
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.topbar-clock {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.125rem;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    white-space: nowrap;
    line-height: 1;
}

.topbar-studio {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    min-width: 0;
}
.topbar-studio.hidden { display: none; }
.topbar-station-select {
    width: auto;
    max-width: 14rem;
    min-width: 8rem;
    font-size: 0.85rem;
}
.topbar-studio-gear {
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.topbar-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
    background: var(--accent-glow);
    color: var(--accent);
}
.topbar-iconbtn {
    padding: 0.45rem;
    border-radius: 0.5rem;
    color: var(--text-subtle);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.topbar-iconbtn:hover {
    color: var(--text);
    background: var(--surface-hover);
}
.launcher-btn[aria-expanded="true"] {
    color: var(--accent);
    background: var(--accent-glow);
}

/* ============================================================
   App launcher popover (Google-style page grid)
   ============================================================ */
.app-launcher {
    position: absolute;
    top: calc(var(--topbar-h) - 2px);
    right: 0.5rem;
    z-index: 60;
    width: 320px;
    max-width: calc(100vw - 1rem);
    padding: 0.75rem;
    border-radius: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.app-launcher.hidden { display: none; }
.app-launcher-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
}
.launcher-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.85rem 0.5rem;
    border-radius: 0.75rem;
    text-decoration: none;
    color: var(--text-muted);
    transition: background-color 0.15s ease;
}
.launcher-tile:hover { background: var(--surface-hover) !important; }
.launcher-tile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}
.launcher-tile-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

/* ============================================================
   Main content — full-bleed by default, opt-in constrained width
   ============================================================ */
.app-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* ------------------------------------------------------------
   Footer player — persistent compact view of the shared live
   stream (LivePlayer).
   ------------------------------------------------------------ */
.player-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: var(--player-footer-h);
    padding: 0 1rem;
    background: var(--sidebar-bg);
    --live-progress: 0%;
}
.player-footer.is-track-progress {
    background: linear-gradient(
        90deg,
        rgba(239, 68, 68, 0.18) 0 var(--live-progress),
        var(--sidebar-bg) var(--live-progress) 100%
    );
}
.player-footer.hidden {
    display: none;
}
.fp-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex: 0 1 auto;
}
.fp-center {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    min-width: 0;
    flex: 1 1 0;
    max-width: 42rem;
    margin: 0 auto;
}
.fp-center[hidden] {
    display: none !important;
}
.fp-now-label {
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fp-now-sep {
    flex-shrink: 0;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    color: var(--text-subtle);
    opacity: 0.45;
    user-select: none;
}
.fp-now-sep[hidden],
.fp-track[hidden],
.fp-now-detail[hidden] {
    display: none !important;
}
.fp-track,
.fp-now-detail {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    min-width: 0;
    max-width: 100%;
}
.fp-track {
    flex: 0 1 auto;
    max-width: 55%;
}
.fp-now-detail {
    flex: 0 1 auto;
    max-width: 45%;
}
.fp-track:hover,
.fp-now-detail:hover {
    color: var(--accent);
}
.fp-art {
    width: 2.4rem;
    height: 2.4rem;
    object-fit: contain;
    border-radius: 0.25rem;
    flex-shrink: 0;
}
.fp-meta {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.fp-station-select {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0;
    max-width: 16rem;
    cursor: pointer;
    text-overflow: ellipsis;
}
.fp-station-select:focus {
    outline: none;
}
.fp-status {
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-subtle);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-decoration: none;
    cursor: pointer;
    width: fit-content;
}
.fp-status:hover {
    opacity: 0.85;
}
.fp-status.is-live {
    color: var(--accent);
    font-weight: 600;
}
.fp-status.is-live:hover {
    color: var(--accent-dim);
}
.fp-live-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.7);
    animation: fp-live-pulse 1.6s ease-in-out infinite;
}
@keyframes fp-live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}
.fp-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    flex: 0 1 auto;
    min-width: 0;
    color: var(--text-muted);
}
.fp-vol-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.fp-vol-btn:hover,
.fp-vol-btn.is-muted {
    color: var(--accent);
    background: var(--accent-surface);
}
.fp-volume {
    width: 9rem;
    min-width: 9rem;
    flex-shrink: 0;
    accent-color: var(--accent);
}
.fp-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    display: inline-flex;
}
.fp-icon-btn:hover {
    color: var(--accent);
    background: var(--accent-surface);
}
@media (max-width: 640px) {
    .player-footer .fp-volume { display: none; }
    .player-footer .fp-vol-btn { display: none; }
    .player-footer .fp-station-select { max-width: 9rem; }
    .player-footer .fp-center { display: none; }
}

/* Miniplayer (Document Picture-in-Picture) */
.fp-pip-body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    height: 100%;
    overflow: hidden;
    display: flex;
}
.fp-pip {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(0.35rem, 2vh, 0.65rem);
    padding: clamp(0.5rem, 3vw, 1rem);
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
    --live-progress: 0%;
}
.fp-pip.is-track-progress {
    background: linear-gradient(
        90deg,
        rgba(239, 68, 68, 0.18) 0 var(--live-progress),
        var(--bg) var(--live-progress) 100%
    );
}
.fp-pip-art {
    width: auto;
    height: auto;
    max-width: min(7rem, 52%);
    max-height: min(7rem, 28vh);
    object-fit: contain;
    border-radius: 0.5rem;
    flex-shrink: 1;
}
.fp-pip-name {
    font-size: clamp(0.75rem, 3.5vw, 0.85rem);
    font-weight: 600;
    text-align: center;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fp-pip-now {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    flex-wrap: nowrap;
}
.fp-pip-now[hidden] {
    display: none !important;
}
.fp-pip .fp-track,
.fp-pip .fp-now-detail {
    max-width: none;
    flex: 1 1 0;
    min-width: 0;
}
.fp-pip .fp-track {
    flex: 1.15 1 0;
}
.fp-pip-vol {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
}
.fp-pip-vol .fp-volume {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}
.page-pad {
    padding: 1rem;
}
@media (min-width: 768px) {
    .page-pad { padding: 1.25rem 1.5rem; }
}
/* Opt-in: pages that prefer a constrained reading width */
.page-container {
    max-width: 80rem;
    margin-left: auto;
    margin-right: auto;
}

/* Full-height "shell" pages fill the viewport below the top bar */
.page-shell {
    height: calc(100dvh - var(--topbar-h) - 2rem);
}
.app-frame:has(.player-footer:not(.hidden)) .page-shell {
    height: calc(100dvh - var(--topbar-h) - var(--player-footer-h) - 2rem);
}
@media (min-width: 768px) {
    .page-shell {
        height: calc(100dvh - var(--topbar-h) - 2.5rem);
    }
    .app-frame:has(.player-footer:not(.hidden)) .page-shell {
        height: calc(100dvh - var(--topbar-h) - var(--player-footer-h) - 2.5rem);
    }
}
@media (max-width: 767px) {
    .schedule-grid-card,
    .live-grid-card {
        min-height: 55vh;
        flex: 1 1 auto;
    }
    .topbar-version { display: none; }
}

/* ============================================================
   Card
   ============================================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* ============================================================
   Table Styles
   ============================================================ */
.table-container {
    overflow-x: auto;
}

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

.data-table th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.data-table tbody tr:hover {
    background: var(--surface-hover);
}

/* Compact inline audio player for cart tables */
.cart-audio-mini {
    height: 28px;
    width: 180px;
    min-width: 120px;
    border-radius: 14px;
    opacity: 0.85;
}
.cart-audio-mini:hover { opacity: 1; }

/* Orders list: keyboard-highlighted row */
.order-row-highlight {
    background: var(--accent-glow) !important;
    outline: 1px solid var(--accent);
    outline-offset: -1px;
    opacity: 0.9;
}
.order-row-highlight:hover {
    opacity: 1;
}

/* ============================================================
   Badge
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.badge-priority {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 9999px;
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
    flex-shrink: 0;
}

/* ============================================================
   Form Inputs
   ============================================================ */
.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 0.8rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
    color: var(--text-subtle);
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.form-select {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 0.8rem;
    font-family: inherit;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.25rem;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ============================================================
   Login Page
   ============================================================ */
html:has(body.login-page) {
    height: 100%;
    overflow: hidden;
}

body.login-page {
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.login-form {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 408px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1.5rem;
    box-sizing: border-box;
}

.login-title {
    margin: 0 0 0.5rem;
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text);
}

.login-field-box {
    position: relative;
    min-height: 3.75rem;
    padding: 0 0.875rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.25rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    cursor: text;
}

.login-field-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-field-label {
    position: absolute;
    left: 0.875rem;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    line-height: 1.25;
    color: var(--text-subtle);
    pointer-events: none;
    transition: top 0.18s ease, transform 0.18s ease;
}

.login-field-box.is-active .login-field-label {
    top: 0.625rem;
    transform: translateY(0);
}

.login-field-box-password {
    padding-right: 2.5rem;
}

.login-field-box-password .login-field-label {
    right: 2.5rem;
}

.login-field-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    min-height: 3.75rem;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.25;
    color: var(--text);
    font-family: inherit;
    outline: none;
}

.login-field-box.is-active .login-field-input {
    padding-top: 1.9rem;
    padding-bottom: 0.625rem;
}

.login-password-toggle {
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    background: none;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
}

.login-password-toggle:hover {
    color: var(--text-muted);
}

.login-password-toggle svg.hidden {
    display: none;
}

.login-submit {
    width: fit-content;
    align-self: flex-start;
    margin-top: 0.25rem;
    padding: 0.45rem 0.85rem;
}

.login-error {
    display: none;
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--danger);
    font-size: 0.8rem;
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-dim);
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-accent {
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border));
    color: var(--accent);
    box-shadow: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-accent:not(:disabled):hover {
    background: var(--accent-surface);
    border-color: var(--accent);
    color: var(--accent-dim);
    box-shadow: none;
}
.btn-accent:disabled {
    opacity: 0.55;
    cursor: default;
}

.btn-fill {
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--fill) 55%, var(--border));
    color: var(--fill);
    box-shadow: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-fill:not(:disabled):hover {
    background: var(--fill-surface);
    border-color: var(--fill);
    color: var(--fill-dim);
    box-shadow: none;
}
.btn-fill:disabled {
    opacity: 0.55;
    cursor: default;
}

.btn-secondary {
    background: var(--surface-dim);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--surface-hover);
    color: var(--text);
}


.btn-secondary {
    background: var(--surface-dim);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    opacity: 0.9;
}

.btn-ghost {
    background: transparent;
    color: var(--text-subtle);
}
.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.7rem;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-content {
    background: var(--modal-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-sm { max-width: 28rem; }
.modal-md { max-width: 40rem; }
.modal-lg { max-width: 56rem; }
.modal-xl { max-width: 72rem; }

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease;
    max-width: 24rem;
    border: 1px solid var(--border);
}

.toast-success {
    background: rgba(22, 163, 74, 0.1);
    border-color: rgba(22, 163, 74, 0.3);
    color: var(--success);
}
.toast-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}
.toast-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--info);
}
.toast a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}
.toast a:hover {
    opacity: 0.8;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   Live Broadcast Schedule
   ============================================================ */

/* Now Playing */
/* De-carded (Phase 5c): flat strip with the accent spine kept. */
.rs-now-playing {
    border-left: 3px solid var(--accent);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.rs-flat-panel {
    border-left: 3px solid #ef4444;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.rs-visualizer {
    background: var(--surface-dim);
    border: 1px solid var(--border-light);
    flex-shrink: 0;
}

.rs-play-btn:hover {
    color: var(--accent);
}

/* Timeline */
.rs-timeline {
    max-height: 600px;
    overflow-y: auto;
}

.rs-slot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    background: var(--surface-dim);
    transition: all 0.2s ease;
}

.rs-slot:hover {
    background: var(--surface-hover);
}

.rs-slot-locked {
    border-color: var(--accent-glow);
    background: var(--accent-surface);
}

.rs-slot-adhoc {
    border-color: var(--border);
    background: var(--surface-dim);
}

.rs-slot-playing {
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.06);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.1);
}

.rs-slot-played {
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.04);
    opacity: 0.6;
}

.rs-slot-time {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 80px;
    flex-shrink: 0;
}

.rs-slot-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.rs-slot-title {
    color: var(--text);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.rs-slot-duration {
    font-size: 0.6875rem;
    color: var(--text-subtle);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.rs-slot-rate {
    font-size: 0.625rem;
    color: var(--text-subtle);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.rs-slot-client {
    font-size: 0.6875rem;
    color: var(--accent);
}

.rs-slot-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.rs-slot-lock {
    color: var(--accent);
    opacity: 0.5;
}

/* Current time marker */
.rs-time-marker {
    position: relative;
    height: 2px;
    background: var(--accent);
    margin: 4px 0;
    border-radius: 1px;
}

.rs-time-marker-label {
    position: absolute;
    left: 0;
    top: -8px;
    font-size: 0.5625rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Mode toggle buttons */
.li-mode-btn.active,
.modal-mode-btn.active {
    background: var(--accent-glow);
    color: var(--accent);
}

/* Category columns */
.rs-columns-grid {
    -webkit-overflow-scrolling: touch;
}

.rs-category-column {
    min-width: 200px;
}

.rs-cat-header {
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Bill detail page grid (screen) */
.bill-print-layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}
.bill-print-layout > :first-child {
    grid-column: span 2;
}
@media (max-width: 1024px) {
    .bill-print-layout {
        grid-template-columns: 1fr;
    }
    .bill-print-layout > :first-child {
        grid-column: span 1;
    }
}

/* Category badges */
.rs-cat-ad { background: rgba(245, 158, 11, 0.1); color: #d97706; }
.rs-cat-liner { background: rgba(168, 85, 247, 0.1); color: #9333ea; }
.rs-cat-news { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
.rs-cat-promo { background: var(--accent-surface); color: var(--accent); }
.rs-cat-psa { background: rgba(6, 182, 212, 0.1); color: #0891b2; }
.rs-cat-music { background: rgba(236, 72, 153, 0.1); color: #db2777; }
.rs-cat-other { background: var(--surface-dim); color: var(--text-muted); }

[data-theme="dark"] .rs-cat-ad { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
[data-theme="dark"] .rs-cat-liner { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
[data-theme="dark"] .rs-cat-news { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
[data-theme="dark"] .rs-cat-promo { background: var(--accent-surface); color: var(--accent); }
[data-theme="dark"] .rs-cat-psa { background: rgba(6, 182, 212, 0.12); color: #06b6d4; }
[data-theme="dark"] .rs-cat-music { background: rgba(236, 72, 153, 0.12); color: #ec4899; }

/* ============================================================
   Theme Toggle
   ============================================================ */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 2px;
}
.theme-toggle button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 0.375rem;
    border: none;
    background: transparent;
    color: var(--text-subtle);
    cursor: pointer;
    transition: all 0.15s ease;
}
.theme-toggle button:hover {
    color: var(--text);
}
.theme-toggle button.active {
    background: var(--card-bg);
    color: var(--accent);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ============================================================
   Print Document Components (screen appearance)
   ============================================================ */
.print-only {
    display: none;
}

.print-doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.print-meta-table {
    border-collapse: collapse;
}
.print-meta-table td {
    padding: 1px 0;
}

.print-fill-line {
    display: inline-block;
    min-width: 100px;
    border-bottom: 1px solid var(--text-subtle);
}

.print-doc-amount-box {
    display: inline-block;
    border: 2px solid var(--border);
    padding: 0.375rem 1.25rem;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text);
}

/* Aging table (statements) */
.aging-table {
    width: 100%;
    border-collapse: collapse;
}
.aging-table th,
.aging-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: center;
    font-size: 0.7rem;
}
.aging-table th {
    background: var(--surface-dim);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============================================================
   Print Styles — Professional paper layout for invoices,
   statements, and order forms
   ============================================================ */
@media print {
    /* Hide UI chrome */
    #app-topbar,
    #app-launcher,
    .no-print,
    .toast-container,
    .modal-overlay,
    #modal-container,
    #toast-container,
    #bulk-bar,
    #demo-progress { display: none !important; }

    .print-only {
        display: block !important;
    }

    /* Black angel in bill header for print/PDF */
    .print-header-logo {
        filter: brightness(0);
    }

    *, *::before, *::after {
        color-adjust: exact;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    html, body {
        background: white !important;
        color: #1a1a1a !important;
        font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
        font-size: 10pt !important;
        line-height: 1.45 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
:root { --topbar-h: 52px; }

.app-frame {
        display: block !important;
        height: auto !important;
    }

    main {
        overflow: visible !important;
    }

    #main-content {
        padding: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    @page {
        size: letter;
        margin: 0.6in 0.65in 0.7in 0.65in;
    }

    .card {
        background: white !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
    }

    h1, h2, h3 {
        color: #111 !important;
    }
    h2 { font-size: 14pt !important; }
    h3 { font-size: 11pt !important; }

    p, span, div, td, th, dd, dt, a, label, strong {
        color: #222 !important;
    }

    .text-white { color: #111 !important; }
    .text-white\/40, .text-white\/30 { color: #666 !important; }
    .text-white\/50 { color: #555 !important; }
    .text-white\/60 { color: #444 !important; }
    .text-white\/70 { color: #333 !important; }
    .text-emerald-400 { color: #047857 !important; }
    .text-red-400 { color: #cc0000 !important; }
    .text-accent, [class*="text-accent"] { color: #111 !important; }

    .print-doc-header {
        border-bottom: 2px solid #222 !important;
        margin-bottom: 10px !important;
        padding-bottom: 8px !important;
    }

    .print-fill-line {
        border-bottom-color: #333 !important;
    }

    .print-doc-amount-box {
        border: 2px solid #222 !important;
        color: #111 !important;
        padding: 4px 16px !important;
    }

    .data-table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    .data-table th {
        background: #f0f0f0 !important;
        color: #222 !important;
        font-size: 7pt !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.03em !important;
        padding: 5px 6px !important;
        border-bottom: 2px solid #999 !important;
        border-top: 1px solid #999 !important;
    }

    .data-table td {
        color: #222 !important;
        font-size: 8pt !important;
        padding: 4px 6px !important;
        border-bottom: 1px solid #ddd !important;
    }

    .data-table tbody tr:hover {
        background: transparent !important;
    }

    .data-table tfoot td {
        border-top: 2px solid #999 !important;
        border-bottom: none !important;
        font-weight: 700 !important;
        padding-top: 6px !important;
    }

    .aging-table th,
    .aging-table td {
        border-color: #999 !important;
        color: #222 !important;
    }
    .aging-table th {
        background: #f0f0f0 !important;
        color: #222 !important;
    }

    .badge {
        border: 1px solid #999 !important;
        background: transparent !important;
        color: #333 !important;
        font-size: 7pt !important;
        padding: 1px 5px !important;
    }

    [class*="rs-cat-"] {
        background: transparent !important;
        border: 1px solid #999 !important;
        color: #333 !important;
    }

    a {
        color: #222 !important;
        text-decoration: none !important;
    }

    [class*="border-white/"] {
        border-color: #ccc !important;
    }
    .border-b { border-color: #ccc !important; }
    .border-t { border-color: #ccc !important; }

    .bill-print-layout {
        display: block !important;
    }

    .flex { display: flex !important; }
    .flex.justify-between { justify-content: space-between !important; }
    .flex.justify-end { justify-content: flex-end !important; }
    .flex.items-start { align-items: flex-start !important; }
    .flex.items-center { align-items: center !important; }
    .flex.items-end { align-items: flex-end !important; }
    .flex.gap-8 { gap: 24px !important; }
    .flex.gap-3 { gap: 10px !important; }
    .flex-1 { flex: 1 !important; }

    .mb-6 { margin-bottom: 14px !important; }
    .mb-4 { margin-bottom: 10px !important; }
    .mt-8 { margin-top: 20px !important; }
    .mt-6 { margin-top: 14px !important; }
    .pt-4 { padding-top: 10px !important; }
    .pb-4 { padding-bottom: 10px !important; }
    .pb-2 { padding-bottom: 6px !important; }
    .space-y-1 > * + * { margin-top: 2px !important; }
    .space-y-2 > * + * { margin-top: 4px !important; }

    .text-xl { font-size: 14pt !important; }
    .text-lg { font-size: 12pt !important; }
    .text-base { font-size: 10pt !important; }
    .text-sm { font-size: 9pt !important; }
    .text-xs { font-size: 8pt !important; }

    .bg-black,
    [class*="bg-white/"],
    [class*="bg-accent"] {
        background: transparent !important;
    }

    * {
        overflow: visible !important;
    }

    .animate-pulse { display: none !important; }

    #app-topbar,
    #app-launcher,
    .no-print,
    .toast-container,
    .modal-overlay,
    #modal-container,
    #toast-container,
    #bulk-bar,
    #demo-progress {
        display: none !important;
        visibility: hidden !important;
    }
}

/* ============================================================
   Paper Order Form — exact recreation of the Flack Broadcasting
   physical order form layout
   ============================================================ */

.paper-form {
    background: var(--surface);
    border: 2px solid var(--text);
    font-size: 11px;
    line-height: 1.35;
    color: var(--text);
    max-width: 900px;
    margin: 0 auto;
}

.paper-form *,
.paper-form *::before,
.paper-form *::after {
    box-sizing: border-box;
}

/* Header row */
.pf-header {
    display: flex;
    border-bottom: 2px solid var(--text);
}
.pf-header-company {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    border-right: 1px solid var(--text);
}
.pf-header-company-name {
    font-weight: 900;
    font-size: 14px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.pf-header-company-stations {
    font-weight: 700;
    font-size: 11px;
    margin-top: 1px;
}
.pf-header-company-addr,
.pf-header-company-contact {
    font-size: 10px;
    color: var(--text-secondary);
}
.pf-header-order {
    width: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pf-header-order-value {
    font-size: 16px;
    font-weight: 900;
    margin-top: 2px;
    color: var(--text);
}

/* Body: 2-column layout */
.pf-body {
    display: flex;
    border-bottom: 1px solid var(--text);
}
.pf-left {
    flex: 1;
    border-right: 1px solid var(--text);
    min-width: 0;
}
.pf-right {
    width: 340px;
    min-width: 340px;
}

/* Generic labeled row (label: value) */
.pf-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
    min-height: 26px;
}
.pf-row:last-child {
    border-bottom: none;
}
/* Red asterisk for required fields */
.pf-required {
    color: #ef4444;
    font-weight: 700;
    margin-left: 2px;
}

.pf-row-label {
    font-weight: 700;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    padding: 3px 6px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    min-width: 110px;
}
.pf-row-value {
    flex: 1;
    padding: 1px 6px;
    display: flex;
    align-items: center;
    min-width: 0;
}
.pf-row-value input[type="text"],
.pf-row-value input[type="email"],
.pf-row-value input[type="tel"],
.pf-row-value input[type="url"],
.pf-row-value input[type="number"],
.pf-row-value input[type="date"],
.pf-row-value select,
.pf-row-value textarea {
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    font-family: inherit;
    font-size: 11px;
    color: var(--text);
    padding: 2px 2px;
    outline: none;
}
.pf-row-value input:focus,
.pf-row-value select:focus,
.pf-row-value textarea:focus {
    border-bottom-color: var(--accent);
}
.pf-row-value .pf-readonly {
    border-bottom-color: transparent;
    cursor: default;
}

/* Split row (multiple labeled fields in one row) */
.pf-row-split {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
    min-height: 26px;
}
.pf-row-split > .pf-cell {
    display: flex;
    align-items: center;
    padding: 2px 6px;
    gap: 4px;
}
.pf-row-split > .pf-cell + .pf-cell {
    border-left: 1px solid var(--border);
}
.pf-cell-label {
    font-weight: 700;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    white-space: nowrap;
}
.pf-cell-value {
    flex: 1;
    min-width: 0;
}
.pf-cell-value input {
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    font-family: inherit;
    font-size: 11px;
    color: var(--text);
    padding: 2px 2px;
    outline: none;
}
.pf-cell-value input:focus {
    border-bottom-color: var(--accent);
}

/* Section header bar */
.pf-section-header {
    font-weight: 800;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 6px;
    border-bottom: 1px solid var(--text);
    background: var(--surface-dim);
    color: var(--text);
}

/* Right column: SPOTS THIS ORDER */
.pf-spots-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    border-bottom: 1px solid var(--text);
    font-weight: 800;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--surface-dim);
}
.pf-spots-revenue {
    display: flex;
    align-items: center;
    gap: 6px;
}
.pf-spots-revenue input {
    width: 80px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    padding: 1px 2px;
    outline: none;
    text-align: right;
}
.pf-spots-revenue input:focus {
    border-bottom-color: var(--accent);
}

/* Checkbox grid for spot types */
.pf-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
}
.pf-checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.pf-checkbox-grid label:nth-child(4n) {
    border-right: none;
}
.pf-checkbox-grid input[type="checkbox"] {
    width: 13px;
    height: 13px;
    border: 1.5px solid var(--text-secondary);
    border-radius: 2px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
}
.pf-checkbox-grid input[type="checkbox"]:checked {
    background: var(--text);
    border-color: var(--text);
}
.pf-checkbox-grid input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 3.5px;
    width: 4px;
    height: 7px;
    border: solid var(--surface);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* COPY section */
.pf-copy-table {
    width: 100%;
    border-collapse: collapse;
}
.pf-copy-table th {
    font-weight: 700;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 3px 6px;
    text-align: left;
    border-bottom: 1px solid var(--text);
    background: var(--surface-dim);
}
.pf-copy-table th:nth-child(2) {
    text-align: left;
    min-width: 120px;
    width: 180px;
}
.pf-copy-table th:last-child {
    text-align: right;
    width: 36px;
}
.pf-copy-table td {
    padding: 2px 6px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.pf-copy-table td input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 11px;
    color: var(--text);
    padding: 2px 0;
    outline: none;
}
.pf-copy-table td:nth-child(2) {
    vertical-align: middle;
}
.pf-copy-table td:last-child {
    text-align: right;
    width: 36px;
}

/* Station checkboxes */
.pf-station-list {
    padding: 6px 8px;
}
.pf-station-list label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}
.pf-station-list input[type="checkbox"] {
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--text-secondary);
    border-radius: 2px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
}
.pf-station-list input[type="checkbox"]:checked {
    background: var(--text);
    border-color: var(--text);
}
.pf-station-list input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 3.5px;
    width: 5px;
    height: 8px;
    border: solid var(--surface);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Invoice / Account Exec section */
.pf-invoice-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
    min-height: 26px;
}
.pf-invoice-row > .pf-cell {
    display: flex;
    align-items: center;
    padding: 2px 6px;
    gap: 4px;
}
.pf-invoice-row > .pf-cell + .pf-cell {
    border-left: 1px solid var(--border);
}

.pf-calendar-view-link {
    margin-left: 6px;
    padding: 2px 6px;
    font-size: 10px;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}
.pf-calendar-view-link:hover {
    color: var(--accent-dim);
}

.pf-calendar-modal.hidden {
    display: none;
}
.pf-calendar-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.pf-calendar-modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--modal-overlay, rgba(0,0,0,0.4));
    cursor: pointer;
}
.pf-calendar-modal-content {
    position: relative;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    padding: 16px;
    max-width: 360px;
    width: 100%;
}
.pf-calendar-modal-content-year {
    max-width: 720px;
    max-height: 90vh;
    overflow: auto;
}
.pf-calendar-year-grid {
    overflow: auto;
    padding: 6px;
}
.pf-calendar-year-months {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 16px;
}
.pf-calendar-year-month {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px;
    background: var(--surface-dim);
}
.pf-calendar-year-month.pf-calendar-current-month,
.pf-broadcast-month-block.pf-calendar-current-month {
    outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
    outline-offset: 2px;
}
.pf-calendar-year-month-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-align: center;
}
.pf-calendar-table-small th,
.pf-calendar-table-small td {
    padding: 2px 4px;
    font-size: 10px;
}
.pf-calendar-table .pf-calendar-weekend {
    background: rgba(234, 179, 8, 0.12);
}
.pf-calendar-table .pf-calendar-last-day {
    background: rgba(185, 28, 28, 0.1);
}
.pf-calendar-table .pf-calendar-weekend.pf-calendar-last-day {
    background: rgba(185, 28, 28, 0.12);
}
/* Weekend column headers: Sun & Sat in regular (cols 1,7); Sat & Sun in broadcast (cols 6,7) */
.pf-calendar-year-month .pf-calendar-table-small th:nth-child(1),
.pf-calendar-year-month .pf-calendar-table-small th:nth-child(7) {
    background: rgba(234, 179, 8, 0.18);
}
.pf-broadcast-month-block .pf-calendar-table-small th:nth-child(6),
.pf-broadcast-month-block .pf-calendar-table-small th:nth-child(7) {
    background: rgba(234, 179, 8, 0.18);
}
.pf-broadcast-year-months {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 14px;
}
.pf-broadcast-month-block {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px;
    background: var(--surface-dim);
}
.pf-broadcast-month-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.pf-broadcast-month-range {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.pf-broadcast-other-year {
    color: var(--text-muted);
    opacity: 0.7;
}
.pf-calendar-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.pf-calendar-nav {
    padding: 4px 10px;
    font-size: 14px;
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text);
}
.pf-calendar-nav:hover {
    background: var(--surface-hover);
}
.pf-calendar-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.pf-calendar-grid {
    margin-bottom: 12px;
}
.pf-calendar-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.pf-calendar-table th,
.pf-calendar-table td {
    border: 1px solid var(--border);
    padding: 4px 6px;
    text-align: center;
}
.pf-calendar-table th {
    background: var(--surface-dim);
    font-weight: 600;
    color: var(--text-secondary);
}
.pf-calendar-table td:empty {
    background: var(--surface-dim);
    opacity: 0.6;
}
.pf-calendar-close {
    display: block;
    width: 100%;
    padding: 8px;
    font-size: 12px;
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text);
}
.pf-calendar-close:hover {
    background: var(--surface-hover);
}

/* YES/NO toggle */
.pf-yesno {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
}
.pf-yesno label {
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    color: var(--text-secondary);
}
.pf-yesno input[type="checkbox"],
.pf-yesno input[type="radio"] {
    width: 12px;
    height: 12px;
    border: 1.5px solid var(--text-secondary);
    border-radius: 2px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
    position: relative;
}
.pf-yesno input:checked {
    background: var(--text);
    border-color: var(--text);
}
.pf-yesno input:checked::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 3px;
    width: 4px;
    height: 6px;
    border: solid var(--surface);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

/* Script section */
.pf-script {
    border-top: 1px solid var(--text);
    padding: 0;
}
.pf-script-header {
    font-weight: 800;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.pf-script textarea {
    width: 100%;
    min-height: 80px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 11px;
    color: var(--text);
    padding: 6px;
    outline: none;
    resize: vertical;
}

/* AI Voice controls (inside script section) */
.pf-ai-controls {
    border-top: 1px solid var(--border);
    padding: 8px;
    background: var(--surface-dim);
}
.pf-ai-controls .pf-ai-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.pf-ai-controls .pf-ai-row:last-child {
    margin-bottom: 0;
}
.pf-ai-controls label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    white-space: nowrap;
}
.pf-ai-controls select,
.pf-ai-controls input[type="range"] {
    font-family: inherit;
    font-size: 10px;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    padding: 3px 6px;
}
.pf-ai-controls select {
    max-width: 180px;
}
.pf-ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}
.pf-ai-btn-primary {
    background: var(--accent);
    color: #fff;
}
.pf-ai-btn-primary:hover {
    background: var(--accent-dim);
}
.pf-ai-btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.pf-ai-btn-secondary:hover {
    background: var(--surface-hover);
}
.pf-ai-status {
    font-size: 10px;
    color: var(--text-muted);
}
.pf-ai-preview {
    margin-top: 6px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
}
.pf-ai-preview audio {
    width: 100%;
    height: 32px;
}

/* Flight Dates Table */
.pf-flight-section {
    border-top: 1px solid var(--text);
}
.pf-flight-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.pf-flight-table th {
    font-weight: 700;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    padding: 4px 3px;
    text-align: center;
    border: 1px solid var(--text);
    background: var(--surface-dim);
    vertical-align: bottom;
    line-height: 1.2;
}
.pf-flight-subheader th {
    background: var(--surface-dim);
}
.pf-flight-table .pf-flight-subheader th:first-child {
    width: 61px;
}
.pf-flight-table .pf-flight-subheader th:nth-child(2),
.pf-flight-table .pf-flight-subheader th:nth-child(3) {
    width: 83px;
}
.pf-flight-table .pf-flight-subheader th:nth-child(4) {
    width: 73px;
}
.pf-flight-table .pf-flight-subheader th:nth-child(5),
.pf-flight-table .pf-flight-subheader th:nth-child(6) {
    width: 53px;
}
.pf-flight-table th.pf-day-col {
    width: 38px;
}
.pf-flight-table td.pf-day-col input {
    width: 2em;
    text-align: center;
    display: inline-block;
}
.pf-flight-table .pf-day-unit {
    font-size: 8px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: 1px;
}
.pf-flight-table .pf-flight-subheader th.pf-nc-col {
    width: 36px;
    text-align: center;
}
.pf-flight-table .pf-nc-cell {
    text-align: center;
    vertical-align: middle;
}
.pf-flight-table .pf-nc-label {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.pf-flight-table .pf-nc-label input[type="checkbox"] {
    width: 12px;
    height: 12px;
    margin: 0;
    cursor: pointer;
}
/* TFN — "Till Further Notice" toggle inside each flight row's End Date cell */
.pf-flight-table .pf-end-cell {
    vertical-align: middle;
}
.pf-flight-table .pf-end-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}
.pf-flight-table .pf-end-wrap input[type="date"] {
    flex: 1 1 auto;
    min-width: 0;
}
.pf-flight-table .pf-tfn-label {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    color: var(--text-muted, #888);
}
.pf-flight-table .pf-tfn-label input[type="checkbox"] {
    width: 11px;
    height: 11px;
    margin: 0;
    cursor: pointer;
}
.pf-flight-table .pf-tfn-label:has(input:checked) {
    color: var(--accent);
}
/* Rates column (per-broadcast only) — aligned 1:1 with cart subrows */
.pf-flight-table .pf-flight-subheader th.pf-rate-col {
    width: 80px;
    text-align: center;
    font-size: 8px;
}
.pf-flight-table .pf-rate-cell {
    text-align: center;
    vertical-align: top !important;
    padding: 2px !important;
}
.pf-rate-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.pf-rate-entry {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-height: 20px;
}
.pf-rate-input {
    width: 40px;
    font-size: 9px;
    text-align: right;
    border: none;
    background: transparent;
    color: var(--text);
    outline: none;
    padding: 1px 1px;
}
.pf-rate-input:focus {
    background: var(--input-bg);
    border-radius: 3px;
}
.pf-rate-input.pf-rate-override,
.pf-rate-entry.pf-rate-override {
    color: var(--accent);
    font-weight: 600;
}
.pf-cart-rate-display {
    font-size: 10px;
    color: var(--text-muted);
}
.pf-cart-rate-display.pf-rate-override {
    color: var(--accent);
    font-weight: 600;
}
.pf-flight-table .pf-flight-subheader th.pf-flight-actions {
    width: 28px;
    border: none;
    background: var(--surface-dim);
    box-shadow: none;
}
.pf-flight-table td {
    padding: 2px 3px;
    border: 1px solid var(--border);
    text-align: center;
    vertical-align: middle;
    font-size: 11px;
    color: var(--text);
}
.pf-flight-table td input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 11px;
    color: var(--text);
    padding: 2px 0;
    outline: none;
    text-align: center;
}
.pf-flight-table td input[type="date"] {
    font-size: 10px;
}
.pf-flight-table td select {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 10px;
    color: var(--text);
    padding: 1px 0;
    outline: none;
    cursor: pointer;
    appearance: none;
}
.pf-flight-table td input:focus,
.pf-flight-table td select:focus {
    background: var(--accent-glow);
}
.pf-flight-table .pf-flight-add-row td {
    border: none;
    padding: 4px 6px;
    text-align: left;
}
.pf-flight-hide-sched {
    visibility: hidden;
    border-color: transparent !important;
}
.pf-day-out-of-range {
    background: rgba(180, 120, 120, 0.12);
    border-color: rgba(180, 120, 120, 0.35) !important;
    pointer-events: none;
}
.pf-day-out-of-range input {
    color: var(--text-muted);
    background: transparent;
}

/* Remove row buttons – tasteful muted red */
.pf-remove-row-btn {
    color: #a07070 !important;
    border-color: rgba(160, 100, 100, 0.5) !important;
    background: rgba(180, 120, 120, 0.08) !important;
}
.pf-remove-row-btn:hover {
    color: #b08080 !important;
    background: rgba(180, 120, 120, 0.18) !important;
    border-color: rgba(160, 100, 100, 0.65) !important;
}

/* FROM / TO time (12h A/P) – keep n + A/P inside column */
.pf-flight-table .pf-time-from-cell,
.pf-flight-table .pf-time-to-cell {
    white-space: nowrap;
    overflow: hidden;
}
.pf-flight-table .pf-time-from-cell input,
.pf-flight-table .pf-time-to-cell input {
    width: 1.5em !important;
    min-width: 0;
    font-size: 10px;
    padding: 0 1px;
    text-align: center;
    box-sizing: border-box;
}
.pf-flight-table .pf-time-from-cell select,
.pf-flight-table .pf-time-to-cell select {
    width: 1.75em;
    max-width: 28px;
    font-size: 10px;
    padding: 0 1px;
    margin-left: 1px;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    box-sizing: border-box;
}
.pf-time-label {
    font-size: 8px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 2px;
}
.pf-time-invalid {
    background: rgba(239, 68, 68, 0.15) !important;
}

/* Multi-cart cell */
.pf-cart-cell {
    padding: 2px !important;
    vertical-align: top !important;
}
.pf-cart-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.pf-cart-entry {
    display: flex;
    align-items: center;
    gap: 2px;
    min-height: 20px;
}
.pf-cart-pct {
    width: 32px !important;
    font-size: 9px !important;
    text-align: center;
    border: 1px solid var(--border) !important;
    border-radius: 2px;
    padding: 0 1px !important;
    background: var(--input-bg);
}
.pf-cart-remove {
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 0 1px;
    line-height: 1;
}
.pf-cart-remove:hover { color: #ef4444; }
.pf-cart-add {
    border: 1px dashed var(--border);
    background: none;
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 2px;
    margin-top: 1px;
    width: 100%;
}
.pf-cart-add:hover { color: var(--accent); border-color: var(--accent); }

/* Monthly Billing section (left = inputs, right = price breakdown, right is 1/3 width) */
.pf-billing {
    border-top: 1px solid var(--text);
    padding: 0;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0;
    min-height: 0;
}
.pf-billing-left {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.pf-billing-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}
.pf-billing-breakdown {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 15px;
    color: var(--text-secondary);
}
.pf-breakdown-single {
    font-size: 17px;
    font-weight: 600;
}
.pf-breakdown-single .pf-breakdown-small {
    font-size: 0.8em;
    font-weight: 600;
}
.pf-breakdown-single strong {
    color: var(--text);
}
.pf-breakdown-carts {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.pf-breakdown-cart-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 11px;
}
.pf-breakdown-cart-label {
    font-weight: 700;
    color: var(--accent);
    font-size: 10px;
    min-width: 36px;
}
.pf-breakdown-total {
    font-size: 14px;
    font-weight: 600;
}
.pf-breakdown-total strong {
    color: var(--text);
}
.pf-billing-breakdown .pf-breakdown-small {
    font-size: 10px;
    color: var(--text-muted);
}
.pf-billing-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.pf-billing-header-label {
    font-weight: 800;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text);
    white-space: nowrap;
}
.pf-billing-amount input {
    width: 70px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    padding: 1px 2px;
    outline: none;
    text-align: right;
}
.pf-billing-amount input:focus {
    border-bottom-color: var(--accent);
}
.pf-billing-unit {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 4px;
    white-space: nowrap;
}
.pf-billing-type {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}
.pf-billing-type label {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    cursor: pointer;
}
.pf-billing-type input[type="radio"] {
    width: 12px;
    height: 12px;
    border: 1.5px solid var(--text-secondary);
    border-radius: 50%;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
    position: relative;
}
.pf-billing-type input[type="radio"]:checked {
    border-color: var(--text);
}
.pf-billing-type input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text);
}
.pf-billing-months {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 3px 8px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}
.pf-billing-months label {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 4px;
}
.pf-billing-months input[type="checkbox"] {
    width: 11px;
    height: 11px;
    border: 1.5px solid var(--text-secondary);
    border-radius: 2px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
    position: relative;
}
.pf-billing-months input[type="checkbox"]:checked {
    background: var(--text);
    border-color: var(--text);
}
.pf-billing-months input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 0px;
    left: 2.5px;
    width: 4px;
    height: 6px;
    border: solid var(--surface);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}
.pf-billing-instructions {
    display: flex;
    align-items: center;
    padding: 3px 8px;
    border-bottom: 1px solid var(--border);
    gap: 6px;
}
.pf-billing-instructions label {
    font-weight: 700;
    font-size: 9px;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
}
.pf-billing-instructions input {
    flex: 1;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    font-family: inherit;
    font-size: 11px;
    color: var(--text);
    padding: 2px;
    outline: none;
}
.pf-billing-instructions input:focus {
    border-bottom-color: var(--accent);
}

/* Footer: policy + signature */
.pf-footer {
    border-top: 1px solid var(--text);
    display: flex;
}
.pf-policy {
    flex: 1;
    padding: 6px 8px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    border-right: 1px solid var(--text);
}
.pf-signature-block {
    display: flex;
    flex-direction: column;
    min-width: 160px;
}
.pf-signature-row {
    display: flex;
    flex: 1;
}
.pf-signature-block .pf-signature-row:first-child {
    flex: 0 0 72px;
}
.pf-signature-cell {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    gap: 8px;
    min-width: 160px;
}
.pf-signature-cell.pf-signature-cell-sig {
    align-items: stretch;
    height: 72px;
    min-height: 72px;
    max-height: 72px;
}
.pf-signature-cell.pf-signature-cell-sig label {
    flex-shrink: 0;
}
.pf-signature-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-family: 'Autograf', 'Dancing Script', cursive;
    font-size: 2.8125rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text);
    outline: none;
    padding: 4px 0;
    overflow: hidden;
}
.pf-signature-input::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}
.pf-signature-cell + .pf-signature-cell {
    border-left: 1px solid var(--text);
}
.pf-signature-row + .pf-signature-row {
    border-top: 1px solid var(--border);
}
.pf-signature-cell label {
    font-weight: 700;
    font-size: 9px;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Back link + title above form */
.pf-page-header {
    max-width: 900px;
    margin: 0 auto 12px auto;
}

/* Action buttons below form */
.pf-actions {
    max-width: 900px;
    margin: 12px auto 0 auto;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Client autocomplete dropdown */
.pf-autocomplete {
    position: absolute;
    z-index: 50;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 1px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.pf-autocomplete-item {
    padding: 6px 8px;
    font-size: 11px;
    cursor: pointer;
    color: var(--text);
}
.pf-autocomplete-item:hover {
    background: var(--accent-glow);
}
.pf-autocomplete-create {
    padding: 6px 8px;
    font-size: 10px;
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    border-top: 1px solid var(--border);
}

/* Ditto marks for repeated fields */
.pf-ditto {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* Separator between left-column sections */
.pf-left-divider {
    border-top: 1px solid var(--text);
}

/* ============================================================
   Paper Form: Mobile Responsive (screen only — must not apply in print)
   ============================================================ */
@media screen and (max-width: 767px) {
    .paper-form {
        font-size: 12px;
        border-width: 1px;
    }
    .pf-header {
        flex-direction: column;
    }
    .pf-header-company {
        border-right: none;
        border-bottom: 1px solid var(--text);
    }
    .pf-header-order {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        padding: 6px 12px;
    }
    .pf-body {
        flex-direction: column;
    }
    .pf-left {
        border-right: none;
        border-bottom: 1px solid var(--text);
    }
    .pf-right {
        width: 100%;
        min-width: 0;
    }
    .pf-checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .pf-checkbox-grid label:nth-child(4n) {
        border-right: 1px solid var(--border);
    }
    .pf-checkbox-grid label:nth-child(2n) {
        border-right: none;
    }
    .pf-flight-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .pf-flight-table {
        min-width: 700px;
    }
    .pf-footer {
        flex-direction: column;
    }
    .pf-policy {
        border-right: none;
        border-bottom: 1px solid var(--text);
    }
    .pf-billing {
        grid-template-columns: 1fr;
    }
    .pf-billing-left {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .pf-billing-header {
        flex-wrap: wrap;
    }
    .pf-billing-months {
        flex-wrap: wrap;
    }
    .pf-row-label {
        min-width: 90px;
        font-size: 8px;
    }
    .pf-ai-controls .pf-ai-row {
        flex-wrap: wrap;
    }
    .pf-ai-controls select {
        max-width: 100%;
        width: 100%;
    }
}

/* ============================================================
   Scripts Section (full-width, between body and flight table)
   ============================================================ */
.pf-scripts-section {
    border-top: 2px solid var(--text);
    padding: 0;
}

.pf-scripts-section .pf-section-header {
    margin: 0;
}

.pf-scripts-container {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

.pf-script-card {
    flex: 1;
    min-width: 280px;
    max-width: 480px;
    border: 1px solid var(--input-border, #444);
    border-radius: 8px;
    padding: 10px;
    background: var(--input-bg, rgba(255,255,255,0.03));
    flex-shrink: 0;
    overflow: hidden;
}

/* AI voice sliders inside script card — keep within card */
.pf-script-card .pf-voice-sliders {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    margin-top: 4px;
    padding: 6px 8px;
    background: var(--input-bg, #2a2a3a);
    border: 1px solid var(--input-border, #444);
    border-radius: 6px;
    min-width: 0;
}

.pf-script-card .pf-voice-sliders > div {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

/* Slider cells that have a footnote: stack slider row and note vertically */
.pf-script-card .pf-voice-sliders > div.pf-tts-slider-with-note {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
}

/* Style/exaggeration row spans full width of the two sliders above */
.pf-script-card .pf-voice-sliders > div.pf-tts-style-row {
    grid-column: 1 / -1;
}

.pf-script-card .pf-voice-sliders label {
    flex-shrink: 0;
    font-size: 9px;
    min-width: 42px;
    color: var(--text-muted, #aaa);
}

.pf-script-card .pf-voice-sliders input[type="range"] {
    flex: 1;
    min-width: 0;
    height: 4px;
}

.pf-script-card .pf-voice-sliders .pf-tts-stability-val,
.pf-script-card .pf-voice-sliders [id$="-val"] {
    flex-shrink: 0;
    font-size: 9px;
    min-width: 22px;
    text-align: right;
    color: var(--text-muted);
}

.pf-tts-note {
    font-size: 8px;
    color: var(--text-muted, #888);
    line-height: 1.2;
    padding-left: 0;
}

.pf-script-card .pf-ai-controls {
    min-width: 0;
}

.pf-script-card .pf-ai-row {
    flex-wrap: wrap;
    min-width: 0;
}

.pf-script-card .pf-ai-row select,
.pf-script-card .pf-ai-row input[type="text"] {
    min-width: 0;
    max-width: 100%;
}

.pf-script-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.pf-script-card-name {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    outline: none;
    padding: 2px 4px;
    border-bottom: 1px solid var(--input-border, #444);
}

.pf-script-card-remove {
    border: none;
    background: none;
    color: var(--danger, #ef4444);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.pf-script-card textarea {
    width: 100%;
    min-height: 60px;
    font-size: 10px;
    border: 1px solid var(--input-border, #444);
    border-radius: 4px;
    background: var(--input-bg, #2a2a3a);
    color: var(--text);
    padding: 6px;
    resize: vertical;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 4px;
}

@media screen and (max-width: 768px) {
    .pf-scripts-container {
        flex-direction: column;
    }
    .pf-script-card {
        max-width: 100%;
        min-width: auto;
    }
}

/* ============================================================
   Order Form / Invoice Tab Switcher
   ============================================================ */
.order-doc-tab-bar {
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-bottom: 1rem;
    padding: 3px;
    border: 1px solid var(--border, #333);
    border-radius: 8px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    background: var(--surface, #1a1a2e);
}
.order-doc-tab {
    padding: 6px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    background: transparent;
    color: var(--text-subtle, #888);
}
.order-doc-tab:hover {
    color: var(--text, #eee);
}
.order-doc-tab.active {
    background: var(--accent, #6c63ff);
    color: #fff;
}

/* ============================================================
   Inline Payment Tabs (Card / Manual)
   ============================================================ */
.inline-pay-tabs {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 8px;
    width: fit-content;
    background: var(--surface, #1a1a2e);
}
.inline-pay-tab {
    padding: 6px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    background: transparent;
    color: var(--text-subtle, #888);
}
.inline-pay-tab:hover { color: var(--text, #eee); }
.inline-pay-tab.active {
    background: var(--accent, #6c63ff);
    color: #fff;
}

#stripe-card-element {
    background: var(--input-bg, #0f0f23);
    border: 1px solid var(--border, #333);
    border-radius: 6px;
}
#stripe-card-element.StripeElement--focus {
    border-color: var(--accent, #3b82f6);
    box-shadow: 0 0 0 2px var(--accent-glow);
}
#stripe-card-element.StripeElement--invalid {
    border-color: #f87171;
}

/* ============================================================
   Invoice Document (paper-form styled)
   Replicates the Flack Broadcasting invoice PDF template.
   ============================================================ */
.paper-form-invoice {
    position: relative;
    padding: 24px 32px;
    font-size: 11px;
    line-height: 1.4;
}
.paper-form-invoice + .paper-form-invoice {
    margin-top: 1.5rem;
}

/* Header: company left, title + meta right */
.pf-inv-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.pf-inv-header-left {
    flex: 0 0 auto;
}
.pf-inv-company-name {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
}
.pf-inv-company-addr {
    font-size: 11px;
    color: var(--text-subtle, #999);
}
.pf-inv-header-right {
    text-align: right;
}
.pf-inv-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}
.pf-inv-meta-table {
    border-collapse: collapse;
    margin-left: auto;
}
.pf-inv-meta-table td {
    padding: 0 0 1px 0;
    font-size: 11px;
}
.pf-inv-meta-label {
    text-align: right;
    padding-right: 8px;
    color: var(--text-subtle, #999);
    font-weight: 600;
}
.pf-inv-meta-value {
    text-align: left;
    color: var(--text);
    font-weight: 600;
}

/* Amount Due / Paid */
.pf-inv-amounts {
    text-align: right;
    margin-bottom: 16px;
}
.pf-inv-amount-row {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}
.pf-inv-amount-label {
    font-weight: 700;
    font-size: 12px;
    color: var(--text);
}
.pf-inv-amount-value {
    font-weight: 700;
    font-size: 12px;
    color: var(--text);
    min-width: 80px;
    text-align: left;
}
.pf-inv-amount-paid-line {
    border-bottom: 1px solid var(--text-subtle, #666);
    min-width: 80px;
    display: inline-block;
}

/* Bill-to + Station row */
.pf-inv-billto-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    padding-bottom: 8px;
}
.pf-inv-billto-name {
    font-weight: 700;
    font-size: 12px;
    color: var(--text);
}
.pf-inv-billto-line {
    font-size: 11px;
    color: var(--text);
}
.pf-inv-station-info {
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

/* Broadcast log table */
.pf-inv-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-bottom: 12px;
}
.pf-inv-log-table thead tr {
    border-bottom: 2px solid var(--border, #444);
}
.pf-inv-log-table th {
    text-align: left;
    padding: 4px 6px;
    font-weight: 700;
    color: var(--text);
    font-size: 10px;
    text-decoration: underline;
}
.pf-inv-log-table td {
    padding: 2px 6px;
    color: var(--text);
    border-bottom: none;
}
.pf-inv-cost-col {
    text-align: right !important;
}
.pf-inv-totals-row {
    border-top: 2px solid var(--border, #444);
}
.pf-inv-totals-row td {
    padding-top: 8px;
    font-weight: 700;
}
.pf-inv-totals-count {
    text-align: center;
}
.pf-inv-totals-label {
    text-align: right;
    font-weight: 700;
}

/* Affidavit */
.pf-inv-affidavit {
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px solid var(--border, #444);
    font-size: 10px;
    color: var(--text-subtle, #999);
}
.pf-inv-affidavit-text {
    margin-bottom: 0;
    width: 50%;
}

/* Amount Due box */
.pf-inv-due-box {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    font-size: 16px;
    font-weight: 800;
}
.pf-inv-due-box-label {
    color: var(--text);
}
.pf-inv-due-box-value {
    border: 2px solid var(--border, #444);
    padding: 4px 16px;
    color: var(--text);
    min-width: 80px;
    text-align: center;
}

/* Draft watermark */
.pf-inv-draft-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 120px;
    font-weight: 900;
    color: rgba(128, 128, 128, 0.08);
    pointer-events: none;
    user-select: none;
    z-index: 1;
    letter-spacing: 12px;
}

/* Inline scripts section (consolidated single-page invoice) */
.pf-inv-scripts-section {
    margin-top: 16px;
    border-top: 2px solid var(--border, #444);
    padding-top: 8px;
}
.pf-inv-scripts-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text);
    margin-bottom: 8px;
}
.pf-inv-script-inline {
    border: 1px solid var(--border, #444);
    padding: 6px 8px;
    margin-bottom: 6px;
}
.pf-inv-script-inline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 10px;
    color: var(--text);
    margin-bottom: 4px;
}
.pf-inv-script-inline-meta b {
    color: var(--text-subtle, #999);
    font-weight: 600;
}
.pf-inv-script-inline-text {
    font-size: 10px;
    line-height: 1.4;
    color: var(--text);
    padding: 4px 0;
    border-top: 1px solid var(--border, #444);
    border-bottom: 1px solid var(--border, #444);
    margin-bottom: 4px;
}
.pf-inv-script-inline-doc {
    font-size: 9px;
    color: var(--text-subtle, #999);
}
.pf-inv-script-inline-doc-title {
    font-weight: 700;
    font-size: 9px;
    color: var(--text);
    margin-bottom: 2px;
}
.pf-inv-script-inline-doc p {
    margin: 0;
    line-height: 1.3;
}
.pf-inv-signature-caption {
    font-size: 10px;
    color: var(--text-subtle, #999);
    text-align: right;
}

/* ============================================================
   Paper Form: Print Overrides
   PDF must match the EXACT shape of the order form box on screen.
   Single page only: form is rendered at full 900px desktop width,
   then scaled to fit the printable area.
   ============================================================ */
@media print {
    /* One full page: container fills printable height so content goes to the bottom */
    #order-detail-body:not(.hidden) {
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        height: var(--print-container-h, 9.7in) !important;
        min-height: 9.7in !important;
        page-break-inside: avoid !important;
    }

    /* Render at full desktop width, then scale to fit page (order form only, not invoice) */
    .paper-form:not(.paper-form-invoice) {
        border-color: #000 !important;
        background: white !important;
        color: #000 !important;
        width: 900px !important;
        min-width: 900px !important;
        max-width: 900px !important;
        margin: 0 !important;
        font-size: 11px !important;
        line-height: 1.35 !important;
        transform: scale(var(--print-scale, 0.77)) !important;
        transform-origin: top left !important;
    }

    /* Two-column body: exactly half the page each (left = right). Use fixed in so PDF respects it. */
    .pf-body {
        border-color: #000 !important;
        height: 5.5in !important;
        min-height: 5.5in !important;
        max-height: 5.5in !important;
        display: flex !important;
        align-items: stretch !important;
        overflow: hidden !important;
    }
    .pf-left {
        border-color: #000 !important;
        flex: 1 1 0 !important;
        min-height: 0 !important;
        max-height: 100% !important;
        overflow: hidden !important;
    }
    .pf-right {
        border-color: #000 !important;
        width: 340px !important;
        min-width: 340px !important;
        flex: 0 0 340px !important;
        min-height: 0 !important;
        max-height: 100% !important;
        overflow: hidden !important;
    }

    .pf-header { border-color: #000 !important; }
    .pf-row { border-color: #999 !important; }
    .pf-row-split { border-color: #999 !important; }
    .pf-row-label,
    .pf-cell-label { color: #333 !important; }
    .pf-section-header,
    .pf-spots-header,
    .pf-script-header { border-color: #000 !important; background: #f0f0f0 !important; color: #000 !important; }
    .pf-flight-table th { border-color: #000 !important; background: #f0f0f0 !important; color: #000 !important; }
    .pf-flight-table td { border-color: #999 !important; color: #000 !important; }
    .pf-copy-table th { border-color: #000 !important; background: #f0f0f0 !important; }
    .pf-copy-table td { border-color: #999 !important; }
    .pf-checkbox-grid label { border-color: #999 !important; color: #333 !important; }
    .pf-checkbox-grid input[type="checkbox"],
    .pf-station-list input[type="checkbox"],
    .pf-yesno input[type="checkbox"],
    .pf-yesno input[type="radio"],
    .pf-billing-type input[type="radio"],
    .pf-billing-months input[type="checkbox"] {
        border-color: #333 !important;
    }
    .pf-checkbox-grid input[type="checkbox"]:checked,
    .pf-station-list input[type="checkbox"]:checked,
    .pf-yesno input:checked,
    .pf-billing-type input[type="radio"]:checked,
    .pf-billing-months input[type="checkbox"]:checked {
        background: #000 !important;
        border-color: #000 !important;
    }
    .pf-footer { border-color: #000 !important; }
    .pf-policy { border-color: #000 !important; color: #555 !important; }
    .pf-billing { border-color: #000 !important; }
    .pf-billing-left { border-color: #999 !important; }
    .pf-billing-header { border-color: #999 !important; }
    .pf-billing-months { border-color: #999 !important; }
    .pf-billing-instructions { border-color: #999 !important; }
    .pf-flight-section { border-color: #000 !important; overflow: visible !important; }
    .pf-flight-hide-sched { visibility: hidden; border-color: transparent !important; }
    .pf-cart-add { display: none !important; }
    .pf-cart-remove { display: none !important; }
    .pf-cart-pct { border-color: #999 !important; }
    .pf-ai-controls { display: none !important; }
    /* Do NOT change scripts layout — keep same as screen (no flex-direction: column) */
    .pf-script-card { border-color: #999 !important; }
    .pf-script-card textarea { border-color: #999 !important; color: #000 !important; background: white !important; }
    .pf-script-card-name { color: #000 !important; border-color: #999 !important; }
    .pf-scripts-section { border-color: #000 !important; }
    .pf-actions { display: none !important; }
    .pf-page-header .no-print { display: none !important; }

    .pf-row-value input,
    .pf-cell-value input,
    .pf-spots-revenue input,
    .pf-copy-table td input,
    .pf-flight-table td input,
    .pf-billing-amount input,
    .pf-billing-instructions input {
        border-bottom: none !important;
        color: #000 !important;
    }

    /* Keep hidden containers hidden during print */
    #order-detail-body.hidden,
    #order-invoice-body.hidden {
        display: none !important;
    }

    /* Invoice document print overrides */
    #order-invoice-body:not(.hidden) {
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .paper-form-invoice {
        background: white !important;
        color: #000 !important;
        border-color: #000 !important;
        width: 100% !important;
        max-width: 100% !important;
        transform: none !important;
        page-break-after: auto;
        page-break-inside: avoid;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
    }
    .pf-inv-company-name { color: #000 !important; }
    .pf-inv-company-addr { color: #333 !important; }
    .pf-inv-title { color: #000 !important; }
    .pf-inv-meta-label { color: #333 !important; }
    .pf-inv-meta-value { color: #000 !important; }
    .pf-inv-amount-label,
    .pf-inv-amount-value { color: #000 !important; }
    .pf-inv-amount-paid-line { border-color: #000 !important; }
    .pf-inv-billto-name,
    .pf-inv-billto-line,
    .pf-inv-station-info { color: #000 !important; }
    .pf-inv-log-table th { color: #000 !important; border-color: #000 !important; }
    .pf-inv-log-table td { color: #000 !important; }
    .pf-inv-log-table thead tr { border-color: #000 !important; }
    .pf-inv-totals-row { border-color: #000 !important; }
    .pf-inv-affidavit { border-color: #999 !important; color: #333 !important; }
    .pf-inv-due-box-label { color: #000 !important; }
    .pf-inv-due-box-value { color: #000 !important; border-color: #000 !important; }
    .pf-inv-draft-watermark { color: rgba(0, 0, 0, 0.06) !important; }
    .pf-inv-scripts-section { border-color: #000 !important; }
    .pf-inv-scripts-title { color: #000 !important; }
    .pf-inv-script-inline { border-color: #999 !important; }
    .pf-inv-script-inline-meta { color: #000 !important; }
    .pf-inv-script-inline-meta b { color: #333 !important; }
    .pf-inv-script-inline-text { color: #000 !important; border-color: #999 !important; }
    .pf-inv-script-inline-doc { color: #333 !important; }
    .pf-inv-script-inline-doc-title { color: #000 !important; }
    .pf-inv-script-inline-doc p { color: #000 !important; }
    .pf-inv-signature-caption { color: #333 !important; }
}

/* ============================================================
   CRM — date range toolbar (persistent, never collapses)
   ============================================================ */
/* De-carded (Phase 5c): flat toolbar row with a hairline underline. */
.crm-toolbar {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.crm-toolbar-select {
    width: auto;
    font-size: 13px;
    padding: 5px 28px 5px 10px;
}
.crm-toolbar-input {
    width: auto;
    font-size: 13px;
    padding: 5px 10px;
}

/* ============================================================
   CRM — unified section headers
   ============================================================ */
.crm-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 0;
    flex-wrap: wrap;
}
/* De-carded (Phase 5c): every section is flat; the header carries the
   hairline that used to belong to the card edge. */
.crm-section > .crm-section-header {
    border-bottom: 1px solid var(--border);
}
.crm-section.crm-section--collapsed > .crm-section-header {
    border-bottom: 1px solid var(--border-light);
}
.crm-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.01em;
}

/* ============================================================
   CRM — collapsible sections
   ============================================================ */
.crm-section--collapsed .crm-section-body {
    display: none !important;
}
.crm-section-toggle {
    flex-shrink: 0;
}
.crm-section-chevron {
    display: block;
    transition: transform 0.15s ease;
    transform-origin: center;
}
.crm-section--collapsed .crm-section-chevron {
    transform: rotate(-90deg);
}
@media print {
    .crm-section--collapsed .crm-section-body {
        display: block !important;
    }
    .crm-section-toggle {
        display: none !important;
    }
}

/* ============================================================
   CRM Calendar
   ============================================================ */
.crm-cal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px 8px;
}
.crm-cal-nav {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.15s;
}
.crm-cal-nav:hover { background: var(--hover); }
.crm-cal-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    min-width: 160px;
    text-align: center;
}
.crm-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    padding: 0 12px 12px;
}
.crm-cal-dow {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.crm-cal-cell {
    min-height: 82px;
    max-height: 82px;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    transition: background 0.15s, max-height 0.25s ease, z-index 0s;
    position: relative;
    overflow: hidden;
}
.crm-cal-cell:hover {
    background: var(--hover);
    max-height: 300px;
    overflow: visible;
    z-index: 10;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.crm-cal-empty { border-color: transparent; cursor: default; }
.crm-cal-empty:hover { background: none; }
.crm-cal-today {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.06);
}
.crm-cal-dimmed { opacity: 0.35; }
.crm-cal-day-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.crm-cal-items {
    display: flex;
    flex-direction: column;
}
.crm-cal-item {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 1px;
    line-height: 1.2;
}
.crm-cal-item-link {
    cursor: pointer;
    border-radius: 3px;
    padding: 0 2px;
    transition: background 0.1s;
}
.crm-cal-item-link:hover {
    background: var(--hover);
}
.crm-item-menu {
    position: fixed;
    z-index: 100;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    padding: 4px 0;
    min-width: 160px;
}
.crm-item-menu-row {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.1s;
}
.crm-item-menu-row:hover {
    background: var(--hover);
}
.crm-cal-item-label {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crm-cal-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.crm-cal-due {
    font-size: 9px;
    font-weight: 700;
    border-radius: 3px;
    padding: 0 3px;
    line-height: 14px;
}
.crm-cal-holiday {
    display: block;
    font-size: 9px;
    color: var(--text-muted);
    background: var(--hover);
    border-radius: 3px;
    padding: 1px 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crm-cal-event {
    display: block;
    font-size: 9px;
    color: #fff;
    border-radius: 3px;
    padding: 1px 4px;
    margin-bottom: 2px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crm-cal-event:hover { filter: brightness(1.2); }
.crm-cal-event-del {
    display: none;
    margin-left: 3px;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    opacity: .7;
    padding: 0 1px;
}
.crm-cal-event-del:hover { opacity: 1; }
.crm-cal-event:hover .crm-cal-event-del { display: inline; }
.crm-cal-followup {
    cursor: pointer;
}
.crm-cal-followup:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* Calendar view toggle (Month / Week / Day) */
.crm-cal-view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-left: 4px;
}
.crm-cal-view-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.crm-cal-view-btn + .crm-cal-view-btn {
    border-left: 1px solid var(--border);
}
.crm-cal-view-btn:hover {
    background: var(--hover);
    color: var(--text);
}
.crm-cal-view-btn.active {
    background: var(--accent, #3b82f6);
    color: #fff;
}
.crm-cal-today-btn {
    font-size: 11px;
    padding: 4px 10px;
}

/* Week view: taller cells, no max-height clamp so all items show */
.crm-cal-grid-week .crm-cal-cell {
    min-height: 240px;
    max-height: none;
}
.crm-cal-grid-week .crm-cal-cell:hover {
    max-height: none;
}

/* Day view: single full-width cell, very tall */
.crm-cal-grid-day .crm-cal-cell {
    min-height: 480px;
    max-height: none;
    padding: 12px 16px;
}
.crm-cal-grid-day .crm-cal-cell:hover {
    max-height: none;
}
.crm-cal-grid-day .crm-cal-day-num {
    font-size: 16px;
    margin-bottom: 8px;
}
.crm-cal-grid-day .crm-cal-item-label,
.crm-cal-grid-day .crm-cal-event,
.crm-cal-grid-day .crm-cal-holiday {
    font-size: 12px;
}
.crm-cal-grid-day .crm-cal-dow {
    font-size: 12px;
}

/* Calendar +Add dropdown */
.crm-add-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 160px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 50;
    overflow: hidden;
}
.crm-add-option {
    display: block;
    width: 100%;
    padding: 8px 14px;
    text-align: left;
    font-size: 12px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.crm-add-option:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* Chart client filter dropdown */
.crm-client-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 50;
    min-width: 200px;
    max-height: 280px;
    overflow-y: auto;
    background: var(--card-bg, #1a1a2e);
    border: 1px solid var(--border, #333);
    border-radius: 6px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    margin-top: 4px;
}
.crm-client-dd-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    font-size: 12px;
    color: var(--text, #eee);
    cursor: pointer;
    border-radius: 4px;
}
.crm-client-dd-item:hover { background: var(--hover, rgba(255,255,255,0.05)); }
.crm-client-dd-item input[type="checkbox"] { accent-color: var(--accent, #3b82f6); }

/* Daily Report card */
.crm-daily-report-card {
    border: 2px solid #ef4444;
    border-radius: 8px;
    padding: 16px 20px;
    background: rgba(239, 68, 68, 0.04);
}
.crm-dr-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-subtle, #aaa);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border, #333);
}

/* Scrollable list inside daily report cells */
.crm-dr-scroll {
    max-height: 160px;
    overflow-y: auto;
}

/* Follow-up action modal */
.crm-followup-action { max-width: 100%; }
.crm-interaction-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.06));
}
.crm-interaction-row:last-child { border-bottom: none; }
.crm-fu-clickable:hover { background: rgba(59, 130, 246, 0.08); border-radius: 3px; }

/* Client detail card scroll containers */
.client-card-scroll {
    max-height: 280px;
    overflow-y: auto;
}

/* Calendar popover */
.crm-cal-popover {
    position: absolute;
    z-index: 50;
    top: 100%;
    left: 0;
    min-width: 220px;
    max-width: 300px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    padding: 10px 12px;
    font-size: 12px;
}
.crm-cal-popover-title {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    font-size: 13px;
}
.crm-cal-popover-hol {
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 4px;
}
.crm-cal-popover-section {
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 6px;
    margin-bottom: 2px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.crm-cal-popover-row {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    padding: 2px 0;
}
/* Expandable KPI card lists */
.crm-kpi-expandable { overflow: hidden; }
.crm-kpi-list {
    margin-top: 8px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.crm-kpi-expandable:hover .crm-kpi-list,
.crm-kpi-expandable.crm-kpi-pinned .crm-kpi-list {
    max-height: 300px;
    overflow-y: auto;
}
.crm-outstanding-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px;
    font-size: 11px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s, border-color 0.15s;
    border-left: 2px solid transparent;
}
.crm-outstanding-item:hover {
    background: var(--item-color-bg, var(--hover));
    border-left-color: var(--item-color, transparent);
}
.crm-outstanding-label {
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}
.crm-outstanding-amt {
    color: #f59e0b;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}
.crm-outstanding-due {
    color: var(--text-muted);
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.crm-cal-popover-ev {
    padding: 3px 6px;
    margin-bottom: 3px;
    color: var(--text);
}

/* ============================================================
   Station library — analytical view
   ============================================================ */

/* Split shell: left rail (controls) + right main (table), matching
   the Planner/Schedule proportions — narrow controls column, bulk view. */
.sl-shell {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    min-height: 0;
}
.sl-page.page-stack {
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
}
.sl-page .page-action-footer {
    flex: 0 0 auto;
}
.station-library-page .ce-runbar-inner {
    align-items: flex-start;
    gap: 0;
    width: 100%;
    max-width: 100%;
}
.station-library-page .ce-runbar-actions {
    align-content: flex-start;
    row-gap: 0.35rem;
    width: 100%;
}
.station-library-page .ce-footer-context {
    display: contents;
}
.station-library-page .ce-footer-context[hidden] {
    display: none !important;
}
.station-library-page .sl-runbar-status-line {
    flex: 0 0 100%;
    width: 100%;
    margin: 0;
}
.sl-page-main {
    position: relative;
}
.sl-page.is-busy .ce-runbar {
    pointer-events: none;
    opacity: 0.72;
}
.sl-page.is-busy .sl-shell {
    pointer-events: none;
}
#sl-busy-overlay {
    position: absolute;
    z-index: 80;
}
.lib-row-selected {
    box-shadow: inset 0 0 0 2px var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.sl-shell:has(.fk-select.is-open) {
    overflow: visible;
}
.sl-rail {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
    padding: 0.75rem 0.85rem 0.85rem;
    border-right: 1px solid var(--border);
    gap: 0.65rem;
}
.sl-rail .rules-root {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
.sl-rail .rules-tree-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.sl-rail .lib-toolbar {
    flex-shrink: 0;
    max-height: 42vh;
    overflow-y: auto;
}
.sl-section-head {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.12rem 0.1rem;
    border-radius: 0.25rem;
}
.sl-section-head:hover {
    background: var(--surface-hover);
}
.rules-tree-section-chev-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: inherit;
}
.rules-tree-section-chev-spacer {
    display: inline-block;
    width: 0.75rem;
    flex-shrink: 0;
}
.rules-tree-section-select {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    text-align: left;
    font: inherit;
    cursor: pointer;
    color: inherit;
}
.rules-tree-section-select.is-selected .rules-tree-section-title {
    color: var(--accent, #3b82f6);
    font-weight: 600;
}
.rules-tree-group-select {
    border: none;
    background: none;
    font: inherit;
    text-align: left;
    padding: 0;
    cursor: pointer;
    color: inherit;
    width: 100%;
}
.rules-tree-group-select.is-selected {
    color: var(--accent, #3b82f6);
    font-weight: 600;
}
.rules-tree-section.is-leaf.is-collapsed .rules-tree-section-body,
.rules-tree-section.is-leaf .rules-tree-section-body {
    display: none;
}
.sl-toolbar-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
}
.sl-rail .lib-toolbar {
    margin-bottom: 0;
    padding: 8px;
}
.sl-rail .lib-toolbar-row {
    gap: 6px;
}
.sl-rail .lib-toolbar-row-top {
    flex-direction: column;
    align-items: stretch;
}
.sl-rail .lib-search {
    flex: none;
    min-width: 0;
    width: 100%;
}
.sl-rail .lib-facet {
    flex-wrap: wrap;
    align-items: flex-start;
}
.sl-rail .lib-facet-label {
    min-width: 3.2rem;
}
.sl-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0.75rem 1rem 1rem;
    box-sizing: border-box;
}
.sl-main:has(.fk-select.is-open) {
    overflow: visible;
}
.sl-main-banner:empty { display: none; }
.sl-main-banner:not(:empty) { margin-bottom: 0.6rem; flex-shrink: 0; }
.sl-main .lib-stats {
    flex-shrink: 0;
}
.sl-main-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}
/* Let FlackSelect menus escape the scroll pane while open */
.sl-main-body:has(.fk-select.is-open) {
    overflow: visible;
}

/* AI program list — compact rows + inline expand (Community Events pattern) */
.sl-ai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.sl-ai-row {
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
}
.sl-ai-row:hover { background: var(--surface-hover); }
.sl-ai-row.is-expanded { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.sl-ai-row.is-selected {
    box-shadow: inset 0 0 0 2px var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.sl-ai-row.is-selected.is-expanded {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.sl-ai-row td {
    padding: 0.45rem 0.55rem;
    vertical-align: middle;
}
.sl-ai-name-cell {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}
.sl-ai-chevron {
    flex-shrink: 0;
    width: 0.85rem;
    color: var(--text-subtle);
    font-size: 11px;
}
.sl-ai-name {
    color: var(--text);
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sl-ai-meta-cell {
    color: var(--text-subtle);
    font-size: 11px;
    text-align: right;
    white-space: nowrap;
}
.sl-ai-detail-row td {
    padding: 0;
    border-bottom: 1px solid var(--border-light);
    background: color-mix(in srgb, var(--surface) 40%, transparent);
    overflow: visible;
}
.sl-ai-detail-row:has(.fk-select.is-open) td {
    overflow: visible;
}
.sl-ai-detail-block {
    position: relative;
    overflow: visible;
}
.sl-ai-detail-block .sl-ai-outline-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    overflow: visible;
}
.sl-ai-outline-rect {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
    stroke-dasharray: 7 7;
    stroke-linecap: butt;
    animation: sl-ai-march 1.4s linear infinite;
}
@keyframes sl-ai-march {
    to { stroke-dashoffset: 14; }
}
.sl-ai-detail {
    padding: 0;
    min-width: 0;
}
.sl-ai-detail-panel {
    overflow: visible;
    padding: 0.65rem 0.75rem 0.75rem;
    min-width: 0;
}
.sl-ai-detail-panel:has(.fk-select.is-open) {
    overflow: visible;
}
.sl-ai-detail-panel .fk-select.is-open {
    z-index: 200;
}

.sl-ai-script-block {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.sl-ai-script-mode {
    display: inline-flex;
    align-self: flex-start;
    padding: 0.15rem;
    border: 1px solid var(--border-light);
    border-radius: 0.55rem;
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    gap: 0.15rem;
}
.sl-ai-mode-btn {
    border: none;
    border-radius: 0.4rem;
    padding: 0.28rem 0.65rem;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.sl-ai-mode-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}
.sl-ai-mode-btn.is-active {
    color: #fff;
    background: var(--accent);
    box-shadow: 0 1px 0 color-mix(in srgb, #000 12%, transparent);
}
.sl-ai-script-block.is-manual .sl-ai-mode-btn.is-active {
    background: color-mix(in srgb, var(--accent) 82%, #6366f1);
}
.sl-ai-script-hint {
    margin: 0 0 0.35rem;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-subtle);
}
.sl-ai-script-hint code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
    color: var(--accent);
}
.sl-ai-script-drop-wrap {
    position: relative;
    border-radius: 0.5rem;
    transition: box-shadow 0.15s ease, background 0.15s ease;
}
.sl-ai-script-drop-wrap.is-drag-over {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent);
    background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.sl-ai-script-drop-wrap.is-dragging .sl-ai-script-editor {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--input-border));
}
.sl-ai-script-editor {
    font-family: inherit;
    font-size: 0.8125rem;
    line-height: 1.55;
    min-height: 9.5rem;
    max-height: 16rem;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    outline: none;
    cursor: text;
}
.sl-ai-script-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-subtle);
    pointer-events: none;
}
.sl-ai-field-pill {
    display: inline-flex;
    align-items: center;
    vertical-align: baseline;
    margin: 0 0.12rem;
    padding: 0.08rem 0.45rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
    background: color-mix(in srgb, var(--accent) 14%, var(--surface));
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.35;
    cursor: grab;
    user-select: none;
    white-space: nowrap;
}
.sl-ai-field-pill:hover {
    background: color-mix(in srgb, var(--accent) 22%, var(--surface));
    border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
}
.sl-ai-field-pill.is-dragging {
    opacity: 0.45;
    cursor: grabbing;
}
.sl-ai-field-pill-label {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
    font-weight: 600;
}
.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;
}

.sl-ai-form {
    min-height: 0;
}
.sl-ai-form-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 44%);
    gap: 0.85rem;
    align-items: stretch;
    min-height: 0;
}
.sl-ai-form-col,
.sl-ai-data-col {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-width: 0;
    min-height: 0;
}
.sl-ai-data-col {
    overflow: hidden;
    align-self: stretch;
}
.sl-ai-data-col > :not(.sl-ai-data-panel) {
    flex: 0 0 auto;
}
.sl-ai-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-top: 0.15rem;
}
.sl-ai-input-bindings {
    flex: 0 0 auto;
    margin-top: 0.65rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border-light);
    border-radius: 0.4rem;
    background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.sl-ai-input-bindings[hidden] { display: none !important; }
.sl-ai-input-bindings-head { margin-bottom: 0.45rem; }
.sl-ai-input-row {
    display: grid;
    grid-template-columns: minmax(5rem, 7rem) 1fr;
    gap: 0.35rem 0.5rem;
    align-items: center;
    margin-bottom: 0.4rem;
}
.sl-ai-input-row:last-child { margin-bottom: 0; }
.sl-ai-input-label {
    font-size: 11px;
    color: var(--text-subtle);
}
.sl-ai-input-literal { min-width: 0; }

/* TTS recipe music bed + speech timeline */
.sl-tts-bed {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem 0.65rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.sl-tts-bed-title {
    display: block;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-subtle);
}
.sl-tts-bed-hint,
.sl-tts-timeline-hint {
    margin: 0.15rem 0 0;
    font-size: 11px;
    color: var(--text-subtle);
}
.sl-tts-bed-source {
    display: inline-flex;
    gap: 0.2rem;
    padding: 0.15rem;
    border-radius: 0.4rem;
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    border: 1px solid var(--border-light);
    width: fit-content;
}
.sl-tts-source-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    padding: 0.25rem 0.55rem;
    border-radius: 0.3rem;
    cursor: pointer;
}
.sl-tts-source-btn.is-active {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--text);
}
.sl-tts-gen-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.65rem;
    margin-top: 0.45rem;
}
.sl-tts-vol-label,
.sl-tts-dur-label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 7rem;
}
.sl-tts-dur-label .form-input {
    width: 4.5rem;
}
.sl-tts-upload-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}
.sl-tts-library-panel {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.sl-tts-lib-pick {
    display: block;
}
.sl-tts-lib-picker {
    display: block;
    width: 100%;
}
.sl-tts-lib-picker-panel {
    min-width: 100%;
    width: max-content;
    max-width: min(16rem, 92vw);
}
.sl-tts-lib-picker-item.has-flyout {
    position: relative;
}
.sl-tts-lib-picker-folder {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    cursor: default;
}
.sl-tts-lib-picker-chevron {
    width: 0.75rem;
    height: 0.75rem;
    flex-shrink: 0;
    opacity: 0.45;
}
.sl-tts-lib-picker-flyout {
    display: none;
    flex-direction: column;
    min-width: 11rem;
    max-width: min(18rem, 88vw);
    max-height: min(14rem, 38vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.25rem;
    z-index: 130;
}
.sl-tts-lib-picker-empty {
    margin: 0.25rem 0.55rem;
    font-size: 0.7rem;
    color: color-mix(in srgb, var(--text) 40%, transparent);
}
.sl-tts-lib-vol { margin-top: 0.15rem; }
.sl-tts-timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-top: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    overflow: hidden;
    box-sizing: border-box;
}
.sl-tts-timeline-program {
    position: relative;
    height: 2.75rem;
    cursor: crosshair;
}
.sl-tts-strip {
    position: absolute;
    inset: 0.35rem 0.4rem;
    overflow: hidden;
    border-radius: 4px;
}
.sl-tts-bed-track {
    position: absolute;
    inset: 0;
    border-radius: 4px;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--accent) 12%, var(--surface)) 0%,
        color-mix(in srgb, var(--accent) 6%, var(--surface)) 100%
    );
    border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
    box-sizing: border-box;
    pointer-events: none;
    z-index: 1;
}
.sl-tts-bed-track-label {
    position: absolute;
    left: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--accent) 55%, var(--text-subtle));
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
.sl-tts-speech-block {
    position: absolute;
    top: 3px;
    bottom: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rules-accent, #7c3aed);
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    cursor: grab;
    user-select: none;
    box-sizing: border-box;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--rules-accent) 80%, #000);
    z-index: 3;
    overflow: hidden;
}
.sl-tts-speech-block.is-pending {
    box-shadow: 0 0 0 1px color-mix(in srgb, #f59e0b 70%, var(--rules-accent)),
        0 0 0 3px color-mix(in srgb, #f59e0b 25%, transparent);
}
.sl-tts-speech-block.is-busy {
    opacity: 0.55;
    pointer-events: none;
}
.sl-tts-block-label {
    pointer-events: none;
    font-variant-numeric: tabular-nums;
    font-size: 10px;
    font-weight: 600;
}
.sl-tts-block-kind {
    position: absolute;
    left: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 8px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0.85;
    pointer-events: none;
}
.sl-tts-timeline .sl-tts-busy-overlay {
    border-radius: 6px;
    z-index: 25;
}
.sl-tts-play-btn.is-pending-play {
    color: color-mix(in srgb, #f59e0b 80%, var(--text));
}
.sl-tts-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
}
.sl-tts-handle.is-w { left: 0; }
.sl-tts-handle.is-e { right: 0; }
.sl-tts-handle:hover {
    background: color-mix(in srgb, #fff 25%, transparent);
}
.sl-tts-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: #ef4444;
    z-index: 4;
    pointer-events: none;
}
.sl-tts-playhead.is-hidden { display: none; }
.sl-tts-playhead::after {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #ef4444;
}
.sl-tts-tick-labels {
    position: relative;
    height: 1.1rem;
    margin: 0 0.4rem 0.2rem;
}
.sl-tts-tick-label {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: 9px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}
.sl-tts-tick-label.is-edge-start { transform: none; }
.sl-tts-tick-label.is-edge-end { transform: none; text-align: right; }
.sl-tts-player {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.5rem 0.5rem;
}
.sl-tts-play-btn {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.sl-tts-download-btn {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-subtle);
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.sl-tts-download-btn.is-ready {
    color: var(--text);
}
.sl-tts-download-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.sl-tts-download-btn:not(:disabled):hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    color: var(--accent);
}
.sl-tts-player-volume {
    width: 5rem;
}
.sl-tts-timeline.is-scrubbing .sl-tts-speech-block {
    pointer-events: none;
    opacity: 0.85;
}
body.sl-tts-dragging {
    cursor: ew-resize !important;
    user-select: none;
}
body.sl-tts-dragging .sl-tts-speech-block {
    cursor: grabbing;
}

.sl-ai-data-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 0;
    padding: 0.55rem 0.6rem 0.6rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--surface) 55%, transparent);
    overflow: hidden;
}
.sl-ai-data-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.15rem;
    overscroll-behavior: contain;
}
.sl-ai-data-panel-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}
.sl-ai-data-config,
.sl-ai-data-status {
    flex: 0 0 auto;
}
.sl-ai-data-panel-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-subtle);
}
.sl-ai-data-config {
    font-size: 11px;
    line-height: 1.45;
    color: var(--text-subtle);
    margin: 0 0 0.4rem;
}
.sl-ai-data-status {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
}
.sl-ai-data-status--error {
    color: color-mix(in srgb, var(--danger) 80%, var(--text-muted));
}
.sl-ai-data-group-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
    margin: 0.35rem 0 0.25rem;
}
.sl-ai-data-group-label:first-child {
    margin-top: 0;
}
.sl-ai-data-field-list {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.sl-ai-data-field {
    display: grid;
    grid-template-columns: auto minmax(7rem, 1fr) minmax(0, 1.4fr) auto;
    gap: 0.35rem 0.45rem;
    align-items: baseline;
    width: 100%;
    text-align: left;
    padding: 0.28rem 0.4rem;
    border: 1px solid transparent;
    border-radius: 0.35rem;
    background: transparent;
    cursor: grab;
    font: inherit;
    color: inherit;
}
.sl-ai-data-field:active {
    cursor: grabbing;
}
.sl-ai-data-field-grip {
    font-size: 10px;
    line-height: 1;
    color: var(--text-subtle);
    opacity: 0.65;
    user-select: none;
}
.sl-ai-data-field:hover .sl-ai-data-field-grip {
    opacity: 1;
    color: var(--accent);
}
.sl-ai-data-field:hover {
    background: var(--surface-hover);
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border-light));
}
.sl-ai-data-field-path {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: var(--accent);
}
.sl-ai-data-field-sample {
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sl-ai-data-field-type {
    font-size: 10px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}
.sl-ai-data-empty {
    font-size: 11px;
    color: var(--text-subtle);
    font-style: italic;
}

.lib-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface-dim);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 10px;
}
.lib-toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}
.lib-toolbar-row-top {
    gap: 10px;
}
.lib-search {
    position: relative;
    flex: 1 1 240px;
    min-width: 200px;
}
.lib-search-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-subtle);
    pointer-events: none;
}
.lib-search-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    padding: 6px 10px 6px 30px;
    outline: none;
    transition: border-color 0.15s;
}
.lib-search-input:focus { border-color: var(--accent); }
.lib-active-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.lib-active-toggle input { margin: 0; cursor: pointer; }
.lib-link-btn {
    background: transparent;
    border: none;
    color: var(--text-subtle);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.lib-link-btn:hover { color: var(--accent); background: var(--surface-hover); }
.lib-facet {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
}
.lib-facet-mood { flex: 1 1 100%; align-items: flex-start; }
.lib-facet-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
    font-weight: 600;
    margin-right: 2px;
}
.lib-facet-chips {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.lib-facet-chips-wrap { flex-wrap: wrap; row-gap: 4px; }
.lib-facet-range { display: inline-flex; align-items: center; gap: 4px; }
.lib-range-sep { color: var(--text-subtle); font-size: 11px; }
.lib-range-input,
.lib-range-select {
    width: 56px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text);
    font-size: 12px;
    padding: 3px 6px;
    outline: none;
}
.lib-range-input:focus,
.lib-range-select:focus { border-color: var(--accent); }
.lib-chip {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 11px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.lib-chip:hover { border-color: var(--text-subtle); color: var(--text); }
.lib-chip-on {
    background: var(--accent-surface);
    border-color: var(--accent);
    color: var(--accent);
}
.lib-chip-tier-A.lib-chip-on { background: rgba(239, 68, 68, 0.12);  border-color: #ef4444; color: #f87171; }
.lib-chip-tier-B.lib-chip-on { background: rgba(245, 158, 11, 0.12); border-color: #f59e0b; color: #fbbf24; }
.lib-chip-tier-C.lib-chip-on { background: rgba(96, 165, 250, 0.12); border-color: #60a5fa; color: #93c5fd; }
.lib-chip-tier-D.lib-chip-on { background: rgba(148, 163, 184, 0.12); border-color: #94a3b8; color: #cbd5e1; }

/* Stats band */
.lib-stats {
    margin-bottom: 8px;
}
.lib-stats-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
    padding: 8px 12px;
    background: var(--surface-dim);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.lib-stats-count { font-size: 12px; color: var(--text-secondary); }
.lib-stats-group { display: inline-flex; align-items: center; gap: 6px; }
.lib-stats-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-subtle);
    font-weight: 600;
}
.lib-stats-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.lib-stats-numeric { gap: 14px; }
.lib-stats-numeric > div { display: inline-flex; align-items: center; gap: 4px; }
.lib-stats-num { font-family: 'SF Mono','Fira Code','Consolas',monospace; font-size: 12px; color: var(--text); font-weight: 600; }
.lib-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
}
.lib-stat-k { color: var(--text-subtle); font-weight: 600; }
.lib-stat-v { color: var(--text); font-family: 'SF Mono','Fira Code','Consolas',monospace; }
.lib-stat-tier-A .lib-stat-k { color: #f87171; }
.lib-stat-tier-B .lib-stat-k { color: #fbbf24; }
.lib-stat-tier-C .lib-stat-k { color: #93c5fd; }
.lib-stat-tier-D .lib-stat-k { color: #cbd5e1; }

/* Table */
.lib-table {
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    overflow-x: auto;
}
.lib-thead,
.lib-row {
    display: grid;
    grid-template-columns: 8px 60px 60px minmax(220px, 1fr) 54px 62px 56px 58px 90px;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    min-width: 720px;
}
.lib-thead {
    background: var(--surface-dim);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-subtle);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    padding: 6px 10px;
    position: sticky;
    top: 0;
    z-index: 1;
}
.lib-h {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: color 0.15s;
}
.lib-h:hover { color: var(--text); }
.lib-h-active { color: var(--accent); }
.lib-h-r { justify-content: flex-end; text-align: right; }
.lib-h-arrow { font-size: 8px; opacity: 0.7; }
.lib-h-dot { width: 8px; }
.lib-tbody { display: block; }
.lib-row {
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text);
    transition: background 0.1s;
    min-height: 32px;
}
.lib-row:last-child { border-bottom: none; }
.lib-row:hover { background: var(--surface-hover); }
.lib-row-inactive { opacity: 0.45; }

/* Folder tree (Plan B Phase 1) */
.sl-folder-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text);
    font-size: 12px;
    transition: background 0.1s;
}
.sl-folder-row:hover { background: var(--surface-hover); }
.sl-folder-selected { background: var(--accent-glow); color: var(--accent, #3b82f6); }
.sl-folder-selected:hover { background: var(--accent-surface); }
.sl-folder-name { flex: 1; }
.sl-folder-count { color: var(--text-muted, rgba(255,255,255,0.4)); font-size: 11px; padding-left: 6px; }
.lib-row-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.lib-cell { min-width: 0; }
.lib-cell-num { text-align: right; font-family: 'SF Mono','Fira Code','Consolas',monospace; font-size: 11px; }
.lib-cell-mono { color: var(--text-secondary); }
.lib-cell-title {
    display: flex;
    align-items: baseline;
    gap: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.lib-row-title {
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
}
.lib-row-artist {
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
    margin-left: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lib-cell-actions { display: inline-flex; gap: 2px; justify-content: flex-end; }
.lib-act {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-subtle);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.lib-act svg { width: 13px; height: 13px; }
.lib-row:hover .lib-act { opacity: 0.85; }
.lib-act:hover { opacity: 1; color: var(--accent); background: var(--surface-hover); }
.lib-act-on { opacity: 1; color: var(--accent); background: var(--accent-surface); }
.lib-act-del:hover { color: var(--danger); }

.lib-dim { color: var(--text-subtle); }

/* Inline tier/decade selects */
.lib-inline-select {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 4px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.lib-inline-select:hover { border-color: var(--border); background: var(--surface-dim); color: var(--text); }
.lib-inline-select:focus { outline: none; border-color: var(--accent); background: var(--surface-dim); }
.lib-tier { font-weight: 700; text-align: center; }
.lib-tier-A { color: #f87171; }
.lib-tier-B { color: #fbbf24; }
.lib-tier-C { color: #93c5fd; }
.lib-tier-D { color: #cbd5e1; }
.lib-tier-none { color: var(--text-subtle); font-weight: 400; }
.lib-decade { font-family: 'SF Mono','Fira Code','Consolas',monospace; font-size: 10px; color: var(--text-muted); }

/* Energy dots */
.lib-energy { display: inline-flex; gap: 2px; align-items: center; justify-content: flex-end; }
.lib-energy-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--border);
}
.lib-energy-on { background: var(--accent); }

/* Last-played age coloring */
.lib-age { font-family: 'SF Mono','Fira Code','Consolas',monospace; font-size: 11px; }
.lib-age-hot { color: #fbbf24; }
.lib-age-warm { color: var(--text); }
.lib-age-stale { color: var(--text-subtle); }
.lib-age-never { color: var(--success); font-weight: 600; }

/* Edit modal */
.lib-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lib-modal.hidden { display: none; }
.lib-modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--modal-overlay);
    cursor: pointer;
}
.lib-modal-card {
    position: relative;
    width: min(560px, 92vw);
    max-height: 88vh;
    overflow: auto;
    background: var(--modal-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
}
.lib-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
}
.lib-modal-header h3 { margin: 0; font-size: 14px; color: var(--text); font-weight: 600; }
.lib-modal-close {
    background: transparent;
    border: none;
    color: var(--text-subtle);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
}
.lib-modal-close:hover { color: var(--text); }
.lib-modal-body { padding: 14px 16px; }
.lib-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
}
.lib-modal-field { display: flex; flex-direction: column; gap: 4px; }
.lib-modal-field label {
    font-size: 11px;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.lib-modal-span2 { grid-column: span 2; }
.lib-modal-checkbox {
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: var(--text-secondary) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
}
.lib-modal-checkbox input { margin: 0; }
.lib-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
}

/* ============================================================
   Community Events — three-column workspace (planner-style shell)
   ============================================================ */
.ce-workspace {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
}
.ce-columns {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    overflow: hidden;
    background: var(--bg);
}
.ce-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    background: transparent;
}
.ce-col-inbox { flex: 0 0 var(--ce-inbox-w, 300px); min-width: 200px; position: relative; }
.ce-inbox-busy-overlay { z-index: 30; }
.ce-col-inbox.is-busy .ce-col-head,
.ce-col-inbox.is-busy .ce-col-select-bar,
.ce-col-inbox.is-busy .ce-col-body {
    pointer-events: none;
}
.ce-col-queue { flex: 1 1 auto; min-width: 160px; position: relative; }
.ce-events-busy-overlay { z-index: 30; }
.ce-col-queue.is-busy .ce-col-head,
.ce-col-queue.is-busy .ce-col-select-bar,
.ce-col-queue.is-busy .ce-col-body {
    pointer-events: none;
}
.ce-col-digest { flex: 0 0 var(--ce-digest-w, 420px); min-width: 280px; position: relative; }
.ce-digest-busy-overlay { z-index: 30; }
.ce-col-digest.is-busy .ce-col-head,
.ce-col-digest.is-busy .ce-col-body {
    pointer-events: none;
    user-select: none;
}
.ce-music-bed-busy { z-index: 30; }
.ce-event-detail-panel--digest.is-busy {
    pointer-events: none;
    user-select: none;
}

/* Draggable dividers — hairline only, no card gaps */
.ce-col-resizer {
    flex: 0 0 1px;
    position: relative;
    z-index: 5;
    cursor: col-resize;
    background: var(--border);
    touch-action: none;
}
.ce-col-resizer::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 7px;
    transform: translateX(-50%);
    background: transparent;
}
.ce-col-resizer:hover,
.ce-col-resizer.is-dragging {
    background: var(--accent);
}
body.ce-col-resizing { cursor: col-resize; user-select: none; }
body.ce-col-resizing * { cursor: col-resize !important; }

/* Column heads — same rhythm as .planner-toolbar */
.ce-col-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0 0.65rem 0.5rem;
    border-bottom: 1px solid var(--border);
    background: transparent;
}
.ce-col-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    white-space: nowrap;
}
.ce-col-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem 0.65rem;
}

/* Flat event rows — compact table + expandable detail */
.ce-event-table {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
    font-size: 12px;
    line-height: 1.2;
}
.ce-event-table th {
    padding: 4px 8px 4px 0;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ce-event-table th:last-child { padding-right: 0; }
.ce-cell-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0;
}
.ce-event-blurb-cell {
    color: var(--text);
    white-space: normal;
    line-height: 1.45;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
.ce-inbox-subject-cell {
    color: var(--text);
    white-space: normal;
    line-height: 1.45;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.ce-digest-table .ce-event-row td {
    vertical-align: top;
}
.ce-digest-table .ce-digest-week-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0;
    line-height: 1.35;
    color: var(--text-muted);
    font-size: 11px;
}
.ce-digest-table .ce-digest-status-cell {
    white-space: nowrap;
    width: 14%;
    overflow: visible;
    text-align: left;
    vertical-align: top;
}
.ce-event-row {
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
}
.ce-event-row:hover { background: var(--surface-hover); }
.ce-event-row.is-expanded { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.ce-event-row.is-selected {
    box-shadow: inset 0 0 0 2px var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.ce-event-row.is-selected.is-expanded {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.ce-col-select-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-light);
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.ce-col-select-bar.is-hidden { display: none; }
.ce-col-select-summary {
    margin: 0;
    font-size: 11px;
    color: var(--text-muted);
}
.ce-col-select-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.ce-delete-skipped-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.35rem;
}
.ce-delete-skipped-btn {
    position: relative;
    overflow: hidden;
    min-width: 8.5rem;
    transition: flex 0.18s ease, padding 0.18s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--danger) 55%, var(--border));
    color: var(--danger);
}
.ce-delete-skipped-btn:not(:disabled):hover {
    background: color-mix(in srgb, var(--danger) 8%, transparent);
    border-color: var(--danger);
    color: var(--danger);
    box-shadow: none;
}
.ce-delete-skipped-btn:disabled {
    opacity: 0.45;
    cursor: default;
}
.ce-delete-skipped-label {
    position: relative;
    z-index: 1;
}
.ce-delete-skipped-progress {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: color-mix(in srgb, var(--danger) 24%, transparent);
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 0.12s ease-out;
    pointer-events: none;
}
.ce-delete-skipped-btn.is-clearing .ce-delete-skipped-label {
    color: var(--danger);
}
.ce-delete-skipped-btn.is-clearing .ce-delete-skipped-progress {
    transition: transform 0.18s ease-out;
}
.ce-delete-skipped-confirm {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.35rem;
}
.ce-delete-skipped-row.is-confirming .ce-delete-skipped-confirm {
    display: flex;
}
.ce-delete-skipped-row.is-confirming .ce-delete-skipped-btn {
    flex: 1 1 auto;
    min-width: 0;
    cursor: default;
    color: var(--danger);
}
.ce-delete-skipped-confirm-btn {
    flex-shrink: 0;
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    border-radius: 0.35rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.ce-delete-skipped-confirm-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.ce-delete-skipped-confirm-btn.is-yes {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}
.ce-delete-skipped-confirm-btn.is-yes:hover {
    background: color-mix(in srgb, var(--danger) 8%, transparent);
    color: var(--danger);
}
.ce-event-row.is-linked {
    position: relative;
    z-index: 1;
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}
.ce-event-row td {
    padding: 6px 8px 6px 0;
    vertical-align: top;
    overflow: hidden;
}
.ce-event-row td:last-child { padding-right: 0; }
.ce-event-name-cell {
    font-weight: 600;
    color: var(--text);
}
.ce-event-date-cell {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.35;
}
.ce-recurring-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0 0.3rem;
    border-radius: 0.25rem;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--accent) 90%, white);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    vertical-align: middle;
}
.ce-recurrence-block .is-hidden {
    display: none;
}
.ce-recurrence-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}
@media (max-width: 767px) {
    .ce-recurrence-controls {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
}
.ce-recurrence-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    margin: 0;
}
.ce-recurrence-field > span {
    line-height: 1.25;
}
.ce-recurrence-summary:empty {
    display: none;
}
.ce-recurrence-madlib-quote {
    text-align: center;
    margin: 0 0 10px;
}
.ce-recurrence-madlib-quote:empty {
    display: none;
}
.ce-recurrence-madlib {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.ce-recurrence-madlib-lead {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
}
.ce-recurrence-madlib-select {
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
    color: inherit;
    max-width: 100%;
}
.ce-recurrence-madlib-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}
.ce-recurrence-madlib-part {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
}
.ce-event-status-cell { white-space: nowrap; width: 12%; }
.ce-event-detail-block {
    position: relative;
    overflow: visible;
}
.ce-event-detail-block .ce-event-outline-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    overflow: visible;
}
.ce-event-outline-rect {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
    stroke-dasharray: 7 7;
    stroke-linecap: butt;
    animation: ce-event-march 1.4s linear infinite;
}
@keyframes ce-event-march {
    to { stroke-dashoffset: 14; }
}
.ce-event-detail-row td {
    padding: 0;
    border-bottom: 1px solid var(--border-light);
    background: color-mix(in srgb, var(--surface) 40%, transparent);
    overflow: visible;
}
.ce-event-detail {
    padding: 0;
    min-width: 0;
}
.ce-event-detail-meta {
    padding: 0.5rem 0.65rem 0.4rem;
}
.ce-event-detail-panel {
    max-height: min(220px, 36vh);
    overflow: auto;
    padding: 0.5rem 0.65rem 0.65rem;
    border-top: 1px solid var(--border-light);
    min-width: 0;
}
.ce-event-detail-panel--form {
    max-height: min(320px, 48vh);
    border-top: none;
    padding-top: 0.65rem;
}
.ce-event-detail-panel--digest {
    max-height: min(800px, 85vh);
    border-top: none;
    overflow: auto;
    padding: 0.65rem 0.65rem 0.75rem;
    min-width: 0;
    position: relative;
}
.ce-event-detail-panel--digest .ce-digest-inner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: min(640px, 75vh);
}
.ce-event-detail-panel--digest .ce-digest-field {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    gap: 0.25rem;
}
.ce-event-detail-panel--digest .ce-digest-field {
    flex: 0 0 auto;
}
.ce-event-detail-panel--digest .ce-digest-textarea {
    flex: 0 0 auto;
    min-height: 150px;
    resize: vertical;
    font-size: 12px;
    line-height: 1.45;
}

/* Segmented on-air script (intro / per-event / outro) */
.ce-digest-segments {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ce-digest-segments-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.ce-digest-segment {
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0.5rem 0.55rem 0.55rem;
    background: var(--surface-dim, rgba(255,255,255,0.02));
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.ce-digest-segment.is-recorded {
    border-color: color-mix(in srgb, var(--success, #10b981) 45%, var(--border));
}
.ce-digest-segment-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.ce-seg-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    flex: 0 0 auto;
}
.ce-digest-segment.is-recorded .ce-seg-dot {
    background: var(--success, #10b981);
}
.ce-seg-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}
.ce-seg-type {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 1px 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
}
.ce-seg-gen {
    margin-left: auto;
}
.ce-digest-seg-textarea {
    width: 100%;
    min-height: 64px;
    resize: vertical;
    font-size: 12px;
    line-height: 1.45;
}
.ce-seg-audio {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.ce-event-detail-body {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
}
.ce-event-detail-panel--inbox-attachments {
    max-height: min(560px, 72vh);
}
.ce-inbox-body-block + .ce-inbox-attachments {
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border-light);
}
.ce-inbox-body-label,
.ce-inbox-attachments-title,
.ce-inbox-attachment-pane-label {
    margin: 0 0 0.35rem;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted, rgba(255, 255, 255, 0.45));
}
.ce-inbox-attachments {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.ce-inbox-attachment {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.55rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface) 65%, transparent);
}
.ce-inbox-attachment-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.ce-inbox-attachment-name {
    font-size: 12px;
    color: #38bdf8;
    text-decoration: none;
}
.ce-inbox-attachment-name:hover {
    text-decoration: underline;
}
.ce-inbox-attachment-compare {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.55rem;
}
@media (max-width: 900px) {
    .ce-inbox-attachment-compare {
        grid-template-columns: 1fr;
    }
}
.ce-inbox-attachment-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.ce-inbox-attachment-preview {
    min-height: 180px;
    max-height: 280px;
    overflow: auto;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
}
.ce-inbox-attachment-img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 280px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.15);
}
.ce-inbox-attachment-frame {
    display: block;
    width: 100%;
    height: 260px;
    border: 0;
    background: #fff;
}
.ce-inbox-attachment-fallback,
.ce-inbox-attachment-extract-empty {
    margin: 0;
    padding: 0.65rem;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted, rgba(255, 255, 255, 0.45));
}
.ce-inbox-attachment-extract {
    margin: 0;
    min-height: 180px;
    max-height: 280px;
    overflow: auto;
    padding: 0.55rem 0.6rem;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.15);
    font-family: inherit;
}

.ce-digest-inner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ce-digest-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.ce-digest-approve-btn.is-nudge,
.ce-run-btn--fill.is-nudge {
    animation: ce-approve-nudge 0.7s ease-in-out 3;
}
@keyframes ce-approve-nudge {
    0%, 100% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 0%, transparent);
    }
    50% {
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 28%, transparent);
    }
}
.ce-digest-field {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    gap: 0.25rem;
}
.ce-digest-textarea {
    flex: 1 1 auto;
    min-height: 88px;
    resize: none;
    font-size: 12px;
    line-height: 1.45;
}
.ce-digest-stale-notice {
    margin: 0;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.1);
    color: rgb(251, 191, 36);
    font-size: 11px;
    line-height: 1.45;
}
.ce-music-bed {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.35rem;
    padding: 0.55rem 0.6rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}
.ce-music-bed-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.ce-music-bed-prompt-text {
    margin: 0.15rem 0 0;
    font-size: 11px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.55);
    white-space: pre-wrap;
}
.ce-music-bed-controls {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.ce-music-bed-download {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.15rem;
    padding-top: 0.2rem;
}
.ce-music-bed-volume {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1 1 140px;
    min-width: 120px;
}
.ce-music-bed-slider {
    width: 100%;
    max-width: 160px;
    accent-color: var(--accent);
}
.ce-music-bed-volume.is-pending .ce-music-bed-slider {
    accent-color: var(--rules-accent-pending-text);
}
.ce-music-bed-volume.is-pending {
    padding: 0.15rem 0.35rem;
    margin: -0.15rem -0.35rem;
    border-radius: 6px;
    background: color-mix(in srgb, var(--rules-accent-pending-bg) 30%, transparent);
}
.ce-music-bed-prompt-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.ce-bed-prompt-input {
    width: 100%;
    resize: vertical;
    font-size: 12px;
    line-height: 1.45;
    min-height: 3rem;
}
.ce-music-bed-prompt-wrap.is-pending .ce-bed-prompt-input {
    border-color: color-mix(in srgb, var(--rules-accent-pending-text) 55%, var(--input-border));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--rules-accent-pending-text) 35%, transparent);
    background: color-mix(in srgb, var(--rules-accent-pending-bg) 18%, var(--input-bg));
}
.ce-music-bed-bed-only {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.ce-inline-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: rgb(125, 211, 252);
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
    font-size: inherit;
}
.ce-inline-link:hover {
    color: rgb(186, 230, 253);
}

/* Run bar — page action footer (sits above the live player bar) */
.ce-runbar {
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}
.ce-runbar.page-action-footer {
    padding: 0.6rem 0.85rem;
    overflow: visible;
}
.ce-runbar-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    width: 100%;
    max-width: min(72rem, 100%);
}
.ce-runbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    overflow: visible;
}
.ce-runbar-actions:has(.ce-footer-context[hidden]) {
    justify-content: space-between;
}
.ce-runbar-actions:has(.ce-footer-context:not([hidden])) > .ce-delete-skipped-row {
    margin-left: auto;
}
.ce-run-btn--danger {
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--danger) 55%, var(--border));
    color: var(--danger);
    box-shadow: none;
}
.ce-run-btn--danger:not(:disabled):hover {
    background: color-mix(in srgb, var(--danger) 8%, transparent);
    border-color: var(--danger);
    color: var(--danger);
}
.ce-run-btn--danger:disabled {
    opacity: 0.45;
    cursor: default;
}
.ce-run-btn--danger .ce-run-btn-progress {
    background: color-mix(in srgb, var(--danger) 24%, transparent);
}
.ce-run-btn--danger.is-running .ce-run-btn-label,
.ce-run-btn.is-clearing .ce-run-btn-label {
    color: var(--danger);
}
.ce-run-btn--fill {
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--fill) 55%, var(--border));
    color: var(--fill);
    box-shadow: none;
}
.ce-run-btn--fill:not(:disabled):hover {
    background: var(--fill-surface);
    border-color: var(--fill);
    color: var(--fill-dim);
}
.ce-run-btn--fill:disabled {
    opacity: 0.45;
    cursor: default;
}
.ce-run-btn--fill .ce-run-btn-progress {
    background: color-mix(in srgb, var(--fill) 24%, transparent);
}
.ce-run-btn--fill.is-running .ce-run-btn-label {
    color: var(--fill);
}


/* restored: fill */

/* restored: footer-context */
.ce-footer-context {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    flex: 1 1 auto;
    min-width: min(100%, 12rem);
}
.ce-footer-context .ce-run-btn,
.ce-footer-context .ce-footer-confirm-row {
    min-width: 0;
}
.ce-footer-context .ce-run-btn {
    min-width: 6.5rem;
}
.ce-footer-context[hidden] {
    display: none !important;
}
.ce-footer-confirm-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.35rem;
}
.ce-footer-confirm-row.is-confirming .fk-confirm-actions {
    display: flex;
}
.ce-footer-confirm-row.is-confirming .ce-footer-confirm-trigger {
    flex: 1 1 auto;
    min-width: 0;
}
.ce-footer-confirm-trigger .ce-run-btn {
    width: 100%;
}


/* restored: inbox-tools */
.ce-footer-inbox-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.ce-footer-inbox-tools[hidden] {
    display: none !important;
}
.ce-footer-download-picker {
    display: flex;
    align-items: center;
    margin: 0;
    overflow: visible;
}
.ce-footer-download-select {
    min-width: 9.5rem;
    max-width: 12rem;
    font-size: 11px;
}

/* Digest footer download menu (nested part picker) */
.ce-download-menu {
    position: relative;
    display: inline-block;
    min-width: 9.5rem;
    max-width: 12rem;
}
.ce-download-menu.is-open {
    z-index: 130;
}
.ce-download-menu-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    width: 100%;
    padding: 0.32rem 0.5rem 0.32rem 0.6rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ce-download-menu-btn:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--input-border));
}
.ce-download-menu.is-open .ce-download-menu-btn {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.ce-download-menu-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ce-download-menu-caret {
    width: 0.85rem;
    height: 0.85rem;
    flex-shrink: 0;
    opacity: 0.55;
}
.ce-download-menu.is-open .ce-download-menu-caret {
    transform: rotate(180deg);
}
.ce-download-menu-panel {
    display: none;
    position: absolute;
    left: 0;
    bottom: calc(100% + 4px);
    min-width: 100%;
    width: max-content;
    max-width: min(16rem, 92vw);
    padding: 0.25rem;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
}
.station-library-page .ce-footer-download-picker {
    display: flex;
    align-items: center;
    overflow: visible;
}
.ce-download-menu.is-open .ce-download-menu-panel {
    display: block;
    z-index: 140;
}
.ce-download-menu-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.38rem 0.55rem;
    border: none;
    border-radius: 0.35rem;
    background: transparent;
    color: var(--text);
    font-size: 0.75rem;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
.ce-download-menu-option:hover {
    background: var(--surface-hover);
}
.ce-download-menu-option--parent {
    cursor: default;
}
.ce-download-menu-option[disabled],
.ce-download-menu-option[aria-disabled="true"] {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}
.ce-download-menu-divider {
    height: 1px;
    margin: 0.2rem 0.35rem;
    background: var(--border);
}
.ce-download-menu-item.has-flyout {
    position: relative;
}
.ce-download-menu-panel > .ce-download-menu-item.has-flyout:hover > .ce-download-menu-flyout--parts,
.ce-download-menu-panel > .ce-download-menu-item.has-flyout:focus-within > .ce-download-menu-flyout--parts {
    display: block;
}
.ce-download-menu-flyout--parts {
    display: none;
    position: absolute;
    left: calc(100% + 2px);
    top: auto;
    bottom: 0;
    min-width: 10rem;
    max-height: min(65vh, 26rem);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.25rem;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
    z-index: 2;
}
.ce-download-menu-flyout--sub {
    display: none;
    position: fixed;
    min-width: 8.5rem;
    padding: 0.25rem;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
    z-index: 140;
}
.ce-download-menu.is-open .ce-download-menu-flyout--parts {
    z-index: 130;
}
.ce-download-menu-chevron {
    width: 0.75rem;
    height: 0.75rem;
    flex-shrink: 0;
    opacity: 0.45;
}
.ce-download-menu-empty {
    margin: 0.25rem 0.55rem;
    font-size: 0.7rem;
    color: color-mix(in srgb, var(--text) 40%, transparent);
}
.ce-download-menu.is-disabled .ce-download-menu-btn,
.ce-download-menu-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.ce-test-email-picker {
    display: flex;
    align-items: center;
    margin: 0;
    overflow: visible;
}
.ce-test-email-type {
    min-width: 9.5rem;
    max-width: 12rem;
    font-size: 11px;
    padding: 0.28rem 0.45rem;
    height: auto;
    line-height: 1.3;
}

.ce-run-btn {
    position: relative;
    overflow: hidden;
    min-width: 7.5rem;
}
.ce-run-btn:disabled { cursor: default; opacity: 1; }
.ce-run-btn.is-running .ce-run-btn-label { color: var(--accent); }
.ce-run-btn-label {
    position: relative;
    z-index: 1;
}
.ce-run-btn-progress {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: color-mix(in srgb, var(--accent) 24%, transparent);
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 0.12s ease-out;
    pointer-events: none;
}
.ce-run-btn.is-running .ce-run-btn-progress {
    transition: transform 0.18s ease-out;
}
.ce-runbar-status {
    margin: 0;
    font-size: 0.68rem;
    line-height: 1.35;
    color: var(--text-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Busy overlay subline (planner uses overlay label + bar only) */
.ce-busy-sub {
    margin: 0.65rem 0 0;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--text-muted);
}
.ce-workspace.is-busy .ce-col-head,
.ce-workspace.is-busy .ce-col-body,
.ce-workspace.is-busy .ce-col-resizer,
.ce-workspace.is-busy .ce-runbar {
    pointer-events: none;
}

@media (max-width: 1100px) {
    .ce-columns {
        flex-direction: column;
        overflow-y: auto;
    }
    .ce-col {
        flex: none;
        width: 100%;
        max-width: none;
        min-height: 240px;
    }
    .ce-col-resizer { display: none; }
}

/* ============================================================
   Settings page — flat compact sections (mirrors the Community
   Events column style: slim bordered headers + tight rows, no
   floating cards).
   ============================================================ */
.settings-workspace.page-stack {
    height: 100%;
}
.settings-workspace .page-stack-main {
    position: relative;
    min-height: 0;
}
.settings-stack-scroll {
    overflow: hidden;
}
.settings-page {
    position: absolute;
    inset: 0;
    min-height: 0;
    max-width: none;
}
.settings-shell {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    min-height: 0;
}
.settings-rail {
    width: 260px;
}
.settings-rail .rules-root {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.settings-rail .rules-tree-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}
.settings-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
}
.settings-panel {
    display: none;
    position: absolute;
    inset: 0;
    overflow: auto;
    padding: 0.75rem 1rem 1rem;
    box-sizing: border-box;
}
.settings-panel.is-active {
    display: block;
}
.settings-page-head {
    flex-shrink: 0;
    margin-bottom: 1rem;
}
.settings-role-matrix-wrap {
    overflow-x: auto;
}
.settings-role-matrix .settings-role-label {
    background: var(--surface);
    border-color: var(--border);
}
.settings-role-matrix th,
.settings-role-matrix td {
    font-size: 12px;
    padding: 0.45rem 0.5rem;
}
.settings-role-matrix input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}
.settings-role-matrix input[type="checkbox"]:disabled {
    cursor: default;
    opacity: 0.7;
}
.settings-section {
    margin-bottom: 1.75rem;
}
.settings-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0 0 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}
.settings-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    white-space: nowrap;
}
.settings-section-sub {
    font-size: 11px;
    color: var(--text-subtle);
    margin: 2px 0 0;
    line-height: 1.35;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}
.settings-row-label {
    flex: 1 1 46%;
    min-width: 0;
}
.settings-row-label .form-label {
    margin-bottom: 0;
    color: var(--text);
}
.settings-row-hint {
    font-size: 11px;
    color: var(--text-subtle);
    margin: 2px 0 0;
    line-height: 1.35;
}
.settings-row-control {
    flex: 1 1 54%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 0;
}
.settings-row-control .form-input,
.settings-row-control .form-select {
    max-width: 320px;
}
.settings-row-control:empty { display: none; }
.sp-data-source-row { border-bottom: 1px solid var(--border-light); padding-bottom: 0.75rem; margin-bottom: 0.75rem; }
.sp-ds-advanced summary { user-select: none; }
.sp-ds-test-panel {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    font-size: 11px;
}
.sp-ds-test-ok { color: var(--text-muted); margin: 0 0 0.35rem; }
.sp-ds-test-sub { color: var(--text-subtle); margin: 0 0 0.35rem; }
.sp-ds-test-error { color: #f87171; margin: 0; }
.sp-ds-test-fields { display: flex; flex-direction: column; gap: 0.25rem; max-height: 160px; overflow-y: auto; }
.sp-ds-test-field { display: flex; gap: 0.5rem; align-items: baseline; }
.sp-ds-test-field code { flex: 0 0 auto; color: var(--accent); font-size: 10px; }
.sp-ds-test-field span { color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-user-role-select {
    font-size: 12px;
    padding: 4px 8px;
    min-width: 140px;
    max-width: 200px;
}
.digest-forward-health-wrap {
    min-width: 5.5rem;
}
.digest-forward-health {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    white-space: nowrap;
    cursor: help;
}
.digest-forward-health--ok {
    background: rgb(16 185 129 / 0.15);
    color: rgb(52 211 153);
}
.digest-forward-health--pending {
    background: rgb(245 158 11 / 0.15);
    color: rgb(251 191 36);
}
.digest-forward-health--failed {
    background: rgb(239 68 68 / 0.15);
    color: rgb(248 113 113);
}
.digest-forward-health--warning {
    background: rgb(245 158 11 / 0.15);
    color: rgb(251 191 36);
}
.digest-forward-health--unknown {
    background: rgb(100 116 139 / 0.15);
    color: rgb(148 163 184);
}
.settings-table th {
    padding: 0.45rem 0.65rem;
}
.settings-table td {
    padding: 0.45rem 0.65rem;
    font-size: 0.8rem;
}
.settings-row-clickable { cursor: pointer; }
@media (max-width: 640px) {
    .settings-row {
        flex-direction: column;
        align-items: stretch;
    }
    .settings-row-control {
        justify-content: flex-start;
    }
    .settings-row-control .form-input,
    .settings-row-control .form-select {
        max-width: none;
    }
}

/* ============================================================
   FlackSelect — custom dropdown matching form-input styling
   (native select popups clash with the app's dark surfaces)
   ============================================================ */
.fk-select {
    position: relative;
    display: inline-block;
}
.fk-select.is-open {
    z-index: 120;
}
.fk-select-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    width: 100%;
    padding: 0.32rem 0.5rem 0.32rem 0.6rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.fk-select-btn:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--input-border));
}
.fk-select.is-open .fk-select-btn {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.fk-select-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fk-select-caret {
    width: 0.85rem;
    height: 0.85rem;
    flex: 0 0 auto;
    color: var(--text-subtle);
    transition: transform 0.15s ease;
}
.fk-select.is-open .fk-select-caret {
    transform: rotate(180deg);
}
.fk-select.is-drop-up.is-open .fk-select-caret {
    transform: rotate(0deg);
}
.fk-select-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    z-index: 60;
    flex-direction: column;
    padding: 0.25rem;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
}
.fk-select.is-open .fk-select-panel {
    display: flex;
}
.fk-select.is-drop-up .fk-select-panel {
    top: auto;
    bottom: calc(100% + 4px);
}
.fk-select--scroll .fk-select-panel {
    max-height: min(14rem, 38vh);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.fk-select-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.32rem 0.55rem;
    border: none;
    border-radius: 0.35rem;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.fk-select-option:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.fk-select-option.is-selected {
    color: var(--accent);
    font-weight: 600;
}
.fk-select.is-disabled .fk-select-btn,
.fk-select-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.fk-select-option[disabled],
.fk-select-option[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
}
.fk-select-group {
    padding: 0.2rem 0.55rem 0.1rem;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
}
.fk-select--compact .fk-select-btn {
    padding: 0.15rem 0.35rem 0.15rem 0.45rem;
    font-size: 0.65rem;
    border-radius: 0.35rem;
}
.fk-select--compact .fk-select-option {
    padding: 0.2rem 0.45rem;
    font-size: 0.65rem;
}
.fk-native-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ============================================================
   FlackCopyField — icon-only copy control in the field corner
   ============================================================ */
.fk-copy-field {
    position: relative;
    width: 100%;
}
.fk-copy-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    border: none;
    border-radius: 0.3rem;
    background: color-mix(in srgb, var(--surface-raised) 82%, transparent);
    color: var(--text-subtle);
    cursor: pointer;
    transition: color 0.12s ease, background 0.12s ease;
}
.fk-copy-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}
.fk-copy-btn.is-copied {
    color: var(--success, #10b981);
    background: color-mix(in srgb, var(--success, #10b981) 12%, var(--surface-raised));
}
.fk-copy-icon {
    width: 0.85rem;
    height: 0.85rem;
    flex: 0 0 auto;
}
.fk-copy-field textarea.fk-copy-textarea,
.fk-copy-field .fk-copy-textarea {
    padding-right: 2rem;
}
.ce-chunk-text-wrap.fk-copy-field .ce-chunk-text-highlight {
    padding-right: 2rem;
}

/* ============================================================
   Community Events — digest splice mode + time-chunk editor
   ============================================================ */
.ce-splice-controls {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.ce-splice-mode {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}
.ce-splice-mode button {
    padding: 0.3rem 0.65rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-family: inherit;
    cursor: pointer;
}
.ce-splice-mode button + button {
    border-left: 1px solid var(--border);
}
.ce-splice-mode button.is-active {
    background: color-mix(in srgb, var(--rules-accent) 16%, transparent);
    color: var(--rules-accent);
    font-weight: 600;
}
.ce-chunk-summary {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-dim, rgba(255,255,255,0.02));
    font-size: 11px;
    color: var(--text-muted);
}
.ce-chunk-summary .ce-chunk-warn {
    color: rgb(251, 191, 36);
}

/* Chunk editor popup (reuses .rules-popover shell + dragbar) */

/* Chunk editor — inline in weekly digest expand (time-splice mode) */
.ce-chunk-editor-inline {
    position: relative;
    min-width: 0;
}
.ce-chunk-editor-inline .ce-chunk-secs-toolbar {
    padding: 0.35rem 0 0.45rem;
    border-bottom: 1px solid var(--border-light);
}
.ce-chunk-editor-inline .ce-chunk-list {
    padding: 0.35rem 0 0.15rem;
    min-width: 0;
}
.ce-chunk-editor-inline .ce-chunk-editor-foot {
    padding: 0.35rem 0 0;
}
.ce-event-detail-panel.is-chunk-busy,
.ce-chunk-editor-inline.is-chunk-busy {
    pointer-events: none;
}
.ce-chunk-popover .rules-popover-shell {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
}
.ce-chunk-apply-busy-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    border-radius: inherit;
}
.ce-chunk-popover.is-busy .rules-popover-minimize,
.ce-chunk-popover.is-busy .rules-popover-close,
.ce-chunk-popover.is-busy .ce-chunk-secs-toolbar,
.ce-chunk-popover.is-busy .ce-chunk-list,
.ce-chunk-popover.is-busy .ce-chunk-editor-foot {
    pointer-events: none;
    user-select: none;
}
.ce-chunk-popover.is-busy .rules-popover-minimize,
.ce-chunk-popover.is-busy .rules-popover-close {
    opacity: 0.35;
}
.ce-chunk-secs-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    flex-wrap: wrap;
    padding: 0.45rem 0.65rem 0.35rem;
    border-bottom: 1px solid var(--border-light);
    flex: 0 0 auto;
}
.ce-chunk-secs-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
}
.ce-chunk-secs-confirm {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.ce-chunk-editor-foot .btn-success:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    filter: grayscale(0.35);
}
.ce-chunk-popover .rules-popover-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 0;
}
.ce-chunk-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: min(50rem, calc(100vw - 2rem));
}
.ce-chunk-popover .ce-chunk-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.75rem 0.85rem 0.35rem;
}
.ce-chunk-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(11rem, 46%);
    gap: 0.65rem;
    align-items: stretch;
    padding: 0.5rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-dim, rgba(255,255,255,0.02));
}
.ce-chunk-row.is-recorded {
    border-color: color-mix(in srgb, var(--success, #10b981) 40%, var(--border));
}
.ce-chunk-text-col {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}
.ce-chunk-timeline-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}
.ce-chunk-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.ce-chunk-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 0;
}
.ce-chunk-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}
.ce-chunk-dur {
    font-size: 10px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.ce-chunk-speed-select {
    flex-shrink: 0;
}
.ce-chunk-speed-select .fk-select {
    width: auto;
    min-width: 6.75rem;
}
.ce-chunk-speed-select .fk-select-btn {
    font-size: 10px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, monospace;
    padding: 0.18rem 0.45rem 0.18rem 0.5rem;
    white-space: nowrap;
}
.ce-chunk-speed-select .fk-select-label {
    overflow: visible;
    text-overflow: unset;
}
.ce-chunk-speed-select .fk-select-panel {
    max-height: 12rem;
    min-width: 100%;
    width: max-content;
}
.ce-chunk-speed-select .fk-select-option {
    white-space: nowrap;
}
.ce-chunk-speed-select.is-fast .fk-select-btn {
    color: #f59e0b;
    border-color: color-mix(in srgb, #f59e0b 45%, var(--input-border));
}
.ce-chunk-speed-select.is-slow .fk-select-btn {
    color: #60a5fa;
    border-color: color-mix(in srgb, #60a5fa 45%, var(--input-border));
}
.ce-chunk-speed-select.is-pending .fk-select-btn {
    box-shadow: 0 0 0 1px color-mix(in srgb, #f59e0b 35%, transparent);
}
.ce-chunk-text-wrap {
    position: relative;
    width: 100%;
}
.ce-chunk-text-highlight {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    font-size: 12px;
    line-height: 1.45;
    font-family: inherit;
    color: var(--text);
    visibility: hidden;
}
.ce-chunk-text-wrap.is-text-pending .ce-chunk-text-highlight {
    visibility: visible;
}
.ce-chunk-text-highlight mark.ce-chunk-text-pending {
    background: var(--rules-accent-pending-bg);
    color: var(--rules-accent-pending-text);
    border-radius: 2px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}
.ce-chunk-text-wrap.is-text-pending .ce-chunk-text-highlight {
    color: var(--text);
}
.ce-chunk-text-wrap.is-text-pending .ce-chunk-textarea {
    background: transparent;
    color: transparent;
    caret-color: var(--text);
}
.ce-chunk-textarea {
    width: 100%;
    min-height: 2.5rem;
    resize: vertical;
    overflow-y: hidden;
    font-size: 12px;
    line-height: 1.45;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}
/* Planner-style per-chunk timeline (scaled to X-second slot, not 60 min).
   Self-contained: the .planner-* classes only exist inside the planner
   page's inline <style>, so nothing here may depend on them. */
.ce-chunk-timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 3.25rem;
    margin-top: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    overflow: hidden;
    box-sizing: border-box;
}
.ce-chunk-timeline .ce-chunk-busy-overlay {
    border-radius: 6px;
    z-index: 25;
}
.ce-chunk-record-btn {
    position: relative;
    overflow: hidden;
    min-width: 5.5rem;
}
.ce-chunk-render-btn {
    position: relative;
    overflow: hidden;
    min-width: 4.75rem;
}
.ce-chunk-render-btn.is-running .ce-run-btn-label {
    color: #fff;
}
.ce-chunk-render-btn .ce-run-btn-progress {
    background: color-mix(in srgb, var(--accent) 35%, transparent);
}
.ce-chunk-row.is-part-busy .ce-chunk-timeline-col {
    pointer-events: none;
}
.ce-chunk-player-play.is-pending-play {
    color: color-mix(in srgb, #f59e0b 80%, var(--text));
}
.ce-chunk-record-btn:disabled,
.ce-chunk-record-btn.is-locked {
    cursor: default;
    opacity: 0.38;
}
.ce-chunk-record-btn.is-running .ce-run-btn-label {
    color: var(--accent);
}
.ce-chunk-record-btn .ce-run-btn-progress {
    background: color-mix(in srgb, var(--accent) 24%, transparent);
}
.ce-chunk-timeline-program {
    position: relative;
    flex: 1 1 auto;
    min-height: 2.35rem;
    background: color-mix(in srgb, var(--surface-hover) 65%, var(--surface));
}
.ce-chunk-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 14px;
    height: auto;
    margin-left: -7px;
    transform: none;
    background: transparent;
    z-index: 20;
    pointer-events: auto;
    cursor: ew-resize;
}
.ce-chunk-playhead::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    transform: translateX(-50%);
    background: #ef4444;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 8px rgba(239, 68, 68, 0.75);
    pointer-events: none;
}
.ce-chunk-playhead::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 6px rgba(239, 68, 68, 0.65);
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.ce-chunk-playhead.is-hidden {
    display: none;
}
.ce-chunk-timeline.is-scrubbing .ce-chunk-audio-block {
    pointer-events: none;
    opacity: 0.7;
}
.ce-chunk-timeline.is-scrubbing .ce-chunk-strip,
.ce-chunk-timeline.is-scrubbing .ce-chunk-timeline-program {
    cursor: ew-resize;
}
.ce-chunk-timeline.has-playhead:not(.is-scrubbing) .ce-chunk-playhead {
    pointer-events: none;
}
body.ce-chunk-dragging .ce-chunk-audio-block {
    cursor: ew-resize;
}
.ce-chunk-tick-ruler {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(var(--ce-slot, 30), minmax(0, 1fr));
    pointer-events: none;
    z-index: 1;
}
.ce-chunk-tick {
    border-left: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
    min-width: 0;
}
.ce-chunk-tick.is-major {
    border-left-color: color-mix(in srgb, var(--text-subtle) 70%, var(--border));
}
.ce-chunk-tick:first-child { border-left: none; }
.ce-chunk-strip {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    background: transparent;
}
.ce-chunk-audio-block {
    position: absolute;
    top: 3px;
    bottom: 3px;
    border-radius: 4px;
    background: var(--rules-accent);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 0.35rem;
    box-sizing: border-box;
    overflow: hidden;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--rules-accent) 80%, #000);
    z-index: 3;
}
.ce-chunk-audio-block.is-estimate {
    background: color-mix(in srgb, var(--rules-accent) 35%, var(--surface));
    border: 1px dashed color-mix(in srgb, var(--rules-accent) 55%, var(--border));
    box-shadow: none;
    cursor: default;
    opacity: 0.75;
}
.ce-chunk-audio-block.is-busy {
    opacity: 0.55;
    pointer-events: none;
}
.ce-chunk-audio-block.is-pending {
    box-shadow: 0 0 0 1px color-mix(in srgb, #f59e0b 70%, var(--rules-accent)),
        0 0 0 3px color-mix(in srgb, #f59e0b 25%, transparent);
}
.ce-chunk-timeline.is-over-estimate {
    overflow: visible;
    z-index: 4;
}
.ce-chunk-timeline.is-over-estimate .ce-chunk-strip {
    overflow: visible;
}
.ce-chunk-audio-block.is-estimate.is-over {
    background: color-mix(in srgb, #f59e0b 40%, var(--rules-accent));
    box-shadow: 0 0 0 1px color-mix(in srgb, #f59e0b 65%, var(--rules-accent));
}
.ce-chunk-row.is-pending .ce-chunk-dur,
.ce-chunk-row:has(.ce-chunk-audio-block.is-over) .ce-chunk-dur {
    color: color-mix(in srgb, #f59e0b 75%, var(--text-muted));
}
.ce-chunk-block-label {
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    white-space: nowrap;
}
.ce-chunk-audio-block.is-estimate .ce-chunk-block-label {
    color: var(--rules-accent-pending-text);
}
.ce-chunk-audio-block.is-estimate.is-over .ce-chunk-block-label {
    color: color-mix(in srgb, #78350f 75%, var(--text));
}
.ce-chunk-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
    z-index: 4;
}
.ce-chunk-handle.is-w {
    left: 0;
    border-radius: 4px 0 0 4px;
}
.ce-chunk-handle.is-e {
    right: 0;
    border-radius: 0 4px 4px 0;
}
.ce-chunk-handle:hover {
    background: rgba(255, 255, 255, 0.22);
}
.ce-chunk-tick-labels {
    position: relative;
    flex-shrink: 0;
    height: 1.1rem;
    padding: 0 0.35rem;
    border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
    box-sizing: border-box;
}
.ce-chunk-tick-label {
    position: absolute;
    top: 0.1rem;
    transform: translateX(-50%);
    font-size: 0.62rem;
    font-family: ui-monospace, monospace;
    color: var(--text-subtle);
    white-space: nowrap;
    pointer-events: none;
}
.ce-chunk-tick-label.is-edge-start {
    transform: none;
}
.ce-chunk-tick-label.is-edge-end {
    left: auto;
    transform: none;
}
.ce-digest-player {
    border: 1px solid var(--border);
    border-radius: 6px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-hover) 28%, var(--surface));
    margin-top: 0.3rem;
}
.ce-digest-player .ce-chunk-player-volume {
    max-width: 8rem;
}
.ce-music-bed-bed-only .ce-digest-player {
    margin-top: 0.2rem;
}
.ce-digest-segment .ce-digest-player,
.ce-digest-segments .ce-digest-player {
    width: 100%;
}

/* Per-part scrub player (mirrors ce-digest-scrub / full program) */
.ce-chunk-part-scrub .ce-chunk-timeline-program {
    cursor: pointer;
}
.ce-chunk-part-scrub.has-playhead .ce-chunk-playhead {
    z-index: 30;
}
.ce-chunk-part-scrub.is-scrubbing .ce-chunk-audio-block {
    cursor: ew-resize;
}
.ce-chunk-part-scrub .ce-digest-player {
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    margin-top: 0;
}
.ce-chunk-part-scrub .ce-digest-player .ce-chunk-player-volume {
    max-width: 8rem;
}

/* Scrubbing viewport player in the digest panel (reuses chunk timeline) */
.ce-digest-scrub {
    margin-top: 0.4rem;
}
.ce-digest-scrub-title {
    padding: 0.3rem 0.5rem 0.15rem;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-subtle);
}
.ce-digest-scrub .ce-chunk-timeline-program {
    cursor: pointer;
}
.ce-digest-scrub .ce-digest-scrub-block {
    background: color-mix(in srgb, var(--rules-accent) 55%, var(--surface));
    cursor: pointer;
}
.ce-digest-scrub .ce-digest-player {
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    margin-top: 0;
}
.ce-chunk-player {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
    min-height: 2.15rem;
    padding: 0.3rem 0.5rem;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-hover) 35%, var(--surface));
    box-sizing: border-box;
}
.ce-chunk-player.is-empty {
    opacity: 0.5;
}
.ce-chunk-audio-el {
    display: none !important;
}
.ce-chunk-player-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ce-chunk-player-btn:hover:not(:disabled) {
    color: var(--accent);
    background: var(--accent-surface);
}
.ce-chunk-player-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.ce-chunk-player-volume {
    flex: 1 1 auto;
    min-width: 3.5rem;
    max-width: 6.5rem;
    accent-color: var(--accent);
}
.ce-chunk-player-volume:disabled {
    opacity: 0.35;
}
.ce-chunk-player-dl {
    font-size: 10px !important;
    flex-shrink: 0;
    margin-left: auto;
    white-space: nowrap;
}
.ce-chunk-player-dl.is-disabled {
    opacity: 0.35;
    pointer-events: none;
}
body.ce-chunk-dragging {
    user-select: none;
    cursor: ew-resize;
}
body.ce-chunk-dragging .ce-chunk-audio-block {
    cursor: ew-resize;
}
@media (max-width: 720px) {
    .ce-chunk-row {
        grid-template-columns: 1fr;
    }
}
.ce-chunk-row.is-empty .ce-chunk-dur {
    color: var(--text-subtle);
    font-style: italic;
}
.ce-chunk-row.is-empty .ce-chunk-textarea {
    min-height: 2.5rem;
    border-style: dashed;
}
.ce-chunk-boundary-start,
.ce-chunk-boundary-end {
    margin: 0.15rem 0;
}
.ce-chunk-boundary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.05rem 0;
}
.ce-chunk-boundary button {
    padding: 0.1rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-subtle);
    font-size: 10px;
    font-family: inherit;
    cursor: pointer;
    line-height: 1.5;
}
.ce-chunk-boundary button:hover:not(:disabled) {
    border-color: var(--rules-accent);
    color: var(--rules-accent);
}
.ce-chunk-boundary button:disabled {
    opacity: 0.35;
    cursor: default;
}
.ce-chunk-editor-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    flex-wrap: wrap;
    flex-shrink: 0;
    margin-top: 0;
    padding: 0.65rem 0.85rem 0.9rem;
    border-top: 1px solid var(--border);
    background: var(--surface-raised);
}
.ce-chunk-revert-text.is-hidden,
.ce-chunk-undo-layout.is-hidden {
    display: none;
}
.ce-chunk-revert-text:not(:disabled),
.ce-chunk-undo-layout:not(:disabled) {
    color: var(--rules-accent-pending-text);
    border-color: color-mix(in srgb, var(--rules-accent) 45%, var(--input-border));
    background: color-mix(in srgb, var(--rules-accent-pending-bg) 55%, var(--input-bg));
}
.ce-chunk-revert-text:not(:disabled):hover,
.ce-chunk-undo-layout:not(:disabled):hover {
    border-color: var(--rules-accent);
    background: var(--rules-accent-pending-bg);
    color: var(--rules-accent-pending-text);
}
.ce-chunk-undo-structure:not(:disabled) {
    color: var(--rules-accent-pending-text);
    border-color: color-mix(in srgb, var(--rules-accent) 45%, var(--input-border));
    background: color-mix(in srgb, var(--rules-accent-pending-bg) 55%, var(--input-bg));
}
.ce-chunk-undo-structure:not(:disabled):hover {
    border-color: var(--rules-accent);
    background: var(--rules-accent-pending-bg);
    color: var(--rules-accent-pending-text);
}

/* ============================================================
   Dashboard — CE-doctrine workspace: viewport-locked page-stack,
   full-width resizable columns, compact table rows, runbar.
   ============================================================ */
.dash-workspace {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
}
.dash-columns {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    overflow: hidden;
}
.page-stack-main > .dash-columns { height: 100%; }
.dash-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}
.dash-col-onair { flex: 0 0 var(--dash-onair-w, 300px); min-width: 220px; }
.dash-col-prog  { flex: 0 0 var(--dash-prog-w, 330px);  min-width: 250px; }
.dash-col-sales { flex: 1 1 auto; min-width: 260px; }
.dash-col-ce    { flex: 0 0 var(--dash-ce-w, 320px); min-width: 240px; }
.dash-col.dash-col-flex { flex: 1 1 auto; }
.dash-col-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.65rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.dash-col-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text);
    white-space: nowrap;
}
.dash-col-aside {
    font-size: 11px;
    color: var(--text-subtle);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-col-station-select {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 14rem;
    font-size: 11px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-muted);
}
.dash-col-link {
    margin-left: auto;
    font-size: 12px;
    color: var(--accent);
    white-space: nowrap;
}
.dash-col-link:hover { text-decoration: underline; }
.dash-col-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.35rem 0.65rem 0.6rem;
}
.dash-col-resizer {
    flex: 0 0 1px;
    cursor: col-resize;
    background: var(--border);
    position: relative;
    touch-action: none;
}
.dash-col-resizer::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -3px;
    right: -3px;
}
.dash-col-resizer:hover,
.dash-col-resizer.is-dragging { background: var(--accent); }
body.dash-col-resizing {
    cursor: col-resize;
    user-select: none;
}
.dash-table {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
    font-size: 12px;
    line-height: 1.25;
}
.dash-tr { border-bottom: 1px solid var(--border-light); }
.dash-tr[data-nav] { cursor: pointer; }
.dash-tr[data-nav]:hover { background: var(--surface-hover); }
.dash-tr.is-selected { box-shadow: inset 0 0 0 2px var(--accent); }
.dash-tr td {
    padding: 6px 8px 6px 0;
    vertical-align: top;
    color: var(--text);
}
.dash-td-main {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-ai-refresh {
    font-size: 10px;
    color: var(--text-subtle);
    white-space: nowrap;
}
.dash-td-side {
    text-align: right;
    color: var(--text-muted);
    white-space: nowrap;
    width: 45%;
}
.dash-empty {
    padding: 8px 2px;
    font-size: 12px;
    color: var(--text-subtle);
}
.dash-runbar {
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}
.dash-runbar.page-action-footer {
    padding: 0.6rem 0.85rem;
    overflow: visible;
}
.dash-runbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}
.dash-footer-context {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}
.dash-footer-context[hidden] { display: none !important; }
.dash-runbar-status {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-subtle);
    white-space: nowrap;
}
@media (max-width: 1100px) {
    .dash-columns {
        flex-direction: column;
        overflow-y: auto;
    }
    .dash-col,
    .dash-col-onair,
    .dash-col-prog,
    .dash-col-sales,
    .dash-col-ce {
        flex: 0 0 auto;
        min-height: 0;
    }
    .dash-col-body {
        overflow-y: visible;
        max-height: none;
    }
    .dash-col-resizer { display: none; }
}
.dash-subhead {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 0.8rem;
    padding-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-subtle);
    border-bottom: 1px solid var(--border-light);
}
.dash-subhead:first-child { margin-top: 0.15rem; }
.dash-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: var(--text-subtle);
}
.dash-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 9999px;
    margin-right: 4px;
    vertical-align: baseline;
}
.dash-dot.is-ok { background: #34d399; }
.dash-dot.is-bad { background: #f87171; }
.dash-chip {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}
.dash-chip.is-ok   { background: color-mix(in srgb, #10b981 14%, transparent); color: #34d399; }
.dash-chip.is-warn { background: color-mix(in srgb, #f59e0b 14%, transparent); color: #fbbf24; }
.dash-chip.is-bad  { background: color-mix(in srgb, #ef4444 14%, transparent); color: #f87171; }
.dash-stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.6rem;
    padding: 8px 2px 4px;
}
.dash-stat {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.dash-stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.dash-stat-label {
    font-size: 11px;
    color: var(--text-subtle);
    white-space: nowrap;
}

/* ============================================================
   Footer-context right-click fly-out (ported from ~/ui, Phase 5b)
   ============================================================ */
.ui-footer-context-menu {
    position: fixed;
    z-index: 260;
    min-width: 9.5rem;
    max-width: 16rem;
    padding: 0.25rem 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--card-shadow, 0 8px 24px rgba(0, 0, 0, 0.35));
}
.ui-footer-context-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
}
.ui-footer-context-item:hover,
.ui-footer-context-item:focus-visible {
    background: var(--surface-hover);
    outline: none;
}
.ui-footer-context-item.is-danger {
    color: #f87171;
}
.ui-footer-context-item.is-create {
    color: var(--accent);
}

/* ============================================================
   Client detail — de-carded flat sections (Phase 5c)
   ============================================================ */
.client-detail-section > h3:first-child,
.client-detail-section > .flex:first-child {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
