/* Design Tokens based on shadcn/ui defaults */
:root {
    /* Colors */
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;

    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;

    --popover: 0 0% 100%;
    --popover-foreground: 222.2 84% 4.9%;

    --primary: 222.2 47.4% 11.2%;
    --primary-foreground: 210 40% 98%;

    --secondary: 210 40% 96.1%;
    --secondary-foreground: 222.2 47.4% 11.2%;

    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;

    --accent: 210 40% 96.1%;
    --accent-foreground: 222.2 47.4% 11.2%;

    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;

    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 222.2 84% 4.9%;

    --radius: 0.5rem;

    /* Typography */
    --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

[x-cloak] {
    display: none !important;
}

* {
    box-sizing: border-box;
    border-color: hsl(var(--border));
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    line-height: 1.5;
    color: hsl(var(--foreground));
    background-color: hsl(var(--background));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.lucide {
    display: inline-block;
    vertical-align: middle;
}

/* Manager Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    border-right: 1px solid hsl(var(--border));
    background-color: #f9fafb;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: width 0.2s ease, padding 0.2s ease;
}

.sidebar h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar a {
    text-decoration: none;
    color: hsl(var(--foreground));
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: background-color 0.2s, color 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
}

.sidebar a:hover {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.header {
    height: 60px;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    padding: 0 2rem;
    background-color: hsl(var(--card));
}

.content-area {
    padding: 2rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
}

/* Base Elements */
h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

p {
    margin-top: 0;
    margin-bottom: 1rem;
    color: hsl(var(--muted-foreground));
}

a {
    color: hsl(var(--primary));
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Cards */
.card {
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card--mt {
    margin-top: 0;
}

.card__title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 1.25rem 0;
    color: hsl(var(--foreground));
}

.card__subtitle {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    color: hsl(var(--foreground));
}

.card__text {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin: 0.25rem 0;
}

/* Key-Value definition list */
.kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1.25rem;
    margin: 0 0 1rem 0;
    padding: 0;
    font-size: 0.875rem;
}

.kv dt {
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
}

.kv dd {
    margin: 0;
    color: hsl(var(--foreground));
    word-break: break-all;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

/* Nav link */
.nav__link {
    display: inline-flex;
    align-items: center;
    font-size: 0.875rem;
    color: hsl(var(--primary));
    text-decoration: none;
    margin-top: 0.75rem;
}

.nav__link:hover {
    text-decoration: underline;
}

.layout-delta {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    box-shadow: none;
}

.layout-delta__title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 0.45rem 0;
}

.layout-delta__list {
    margin: 0 0 0.45rem 1.1rem;
    padding: 0;
    font-size: 0.85rem;
}

.layout-delta__description {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.45;
}

.layout-delta--notice {
    border-color: hsl(var(--border));
    background: hsl(var(--muted) / 0.45);
    color: hsl(var(--muted-foreground));
}

.layout-delta--ok {
    border-color: hsl(var(--border));
    background: hsl(var(--muted) / 0.3);
    color: hsl(var(--muted-foreground));
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
}

.btn:hover {
    background-color: hsl(var(--primary) / 0.9);
    text-decoration: none;
}

.btn:disabled,
.btn[disabled],
.btn--disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.form--loading {
    pointer-events: none;
    opacity: 0.6;
    cursor: wait;
}

.suggestion-form {
    margin-top: 1rem;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0;
    font-size: 0.875rem;
    cursor: pointer;
}

.suggestion-item input[type="checkbox"] {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.form-grid--inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.form-grid--inline .form-control {
    width: auto;
    flex: 1 1 10rem;
}

.form-grid--spaced-top {
    margin-top: 1rem;
}

.form-control--inline {
    width: 10rem !important;
    flex-shrink: 0;
}

.btn-secondary,
.btn--secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover,
.btn--secondary:hover {
    background-color: hsl(var(--secondary) / 0.8);
}

.btn-danger {
    background-color: hsl(0 72% 51%);
    color: #fff;
}

.btn-danger:hover {
    background-color: hsl(0 72% 44%);
}

.btn--icon-only {
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    justify-content: center;
    flex-shrink: 0;
}

/* Data Tables */
.data-table-wrapper {
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.data-table {
    width: 100%;
    caption-side: bottom;
    font-size: 0.875rem;
    border-collapse: collapse;
}

.data-table__thead {
    border-bottom: 1px solid hsl(var(--border));
    background-color: transparent; /* shadcn typical is transparent or very light like muted/50 */
}

.data-table__th {
    height: 3rem;
    padding: 0 1.5rem;
    text-align: left;
    vertical-align: middle;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    border-bottom: 1px solid hsl(var(--border));
}

.data-table__row {
    border-bottom: 1px solid hsl(var(--border));
    transition: background-color 0.15s ease-in-out;
}

.data-table__row:last-child {
    border-bottom: 0;
}

.data-table__row:hover {
    background-color: hsl(var(--muted) / 0.5); /* subtle bg on hover */
}

.data-table__td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    color: hsl(var(--foreground));
}

.org-scope {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Dashboard Specific */
.dashboard__title {
    margin-bottom: 0.5rem;
}

.dashboard__subtitle {
    font-size: 1.25rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-top: 0;
    margin-bottom: 1.5rem;
}


/* Dashboard Header */
.dashboard__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.dashboard__title-main {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}
.btn--with-icon {
    display: inline-flex;
    align-items: center;
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
}
.btn-outline {
    background-color: transparent;
    border: 1px solid hsl(var(--border));
    color: hsl(var(--foreground));
    display: inline-flex;
    align-items: center;
}
.btn-outline:hover {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.kpi-card {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.5rem;
    background-color: hsl(var(--card));
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 0;
}
.dashboard-action-row {
    margin-bottom: 2rem;
}
.kpi-card--action {
    min-height: 160px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.kpi-card--action .btn {
    font-size: 1rem;
    padding: 0.75rem 1.25rem;
}
.kpi-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.kpi-card__title {
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
    color: hsl(var(--muted-foreground));
}
.kpi-card__value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}
.kpi-card__trend {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.1rem 0.5rem;
    border-radius: calc(var(--radius) * 2);
    background-color: hsl(var(--muted)/0.5);
}
.kpi-card__trend--up {
    /* Muted look for positive */
}
.kpi-card__detail-text {
    font-size: 0.875rem;
    margin: 1rem 0 0 0;
    color: hsl(var(--foreground));
}
.kpi-card__detail-subtext {
    font-size: 0.875rem;
    margin: 0;
    color: hsl(var(--muted-foreground));
}

/* Settings */
.settings-two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    align-items: start;
}

.settings-card {
    margin-bottom: 0;
    padding: 1.5rem;
}

.card__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.settings-card__actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
}
.settings-card__actions .btn {
    width: min(360px, 100%);
}

@media (max-width: 900px) {
    .settings-two-column {
        grid-template-columns: 1fr;
    }
}

/* Generic table + table-wrap (used by page templates) */
.table-wrap {
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.table {
    width: 100%;
    font-size: 0.875rem;
    border-collapse: collapse;
}

.table thead {
    border-bottom: 1px solid hsl(var(--border));
}

.table th {
    height: 2.75rem;
    padding: 0 1rem;
    text-align: left;
    vertical-align: middle;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    color: hsl(var(--foreground));
    border-top: 1px solid hsl(var(--border) / 0.5);
}

.table tbody tr:hover {
    background-color: hsl(var(--muted) / 0.4);
}

.table__link {
    color: hsl(var(--primary));
    text-decoration: none;
    font-size: 0.8125rem;
}

.table__link:hover {
    text-decoration: underline;
}

.table__mono {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
}

.table__group-header td {
    background-color: hsl(var(--muted) / 0.6);
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.375rem 1rem;
    border-top: 1px solid hsl(var(--border));
}

.table__group-header:hover {
    background-color: transparent !important;
}

.badge--muted {
    color: hsl(var(--muted-foreground));
    background-color: hsl(var(--muted));
}

.badge--info {
    color: hsl(var(--primary));
    background-color: hsl(var(--primary) / 0.1);
}

/* ── Activity history ───────────────────────────────────────────────────── */

.activity-week {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.activity-week__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    background-color: hsl(var(--muted) / 0.7);
    cursor: pointer;
    user-select: none;
}

.activity-week__header:hover {
    background-color: hsl(var(--muted));
}

.activity-week__label {
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: var(--font-mono, ui-monospace, monospace);
    color: hsl(var(--foreground));
}

.activity-week__meta {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

.activity-week__chevron {
    margin-left: auto;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    transition: transform 0.15s ease;
    display: inline-block;
}

.activity-week__chevron--open {
    transform: rotate(180deg);
}

.activity-week__body .table-wrap {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
}

.activity-item__type {
    white-space: nowrap;
}

.activity-item__toggle {
    background: none;
    border: none;
    padding: 0 0 0 0.4rem;
    cursor: pointer;
    color: hsl(var(--muted-foreground));
    font-size: 0.7rem;
    vertical-align: middle;
    transition: transform 0.15s ease;
    display: inline-block;
}

.activity-item__toggle--open {
    transform: rotate(180deg);
}

.activity-item__summary-cell {
    padding: 0.75rem 1rem 0.75rem 2rem !important;
    background-color: hsl(var(--muted) / 0.3);
    color: hsl(var(--foreground));
    font-size: 0.8125rem;
    line-height: 1.6;
}

.activity-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.activity-summary__text {
    margin: 0;
    white-space: pre-wrap;
}

.activity-summary__empty {
    margin: 0;
    color: hsl(var(--muted-foreground));
    font-style: italic;
}

.activity-summary__actions {
    margin: 0.25rem 0 0 1rem;
    padding: 0;
    list-style: disc;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Code block */
.codeblock {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    background: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: hsl(var(--foreground));
    margin: 0.5rem 0;
}

.codeblock--light {
    background: hsl(var(--background));
}

/* Media player */
.media-player {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    background: #000;
    display: block;
    max-height: 480px;
}

/* Narrative prose */
.narrative-prose {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: hsl(var(--foreground));
    white-space: pre-wrap;
    max-width: 72ch;
}

/* Transcript timeline */
.transcript-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.75rem;
    max-height: 480px;
    overflow-y: auto;
}

.segment {
    display: grid;
    grid-template-columns: max-content minmax(7rem, 9rem) minmax(10rem, 14rem) minmax(0, 1fr);
    column-gap: 0.75rem;
    row-gap: 0.15rem;
    align-items: start;
    font-size: 0.8125rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid hsl(var(--border) / 0.4);
}

.segment__meta {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
    grid-column: 4;
    margin: 0;
}

.segment__speaker {
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.segment__text {
    color: hsl(var(--foreground));
    margin: 0;
    min-width: 0;
}

.segment__member {
    margin: 0;
    color: hsl(var(--muted-foreground));
}

.segment__seek {
    font-size: 0.75rem;
    color: hsl(var(--primary));
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    text-decoration: underline;
    white-space: nowrap;
}

.speaker-assignment__jump-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.speaker-assignment__jump-row {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.6rem;
    align-items: center;
}

.speaker-assignment__sample {
    font-size: 0.85rem;
    color: hsl(var(--foreground));
    line-height: 1.3;
}

/* Summary columns */
.summary-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.summary-quote {
    font-style: italic;
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    border-left: 3px solid hsl(var(--border));
    padding-left: 0.75rem;
    margin: 0.4rem 0;
}

.summary-meta {
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
}

/* Filter bar — one-line horizontal filter row */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-bar .form-control {
    width: auto;
    min-width: 8rem;
    flex-shrink: 0;
}

.filter-bar__check-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: hsl(var(--foreground));
    cursor: pointer;
    white-space: nowrap;
}

/* Small button variant */
.btn--sm {
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
    height: auto;
}

/* Table Toolbar */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.toolbar-tabs {
    display: flex;
    gap: 1rem;
}
.toolbar-tab {
    display: inline-flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    padding: 0.5rem 0;
}
.toolbar-tab--active {
    color: hsl(var(--foreground));
    border-bottom: 2px solid hsl(var(--primary));
}
.toolbar-actions {
    display: flex;
    gap: 0.5rem;
}
.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    border-radius: 999px;
    font-size: 0.75rem;
    padding: 0 0.5rem;
    height: 1.25rem;
    margin-left: 0.5rem;
    line-height: 1;
}

.scope-filter {
    margin-bottom: 1rem;
}

.scope-filter__group {
    max-width: 20rem;
}

.scope-filter__select {
    height: 2.35rem;
}

/* Badges & Checkboxes */
.badge-outline {
    display: inline-flex;
    align-items: center;
    border: 1px solid hsl(var(--border));
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}
.status-badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid hsl(var(--border));
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: hsl(var(--muted)/0.3);
}
.checkbox {
    width: 1rem;
    height: 1rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) * 0.55);
    appearance: none;
    -webkit-appearance: none;
    background-color: hsl(var(--background));
    cursor: pointer;
    position: relative;
    display: inline-block;
    vertical-align: middle;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.checkbox:hover {
    border-color: hsl(var(--muted-foreground) / 0.55);
}
.checkbox:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring) / 0.45);
}
.checkbox:checked {
    background-color: hsl(var(--primary));
    border-color: hsl(var(--primary));
}
.checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 3px;
    height: 7px;
    border: solid hsl(var(--primary-foreground));
    border-width: 0 1.8px 1.8px 0;
    transform: rotate(45deg);
}
.checkbox:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.cell-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.row-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.btn-icon {
    background: none;
    border: none;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    padding: 0.25rem;
}
.btn-icon:hover {
    color: hsl(var(--foreground));
}
.drag-handle {
    color: hsl(var(--muted-foreground));
    cursor: grab;
}


/* Sidebar Updates */
.sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0;
    margin-bottom: 0;
}
.sidebar__brand-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.sidebar__brand-icon {
    flex-shrink: 0;
}
.sidebar__brand-text {
    font-weight: 600;
    font-size: 1rem;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar__collapse-btn {
    border: 1px solid hsl(var(--border));
    background: transparent;
    border-radius: var(--radius);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    flex-shrink: 0;
}
.sidebar__collapse-btn:hover {
    background: hsl(var(--accent));
}
.sidebar__group {
    margin-bottom: 2rem;
}
.sidebar__group-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}
.sidebar__nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.sidebar__nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.5rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}
.sidebar__nav-item:hover {
    background-color: hsl(var(--accent));
    color: hsl(var(--foreground));
    text-decoration: none;
}
.sidebar__nav-item--active {
    color: hsl(var(--foreground));
    background-color: hsl(var(--accent));
}
.sidebar__nav-icon {
    flex-shrink: 0;
}
.sidebar__nav-item { cursor: pointer; }

.layout--sidebar-collapsed .sidebar,
.sidebar-collapsed-persist .layout .sidebar {
    width: 76px;
    padding: 1rem 0.6rem;
}

.layout--sidebar-collapsed .sidebar__brand-text,
.layout--sidebar-collapsed .sidebar__group-title,
.layout--sidebar-collapsed .sidebar__nav-label,
.sidebar-collapsed-persist .layout .sidebar__brand-text,
.sidebar-collapsed-persist .layout .sidebar__group-title,
.sidebar-collapsed-persist .layout .sidebar__nav-label {
    display: none;
}

.layout--sidebar-collapsed .sidebar__brand-icon,
.sidebar-collapsed-persist .layout .sidebar__brand-icon {
    display: none;
}

.layout--sidebar-collapsed .sidebar__brand,
.sidebar-collapsed-persist .layout .sidebar__brand {
    justify-content: center;
}

.layout--sidebar-collapsed .sidebar__brand-main,
.sidebar-collapsed-persist .layout .sidebar__brand-main {
    justify-content: center;
}

.layout--sidebar-collapsed .sidebar__nav-item,
.sidebar-collapsed-persist .layout .sidebar__nav-item {
    justify-content: center;
    padding: 0.5rem 0;
}

.layout--sidebar-collapsed .sidebar__footer,
.sidebar-collapsed-persist .layout .sidebar__footer {
    display: none;
}
/* Form Styles */
.form-container {
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) * 1.5);
    padding: 2.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
    max-width: 600px;
}

.form-header {
    margin-bottom: 2rem;
}

.form-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    color: hsl(var(--foreground));
}

.form-header p {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin: 0;
}

.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

.form-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-row > .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: hsl(var(--foreground));
    display: block;
}

.form-control {
    display: flex;
    height: 2.75rem;
    width: 100%;
    border-radius: calc(var(--radius) * 1.2);
    border: 1px solid hsl(var(--border));
    background-color: transparent;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: hsl(var(--foreground));
    transition: outline 0.15s ease, border-color 0.15s ease;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.15);
}

.form-control::placeholder {
    color: hsl(var(--muted-foreground));
}

.form-control:disabled {
    background-color: hsl(var(--muted) / 0.7);
    color: hsl(var(--muted-foreground));
    border-color: hsl(var(--border));
    cursor: not-allowed;
    opacity: 1;
}

.CodeMirror {
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) * 1.2);
    font-size: 0.875rem;
    height: auto;
    min-height: 24rem;
}

.CodeMirror-focused {
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.15);
}

textarea[data-json-editor="true"][data-cm-initialized="1"] {
    display: none !important;
}

textarea[data-schema-editor="true"][data-cm-initialized="1"] {
    display: none !important;
}

.schema-modal {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1rem;
    width: min(900px, 92vw);
    max-height: 85vh;
}

.schema-modal::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.schema-modal__code {
    margin: 0;
    padding: 0.75rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--muted) / 0.35);
    overflow: auto;
    max-height: 65vh;
    font-size: 0.8rem;
}

textarea.form-control {
    min-height: 100px;
    height: auto;
    resize: vertical;
}

select.form-control {
    display: block;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    padding-right: 2.25rem;
}

.combobox {
    position: relative;
}

.combobox__control {
    position: relative;
}

.combobox__input {
    padding-right: 2rem;
}

.combobox__input--invalid {
    border-color: hsl(var(--destructive));
    box-shadow: 0 0 0 2px hsl(var(--destructive) / 0.12);
}

.combobox__clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: hsl(var(--muted-foreground));
    width: 1.5rem;
    height: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.combobox__clear:hover {
    color: hsl(var(--foreground));
}

.combobox__panel {
    position: absolute;
    z-index: 40;
    width: 100%;
    margin: 0.3rem 0 0;
    padding: 0.25rem 0;
    max-height: 15rem;
    overflow-y: auto;
    list-style: none;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) * 1.2);
    box-shadow: 0 12px 24px rgb(15 23 42 / 0.1);
}

.combobox__option {
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: hsl(var(--foreground));
}

.combobox__option--active {
    background: hsl(var(--muted) / 0.55);
}

.combobox__option--selected {
    font-weight: 600;
}

.combobox__option--disabled {
    color: hsl(var(--muted-foreground));
    cursor: not-allowed;
}

.combobox__empty {
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
}

.combobox__error {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: hsl(var(--destructive));
}

.form-subtext {
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2.5rem;
}

.form-actions .btn {
    min-width: 100px;
}

/* Component editor specific overrides */
.component-form-shell {
    max-width: 1480px;
    width: 100%;
}

.component-main-cards {
    display: grid;
    grid-template-columns: minmax(320px, 0.95fr) minmax(640px, 1.9fr);
    gap: 1.25rem;
    align-items: start;
}

.component-main-card {
    max-width: none;
    margin: 0;
    padding: 2rem;
}

.component-main-card > :first-child {
    margin-top: 0;
}

.component-main-card > :last-child {
    margin-bottom: 0;
}

.scope-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 1.25rem;
}

.scope-row > .form-group {
    margin-bottom: 0;
}

.scope-row .form-control {
    white-space: nowrap;
}

.layout-design__required-select,
.layout-design__state-select {
    min-width: 8.5rem;
}

.layout-design-section {
    max-width: none;
    width: 100%;
}

.layout-design__component-select {
    min-width: 20rem;
    width: 100%;
}

.layout-design-section .data-table {
    table-layout: auto;
}

.layout-design__col-component {
    width: auto;
}

.layout-design__col-required {
    width: auto;
}

.layout-design__col-state {
    width: auto;
}

.layout-design__col-actions {
    width: auto;
}

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

/* Auth Specific */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: hsl(var(--muted)/0.4);
}

.auth-card {
    max-width: 400px;
    width: 100%;
    padding: 2rem;
    background-color: hsl(var(--card));
    border-radius: calc(var(--radius) * 1.5);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid hsl(var(--border)/0.5);
}

.auth-card__title {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    margin-top: 0;
    margin-bottom: 2rem;
    color: hsl(var(--foreground));
}

.auth-alert {
    color: hsl(var(--destructive));
    background-color: hsl(var(--destructive)/0.1);
    border: 1px solid hsl(var(--destructive)/0.2);
    border-radius: calc(var(--radius) * 1.2);
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

/* ── Media Library ─────────────────────────────────────────── */
.upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
    cursor: default;
}

.upload-dropzone--active {
    border-color: var(--primary);
    background: hsl(var(--primary) / 0.05);
}


.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.media-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    background: var(--card);
}

.media-card__thumb {
    width: 100%;
    aspect-ratio: 1;
    border-radius: calc(var(--radius) - 2px);
    background: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.media-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-card__name {
    font-size: 0.75rem;
    margin-top: 0.375rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-card__meta {
    font-size: 0.7rem;
    color: var(--muted-foreground);
}

.media-card__thumb {
    position: relative;
}

.media-card__lock-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: hsl(var(--muted-foreground) / 0.25);
    color: hsl(var(--muted-foreground));
    border-radius: calc(var(--radius) - 2px);
    padding: 0.15rem 0.25rem;
    display: flex;
    align-items: center;
    line-height: 1;
}

.media-card__lock-badge--locked {
    background: hsl(var(--foreground) / 0.7);
    color: hsl(var(--background));
}

.media-card:hover {
    border-color: hsl(var(--primary) / 0.5);
    box-shadow: 0 0 0 2px hsl(var(--primary) / 0.15);
}

/* Media edit modal */
.media-modal {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0;
    width: min(980px, 96vw);
    max-height: 90vh;
    overflow: hidden;
}

.media-modal[open] {
    display: flex;
    flex-direction: column;
}

.media-modal::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.media-modal__body {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 90vh;
}

.media-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid hsl(var(--border));
    gap: 0.5rem;
}

.media-modal__body form,
.media-modal__body > form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
}

.media-modal__top {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.media-modal__preview {
    min-height: 220px;
}

.media-modal__editor {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.media-modal__meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    font-size: 0.8rem;
}

.media-modal__meta-value {
    font-size: 0.8rem;
    color: var(--muted-foreground);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.25rem;
}

.media-modal__locked-banner {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
    background: hsl(var(--muted) / 0.5);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--muted-foreground);
    flex-shrink: 0;
}

.btn-icon:hover {
    background: hsl(var(--muted));
    color: var(--foreground);
}

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

/* ── Toast / Sonner-style notifications ──────────────────────────────────── */
.toast-region {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    width: 22rem;
    max-width: calc(100vw - 3rem);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    background: hsl(var(--popover));
    border: 1px solid hsl(var(--border));
    box-shadow: 0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
    font-size: 0.875rem;
    color: hsl(var(--foreground));
    pointer-events: all;
    position: relative;
}

.toast--success .toast__icon-wrap { color: hsl(142 71% 45%); }
.toast--error   .toast__icon-wrap { color: hsl(var(--destructive)); }
.toast--info    .toast__icon-wrap { color: hsl(221 83% 53%); }

.toast--success { border-left: 3px solid hsl(142 71% 45%); }
.toast--error   { border-left: 3px solid hsl(var(--destructive)); }
.toast--info    { border-left: 3px solid hsl(221 83% 53%); }

.toast__icon-wrap {
    flex-shrink: 0;
    margin-top: 1px;
    display: flex;
}

.toast__body {
    flex: 1;
    min-width: 0;
}

.toast__title {
    display: block;
    font-weight: 500;
    line-height: 1.4;
}

.toast__close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: hsl(var(--muted-foreground));
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.125rem;
    margin-top: -1px;
    border-radius: calc(var(--radius) / 2);
}
.toast__close:hover { color: hsl(var(--foreground)); }

/* Alpine transition helpers */
.toast-enter        { transition: transform 0.3s ease, opacity 0.3s ease; }
.toast-enter-start  { transform: translateX(110%); opacity: 0; }
.toast-enter-end    { transform: translateX(0);    opacity: 1; }
.toast-leave        { transition: transform 0.25s ease, opacity 0.25s ease; }
.toast-leave-start  { transform: translateX(0);    opacity: 1; }
.toast-leave-end    { transform: translateX(110%); opacity: 0; }

/* ===== Alert Dialog ===== */
.alert-dialog__overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: hsl(0 0% 0% / 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-dialog__container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.alert-dialog__panel {
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 10px 30px hsl(0 0% 0% / 0.15);
    padding: 1.5rem;
    width: 100%;
    max-width: 28rem;
}

.alert-dialog__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 0 0 0.5rem 0;
}

.alert-dialog__message {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin: 0 0 1.25rem 0;
    line-height: 1.5;
}

.alert-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Publication status badges */
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
}

.badge--hidden {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    opacity: 0.75;
}

.badge--active {
    background: hsl(142 71% 45% / 0.15);
    color: hsl(142 76% 28%);
}

.row--hidden {
    opacity: 0.5;
}

/* Project list: per-week activity cell (email/ticket/call counts) */
.activity-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
}

.activity-cell__icon {
    flex-shrink: 0;
    color: hsl(var(--muted-foreground));
}

.activity-cell__count {
    font-weight: 600;
    color: hsl(var(--foreground));
    min-width: 0.875rem;
}

.activity-cell__count--nonzero {
    font-weight: 800;
}

.activity-cell__sep {
    color: hsl(var(--border));
    margin: 0 0.0625rem;
}

.kv__link-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.kv__icon {
    flex-shrink: 0;
}

.card__title--with-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card__title-icon {
    flex-shrink: 0;
    color: hsl(var(--muted-foreground));
}

.badge--draft {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

.badge--published {
    background: hsl(142 71% 45% / 0.15);
    color: hsl(142 76% 28%);
}

.badge--archived {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    opacity: 0.7;
}

/* Call / job processing status badges */
.badge--completed,
.badge--succeeded {
    background: hsl(142 71% 45% / 0.15);
    color: hsl(142 76% 28%);
}

.badge--failed,
.badge--error {
    background: hsl(0 84% 60% / 0.12);
    color: hsl(0 72% 42%);
}

.badge--in_progress,
.badge--running {
    background: hsl(217 91% 60% / 0.15);
    color: hsl(221 83% 40%);
}

.badge--pending,
.badge--queued,
.badge--discovered,
.badge--candidate {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

.badge--imported,
.badge--approved {
    background: hsl(142 71% 45% / 0.15);
    color: hsl(142 76% 28%);
}

.badge--ignored,
.badge--cancelled {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    text-decoration: line-through;
}

.badge--retry {
    background: hsl(38 92% 50% / 0.15);
    color: hsl(32 95% 35%);
}

.badge--rolling {
    background: hsl(217 91% 60% / 0.15);
    color: hsl(221 83% 40%);
}

.badge--snapshots {
    background: hsl(262 83% 58% / 0.15);
    color: hsl(262 80% 40%);
}

/* Source Detail Page */
.source-detail-card {
    padding: 1.1rem 1.25rem;
}

.source-detail__kv {
    grid-template-columns: 8rem minmax(0, 1fr);
    gap: 0.45rem 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--muted) / 0.35);
    margin-bottom: 1rem;
}

.source-detail__kv dd {
    font-family: var(--font-sans);
    font-size: 0.84rem;
    word-break: break-word;
}

.source-detail__mono {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: -0.01em;
}

.source-detail__actions {
    margin-top: 0.35rem;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.button-row form {
    margin: 0;
}

.setup-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.setup-step {
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--background));
    padding: 0.85rem 0.95rem;
}

.setup-step--locked {
    opacity: 0.72;
}

.setup-step__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.setup-step__num {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: hsl(var(--background));
    background: hsl(var(--primary));
    flex: 0 0 auto;
}

.setup-step__title {
    font-size: 0.92rem;
}

.setup-step__body {
    padding-left: 1.9rem;
}

.setup-step .form-grid {
    margin-bottom: 0;
}

.folder-tree-wrap {
    margin: 0.5rem 0;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--muted) / 0.25);
    padding: 0.55rem;
    max-height: 16rem;
    overflow: auto;
}

.folder-tree-selected {
    display: grid;
    gap: 0.5rem;
}

.version-immutable-notice {
    background: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 1rem;
}

/* =========================================================
   Product Editor v2 — sticky header, tabs, read-only banner
   ========================================================= */

.editor-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Sticky header */
.editor-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: hsl(var(--background));
    border-bottom: 1px solid hsl(var(--border));
    padding: 0.75rem 1.5rem 0;
}

.editor-header__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.editor-header__left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.editor-header__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 0;
    overflow-wrap: anywhere;
}

.editor-header__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.editor-chip {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    background: hsl(var(--muted));
    border-radius: 9999px;
    padding: 0.1rem 0.5rem;
}

.editor-chip--context {
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    padding: 0.14rem 0.55rem;
}

.editor-header__version {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.version-picker {
    font-size: 0.85rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.3rem 0.6rem;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    cursor: pointer;
}

.editor-header__bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
}

.editor-header__context {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.editor-context-item {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

.editor-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.editor-header__lifecycle {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.editor-header__preview {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

/* Small button modifier */
.btn--sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.65rem;
    height: auto;
}

/* Tabs row */
.editor-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid hsl(var(--border));
    overflow-x: auto;
    background: hsl(var(--background));
    position: sticky;
    top: var(--editor-header-height, 88px);
    z-index: 19;
}

.editor-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.editor-tab:hover {
    color: hsl(var(--foreground));
    border-bottom-color: hsl(var(--border));
}

.editor-tab--active {
    color: hsl(var(--foreground));
    border-bottom-color: hsl(var(--primary));
}

/* Tab content area */
.editor-tab-content {
    padding: 1.5rem;
}

/* Read-only banner */
.readonly-banner {
    display: flex;
    align-items: center;
    background: hsl(45 100% 95%);
    border: 1px solid hsl(45 100% 70%);
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    color: hsl(32 95% 30%);
    margin-bottom: 1rem;
}

/* Editor form sections */
.editor-form-section {
    max-width: 600px;
}

.editor-form-section.layout-design-section {
    max-width: min(1200px, 100%);
    width: 100%;
}

.editor-form-section.layout-set-mappings-section {
    max-width: min(1200px, 100%);
    width: 100%;
}

.form-container.language-set-form {
    max-width: min(1100px, 100%);
}

.language-set-languages-table .data-table {
    table-layout: auto;
    width: 100%;
}

.language-set-languages__col-language {
    width: 75%;
}

.language-set-languages__col-required {
    width: 15%;
}

.language-set-languages-table .combobox__input {
    min-width: 22rem;
}

.layout-set-mappings-section .data-table {
    table-layout: auto;
}

.layout-set-mappings-section .combobox__input,
.layout-set-mappings__layout-select {
    min-width: 22rem;
}

.layout-set-mappings__col-linktype {
    width: 45%;
}

.layout-set-mappings__col-layout {
    width: 45%;
}

.layout-set-mappings__col-actions {
    width: 10%;
}

.component-schema-table-wrap {
    width: 100%;
    max-width: 980px;
    overflow-x: auto;
}

.component-schema-table {
    width: 100%;
    table-layout: fixed;
}

.component-schema__col-name {
    width: 34%;
}

.component-schema__col-type {
    width: 16%;
}

.component-schema__col-required {
    width: 14%;
}

.component-schema__col-actions {
    width: 36%;
}

.component-schema__row-grid {
    display: grid;
    grid-template-columns: minmax(130px, 1.05fr) minmax(112px, 0.72fr) minmax(100px, 0.64fr) auto;
    gap: 0.65rem;
    align-items: center;
}

@media (max-width: 1200px) {
    .component-schema__row-grid {
        grid-template-columns: minmax(120px, 0.95fr) minmax(102px, 0.66fr) minmax(92px, 0.6fr) auto;
    }
}

.editor-basic-grid {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.15fr);
    gap: 1.25rem;
    align-items: start;
}

.editor-basic-grid__col .editor-form-section {
    max-width: none;
}

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

.editor-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 0 0 1rem 0;
}

.editor-section-subtitle {
    font-size: 0.875rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    margin: 0 0 0.75rem 0;
}

.editor-collapsible {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--background));
    padding: 0.5rem 0.75rem;
}

.editor-collapsible__summary {
    cursor: pointer;
    list-style: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.editor-collapsible__summary::-webkit-details-marker {
    display: none;
}

/* Tab action bar (validate button row) */
.editor-tab-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Validation results panel */
.validation-results-panel {
    margin-bottom: 1rem;
}

.validation-results-content {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    background: hsl(var(--background));
}

.validation-results-summary {
    display: block;
    margin-bottom: 0.5rem;
}

.validation-results-summary__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
}

.validation-results-summary__header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.validation-results-summary__set {
    font-weight: 600;
    font-size: 0.9rem;
    color: hsl(var(--foreground));
}

.validation-results-summary__metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.validation-results-summary__metric {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.validation-results-summary__icon {
    flex-shrink: 0;
}

.validation-results-summary__count-number {
    min-width: 0.9rem;
    text-align: right;
}

.validation-results-summary__count-label {
    color: hsl(var(--foreground));
    font-weight: 600;
}

.validation-results-summary__metric--error {
    color: #dc2626;
}

.validation-results-summary__metric--warning {
    color: #d97706;
}

.validation-results-summary__metric--info {
    color: hsl(var(--muted-foreground));
}

.validation-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.validation-item {
    display: flex;
    align-items: flex-start;
    gap: 0.3rem;
    font-size: 0.85rem;
    line-height: 1.4;
}

.validation-item__icon {
    flex-shrink: 0;
    margin-top: 0.05rem;
}

.validation-item--error { color: #dc2626; }
.validation-item--warning { color: #d97706; }
.validation-item--info { color: hsl(var(--muted-foreground)); }


/* ============================================================
   Drawer — right-side sliding panel
   ============================================================ */

.drawer {
    /* Drawer is always in the DOM; panel slides in/out */
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
}

.drawer--open {
    pointer-events: auto;
}

.drawer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.drawer--open .drawer__backdrop {
    opacity: 1;
}

.drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: hsl(var(--background));
    border-left: 1px solid hsl(var(--border));
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer--open .drawer__panel {
    transform: translateX(0);
}

.drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid hsl(var(--border));
    flex-shrink: 0;
}

.drawer__title {
    font-size: 1rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.drawer__close {
    flex-shrink: 0;
}

.drawer__content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

/* ============================================================
   Publish drawer fragment styles
   ============================================================ */

.publish-drawer__section {
    margin-bottom: 1.5rem;
}

.publish-drawer__section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.5rem;
}

.publish-drawer__meta-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.publish-drawer__meta-row {
    vertical-align: top;
}

.publish-drawer__meta-label {
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
    text-align: left;
    font-weight: 500;
    padding: 0.05rem 0.5rem 0.2rem 0;
    width: 8.25rem;
}

.publish-drawer__meta-value {
    word-break: break-word;
    padding: 0.05rem 0 0.2rem 0;
}

.publish-drawer__actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid hsl(var(--border));
    margin-top: 1rem;
}

.publish-drawer__actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.publish-drawer__actions .lucide {
    flex-shrink: 0;
    margin-right: 0 !important;
}

.publish-drawer__section .validation-results-content {
    padding: 0.65rem 0.85rem;
}

.publish-drawer__section .validation-results-summary {
    margin-bottom: 0.35rem;
}

.publish-drawer__validation {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.75rem 0.85rem;
    background: hsl(var(--background));
}

.publish-drawer__validation .publish-drawer__meta-table {
    margin-bottom: 0.65rem;
}

.publish-drawer__validation-value--error {
    font-weight: 700;
    color: #dc2626;
}

.publish-drawer__validation-value--warning {
    font-weight: 700;
    color: #d97706;
}

.publish-drawer__validation-value--info {
    font-weight: 700;
    color: hsl(var(--muted-foreground));
}

.publish-drawer__validation-messages-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.publish-drawer__validation-message {
    line-height: 1.35;
    font-size: 0.92rem;
}

.publish-drawer__validation-message--error {
    color: #dc2626;
}

.publish-drawer__validation-message--warning {
    color: #d97706;
}

.publish-drawer__validation-message--info {
    color: hsl(var(--muted-foreground));
}

.publish-drawer__validation-messages {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--muted) / 0.3);
    padding: 0.6rem 0.7rem;
}

.publish-drawer__blocker {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

/* QR / GS1 Digital Link tab */
.qr-tab__layout {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.qr-tab__left {
    flex: 1 1 520px;
    min-width: 320px;
}

.qr-tab__right {
    flex: 0 1 420px;
    min-width: 280px;
}

.qr-tab__card {
    padding: 1rem;
}

.qr-tab__linktypes-card {
    margin-top: 0.75rem;
}

.qr-tab__sync-message {
    margin-bottom: 0.75rem;
}

.qr-tab__digital-link-cell {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.qr-tab__digital-link-value {
    word-break: break-all;
}

.qr-tab__status-badge {
    gap: 0.35rem;
}

.qr-tab__image {
    width: 240px;
    max-width: 100%;
    height: auto;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: #fff;
    padding: 0.5rem;
}

.qr-tab__asset-id {
    margin-top: 0.5rem;
}

.qr-tab__actions {
    margin-top: 0.75rem;
}

.qr-tab__sync-form {
    display: inline-block;
    margin-right: 0.5rem;
}

.qr-tab__sync-form:last-child {
    margin-right: 0;
}

/* Tabbed richtext editor (data entry form) */
.richtext-tabbed-editor {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.richtext-tabs {
    display: flex;
    gap: 0;
    background: var(--surface-subtle, #f8f9fa);
    border-bottom: 1px solid var(--border-color);
}

.richtext-tab-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.richtext-tab-btn:hover {
    color: var(--text-primary, #111827);
}

.richtext-tab-btn--active {
    color: var(--text-primary, #111827);
    border-bottom-color: var(--primary-color, #ea580c);
}

.richtext-tab-panels {
    padding: 0.75rem;
    background: #fff;
}

.richtext-tab-panel .tox-tinymce {
    border-radius: 4px;
    width: 100% !important;
    max-width: none !important;
}

/* Icon picker (tab schema editor) */
.icon-picker__popover {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 0.75rem;
    top: calc(100% + 4px);
    bottom: auto;
    left: 0;
    max-height: min(360px, 60vh);
    overflow: hidden;
}

.icon-picker__results {
    max-height: min(280px, 45vh);
    overflow-y: auto;
    overflow-x: hidden;
}

.icon-picker__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.25rem;
}

.icon-picker__option {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 2rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    color: hsl(var(--foreground));
    gap: 0.5rem;
    text-align: left;
    transition: background 0.1s, border-color 0.1s;
}

.icon-picker__option:hover {
    background: hsl(var(--accent));
    border-color: hsl(var(--border));
}

.icon-picker__label {
    display: inline-block;
    font-size: 0.8rem;
    line-height: 1.2;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Entity code / public-id fields ───────────────────────── */
.form-group__with-action {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.form-group__with-action .form-control {
    flex: 1;
}

.entity-code {
    display: block;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground, 215 16% 47%));
    margin-top: 0.15rem;
}

/* ── HTMX modal overlay ───────────────────────────────────── */
.modal {
    display: none;
}

.modal--open {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: hsl(0 0% 0% / 0.5);
    align-items: center;
    justify-content: center;
}

.modal__content {
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 10px 30px hsl(0 0% 0% / 0.18);
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid hsl(var(--border));
}

.modal__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.modal__close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: hsl(var(--muted-foreground));
    padding: 0.25rem;
    line-height: 1;
}

.modal__close:hover {
    color: hsl(var(--foreground));
}

.modal__body {
    padding: 1.25rem;
}

/* ── Token Editor ────────────────────────────────────────── */

.token-groups {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.token-group__title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: hsl(var(--muted-foreground));
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid hsl(var(--border));
}

.token-group__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem 1.5rem;
}

.token-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.token-field__label-group {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.token-field__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--foreground));
}

.token-field__var {
    font-size: 0.6875rem;
    font-family: var(--font-mono, monospace);
    color: hsl(var(--muted-foreground));
    background: hsl(var(--muted));
    padding: 0.1em 0.4em;
    border-radius: 3px;
}

.token-color-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.token-color-picker {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0.125rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
}

.token-color-text {
    flex: 1;
    min-width: 0;
}

.token-color-swatch {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
}

@media (max-width: 700px) {
    .token-group__grid {
        grid-template-columns: 1fr;
    }
}


/* ── Message block (collapsible email messages) ── */
.message-block {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
    min-width: 0;
}

.message-block__header {
    margin: 0;
}

.message-block__toggle {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: hsl(var(--muted));
    border: none;
    cursor: pointer;
    text-align: left;
    font-size: 0.875rem;
    color: hsl(var(--foreground));
}

.message-block__toggle:hover {
    background: hsl(var(--accent));
}

.message-block__sender {
    font-weight: 600;
    flex: 1;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message-block__date {
    color: hsl(var(--muted-foreground));
    font-size: 0.8125rem;
    white-space: nowrap;
}

.message-block__chevron {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    margin-left: auto;
}

.message-block__body {
    padding: 0.875rem;
    border-top: 1px solid hsl(var(--border));
    min-width: 0;
}

.message-block__body .transcript__pre {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* ── Email thread participants (wrapping list of addresses) ── */
.email-thread__participants {
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

/* ── IMAP project assignment rules ── */
.imap-rules__list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.imap-rule {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.75rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.imap-rule__body {
    flex: 1;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.imap-rule__fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    flex: 1;
    min-width: 300px;
}

.form-label--sm {
    font-size: 0.8125rem;
}

.form-label--sm .form-control {
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
}
