/*
  MasterChannel base styles.
  Plain CSS, served directly from /public — edit this file and refresh.
  No build step required.
*/

:root {
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-border: #e2e4e9;
    --color-text: #1c1e21;
    --color-text-muted: #6b7280;
    --color-primary: #4338ca;
    --color-primary-hover: #362da3;
    --color-danger: #b42318;
    --color-danger-bg: #fef3f2;
    --color-success: #067647;
    --color-success-bg: #ecfdf3;
    --color-warning: #b54708;
    --color-warning-bg: #fffaeb;
    --color-sidebar-bg: #171923;
    --color-sidebar-text: #cbd2e0;
    --color-sidebar-text-active: #ffffff;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* {
    box-sizing: border-box;
}

/* The browser's default [hidden] rule and any of our own class selectors
   that set `display` are equal specificity, so an author rule (ours) always
   wins over the user-agent default regardless of source order - meaning
   `el.hidden = true` silently does nothing on any element whose class also
   sets `display` (.field, .btn, .tabs-panel, .preview-thumb-empty, ...).
   Hit this three times across unrelated elements before making it a rule
   instead of a per-class patch - !important is deliberate here, this must
   always win. */
[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    font-size: 15px;
    line-height: 1.5;
}

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

/* ---------- Guest / login layout ---------- */

.guest-body {
    background: var(--color-bg);
}

.guest-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 360px;
}

.login-brand {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--color-text-muted);
    margin: 0 0 24px;
    font-size: 14px;
}

.login-footer-link {
    margin: 20px 0 0;
    font-size: 13px;
    color: var(--color-text-muted);
    text-align: center;
}

.login-footer-link a {
    color: var(--color-primary);
    font-weight: 600;
}

/* ---------- Embeddable player (public, standalone page) ---------- */

.embed-body {
    margin: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: #000;
    display: flex;
}

.embed-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.embed-status {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #9aa0ac;
    font-size: 14px;
}

/* ---------- Shared components ---------- */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 28px;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.input {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
}

.input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.15);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--color-text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-block {
    width: 100%;
}

.btn-ghost {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.btn-ghost:hover {
    color: var(--color-text);
    border-color: #c8cbd3;
}

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid #fda29b;
}

/* ---------- Admin shell ---------- */

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.admin-brand {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
    padding: 0 8px;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-nav-link {
    padding: 9px 10px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--color-sidebar-text);
}

.admin-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.admin-nav-link.is-active {
    background: var(--color-primary);
    color: var(--color-sidebar-text-active);
}

.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-topbar {
    height: 60px;
    flex-shrink: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.admin-topbar-title {
    font-size: 15px;
    font-weight: 600;
}

.admin-topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--color-text-muted);
}

.admin-content {
    padding: 28px;
    flex: 1;
}

/* Narrow screens: the sidebar becomes a horizontally scrolling nav strip
   above the content instead of eating a fixed 220px column. */
@media (max-width: 760px) {
    .admin-shell { flex-direction: column; }
    .admin-sidebar { width: auto; padding: 12px 16px; gap: 10px; }
    .admin-nav { flex-direction: row; overflow-x: auto; gap: 4px; }
    .admin-nav-link { white-space: nowrap; }
    .admin-topbar { padding: 0 16px; }
    .admin-content { padding: 16px; }
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 6px;
}

.page-subtitle {
    color: var(--color-text-muted);
    margin: 0 0 20px;
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid #abefc6;
}

.alert-warning {
    background: #fffaeb;
    color: #93370d;
    border: 1px solid #fedf89;
}

.alert-list {
    margin: 0;
    padding-left: 18px;
}

/* ---------- Page header ---------- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.page-header .page-title,
.page-header .preview-heading {
    margin: 0;
}

/* ---------- Upload ---------- */

.upload-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.upload-progress-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--color-border);
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--color-primary);
    transition: width 0.2s ease;
}

.upload-progress-label {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ---------- Data table ---------- */

.table-toolbar {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.table-search {
    flex: 1;
    min-width: 220px;
}

.table-filter {
    width: auto;
    min-width: 180px;
}

.table-filter-date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.table-filter-date .input {
    width: auto;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.data-table thead th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
    position: relative;
}

.data-table thead th:hover {
    color: var(--color-text);
}

.data-table thead th.is-sorted {
    color: var(--color-text);
}

.data-table thead th.is-sorted::after {
    content: "";
    display: inline-block;
    margin-left: 5px;
    border: 4px solid transparent;
    border-bottom-color: var(--color-text-muted);
    transform: translateY(-2px);
}

.data-table thead th.is-sorted[data-dir="desc"]::after {
    border-bottom-color: transparent;
    border-top-color: var(--color-text-muted);
    transform: translateY(2px);
}

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

.col-numeric {
    text-align: right;
}

.col-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: var(--color-text-muted);
}

.col-thumb {
    width: 56px;
}

.table-thumb {
    display: block;
    width: 56px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
}

.table-thumb-empty {
    width: 56px;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    border: 1px dashed var(--color-border);
    background: var(--color-bg);
}

.table-static thead th {
    cursor: default;
}

.output-notes {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-muted);
}

/* ---------- Upload: frame picker ---------- */

.frame-picker-preview {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.frame-picker-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.frame-scrubber {
    width: 100%;
    margin-top: 8px;
    accent-color: var(--color-primary);
}

.frame-picker-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.art-source {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.art-source-row .input {
    flex: 1;
}

.art-source-or {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ---------- Modal (native <dialog>) ---------- */

dialog.modal {
    width: min(1100px, 92vw);
    max-height: 85vh;
    margin: auto;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

dialog.modal::backdrop {
    background: rgba(16, 24, 40, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header .preview-heading {
    margin: 0;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(85vh - 73px);
}

/* ---------- Rendition ladder badges + asset picker ---------- */

.ladder-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    color: #fff;
    white-space: nowrap;
    /* background-color is set per-badge by ladder-badges.js; this is just
       a visible fallback before that runs */
    background: var(--color-text-muted);
}

.picker-row-incompatible {
    opacity: 0.5;
}

/* ---------- Channel schedule timeline (read-only) ---------- */

.schedule-timeline {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.schedule-timeline-track {
    position: relative;
    height: 52px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.schedule-timeline-ruler {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--color-text-muted);
}

.schedule-block {
    position: absolute;
    top: 6px;
    bottom: 6px;
    min-width: 2px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.schedule-block-program {
    background: var(--color-primary);
}

.schedule-block-ad {
    background: var(--color-warning);
}

.schedule-block-label {
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.schedule-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.schedule-list-row {
    display: flex;
    gap: 10px;
    align-items: baseline;
}

.schedule-list-time {
    color: var(--color-text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    white-space: nowrap;
}

.col-actions {
    text-align: right;
}

.table-empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 32px 16px;
    white-space: normal;
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.table-summary {
    font-size: 13px;
    color: var(--color-text-muted);
}

.table-pagination {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-pagination-label {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    background: var(--color-border);
    color: var(--color-text-muted);
}

.badge-status-ready,
.badge-status-running {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-status-processing {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-status-pending {
    background: var(--color-border);
    color: var(--color-text-muted);
}

.badge-status-failed,
.badge-status-suspended {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

/* ---------- Forms (extended) ---------- */

.form-card {
    max-width: 480px;
}

/* ---------- Billing ---------- */

.billing-summary-card {
    display: flex;
    align-items: center;
    gap: 32px;
    margin-bottom: 20px;
}

.billing-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.billing-stat-divider {
    align-self: stretch;
    width: 1px;
    background: var(--color-border);
}

.billing-balance {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

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

.billing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
    align-items: start;
}

.billing-grid .card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ---------- Stat cards (dashboard / metrics) ---------- */

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

@media (max-width: 560px) {
    .billing-summary-card {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .billing-stat-divider {
        width: 100%;
        height: 1px;
    }
}

.billing-card-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.billing-plan-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.billing-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

/* ---------- Edit asset: form + preview ---------- */

.edit-layout {
    display: grid;
    grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

@media (max-width: 860px) {
    .edit-layout {
        grid-template-columns: 1fr;
    }
}

.preview-card {
    max-width: 480px;
}

.preview-heading {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 14px;
}

.preview-player {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.preview-player video {
    width: 100%;
    height: 100%;
    display: block;
}

.preview-player-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #9aa0ac;
    font-size: 13px;
    padding: 16px;
}

.encode-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
    padding: 24px 16px;
}

.encode-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: encode-spin 0.8s linear infinite;
}

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

.encode-progress-times {
    display: flex;
    gap: 16px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.preview-status {
    font-size: 12px;
    color: var(--color-danger);
    margin: 8px 0 0;
    min-height: 1em;
}

.preview-media {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
}

.preview-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
}

.preview-thumb-empty {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: 1px dashed var(--color-border);
    color: var(--color-text-muted);
    font-size: 12px;
    text-align: center;
    padding: 8px;
}

.preview-thumb-resolution {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ---------- Tabs ---------- */

.tabs {
    margin-top: 24px;
}

.tabs-nav {
    display: flex;
    gap: 20px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 20px;
}

.tabs-tab {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 10px 2px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
}

.tabs-tab:hover {
    color: var(--color-text);
}

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

.tabs-tab-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    /*color: green;
    background: rgb(81 243 19 / 28%);*/
    /*color: var(--color-primary);*/
    background: rgba(67, 56, 202, 1);
    border-radius: 999px;
    padding: 2px 7px;
    color: #FFFFFF;
}

.tabs-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field-row {
    display: flex;
    gap: 16px;
}

.field-row .field {
    flex: 1;
}

.field-static {
    padding: 9px 0;
    font-size: 14px;
    color: var(--color-text-muted);
}

.url-copy {
    display: flex;
    gap: 8px;
}

.url-copy .input {
    flex: 1;
}

.input-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: var(--color-text-muted);
}

.status-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.field-hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--color-text-muted);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-icon:hover {
    color: var(--color-text);
    border-color: #c8cbd3;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}

.delete-form {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-danger:hover {
    background: #96190f;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

.list-add-form {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.list-add-form .input {
    flex: 1;
}

.move-buttons {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

/* Platform Economics: negative money (loss-making margin, price below cost) */
.text-negative {
    color: var(--color-danger);
}

/* ---------- Asset art & ad breaks page (admin/assets/{asset}/media) ---------- */

.media-page {
    --media-soft: #eef0ff;
    --media-soft-border: #c7c9f7;
    --media-ink: #1c1e21;
    --media-player-bg: #11121a;
    max-width: 1512px;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

.media-crumb {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}

.media-crumb a:hover {
    color: var(--color-primary);
}

.media-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.media-heading .page-title {
    font-size: 24px;
    letter-spacing: -0.02em;
    margin-bottom: 2px;
}

.media-heading .page-subtitle {
    margin: 0;
}

.media-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.media-draft-status {
    font-size: 12px;
    color: var(--color-text-muted);
}

.media-draft-status.is-dirty {
    color: var(--color-warning);
    font-weight: 600;
}

.media-tabs {
    margin: 18px 0 20px;
}

.media-chip {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: var(--media-soft);
    color: var(--color-primary);
    border-radius: 5px;
    padding: 3px 7px;
}

.media-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 344px;
    gap: 20px;
    align-items: start;
}

.media-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.media-main > [data-tab-panel] {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.media-aside {
    min-width: 0;
}

/* player + transport */

.media-player {
    background: var(--media-player-bg);
    color: #fff;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}

.media-player-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    font-size: 12px;
    background: #1a1b25;
}

.media-player-top .media-chip {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.media-video {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #0f1117;
    overflow: hidden;
}

.media-video video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
}

.media-video-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9aa0ac;
    font-size: 13px;
}

.media-video-time {
    position: absolute;
    left: 16px;
    bottom: 14px;
    background: rgba(13, 14, 25, 0.84);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 14px;
    pointer-events: none;
}

.media-slate {
    position: absolute;
    inset: 0;
    background: #171526;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.media-slate h2 {
    font-size: 28px;
    margin: 12px 0 8px;
}

.media-slate p {
    margin: 0;
    color: #c8c3e2;
    max-width: 420px;
}

.media-transport {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: 0;
    border-radius: 0 0 12px 12px;
}

.media-transport-left {
    display: flex;
    gap: 5px;
    align-items: center;
}

.media-play {
    min-width: 64px;
}

.media-jump {
    width: 132px;
    text-align: center;
}

.media-player-wrap .preview-status:empty {
    display: none;
}

/* cards */

.media-card {
    padding: 14px;
}

.media-card-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.media-card-title h2 {
    font-size: 14px;
    margin: 0;
}

.media-card-title p {
    font-size: 12px;
    margin: 2px 0 0;
    color: var(--color-text-muted);
}

.media-card .frame-picker-preview img {
    max-width: 100%;
}

.media-live-import {
    margin: 0 0 12px;
}

/* inspector (right column) */

.media-inspector {
    padding: 17px;
}

.media-inspector-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.media-inspector-top h2 {
    font-size: 17px;
    margin: 0;
}

.media-inspector .field-label {
    display: block;
    margin: 14px 0 6px;
}

.media-inspector .preview-media {
    margin-top: 0;
}

.media-inspector .art-source {
    margin-bottom: 14px;
}

.abe-empty h2 {
    font-size: 16px;
    margin: 0 0 6px;
}

.abe-segmented {
    display: flex;
    gap: 4px;
    background: var(--color-bg);
    padding: 4px;
    border-radius: 9px;
}

.abe-segmented button {
    flex: 1;
    min-height: 33px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    background: none;
    border: 0;
    border-radius: 6px;
    padding: 6px;
    color: var(--color-text-muted);
    cursor: pointer;
}

.abe-segmented button.active {
    background: var(--color-surface);
    color: var(--color-primary);
    box-shadow: 0 1px 3px rgba(37, 32, 59, 0.12);
}

.abe-timefield {
    display: flex;
    align-items: center;
    gap: 5px;
}

.abe-timefield .input {
    flex: 1;
    min-width: 0;
    font-size: 17px;
    padding: 9px 10px;
}

.abe-timefield .btn {
    width: 40px;
    padding-left: 0;
    padding-right: 0;
    justify-content: center;
}

.abe-read-only {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.abe-helper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.abe-duration-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.abe-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.abe-notice {
    margin: 14px 0 0;
    border: 1px solid #efdcad;
    background: var(--color-warning-bg);
    border-radius: var(--radius);
    padding: 11px;
    font-size: 12px;
    color: #74490e;
}

.abe-notice strong {
    display: block;
    margin-bottom: 4px;
}

.abe-notice.is-aligned {
    border-color: #cce9df;
    background: var(--color-success-bg);
    color: var(--color-success);
}

.abe-pair {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}

.abe-notice-actions {
    display: flex;
    gap: 6px;
    margin-top: 9px;
}

.abe-problem {
    margin-top: 12px;
    border: 1px solid #f5c2bd;
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-radius: var(--radius);
    padding: 9px 11px;
    font-size: 12px;
}

.abe-safe {
    border: 1px solid #cce9df;
    background: var(--color-success-bg);
    color: var(--color-success);
    border-radius: var(--radius);
    padding: 9px 11px;
    font-size: 12px;
    margin-top: 12px;
}

.abe-safe.is-replace {
    border-color: #efdcad;
    background: var(--color-warning-bg);
    color: #74490e;
}

.abe-preview-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 14px 0;
}

.abe-mini-frame {
    aspect-ratio: 16 / 9;
    background: #171821;
    border-radius: 6px;
    overflow: hidden;
}

.abe-mini-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.abe-mini strong {
    display: block;
    font-size: 11px;
    margin: 5px 0 2px;
}

.abe-mini span {
    font-size: 11px;
    color: var(--color-text-muted);
}

.abe-center {
    text-align: center;
    margin: 6px 0 0;
}

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

.abe-details summary {
    cursor: pointer;
    padding: 6px 0;
}

.abe-remove {
    margin-top: 8px;
    color: var(--color-danger);
    background: none;
    border: 0;
}

.abe-remove:hover {
    background: var(--color-danger-bg);
}

/* whole-video overview */

.abe-filmstrip {
    display: flex;
    height: 50px;
    overflow: hidden;
    border-radius: 6px;
    background: #171821;
}

.abe-frame {
    flex: 1;
    min-width: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.abe-frame:last-child {
    border-right: 0;
}

.abe-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.abe-rail {
    height: 27px;
    position: relative;
    margin-top: 5px;
    background: var(--color-bg);
    border-radius: 5px;
}

.abe-overview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 27px;
    margin: 0;
    accent-color: var(--color-primary);
    opacity: 0.85;
    cursor: crosshair;
}

.abe-pin {
    position: absolute;
    top: -6px;
    transform: translateX(-50%);
    z-index: 2;
    width: 25px;
    height: 25px;
    padding: 0;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    border: 1px solid var(--media-soft-border);
    background: var(--color-surface);
    color: var(--color-primary);
    cursor: pointer;
}

.abe-pin.is-active,
.abe-pin:hover {
    background: var(--color-primary);
    color: #fff;
}

.abe-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 7px;
}

/* fine-tune track */

.abe-zoom {
    display: flex;
    gap: 5px;
}

.abe-zoom .btn.active {
    background: var(--media-soft);
    color: var(--color-primary);
    border-color: var(--media-soft-border);
}

.abe-detail {
    height: 91px;
    background: #fbfbfe;
    border: 1px solid var(--color-border);
    border-radius: 7px;
    position: relative;
    overflow: hidden;
}

.abe-second-ticks {
    position: absolute;
    inset: 0;
}

.abe-second-ticks span {
    position: absolute;
    top: 0;
    height: 15px;
    border-left: 1px solid #b2b5c7;
}

.abe-second-ticks b {
    position: absolute;
    top: 18px;
    left: -12px;
    font: 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 400;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.abe-second-ticks b.abe-first {
    left: 3px;
}

.abe-second-ticks b.abe-last {
    left: auto;
    right: 3px;
}

.abe-boundary {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 1px dashed #c6c7d4;
}

.abe-interval {
    position: absolute;
    top: 34px;
    bottom: 0;
    background: rgba(67, 56, 202, 0.1);
    border-top: 2px solid rgba(67, 56, 202, 0.35);
}

.abe-interval.is-active {
    background: rgba(67, 56, 202, 0.18);
    border-top-color: var(--color-primary);
}

.abe-cursor {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 2px solid var(--media-ink);
    z-index: 2;
    pointer-events: none;
}

.abe-cursor::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 7px solid var(--media-ink);
}

.abe-break {
    position: absolute;
    bottom: 12px;
    z-index: 5;
    transform: translateX(-50%);
    height: 26px;
    padding: 4px 8px;
    border: 0;
    border-radius: 5px;
    background: #8f86e3;
    color: #fff;
    font: inherit;
    font-size: 11px;
    white-space: nowrap;
    cursor: pointer;
}

.abe-break.is-active {
    background: var(--color-primary);
}

/* a break shared by on-demand and live */
.abe-break.is-both {
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px #8f86e3;
}

.abe-target-chip.is-both {
    background: var(--color-primary);
    color: #fff;
}

.abe-detail-seek {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: crosshair;
    z-index: 4;
}

.abe-detail-seek:focus-visible {
    opacity: 0.3;
}

.abe-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 9px;
    font-size: 11px;
    color: var(--color-text-muted);
}

.abe-legend b {
    color: var(--color-primary);
}

/* break plan */

.abe-plan {
    margin-top: 18px;
}

.abe-plan-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.abe-plan-head h2 {
    font-size: 16px;
    margin: 0;
}

.abe-plan-table tbody tr {
    cursor: pointer;
}

.abe-plan-table tbody tr.is-selected {
    background: #f5f2ff;
}

.abe-status {
    display: inline-block;
    font-size: 11px;
    color: var(--color-warning);
    background: var(--color-warning-bg);
    padding: 3px 7px;
    border-radius: 5px;
}

.abe-status.is-ok {
    color: var(--color-success);
    background: var(--color-success-bg);
}

.abe-status.is-error {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

.abe-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    font-size: 11px;
    color: var(--color-text-muted);
}

dialog.abe-review {
    width: min(560px, 92vw);
}

dialog.abe-target-dialog {
    width: min(460px, 92vw);
}

.abe-target-choices {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.abe-target-choices .btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    height: auto;
    padding: 10px 14px;
    text-align: left;
}

.abe-target-choices .btn span {
    font-size: 12px;
    font-weight: 400;
    color: var(--color-text-muted);
}

.abe-about {
    margin-top: 16px;
}

.abe-plan-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--color-border);
    padding: 10px 0;
    font-size: 13px;
}

.abe-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: #202130;
    color: #fff;
    padding: 12px 19px;
    border-radius: 9px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 99;
    max-width: 90%;
    font-size: 13px;
}

/* off-screen copy of the stream used only to grab filmstrip/preview frames */
.abe-capture-video {
    position: fixed;
    left: -10000px;
    top: 0;
    width: 320px;
    height: 180px;
    pointer-events: none;
}

.media-page-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.media-page-link .field-label,
.media-page-link .field-hint {
    display: block;
}

@media (max-width: 1100px) {
    .media-workspace {
        grid-template-columns: minmax(0, 1fr) 304px;
        gap: 14px;
    }

    .media-inspector {
        padding: 14px;
    }
}

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

    .media-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .media-actions {
        flex-wrap: wrap;
    }

    .abe-plan-table {
        min-width: 650px;
    }

    .abe-bottom {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 450px) {
    .media-jump {
        width: 100%;
    }

    .abe-zoom .btn {
        padding-left: 6px;
        padding-right: 6px;
    }
}

/* ---------- Platform economics: "how it's calculated" panel ---------- */

.econ-explainer {
    margin-bottom: 20px;
}

.econ-explainer summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px 16px;
    cursor: pointer;
    list-style: none;
}

.econ-explainer summary::-webkit-details-marker {
    display: none;
}

.econ-explainer summary .preview-heading {
    margin: 0;
}

.econ-explainer summary .preview-heading::before {
    content: "▸ ";
    color: var(--color-text-muted);
}

.econ-explainer[open] summary .preview-heading::before {
    content: "▾ ";
}

.econ-explainer-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 8px 28px;
    margin-top: 14px;
    font-size: 13px;
}

.econ-explainer-body h3 {
    font-size: 13px;
    margin: 0 0 6px;
}

.econ-explainer-body ul {
    margin: 0;
    padding-left: 18px;
    color: var(--color-text-muted);
}

.econ-explainer-body li {
    margin-bottom: 6px;
}

.econ-explainer-body strong {
    color: var(--color-text);
}

.econ-reconcile td {
    color: var(--color-text-muted);
    font-size: 13px;
}

/* ---------- Tenant onboarding (onboarding/show) ---------- */

.onboarding-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
}

.onboarding-step {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* the step is a column flexbox, so a button placed directly in it (e.g.
   "Pay now") would stretch full width - size it to its label instead */
.onboarding-step > .btn {
    align-self: flex-start;
}

.onboarding-step.is-done {
    border-color: #abefc6;
}

.onboarding-step-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.onboarding-step-head .preview-heading {
    flex: 1;
    margin: 0;
}

.onboarding-step-num {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-weight: 600;
}

.onboarding-step.is-done .onboarding-step-num {
    background: var(--color-success-bg);
    color: var(--color-success);
}

dialog.modal.onboarding-pay-modal {
    width: min(520px, 92vw);
}

.onboarding-pay-table {
    margin: 12px 0;
}

.onboarding-pay-total td {
    font-weight: 700;
}

.onboarding-extra-input {
    width: 120px;
    text-align: right;
}

/* ---------- Organization page (admin/tenants/show) ---------- */

.tenant-links {
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: flex-end;
    margin-top: 10px;
}

.tenant-links .field {
    min-width: 200px;
}

.tenant-page > .card,
.tenant-page > .field-row {
    margin-bottom: 20px;
}

.tenant-panels {
    align-items: flex-start;
}

@media (max-width: 760px) {
    .tenant-panels {
        flex-direction: column;
        align-items: stretch;
    }
}

/* affiliate referral QR - always dark-on-white so it scans, even in dark mode */
.affiliate-qr {
    width: 200px;
    max-width: 100%;
    padding: 8px;
    background: #ffffff;
    border-radius: 8px;
    line-height: 0;
}

.affiliate-qr svg {
    width: 100%;
    height: auto;
}

/* Pro upsell card on Pro-only feature pages (components/pro-upgrade) */
.pro-upgrade {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.pro-upgrade-body {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.pro-upgrade-body .field-hint {
    margin: 0;
}

/* billing setup (components/billing-setup): add a card, buy credits */
.billing-setup {
    border: 2px solid var(--color-primary, #4f46e5);
}

.billing-setup-title {
    margin: 0 0 4px;
    font-size: 1.25rem;
}

.billing-setup-steps {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.billing-setup-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    border-radius: 8px;
    opacity: 0.75;
}

.billing-setup-step.is-current {
    opacity: 1;
    background: rgba(79, 70, 229, 0.08);
}

.billing-setup-step.is-done {
    opacity: 0.6;
}

.billing-setup-num {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    background: var(--color-primary, #4f46e5);
    color: #ffffff;
}

.billing-setup-step.is-done .billing-setup-num {
    background: #16a34a;
}

.billing-setup-step-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.billing-setup-step-body .field-hint {
    margin: 0;
}

.billing-setup-amounts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.billing-setup-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
