/* ============================================================
   Phase 8 — CSS cho các feature pages: Documents / Chat / Templates.
   Copy từ sme-ai-screens/{documents,chat,templates}.html.
============================================================ */

/* ============================================================
   CUSTOMERS PAGE
============================================================ */
.cust-name-cell { display: flex; align-items: center; gap: var(--sp-3); }
.cust-name-cell__main { font-weight: var(--fw-semibold); color: var(--color-fg); margin-bottom: 1px; }
.cust-name-cell__sub { font-size: var(--fs-xs); color: var(--color-fg-muted); }

.tag-row { display: flex; gap: 4px; flex-wrap: wrap; }

.kv-table {
    display: grid;
    grid-template-columns: 200px 1fr 100px 48px;
    gap: 1px;
    background: var(--color-border);
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.kv-table__head, .kv-table__cell {
    background: var(--color-bg-surface);
    padding: var(--sp-3);
    font-size: var(--fs-sm);
}
.kv-table__head {
    background: var(--p-slate-50);
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-widest);
    text-transform: uppercase;
    color: var(--color-fg-muted);
}
.kv-table__cell { display: flex; align-items: center; gap: var(--sp-2); }
.kv-table__key { font-weight: var(--fw-semibold); color: var(--color-fg); }
.kv-table__type {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 8px;
    background: var(--color-bg-muted);
    color: var(--color-fg-muted);
    border-radius: var(--r-sm);
}
.kv-table__actions { display: flex; justify-content: center; }
.kv-add {
    grid-column: 1 / -1;
    padding: var(--sp-3);
    background: var(--color-bg-surface);
    display: flex; align-items: center; justify-content: center;
    gap: var(--sp-2);
    cursor: pointer;
    color: var(--color-primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    border-top: 1px dashed var(--color-border);
    transition: background var(--d-fast);
}
.kv-add:hover { background: var(--color-primary-light); }

.detail-section { margin-bottom: var(--sp-6); }
.detail-section__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    color: var(--color-fg);
    margin-bottom: var(--sp-3);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.detail-section__title::after {
    content: "";
    flex: 1 1 auto;
    min-width: var(--sp-6);
    height: 1px;
    background: color-mix(in srgb, var(--color-border-strong) 72%, transparent);
}
.detail-grid {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: var(--sp-3) var(--sp-4);
    font-size: var(--fs-sm);
}
.detail-grid dt { color: var(--color-fg-muted); font-weight: var(--fw-medium); }
.detail-grid dd { color: var(--color-fg); }

.timeline { position: relative; padding-left: var(--sp-6); }
.timeline::before {
    content: '';
    position: absolute;
    left: 11px; top: 6px; bottom: 6px;
    width: 2px;
    background: var(--color-border);
}
.timeline-item { position: relative; padding-bottom: var(--sp-4); }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -22px; top: 4px;
    width: 12px; height: 12px;
    border-radius: var(--r-full);
    background: var(--color-bg-surface);
    border: 2px solid var(--p-indigo-400);
}
.timeline-item__when { font-size: var(--fs-xs); color: var(--color-fg-subtle); margin-bottom: 2px; }
.timeline-item__title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); margin-bottom: 2px; }
.timeline-item__desc { font-size: var(--fs-xs); color: var(--color-fg-muted); }

.list-surface__pager {
    display: flex;
    align-items: center;
    width: 100%;
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-surface);
}

.list-surface__pager > .pagination-bar {
    width: 100%;
}

/* ============================================================
   DOCUMENTS PAGE
============================================================ */

.upload-zone {
    background: var(--color-bg-surface);
    border: 2px dashed var(--color-border);
    border-radius: var(--card-radius);
    padding: var(--sp-6);
    text-align: center;
    margin-bottom: var(--sp-5);
    transition: border-color var(--d-fast), background var(--d-fast);
    cursor: pointer;
    position: relative;
}
.upload-zone:hover,
.upload-zone--drag {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}
.upload-zone__input {
    position: absolute; inset: 0;
    opacity: 0;
    cursor: pointer;
}
.upload-zone__icon {
    width: 56px; height: 56px;
    margin: 0 auto var(--sp-3);
    background: var(--gradient-ai-soft);
    border-radius: var(--r-full);
    display: flex; align-items: center; justify-content: center;
    color: var(--p-indigo-600);
}
.upload-zone__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    margin-bottom: 4px;
}
.upload-zone__hint {
    font-size: var(--fs-sm);
    color: var(--color-fg-muted);
}
.text-primary { color: var(--color-primary); font-weight: var(--fw-semibold); }
.text-error   { color: var(--color-error-fg); }

.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--sp-4);
}
.doc-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    padding: var(--sp-4);
    transition: border-color var(--d-fast), transform var(--d-fast), box-shadow var(--d-fast);
    position: relative;
}
.doc-card:hover {
    border-color: var(--p-indigo-300);
    transform: translateY(-2px);
    box-shadow: var(--sh-md);
}
.doc-card--error {
    border-color: var(--color-error);
    background: var(--color-error-bg);
}
.doc-card__head {
    display: flex; align-items: center; gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}
.doc-icon {
    width: 44px; height: 44px;
    border-radius: var(--r-lg);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: var(--fw-bold);
    color: white;
}
.doc-icon--pdf  { background: linear-gradient(135deg, #EF4444, #F87171); }
.doc-icon--docx { background: linear-gradient(135deg, #3B82F6, #60A5FA); }
.doc-icon--md   { background: linear-gradient(135deg, #6366F1, #8B5CF6); }
.doc-icon--txt  { background: linear-gradient(135deg, #64748B, #94A3B8); }
.doc-card__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}
.doc-card__meta {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    margin-bottom: var(--sp-2);
}
.doc-tags {
    display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: var(--sp-3);
}

.progress {
    height: 4px;
    background: var(--color-bg-muted);
    border-radius: var(--r-full);
    overflow: hidden;
    margin-top: var(--sp-2);
}
.progress__fill {
    height: 100%;
    width: 60%;
    background: var(--gradient-ai);
    border-radius: var(--r-full);
    animation: progress-pulse 1.5s ease-in-out infinite;
}
@keyframes progress-pulse {
    0%, 100% { width: 30%; transform: translateX(0); }
    50%      { width: 50%; transform: translateX(50%); }
}

.gap-2 { gap: var(--sp-2); }

/* Documents 2-col layout */
.doc-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: var(--sp-6);
    align-items: start;
}

/* Folders sidebar */
.doc-folders {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    padding: var(--sp-3);
}
.doc-folders__label {
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-widest);
    text-transform: uppercase;
    color: var(--color-fg-subtle);
    padding: var(--sp-2) var(--sp-3) var(--sp-1);
}
.doc-folder {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    color: var(--color-fg);
    cursor: pointer;
    transition: background var(--d-fast);
}
.doc-folder:hover { background: var(--color-bg-hover); }
.doc-folder--active {
    background: var(--color-primary-light);
    color: var(--p-indigo-700);
    font-weight: var(--fw-semibold);
}
.doc-folder__count {
    margin-left: auto;
    font-size: 11px;
    color: var(--color-fg-muted);
}
.doc-folder--active .doc-folder__count { color: var(--p-indigo-600); }

/* Doc card additions */
.doc-card--indexing { border-color: var(--p-amber-500); }
.doc-card__more {
    width: 28px; height: 28px;
    border-radius: var(--r-md);
    border: none;
    background: transparent;
    color: var(--color-fg-muted);
    cursor: pointer;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.doc-card__more:hover { background: var(--color-bg-hover); }
.doc-card__meta-sep { color: var(--color-fg-subtle); margin: 0 1px; }
.doc-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--sp-3);
    border-top: 1px solid var(--color-border);
    margin-top: var(--sp-3);
}
.doc-card__chunks {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
}
.doc-card__chunks strong { color: var(--color-fg); font-weight: var(--fw-semibold); }

/* Context menu */
.doc-card__menu {
    position: absolute;
    top: 44px; right: var(--sp-3);
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-lg);
    z-index: 10;
    min-width: 130px;
    overflow: hidden;
}
.doc-card__menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    cursor: pointer;
    padding: var(--sp-2) var(--sp-3);
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--fs-sm);
    color: var(--color-fg);
    transition: background var(--d-fast);
    text-align: left;
}
.doc-card__menu-item:hover { background: var(--color-bg-hover); }
.doc-card__menu-item--danger { color: var(--color-error-fg); }
.doc-card__menu-item--danger:hover { background: var(--color-error-bg); }

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}
.toolbar__search {
    position: relative;
    flex: 1;
    max-width: 500px;
}
.toolbar__search-icon {
    position: absolute;
    left: var(--sp-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-fg-subtle);
    pointer-events: none;
}
.toolbar__search .input {
    padding-left: calc(var(--sp-3) * 2 + 16px);
    width: 100%;
}

/* Visibility toggle (upload modal) */
.vis-toggle {
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: var(--r-md);
    overflow: hidden;
}
.vis-toggle__btn {
    flex: 1;
    padding: var(--sp-2) var(--sp-3);
    background: none;
    border: none;
    font-size: var(--fs-sm);
    color: var(--color-fg-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    transition: background var(--d-fast), color var(--d-fast);
}
.vis-toggle__btn + .vis-toggle__btn { border-left: 1px solid var(--color-border); }
.vis-toggle__btn:hover { background: var(--color-bg-hover); color: var(--color-fg); }
.vis-toggle__btn--active {
    background: var(--color-primary-light);
    color: var(--p-indigo-700);
    font-weight: var(--fw-semibold);
}

.chat-layout {
    display: grid;
    /* minmax(0, 1fr) thay vì 1fr — quan trọng: cho phép middle column co lại khi
       content (msg dài, code block, URL) muốn expand. Không có 0 minimum thì
       content sẽ đẩy chat-main rộng ra → composer biến mất khỏi viewport. */
    grid-template-columns: 280px minmax(0, 1fr) 320px;
    height: calc(100vh - var(--topbar-h));
    background: var(--color-bg-app);
    overflow: hidden;
    /* Cancel .main padding để fill toàn bộ */
    margin: calc(var(--sp-6) * -1) calc(var(--sp-8) * -1);
}
@media (max-width: 1280px) {
    .chat-layout { grid-template-columns: 240px minmax(0, 1fr); }
    .context-pane { display: none; }
}
@media (max-width: 768px) {
    .chat-layout { grid-template-columns: minmax(0, 1fr); }
    .conv-pane { display: none; }
}

.conv-pane {
    background: var(--color-bg-surface);
    border-right: 1px solid var(--color-border);
    display: flex; flex-direction: column;
    min-height: 0; /* grid item: prevent auto min-height from expanding past grid row */
    overflow: hidden;
}
.conv-pane__header {
    padding: var(--sp-4);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between;
}
.conv-pane__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
}
.conv-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-2);
}
.conv-item {
    padding: var(--sp-3);
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: background var(--d-fast);
    position: relative;
}
.conv-item:hover { background: var(--color-bg-hover); }
.conv-item--active { background: var(--color-primary-light); }
.conv-item__delete {
    position: absolute;
    top: 50%; right: var(--sp-2);
    transform: translateY(-50%);
    display: none;
    align-items: center; justify-content: center;
    width: 24px; height: 24px;
    border: none; background: transparent;
    border-radius: var(--r-sm);
    color: var(--color-fg-muted);
    cursor: pointer;
    padding: 0;
}
.conv-item:hover .conv-item__delete { display: flex; }
.conv-item__delete:hover { background: var(--color-danger-light, #fee2e2); color: var(--color-danger, #ef4444); }
.conv-item__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.conv-item__preview {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.conv-item__time {
    font-size: 11px;
    color: var(--color-fg-subtle);
}

.chat-main {
    display: flex; flex-direction: column;
    position: relative;     /* anchor cho entity-panel absolute */
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}
.chat-stream {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;  /* không cho scroll ngang — nội dung phải wrap */
    min-height: 0;
    padding: var(--sp-6) var(--sp-8);
}
.chat-stream__inner {
    max-width: 760px;
    margin: 0 auto;
    display: flex; flex-direction: column;
    gap: var(--sp-6);
    min-width: 0;
}

/* Composer luôn fixed ở đáy chat-main, không scroll. */
.composer { flex-shrink: 0; }

/* === Mention picker dropdown (đặt phía trên composer) === */
.mention-picker {
    position: absolute;
    left: var(--sp-6);
    right: var(--sp-6);
    bottom: 100%;
    margin-bottom: var(--sp-2);
    max-width: 480px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-lg);
    overflow: hidden;
    max-height: 280px;
    overflow-y: auto;
    z-index: 10;
}
.mention-picker__hint {
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    background: var(--color-bg-app);
    border-bottom: 1px solid var(--color-border);
}
.mention-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--d-fast);
}
.mention-item:hover,
.mention-item--active {
    background: var(--color-primary-light);
}
.mention-item__icon {
    width: 28px; height: 28px;
    border-radius: var(--r-md);
    background: var(--color-bg-muted);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.mention-item__body { flex: 1; min-width: 0; }
.mention-item__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mention-item__sub {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.msg {
    display: flex;
    gap: var(--sp-3);
}
.msg__avatar {
    width: 32px; height: 32px;
    border-radius: var(--r-lg);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-weight: var(--fw-bold);
    font-size: var(--fs-sm);
}
.msg--user .msg__avatar {
    background: var(--p-slate-200);
    color: var(--p-slate-700);
}
.msg--ai .msg__avatar {
    background: var(--gradient-ai);
    color: white;
}
.msg__body { flex: 1; min-width: 0; }
.msg__name {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    margin-bottom: var(--sp-1);
}
.msg__content {
    font-size: var(--fs-md);
    line-height: var(--lh-relaxed);
    color: var(--color-fg);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}
/* Markdown-rendered content: disable pre-wrap, style HTML elements */
.msg__content--markdown {
    white-space: normal;
}
.msg__content--markdown p { margin: 0 0 0.6em; }
.msg__content--markdown p:last-child { margin-bottom: 0; }
.msg__content--markdown h1,
.msg__content--markdown h2,
.msg__content--markdown h3,
.msg__content--markdown h4 {
    font-weight: var(--fw-bold);
    margin: 0.8em 0 0.3em;
    line-height: 1.3;
}
.msg__content--markdown h1 { font-size: 1.25em; }
.msg__content--markdown h2 { font-size: 1.1em; }
.msg__content--markdown h3 { font-size: 1em; }
.msg__content--markdown ul,
.msg__content--markdown ol {
    margin: 0.4em 0 0.6em 1.4em;
    padding: 0;
}
.msg__content--markdown li { margin-bottom: 0.2em; }
.msg__content--markdown code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.875em;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.1em 0.35em;
}
.msg__content--markdown pre {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--r-md);
    padding: var(--sp-3);
    overflow-x: auto;
    margin: 0.5em 0;
}
.msg__content--markdown pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.85em;
}
.msg__content--markdown blockquote {
    border-left: 3px solid var(--color-border);
    margin: 0.5em 0;
    padding: 0.2em 0.8em;
    color: var(--color-fg-muted);
}
.msg__content--markdown table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
    font-size: var(--fs-sm);
}
.msg__content--markdown th,
.msg__content--markdown td {
    border: 1px solid var(--color-border);
    padding: 0.35em 0.6em;
    text-align: left;
}
.msg__content--markdown th { background: var(--color-bg-surface); font-weight: var(--fw-semibold); }
.msg__content--markdown a { color: var(--color-primary); text-decoration: underline; }
.msg__content--markdown hr { border: none; border-top: 1px solid var(--color-border); margin: 0.8em 0; }
/* Task list checkboxes */
.msg__content--markdown input[type="checkbox"] { margin-right: 0.3em; }
.msg__sources {
    margin-top: var(--sp-3);
    padding: var(--sp-3);
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
}
.msg__sources-label {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--color-fg-muted);
    text-transform: uppercase;
    margin-bottom: var(--sp-2);
}
.src-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin-right: var(--sp-2);
    margin-bottom: var(--sp-1);
    background: var(--color-primary-light);
    color: var(--p-indigo-700);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    border-radius: var(--r-full);
}
.src-chip__num {
    width: 16px; height: 16px;
    background: var(--p-indigo-500);
    color: white;
    border-radius: var(--r-full);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 10px;
    font-weight: var(--fw-bold);
}

.ai-step-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    color: var(--color-fg-muted);
    font-size: var(--text-sm);
}
.ai-step-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    flex-shrink: 0;
    animation: step-pulse 1.2s ease-in-out infinite;
}
@keyframes step-pulse {
    0%, 100% { opacity: 0.35; transform: scale(0.8); }
    50%       { opacity: 1;    transform: scale(1.15); }
}
.ai-step-text {
    font-style: italic;
}

.composer {
    padding: var(--sp-4) var(--sp-6) var(--sp-6);
    background: var(--color-bg-app);
}
.composer__inner {
    max-width: 760px;
    margin: 0 auto;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--r-2xl);
    box-shadow: var(--sh-md);
    overflow: hidden;
}
.composer__inner:focus-within {
    border-color: var(--color-border-focus);
    box-shadow: var(--sh-ring-primary), var(--sh-md);
}
.composer__textarea {
    width: 100%;
    border: none;
    padding: var(--sp-4);
    font-size: var(--fs-md);
    line-height: var(--lh-relaxed);
    resize: none;
    background: transparent;
    min-height: 60px;
    max-height: 240px;
    outline: none;
    font-family: var(--font-sans);
}
.composer__toolbar {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-top: 1px solid var(--color-border);
}
.composer__send {
    margin-left: auto;
    width: 36px; height: 36px;
    border-radius: var(--r-lg);
    background: var(--gradient-ai);
    color: white;
    border: none;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px -2px rgb(99 102 241 / 0.5);
}
.composer__send:disabled { opacity: 0.5; cursor: not-allowed; }

.composer__chip {
    display: inline-flex; align-items: center; gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-2);
    border: 1px solid var(--color-border);
    border-radius: var(--r-md);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.composer__chip:hover:not(:disabled) {
    background: var(--color-surface-hover, var(--color-border));
    color: var(--color-text);
}
.composer__chip:disabled { opacity: 0.5; cursor: not-allowed; }
.composer__chip--loading { opacity: 0.7; }
.composer__chip--attached {
    background: var(--color-primary-subtle, #eef2ff);
    border-color: var(--color-primary, #6366f1);
    color: var(--color-primary, #6366f1);
}
.composer__chip-remove {
    background: none; border: none; padding: 0 0 0 var(--sp-1);
    cursor: pointer; color: inherit; font-size: 1rem; line-height: 1;
}
.spinner-xs {
    width: 12px; height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.composer__hint {
    max-width: 760px;
    margin: var(--sp-3) auto 0;
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--color-fg-subtle);
}

/* context-pane: chia 2 phần, flex column */
.context-pane {
    background: var(--color-bg-surface);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.context-pane__section {
    padding: var(--sp-4);
    overflow-y: auto;
}
.context-pane__section--context {
    flex: 1;
    min-height: 0;
    border-bottom: 1px solid var(--color-border);
}
.context-pane__section--nav {
    flex-shrink: 0;
    max-height: 50%;
    overflow-y: auto;
}
.context-pane__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    margin-bottom: var(--sp-2);
}
.context-pane__sub {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    margin-bottom: var(--sp-4);
}
.source-item {
    padding: var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    margin-bottom: var(--sp-2);
}
.source-item__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    margin-bottom: 2px;
}
.source-item__excerpt {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty-chat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: var(--sp-0);
    text-align: center;
}
.empty-chat__icon {
    width: 72px;
    height: 72px;
    margin-bottom: var(--sp-4);
    display: block;
    object-fit: contain;
}
.empty-chat__title {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-bold);
    margin-bottom: var(--sp-3);
}
.empty-chat__sub {
    color: var(--color-fg-muted);
    margin-bottom: var(--sp-6);
}
.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-3);
    max-width: 600px;
}
.suggestion-card {
    padding: var(--sp-4);
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--r-xl);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--d-fast), transform var(--d-fast);
}
.suggestion-card:hover {
    border-color: var(--p-indigo-300);
    transform: translateY(-2px);
}
.suggestion-card__icon { font-size: 24px; margin-bottom: var(--sp-2); }
.suggestion-card__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    margin-bottom: 2px;
}
.suggestion-card__desc {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    line-height: var(--lh-relaxed);
}

/* ============================================================
   TEMPLATES PAGE
============================================================ */

.tpl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--sp-5);
}

/* Card base — no padding (thumbnail touches edges) */
.tpl-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    transition: border-color var(--d-fast), box-shadow var(--d-fast);
    display: flex;
    flex-direction: column;
}
.tpl-card:hover {
    border-color: var(--p-indigo-300);
    box-shadow: var(--sh-lg);
}

/* Thumbnail preview area */
.tpl-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--p-slate-100);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--color-border);
}

/* Simulated doc preview */
.tpl-thumb__doc {
    width: 60%;
    height: 80%;
    background: white;
    box-shadow: var(--sh-md);
    border-radius: var(--r-sm);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tpl-thumb__doc-title {
    height: 8px;
    width: 70%;
    background: var(--p-slate-900);
    border-radius: 2px;
    margin-bottom: 6px;
}
.tpl-thumb__doc-line {
    height: 3px;
    background: var(--p-slate-300);
    border-radius: 1px;
}
.tpl-thumb__doc-line--80  { width: 80%; }
.tpl-thumb__doc-line--60  { width: 60%; }
.tpl-thumb__doc-line--90  { width: 90%; }
.tpl-thumb__doc-line--accent { background: var(--p-indigo-300); }

/* Category badge in thumbnail (top-left absolute) */
.tpl-cat {
    position: absolute;
    top: var(--sp-3);
    left: var(--sp-3);
    padding: 4px 10px;
    border-radius: var(--r-full);
    font-size: 10px;
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: white;
}

/* Type / popular badge (top-right corner) */
.tpl-badge-corner {
    position: absolute;
    top: var(--sp-3);
    right: var(--sp-3);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--r-full);
    font-size: 10px;
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
    box-shadow: var(--sh-sm);
}

/* Card body (below thumbnail) */
.tpl-card__body {
    padding: var(--sp-4) var(--sp-5);
    flex: 1;
    display: flex;
    flex-direction: column;
}
.tpl-card__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-tight);
    margin-bottom: var(--sp-1);
}
.tpl-card__desc {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    line-height: var(--lh-relaxed);
    margin-bottom: var(--sp-3);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}
.tpl-card__meta {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    margin-bottom: var(--sp-3);
}
.tpl-card__meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.tpl-card__footer {
    margin-top: auto;
    padding-top: var(--sp-3);
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: var(--sp-2);
}
.tpl-card__footer .btn { flex: 1; }

/* Legacy (backward compat — old card badge in body) */
.tpl-card__cat {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--r-full);
    font-size: 10px;
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    color: white;
    margin-bottom: var(--sp-3);
}

/* AI generate card */
.tpl-card--ai {
    background: var(--gradient-ai);
    color: white;
    border: none;
    position: relative;
    overflow: hidden;
}
.tpl-card--ai::after {
    content: '';
    position: absolute;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgb(255 255 255 / 0.2), transparent);
    top: -50px; right: -50px;
    pointer-events: none;
}
.tpl-card--ai .tpl-card__title,
.tpl-card--ai .tpl-card__desc { color: white; }
.tpl-card--ai .tpl-card__footer { border-top-color: rgb(255 255 255 / 0.2); }
.tpl-card-ai__icon {
    width: 64px; height: 64px;
    background: rgb(255 255 255 / 0.15);
    border-radius: var(--r-2xl);
    backdrop-filter: blur(10px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--sp-4);
    font-size: 32px;
}

/* Variable chips */
.var-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: var(--sp-3);
}
.var-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    background: var(--color-primary-light);
    color: var(--p-indigo-700);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: var(--fw-semibold);
    border-radius: var(--r-sm);
    margin-right: 4px;
    margin-bottom: 4px;
}

/* Modal */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgb(15 23 42 / 0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: var(--sp-6);
}
.modal {
    background: var(--color-bg-surface);
    border-radius: var(--r-2xl);
    box-shadow: var(--sh-xl);
    max-width: 760px;
    width: 100%;
    max-height: 90vh;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.modal--lg { max-width: 920px; }
.modal__header {
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal__title {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
}
.modal__body {
    padding: var(--sp-6);
    overflow-y: auto;
}
.modal__footer {
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--color-border);
    display: flex; gap: var(--sp-3); justify-content: flex-end;
    background: var(--p-slate-50);
}

.placeholder-chip {
    display: inline;
    padding: 1px 6px;
    background: var(--color-primary-light);
    color: var(--p-indigo-700);
    font-family: var(--font-mono);
    font-size: 0.85em;
    border-radius: var(--r-sm);
    border: 1px dashed var(--p-indigo-300);
}

/* ============================================================
   CUSTOMERS / USERS / COMPANY — shared support styles
============================================================ */

/* Info / detail sections (Customer detail, Company info) */
.info-section {
    padding-top: var(--sp-3);
    border-top: 1px solid var(--color-border);
}
.info-section:first-child { border-top: none; padding-top: 0; }
.info-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    column-gap: var(--sp-4);
    row-gap: var(--sp-2);
    margin: 0;
}
.info-grid dt {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    align-self: center;
}
.info-grid dd {
    font-size: var(--fs-sm);
    margin: 0;
    color: var(--color-fg);
}

/* Activity timeline */
.timeline {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}
.timeline::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--color-border);
}
.timeline-item {
    position: relative;
    padding-left: var(--sp-5);
    padding-bottom: var(--sp-4);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: var(--r-full);
    background: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-bg-surface);
}

/* Avatar size variant */
.avatar--lg {
    width: 56px;
    height: 56px;
    font-size: var(--fs-lg);
}

/* Utility helpers used across pages */
.grow         { flex: 1; }
.font-semibold{ font-weight: var(--fw-semibold); }
.text-sm      { font-size: var(--fs-sm); }
.text-xs      { font-size: var(--fs-xs); }
.text-muted   { color: var(--color-fg-muted); }
.mt-6         { margin-top: var(--sp-6); }
.mb-4         { margin-bottom: var(--sp-4); }
.gap-3        { gap: var(--sp-3); }
.row          { display: flex; align-items: center; }

/* Stats grid (Customers stats cards) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--sp-4);
}
.stat-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    padding: var(--sp-4) var(--sp-5);
}
.stat-card__label {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-1);
}
.stat-card__value {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-bold);
    line-height: 1.1;
}

/* Save / action bar pinned at bottom of settings pages */
.save-bar {
    position: sticky;
    bottom: 0;
    background: var(--color-bg-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--sp-3) var(--sp-5);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin: 0 calc(var(--sp-5) * -1) calc(var(--sp-5) * -1);
}

/* Settings layout (Company page) */
.settings-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: var(--sp-6);
    align-items: start;
}
@media (max-width: 900px) {
    .settings-layout { grid-template-columns: 1fr; }
}
.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: sticky;
    top: var(--sp-4);
}
.settings-nav__item {
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    color: var(--color-fg-muted);
    cursor: pointer;
    background: none;
    border: none;
    text-align: left;
    transition: background var(--d-fast), color var(--d-fast);
}
.settings-nav__item:hover { background: var(--color-bg-hover); color: var(--color-fg); }
.settings-nav__item--active {
    background: var(--color-primary-light);
    color: var(--p-indigo-700);
    font-weight: var(--fw-semibold);
}
.settings-section {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    padding: var(--sp-5);
    margin-bottom: var(--sp-5);
}
.settings-section__title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    margin: 0 0 var(--sp-1);
}
.settings-section__desc {
    font-size: var(--fs-sm);
    color: var(--color-fg-muted);
    margin: 0 0 var(--sp-4);
}

/* Filter chip (Customers status filter) */
.filter-chip {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--r-full);
    padding: 6px 14px;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-fg-muted);
    cursor: pointer;
    transition: all var(--d-fast);
}
.filter-chip:hover { border-color: var(--p-indigo-300); color: var(--color-fg); }
.filter-chip--active {
    background: var(--color-primary-light);
    border-color: var(--p-indigo-300);
    color: var(--p-indigo-700);
}

/* Form row 2-col */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
}
@media (max-width: 640px) {
    .form-row-2 { grid-template-columns: 1fr; }
}

/* Checkbox row */
.form-check {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    cursor: pointer;
}
.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

/* Compact select for inline edit (Users role change) */
.select--sm {
    height: var(--btn-h-sm);
    padding: 0 var(--sp-2);
    font-size: var(--fs-xs);
}

/* Table wrap */
.table-wrap {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-size: var(--fs-sm);
    border-bottom: 1px solid var(--color-border);
}
.table th {
    background: var(--p-slate-50);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-fg-muted);
    font-weight: var(--fw-semibold);
}
.table tbody tr:last-child td { border-bottom: none; }

/* Dynamic entity surface switcher */
.entity-surface-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--color-bg-muted) 78%, #fff);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.entity-surface-switcher__btn {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: calc(var(--r-lg) - 4px);
    color: var(--color-fg-muted);
    background: transparent;
    box-shadow: none;
}

.entity-surface-switcher__btn:hover:not(:disabled) {
    background: rgba(148, 163, 184, 0.14);
    color: var(--color-fg);
}

.entity-surface-switcher__btn--active,
.entity-surface-switcher__btn--active:hover:not(:disabled) {
    background: var(--color-bg-surface);
    color: var(--color-primary);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.08),
        0 0 0 1px color-mix(in srgb, var(--color-primary) 24%, transparent);
}

.entity-surface-switcher__btn i {
    font-size: 1rem;
}

/* ============================================================ */
/* Entity nav menu (context-pane bottom section)               */
/* ============================================================ */
.entity-nav { display: flex; flex-direction: column; gap: var(--sp-2); }
.entity-nav__group {
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.entity-nav__label {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    background: var(--color-bg-canvas);
    color: var(--color-fg);
}
.entity-nav__actions {
    display: flex;
    border-top: 1px solid var(--color-border);
}
.entity-nav__btn {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.entity-nav__btn:not(:last-child) { border-right: 1px solid var(--color-border); }
.entity-nav__btn:hover { background: var(--color-bg-surface-raised); color: var(--color-fg); }
.entity-nav__btn--active { background: var(--color-primary-subtle); color: var(--color-primary); font-weight: var(--fw-semibold); }

/* ============================================================ */
/* Entity panel overlay (inside chat-main, above composer)      */
/* ============================================================ */
.entity-panel {
    position: absolute;
    inset: var(--sp-4);
    bottom: calc(var(--composer-height, 160px) + var(--sp-4));
    background: var(--color-bg-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--r-xl);
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 20;
}
.entity-panel__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-surface);
    flex-shrink: 0;
}
.entity-panel__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
}
.entity-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
}
.table tbody tr:hover { background: var(--color-bg-hover); }

/* ============================================================
   ENTITY LIST PAGE (/data/{typeCode})
============================================================ */

.entity-list__title-icon {
    margin-right: var(--sp-2);
}

.page-loading {
    color: var(--color-fg-muted);
    padding: var(--sp-6) 0;
}

.entity-list-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

/* ============================================================
   UI BLOCKS — wrapper for AI-rendered components in chat
============================================================ */
.msg__ui-blocks {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-top: var(--sp-3);
}
.ui-block { min-width: 0; }

/* ============================================================
   SUMMARY CARD — AI-rendered summary widget in chat
   CSS khớp với sme-ai-screens/chat.html
============================================================ */
.sc {
    background: var(--color-bg-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--sh-sm);
    transition: box-shadow var(--d-fast);
}
.sc:hover { box-shadow: var(--sh-md); }

/* ── Hero strip — gradient accent theo colorScheme ── */
.sc__hero {
    padding: var(--sp-5) var(--sp-5) var(--sp-4);
    position: relative;
    overflow: hidden;
}
.sc__hero::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.07;
    background: var(--sc-accent, var(--gradient-ai));
}
.sc__hero--indigo { --sc-accent: linear-gradient(135deg,#6366f1,#8b5cf6); }
.sc__hero--green  { --sc-accent: linear-gradient(135deg,#10b981,#059669); }
.sc__hero--amber  { --sc-accent: linear-gradient(135deg,#f59e0b,#d97706); }
.sc__hero--rose   { --sc-accent: linear-gradient(135deg,#f43f5e,#e11d48); }
.sc__hero--cyan   { --sc-accent: linear-gradient(135deg,#06b6d4,#0891b2); }

.sc__hero-top {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    position: relative;
}
.sc__icon {
    width: 44px; height: 44px;
    border-radius: var(--r-xl);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
}
.sc__icon--indigo { background: linear-gradient(135deg,#6366f1,#8b5cf6); color: white; }
.sc__icon--green  { background: linear-gradient(135deg,#10b981,#059669); color: white; }
.sc__icon--amber  { background: linear-gradient(135deg,#f59e0b,#d97706); color: white; }
.sc__icon--rose   { background: linear-gradient(135deg,#f43f5e,#e11d48); color: white; }
.sc__icon--cyan   { background: linear-gradient(135deg,#06b6d4,#0891b2); color: white; }

.sc__hero-info { flex: 1; min-width: 0; }
.sc__type {
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-widest);
    text-transform: uppercase;
    color: var(--color-fg-subtle);
    margin-bottom: 3px;
}
.sc__name {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    color: var(--color-fg);
    line-height: 1.2;
}
.sc__meta {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}
.sc__meta-sep { color: var(--color-border); }
.sc__hero-badges {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}

/* ── KPI row ── */
.sc__kpis {
    display: grid;
    grid-template-columns: repeat(var(--sc-kpi-cols, 3), 1fr);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}
.sc__kpi {
    padding: var(--sp-4);
    text-align: center;
    border-right: 1px solid var(--color-border);
    position: relative;
}
.sc__kpi:last-child { border-right: none; }
.sc__kpi-value {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    color: var(--color-fg);
    line-height: 1;
    margin-bottom: 4px;
}
.sc__kpi-value--positive { color: #059669; }
.sc__kpi-value--negative { color: #dc2626; }
.sc__kpi-value--indigo   { color: var(--p-indigo-600); }
.sc__kpi-label {
    font-size: 11px;
    font-weight: var(--fw-medium);
    color: var(--color-fg-subtle);
    text-transform: uppercase;
    letter-spacing: var(--ls-wide);
}
.sc__kpi-delta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    margin-top: 3px;
}
.sc__kpi-delta--up   { color: #059669; }
.sc__kpi-delta--down { color: #dc2626; }
.sc__kpi-delta--flat { color: var(--color-fg-subtle); }

/* ── Sparkline ── */
.sc__sparkline {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--color-border);
}
.sc__sparkline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-3);
}
.sc__sparkline-title {
    font-size: 11px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-fg-subtle);
}
.sc__sparkline-legend {
    font-size: 11px;
    color: var(--color-fg-subtle);
}
.sc__bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 48px;
}
.sc__bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    height: 100%;
    justify-content: flex-end;
}
.sc__bar {
    width: 100%;
    border-radius: 3px 3px 0 0;
    background: var(--p-indigo-200);
    transition: background var(--d-fast);
    min-height: 3px;
}
.sc__bar--active { background: var(--gradient-ai); }
.sc__bar-label {
    font-size: 9px;
    color: var(--color-fg-subtle);
    white-space: nowrap;
}

/* ── Insights ── */
.sc__insights {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--color-border);
}
.sc__insights-title {
    font-size: 11px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-fg-subtle);
    margin-bottom: var(--sp-3);
}
.sc__insight-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.sc__insight {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--r-lg);
    background: var(--color-bg-muted);
    border: 1px solid transparent;
    transition: border-color var(--d-fast);
}
.sc__insight:hover { border-color: var(--color-border); }
.sc__insight-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}
.sc__insight-dot--green  { background: #10b981; }
.sc__insight-dot--amber  { background: #f59e0b; }
.sc__insight-dot--red    { background: #f43f5e; }
.sc__insight-dot--indigo { background: var(--p-indigo-500); }
.sc__insight-dot--gray   { background: var(--color-fg-subtle); }
.sc__insight-body { flex: 1; min-width: 0; }
.sc__insight-text {
    font-size: var(--fs-sm);
    color: var(--color-fg);
    line-height: 1.4;
}
.sc__insight-text strong { font-weight: var(--fw-semibold); }
.sc__insight-time {
    font-size: 11px;
    color: var(--color-fg-subtle);
    margin-top: 2px;
}
.sc__insight-tag {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: var(--fw-semibold);
    padding: 2px 7px;
    border-radius: var(--r-full);
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    color: var(--color-fg-muted);
    white-space: nowrap;
}

/* ── Recommendation strip ── */
.sc__recommend {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-5);
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    border-bottom: 1px solid var(--p-indigo-100);
}
.sc__recommend-icon {
    width: 30px; height: 30px;
    background: var(--gradient-ai);
    border-radius: var(--r-lg);
    display: flex; align-items: center; justify-content: center;
    color: white;
    flex-shrink: 0;
    font-size: 14px;
}
.sc__recommend-text {
    flex: 1;
    font-size: var(--fs-xs);
    color: var(--p-indigo-800);
    line-height: 1.4;
}
.sc__recommend-text strong { font-weight: var(--fw-semibold); }

/* ── Actions footer ── */
.sc__actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    flex-wrap: wrap;
}

/* ============================================================
   ENTITY ACTION BUTTONS — dùng cho EntityCard + SummaryCard
============================================================ */
.entity-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--r-md);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    cursor: pointer;
    border: 1px solid var(--color-border);
    background: var(--color-bg-surface);
    color: var(--color-fg);
    transition: background var(--d-fast), border-color var(--d-fast), color var(--d-fast), transform var(--d-fast);
    white-space: nowrap;
}
.entity-action:hover {
    background: var(--color-bg-hover);
    border-color: var(--p-indigo-300);
    color: var(--p-indigo-700);
    transform: translateY(-1px);
}
.entity-action--primary {
    background: var(--p-indigo-600);
    border-color: var(--p-indigo-600);
    color: white;
}
.entity-action--primary:hover {
    background: var(--p-indigo-700);
    border-color: var(--p-indigo-700);
    color: white;
    transform: translateY(-1px);
}
.entity-action--danger { color: var(--color-error); border-color: transparent; }
.entity-action--danger:hover { background: #fef2f2; border-color: #fca5a5; }

.entity-list__toolbar {
    display: flex;
    gap: var(--sp-3);
}

.entity-list__search {
    max-width: 320px;
}

/* Create modal overlay */
.entity-create-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.entity-create-modal {
    background: var(--color-bg-surface);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-lg);
    width: min(560px, 92vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.entity-create-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--color-border);
    font-weight: var(--fw-semibold);
}

.entity-create-modal__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-5);
}

/* Entity detail side panel */
.entity-detail-overlay {
    position: fixed;
    inset: 0;
    top: var(--topbar-h);
    background: rgba(0, 0, 0, 0.3);
    z-index: var(--z-overlay);
}
.entity-detail-panel {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(480px, 100vw);
    background: var(--color-bg-surface);
    border-left: 1px solid var(--color-border);
    box-shadow: var(--sh-xl);
    z-index: calc(var(--z-overlay) + 1);
    display: flex;
    flex-direction: column;
}
.entity-detail-panel__header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    background: var(--color-bg-surface);
}
.entity-detail-panel__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.entity-detail-panel__actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}
.entity-detail-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
}

/* Danger button variant */
.btn--danger {
    background: var(--color-error-bg, #fee2e2);
    color: var(--color-error-fg, #b91c1c);
    border-color: transparent;
}
.btn--danger:hover {
    background: #fca5a5;
    color: #b91c1c;
}

/* ============================================================
   ENTITY CARD — AI-rendered entity record in chat (EntityCard.razor)
============================================================ */
.ec {
    background: var(--color-bg-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--r-xl);
    overflow: hidden;
    font-size: var(--fs-sm);
    transition: box-shadow var(--d-fast);
}
.ec:hover { box-shadow: var(--sh-md); }

/* ── Hero ── */
.ec__hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    position: relative;
    overflow: hidden;
}
.ec__hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--ec-accent, var(--gradient-ai));
    opacity: 0.09;
}
.ec__hero--indigo { --ec-accent: linear-gradient(135deg,#6366f1,#8b5cf6); }
.ec__hero--green  { --ec-accent: linear-gradient(135deg,#10b981,#059669); }
.ec__hero--amber  { --ec-accent: linear-gradient(135deg,#f59e0b,#d97706); }
.ec__hero--rose   { --ec-accent: linear-gradient(135deg,#f43f5e,#e11d48); }
.ec__hero--cyan   { --ec-accent: linear-gradient(135deg,#06b6d4,#0891b2); }

.ec__hero-main {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    position: relative;
    min-width: 0;
    flex: 1;
}
.ec__avatar {
    width: 40px; height: 40px;
    border-radius: var(--r-xl);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: var(--fw-bold);
    color: white;
    flex-shrink: 0;
    letter-spacing: var(--ls-tight);
}
.ec__avatar--indigo { background: linear-gradient(135deg,#6366f1,#8b5cf6); }
.ec__avatar--green  { background: linear-gradient(135deg,#10b981,#059669); }
.ec__avatar--amber  { background: linear-gradient(135deg,#f59e0b,#d97706); }
.ec__avatar--rose   { background: linear-gradient(135deg,#f43f5e,#e11d48); }
.ec__avatar--cyan   { background: linear-gradient(135deg,#06b6d4,#0891b2); }

.ec__hero-info { min-width: 0; flex: 1; }
.ec__type {
    display: block;
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-fg-muted);
    margin-bottom: 2px;
}
.ec__name {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    color: var(--color-fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Status badge (hero top-right) ── */
.ec__badge {
    position: relative;
    flex-shrink: 0;
    align-self: flex-start;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    padding: 3px 10px;
    border-radius: var(--r-full);
    white-space: nowrap;
}
.ec__badge--green { background: #dcfce7; color: #15803d; }
.ec__badge--red   { background: #fee2e2; color: #b91c1c; }
.ec__badge--amber { background: #fef3c7; color: #b45309; }
.ec__badge--blue  { background: #dbeafe; color: #1d4ed8; }
.ec__badge--gray  { background: var(--p-slate-100); color: var(--p-slate-600); }

/* ── KPI row ── */
.ec__kpis {
    display: grid;
    grid-template-columns: repeat(var(--ec-kpi-cols, 3), 1fr);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}
.ec__kpi {
    padding: var(--sp-3) var(--sp-4);
    text-align: center;
    border-right: 1px solid var(--color-border);
}
.ec__kpi:last-child { border-right: none; }
.ec__kpi-value {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    color: var(--color-primary);
    font-variant-numeric: tabular-nums;
    margin-bottom: 2px;
    line-height: 1.2;
}
.ec__kpi-label {
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-fg-muted);
}

/* ── Section wrapper ── */
.ec__section { border-bottom: 1px solid var(--color-border); }
.ec__section:last-child { border-bottom: none; }
.ec__section-title {
    padding: var(--sp-2) var(--sp-5) 0;
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-fg-subtle);
}

/* ── Fields 2-col grid ── */
.ec__fields {
    padding: var(--sp-3) var(--sp-5) var(--sp-4);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3) var(--sp-6);
}
@media (max-width: 420px) { .ec__fields { grid-template-columns: 1fr; } }

.ec__field { display: flex; flex-direction: column; gap: 2px; }
.ec__field-label {
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-fg-subtle);
}
.ec__field-value {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Actions footer ── */
.ec__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-5);
    background: var(--color-bg-surface-raised);
}

/* ============================================================
   DYNAMIC FORM — AI-rendered smart form in chat (DynamicForm.razor)
============================================================ */
.df {
    background: var(--color-bg-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--r-xl);
    overflow: hidden;
    font-size: var(--fs-sm);
}

/* ── Header ── */
.df__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-surface-raised);
}
.df__type {
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-primary);
    background: var(--color-primary-subtle);
    padding: 2px 8px;
    border-radius: var(--r-full);
}
.df__intent {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    padding: 3px 10px;
    border-radius: var(--r-full);
}
.df__intent--create { background: #dcfce7; color: #15803d; }
.df__intent--edit   { background: var(--p-indigo-100); color: var(--p-indigo-700); }

/* ── Step progress ── */
.df__steps {
    display: flex;
    align-items: center;
    padding: var(--sp-4) var(--sp-5);
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    scrollbar-width: none;
}
.df__steps::-webkit-scrollbar { display: none; }

.df__step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}
.df__step-dot {
    width: 26px; height: 26px;
    border-radius: var(--r-full);
    border: 2px solid var(--color-border);
    background: var(--color-bg-surface);
    color: var(--color-fg-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: var(--fw-semibold);
    transition: all var(--d-fast);
}
.df__step-label {
    font-size: 10px;
    font-weight: var(--fw-medium);
    color: var(--color-fg-subtle);
    white-space: nowrap;
    transition: color var(--d-fast);
}
.df__step--active .df__step-dot {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: white;
    box-shadow: 0 0 0 3px var(--color-primary-ring);
}
.df__step--active .df__step-label {
    color: var(--color-primary);
    font-weight: var(--fw-semibold);
}
.df__step--done .df__step-dot {
    border-color: #10b981;
    background: #10b981;
    color: white;
}
.df__step--done .df__step-label { color: #10b981; }

.df__step-sep {
    flex: 1;
    min-width: 24px;
    height: 2px;
    background: var(--color-border);
    margin: 0 4px;
    margin-top: -14px; /* align with dot center */
    transition: background var(--d-fast);
}
.df__step-sep--done { background: #10b981; }

.df__step-title {
    padding: var(--sp-3) var(--sp-5) 0;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--color-fg-muted);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
}

/* ── Fields body ── */
.df__body {
    padding: var(--sp-4) var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.df__readonly-note {
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--p-indigo-100);
    border-radius: var(--r-xl);
    background: linear-gradient(135deg, rgba(99,102,241,.08), rgba(59,130,246,.04));
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
    line-height: 1.6;
}

.df__readonly-empty {
    color: var(--color-fg-subtle);
    font-size: var(--fs-sm);
}

.df__readonly-value {
    padding: var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--input-radius);
    background: var(--color-bg-surface-raised);
    color: var(--color-fg);
    font-size: var(--fs-sm);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.df__field {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.df__field--prefilled > .input,
.df__field--prefilled > .textarea,
.df__field--prefilled > .df__select-wrap > .df__select {
    border-color: var(--p-indigo-300);
    background: var(--p-indigo-50);
}

.df__label {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
    flex-wrap: wrap;
    row-gap: 3px;
}
.df__req {
    color: var(--color-error-fg);
    font-size: var(--fs-xs);
}
.df__prefill-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: var(--fw-semibold);
    color: var(--p-indigo-600);
    background: var(--p-indigo-100);
    border: 1px solid var(--p-indigo-200);
    padding: 1px 6px;
    border-radius: var(--r-full);
    margin-left: var(--sp-1);
}
.df__hint {
    font-size: var(--fs-xs);
    color: var(--color-fg-subtle);
    margin-top: 2px;
}

/* ── Select ── */
.df__select-wrap {
    position: relative;
}
.df__select {
    width: 100%;
    height: var(--input-h);
    padding: 0 var(--sp-8) 0 var(--sp-3);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--input-radius);
    font-size: var(--fs-sm);
    color: var(--color-fg);
    appearance: none;
    cursor: pointer;
    transition: border-color var(--d-fast), box-shadow var(--d-fast);
}
.df__select:hover  { border-color: var(--color-border-strong); }
.df__select:focus  { border-color: var(--color-border-focus); box-shadow: var(--sh-ring-primary); outline: none; }
.df__select-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--color-fg-muted);
    pointer-events: none;
}

/* ── Radio group ── */
.df__radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}
.df__radio-opt {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 7px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--r-lg);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-fg-muted);
    background: var(--color-bg-surface);
    transition: all var(--d-fast);
    user-select: none;
}
.df__radio-opt input[type="radio"] {
    accent-color: var(--color-primary);
    width: 14px; height: 14px;
    flex-shrink: 0;
}
.df__radio-opt:hover { border-color: var(--p-indigo-300); color: var(--color-fg); }
.df__radio-opt--active {
    border-color: var(--color-primary);
    background: var(--color-primary-subtle);
    color: var(--color-primary);
    font-weight: var(--fw-semibold);
}

/* ── Toggle switch ── */
.df__toggle {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    cursor: pointer;
    user-select: none;
}
.df__toggle-input {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
    pointer-events: none;
}
.df__toggle-track {
    position: relative;
    width: 40px; height: 22px;
    background: var(--p-slate-300);
    border-radius: var(--r-full);
    flex-shrink: 0;
    transition: background var(--d-fast);
}
.df__toggle-thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: white;
    border-radius: var(--r-full);
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: transform var(--d-fast);
}
.df__toggle-input:checked ~ .df__toggle-track         { background: var(--color-primary); }
.df__toggle-input:checked ~ .df__toggle-track .df__toggle-thumb { transform: translateX(18px); }

.df__toggle-desc {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.df__toggle-val {
    font-size: var(--fs-xs);
    color: var(--color-fg-subtle);
    transition: color var(--d-fast);
}
.df__toggle-val--on { color: var(--color-primary); font-weight: var(--fw-medium); }

/* ── Array field editor ── */
.df__array { display: flex; flex-direction: column; gap: var(--sp-2); }

.df__array-rows { display: flex; flex-direction: column; gap: var(--sp-2); }

.df__array-row {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    background: var(--color-surface-raised, #f8f9fa);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--sp-2) var(--sp-3);
}

.df__array-row-fields {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-3);
}

.df__array-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 120px;
    flex: 1;
}

.df__array-cell-label {
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-fg-subtle);
}

.input--sm {
    height: 30px;
    padding: 0 var(--sp-2);
    font-size: var(--fs-sm);
}

.df__array-remove {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-top: 18px;
    border: none;
    background: transparent;
    color: var(--color-fg-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.df__array-remove:hover { background: var(--color-error-bg, #fee2e2); color: var(--color-error-fg, #dc2626); }

.df__array-add {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-primary);
    background: transparent;
    border: 1px dashed var(--color-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
    align-self: flex-start;
}
.df__array-add:hover { background: var(--color-primary-subtle, rgba(99,102,241,.08)); }

/* ── Validation error ── */
.df__error {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin: 0 var(--sp-5);
    padding: var(--sp-2) var(--sp-3);
    background: var(--color-error-bg);
    color: var(--color-error-fg);
    border: 1px solid var(--p-red-100);
    border-radius: var(--r-lg);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
}

/* ── Footer ── */
.df__footer {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-5);
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-surface-raised);
}

/* ============================================================
   DATA TABLE — AI-rendered grid in chat (DataTable.razor)
============================================================ */
.dt {
    background: var(--color-bg-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--r-xl);
    overflow: hidden;
    font-size: var(--fs-sm);
}

/* ── Header ── */
.dt__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-surface-raised);
    flex-wrap: wrap;
}
.dt__title-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.dt__type {
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-primary);
    background: var(--color-primary-subtle);
    padding: 2px 8px;
    border-radius: var(--r-full);
}
.dt__count {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
}
.dt__filter-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.dt__filter-ico {
    position: absolute;
    left: 8px;
    width: 14px; height: 14px;
    color: var(--color-fg-subtle);
    pointer-events: none;
}
.dt__filter {
    padding: 5px 10px 5px 28px;
    border: 1px solid var(--color-border);
    border-radius: var(--r-md);
    background: var(--color-bg-input);
    color: var(--color-fg);
    font-size: var(--fs-xs);
    width: 180px;
    outline: none;
    transition: border-color var(--d-fast), box-shadow var(--d-fast);
}
.dt__filter:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-ring);
}
.dt__filter::-webkit-search-cancel-button { cursor: pointer; }

/* ── Scroll wrapper ── */
.dt__scroll {
    overflow-x: auto;
}

/* ── Table ── */
.dt__table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}
.dt__th {
    padding: 9px var(--sp-4);
    text-align: left;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-fg-muted);
    background: var(--color-bg-surface-raised);
    border-bottom: 1px solid var(--color-border);
    user-select: none;
    white-space: nowrap;
}
.dt__th--sortable { cursor: pointer; }
.dt__th--sortable:hover { background: var(--color-bg-hover); color: var(--color-fg); }
.dt__th--active { color: var(--color-primary); }
.dt__sort-icon {
    display: inline-block;
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.35;
    font-style: normal;
}
.dt__sort-icon--active { opacity: 1; }
.dt__th--active .dt__sort-icon { opacity: 1; }

.dt__row:nth-child(even) { background: var(--color-bg-surface-raised); }
.dt__row:hover { background: var(--p-indigo-50); }
.dt__row--clickable { cursor: pointer; }

.dt__td {
    padding: 9px var(--sp-4);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-fg);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dt__row:last-child .dt__td { border-bottom: none; }
.dt__td--num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: var(--fw-medium);
    color: var(--color-fg);
}
.dt__td--muted { color: var(--color-fg-subtle); }
.dt__td--center { text-align: center; }

/* ── Bool chips ── */
.dt__bool {
    display: inline-block;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    padding: 2px 8px;
    border-radius: var(--r-full);
}
.dt__bool--yes { background: #dcfce7; color: #15803d; }
.dt__bool--no  { background: #f1f5f9; color: var(--color-fg-subtle); }

/* ── Status badges ── */
.dt__badge {
    display: inline-block;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    padding: 2px 9px;
    border-radius: var(--r-full);
    white-space: nowrap;
}
.dt__badge--green { background: #dcfce7; color: #15803d; }
.dt__badge--red   { background: #fee2e2; color: #b91c1c; }
.dt__badge--amber { background: #fef3c7; color: #b45309; }
.dt__badge--blue  { background: #dbeafe; color: #1d4ed8; }
.dt__badge--gray  { background: var(--p-slate-100); color: var(--p-slate-600); }

/* ── Pagination ── */
.dt__pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-4);
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-surface-raised);
}
.dt__pager-summary {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
}
.dt__pager-btns {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}
.dt__pager-page {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    padding: 0 var(--sp-2);
    min-width: 48px;
    text-align: center;
}
.dt__pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border: 1px solid var(--color-border);
    border-radius: var(--r-md);
    background: var(--color-bg-surface);
    color: var(--color-fg-muted);
    cursor: pointer;
    transition: background var(--d-fast), border-color var(--d-fast), color var(--d-fast);
}
.dt__pager-btn:hover:not(:disabled) {
    background: var(--color-bg-hover);
    border-color: var(--p-indigo-300);
    color: var(--p-indigo-700);
}
.dt__pager-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── Empty state ── */
.dt__empty {
    padding: var(--sp-8) var(--sp-4);
    text-align: center;
    color: var(--color-fg-subtle);
    font-size: var(--fs-sm);
}

/* Sidebar entity icon (emoji/text icon) */
.sidebar__entity-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

/* ============================================================
   DOCUMENT PREVIEW PANEL
============================================================ */
.preview-overlay {
    position: fixed;
    inset: 0;
    top: var(--topbar-h);
    background: rgba(0, 0, 0, 0.35);
    z-index: var(--z-overlay);
}

.preview-panel {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(760px, 100vw);
    background: var(--color-bg-surface);
    border-left: 1px solid var(--color-border);
    box-shadow: var(--sh-xl);
    z-index: calc(var(--z-overlay) + 1);
    display: flex;
    flex-direction: column;
}

.preview-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.preview-panel__body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.preview-pdf {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
}

.preview-text {
    flex: 1;
    margin: 0;
    padding: var(--sp-5);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    line-height: var(--lh-relaxed);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
    color: var(--color-fg);
}

.preview-unavailable {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-8);
    color: var(--color-fg-muted);
    text-align: center;
}
.preview-unavailable .ico--lg { width: 48px; height: 48px; margin-bottom: var(--sp-2); }

/* ============================================================
   USERS PAGE
============================================================ */

/* Role overview cards */
.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}
.role-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    padding: var(--sp-5);
}
.role-card__icon {
    width: 40px; height: 40px;
    border-radius: var(--r-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--sp-3);
    color: white;
}
.role-card__icon--admin   { background: linear-gradient(135deg, #EF4444, #F87171); }
.role-card__icon--manager { background: linear-gradient(135deg, #6366F1, #8B5CF6); }
.role-card__icon--staff   { background: linear-gradient(135deg, #10B981, #34D399); }
.role-card__icon--viewer  { background: linear-gradient(135deg, #64748B, #94A3B8); }
.role-card__name {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    margin-bottom: 2px;
}
.role-card__count {
    font-size: var(--fs-3xl);
    font-weight: var(--fw-bold);
    line-height: 1;
    margin: var(--sp-3) 0;
}
.role-card__desc {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    line-height: var(--lh-relaxed);
}

/* Invite banner */
.invite-card {
    background: var(--gradient-ai-soft);
    border: 1px dashed var(--p-indigo-300);
    border-radius: var(--card-radius);
    padding: var(--sp-5);
    margin-bottom: var(--sp-5);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    flex-wrap: wrap;
}
.invite-card__icon {
    width: 56px; height: 56px;
    background: white;
    border-radius: var(--r-2xl);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--p-indigo-600);
    flex-shrink: 0;
    box-shadow: var(--sh-sm);
}
.invite-card__content { flex: 1; min-width: 180px; }
.invite-card__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    margin-bottom: 2px;
}
.invite-card__desc {
    font-size: var(--fs-sm);
    color: var(--color-fg-muted);
}
.invite-card__actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

/* User name cell in table */
.user-name-cell {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}
.user-name-cell__main {
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.user-name-cell__sub {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
}

/* Avatar extra-large size */
.avatar--xl {
    width: 56px; height: 56px;
    font-size: var(--fs-lg);
    flex-shrink: 0;
}

/* User detail side panel */
.user-detail-overlay {
    position: fixed;
    inset: 0;
    top: var(--topbar-h);
    background: rgba(0, 0, 0, 0.35);
    z-index: var(--z-overlay);
}
.user-detail-panel {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(480px, 100vw);
    background: var(--color-bg-surface);
    border-left: 1px solid var(--color-border);
    box-shadow: var(--sh-xl);
    z-index: calc(var(--z-overlay) + 1);
    display: flex;
    flex-direction: column;
}
.user-detail-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-5) var(--sp-5) var(--sp-4);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.user-detail-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-5);
}
.user-detail-panel__footer {
    display: flex;
    gap: var(--sp-3);
    align-items: center;
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

/* Governance modal */
.governance-modal {
    width: min(1120px, calc(100vw - 32px));
    max-width: 1120px;
}
.governance-modal__body {
    max-height: min(78vh, 900px);
    overflow-y: auto;
}
.governance-member-summary {
    margin-bottom: var(--sp-4);
    padding: var(--sp-4);
    border: 1px solid var(--color-border);
    border-radius: var(--r-xl);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.08), rgba(255, 255, 255, 0.88));
}
.governance-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: var(--sp-5);
    align-items: start;
}
.governance-column {
    min-width: 0;
}
.governance-section {
    border: 1px solid var(--color-border);
    border-radius: var(--r-xl);
    background: var(--color-bg-surface);
    padding: var(--sp-5);
}
.governance-column > .governance-section + .governance-section {
    margin-top: var(--sp-4);
}
.governance-section__header {
    margin-bottom: var(--sp-4);
}
.governance-section__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    color: var(--color-fg);
}
.governance-section__desc {
    margin-top: 4px;
    font-size: var(--fs-sm);
    color: var(--color-fg-muted);
    line-height: var(--lh-relaxed);
}
.governance-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-4);
}
.governance-personas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--sp-3);
    margin-top: var(--sp-4);
}
.governance-persona-chip {
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    background: var(--color-bg-app);
}
.governance-persona-chip.is-selected {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.18);
}
.governance-persona-chip__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
}
.governance-persona-chip__meta {
    margin-top: 4px;
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
}
.governance-responsibility-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}
.governance-responsibility {
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    background: var(--color-bg-app);
    padding: var(--sp-4);
}
.governance-responsibility.is-selected {
    border-color: var(--color-primary);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.06), rgba(255, 255, 255, 0.92));
}
.governance-responsibility.is-disabled {
    opacity: 0.72;
}
.governance-responsibility__toggle {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    cursor: pointer;
}
.governance-responsibility__title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
}
.governance-responsibility__meta {
    margin-top: 4px;
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
}
.governance-responsibility__editor {
    margin-top: var(--sp-4);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--color-border);
}
.governance-checklist {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-4);
}
.governance-check {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    color: var(--color-fg);
}
.governance-inline-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-4);
    margin-top: var(--sp-4);
}
.governance-preview__hero {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}
.governance-preview__hero-item {
    padding: var(--sp-4);
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    background: var(--color-bg-app);
}
.governance-preview__hero-label {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    margin-bottom: 6px;
}
.governance-preview__hero-value {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
}
.governance-preview__section + .governance-preview__section {
    margin-top: var(--sp-4);
}
.governance-preview__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
    margin-bottom: var(--sp-2);
}
.governance-preview__group + .governance-preview__group {
    margin-top: var(--sp-3);
}
.governance-preview__group-title {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--color-fg-subtle);
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: var(--sp-2);
}
.governance-preview__list,
.governance-preview__notice-list {
    margin: 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.governance-preview__list li,
.governance-preview__notice-list li {
    color: var(--color-fg);
    line-height: var(--lh-relaxed);
}
.governance-preview__list li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
}

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

    .governance-preview__hero {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .governance-form-grid,
    .governance-inline-fields {
        grid-template-columns: 1fr;
    }

    .governance-personas {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   NOTIFICATION BELL — badge, backdrop, slide-in panel, items
============================================================ */

/* Bell button wrapper — keep badge in position */
.notif-bell-btn { position: relative; }

/* Badge counter on bell */
.notif-count {
    position: absolute;
    top: -3px;
    right: -7px;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    border-radius: var(--r-full);
    background: var(--color-primary);
    color: white;
    font-size: 10px;
    font-weight: var(--fw-bold);
    line-height: 16px;
    text-align: center;
    border: 2px solid var(--color-bg-surface);
    pointer-events: none;
}
.notif-count--alert { background: var(--color-error); }
.notif-count--warn  { background: var(--color-warning); }

/* Dark semi-transparent backdrop */
.notif-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.3);
    z-index: calc(var(--z-modal) - 1);
}

/* Slide-in panel from the right */
.notif-panel {
    position: fixed;
    top: 0; right: 0;
    width: min(400px, 100vw);
    height: 100dvh;
    background: var(--color-bg-surface);
    border-left: 1px solid var(--color-border);
    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.1);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Panel header */
.notif-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.notif-panel__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    color: var(--color-fg);
}
.notif-panel__header-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

/* Severity filter tabs */
.notif-tabs {
    display: flex;
    gap: 2px;
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.notif-tabs::-webkit-scrollbar { display: none; }

.notif-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 5px 10px;
    border-radius: var(--r-md);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    color: var(--color-fg-muted);
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--d-fast), color var(--d-fast);
}
.notif-tab:hover { background: var(--color-bg-hover); color: var(--color-fg); }
.notif-tab--active {
    background: var(--color-primary-light);
    color: var(--p-indigo-700);
    font-weight: var(--fw-semibold);
}

.notif-tab-count {
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: var(--r-full);
    background: var(--color-bg-muted);
    color: var(--color-fg-muted);
    font-size: 10px;
    font-weight: var(--fw-bold);
    line-height: 18px;
    text-align: center;
}
.notif-tab-count--alert   { background: var(--color-error-bg);   color: var(--color-error-fg); }
.notif-tab-count--warn    { background: var(--color-warning-bg);  color: var(--color-warning-fg); }

/* Insight list scroll area */
.notif-list {
    flex: 1;
    overflow-y: auto;
}

/* Empty / loading state */
.notif-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    padding: var(--sp-12, 3rem) var(--sp-6);
    color: var(--color-fg-subtle);
    font-size: var(--fs-sm);
}

/* Single insight item */
.notif-item {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    transition: background var(--d-fast);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-bg-muted); }

/* Unread marker */
.notif-item--unread { background: var(--color-primary-light); }
.notif-item--unread:hover { background: var(--p-indigo-100); }

/* Left severity bar */
.notif-item__bar {
    width: 3px;
    flex-shrink: 0;
    border-radius: 0;
}
.notif-item--alert      .notif-item__bar { background: var(--color-error); }
.notif-item--warning    .notif-item__bar { background: var(--color-warning); }
.notif-item--suggestion .notif-item__bar { background: var(--color-primary); }
.notif-item--info       .notif-item__bar { background: var(--color-info); }

/* Item body */
.notif-item__content {
    flex: 1;
    padding: var(--sp-3) var(--sp-4);
    min-width: 0;
}

.notif-item__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    margin-bottom: var(--sp-1);
}

/* Severity label badge */
.notif-severity {
    display: inline-block;
    font-size: 10px;
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: var(--r-full);
}
.notif-severity--alert      { background: var(--color-error-bg);   color: var(--color-error-fg); }
.notif-severity--warning    { background: var(--color-warning-bg);  color: var(--color-warning-fg); }
.notif-severity--suggestion { background: var(--color-primary-light); color: var(--p-indigo-700); }
.notif-severity--info       { background: var(--color-info-bg);     color: var(--color-info-fg); }

.notif-item__age {
    font-size: 11px;
    color: var(--color-fg-subtle);
    flex-shrink: 0;
}
.notif-item__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
    margin-bottom: var(--sp-1);
    line-height: var(--lh-snug);
}
.notif-item__body {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    line-height: var(--lh-relaxed);
    margin-bottom: var(--sp-2);
}

/* Entity card chip */
.notif-entity-card {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 3px 9px;
    margin-bottom: var(--sp-2);
    background: var(--color-bg-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--r-full);
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    font-weight: var(--fw-medium);
}

/* Action buttons row */
.notif-item__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-top: var(--sp-2);
}

/* ── Modal dialog (confirm action) ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: calc(var(--z-modal) + 10);
    padding: var(--sp-4);
}
.modal-dialog {
    background: var(--color-bg-surface);
    border-radius: var(--r-2xl);
    box-shadow: var(--sh-xl);
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-dialog--sm { max-width: 360px; }
.modal-dialog__header {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--color-border);
}
.modal-dialog__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    margin: 0;
}
.modal-dialog__body {
    padding: var(--sp-4) var(--sp-5);
}
.modal-dialog__body p { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); }
.modal-dialog__body p:last-child { margin-bottom: 0; }
.modal-dialog__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-5);
    border-top: 1px solid var(--color-border);
    background: var(--p-slate-50);
}

/* ============================================================
   DASHBOARD (P5)
============================================================ */

/* Loading state */
.dash-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    padding: var(--sp-12) 0;
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
}

.page-header__actions {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}
.dash-refresh-time {
    color: var(--color-fg-muted);
    font-size: var(--fs-xs);
    white-space: nowrap;
}
@media (max-width: 640px) {
    .page-header__actions {
        align-items: flex-end;
        flex-direction: column;
        gap: var(--sp-2);
    }
}

/* mb-6 utility (dashboard uses slightly more breathing room) */
.mb-6 { margin-bottom: var(--sp-6); }

/* Zone 1 grid */
.dash-zone1 {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}
@media (max-width: 640px) {
    .dash-zone1 { grid-template-columns: 1fr; }
}

.dash-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
}


/* Dashboard domain chart zone */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.dashboard-chart-zone {
    /* margin: var(--sp-4) 0 var(--sp-6); */
}
.dashboard-chart-zone__header {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-3);
}
.dashboard-chart-zone__eyebrow,
.dashboard-chart-card__type {
    display: inline-flex;
    align-items: center;
    color: var(--color-primary);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: .04em;
    text-transform: uppercase;
}
.dashboard-chart-zone__title {
    margin: var(--sp-1) 0 0;
    color: var(--color-fg);
    font-size: clamp(var(--fs-lg), 1.1vw + 1rem, var(--fs-2xl));
    font-weight: var(--fw-bold);
}
.dashboard-chart-zone__description {
    max-width: 760px;
    margin: var(--sp-1) 0 0;
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
    line-height: 1.55;
}
.dashboard-chart-empty {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-5);
    background: linear-gradient(135deg, color-mix(in srgb, var(--color-primary) 7%, transparent), var(--color-bg-surface));
    border: 1px dashed var(--color-border-strong, var(--color-border));
    border-radius: var(--card-radius);
    color: var(--color-fg-muted);
}
.dashboard-chart-empty strong {
    display: block;
    color: var(--color-fg);
    font-size: var(--fs-md);
    margin-bottom: var(--sp-1);
}
.dashboard-chart-empty p {
    margin: 0;
    line-height: 1.55;
}
.dashboard-chart-empty__icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: var(--r-lg, 14px);
    color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
    flex: 0 0 auto;
}
.dashboard-chart-group + .dashboard-chart-group {
    margin-top: var(--sp-5);
}
.dashboard-chart-group__header {
    margin-bottom: var(--sp-3);
}
.dashboard-chart-group__header h3 {
    margin: 0;
    color: var(--color-fg);
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
}
.dashboard-chart-group__header p {
    margin: var(--sp-1) 0 0;
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
    line-height: 1.5;
}
.dashboard-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: var(--sp-4);
}
.dashboard-chart-card {
    position: relative;
    display: grid;
    min-height: 320px;
    grid-template-rows: minmax(118px, auto) minmax(150px, 1fr) auto auto;
    gap: var(--sp-3);
    padding: var(--sp-5);
    overflow: hidden;
    background: linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 3%, var(--color-bg-surface)), var(--color-bg-surface) 38%);
    border: 1px solid color-mix(in srgb, var(--color-primary) 12%, var(--color-border));
    border-radius: var(--card-radius);
    box-shadow: var(--sh-sm, 0 1px 2px rgba(15, 23, 42, .06));
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.dashboard-chart-card::before {
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    content: "";
    background: linear-gradient(90deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 50%, var(--color-info, #38bdf8)));
    opacity: .8;
}
.dashboard-chart-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--color-primary) 34%, var(--color-border));
    box-shadow: var(--sh-md, 0 12px 30px rgba(15, 23, 42, .12));
}
.dashboard-chart-card__header {
    display: grid;
    min-height: 118px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    justify-content: space-between;
    gap: var(--sp-3);
}
.dashboard-chart-card__header h3 {
    margin: var(--sp-1) 0 0;
    color: var(--color-fg);
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
}
.dashboard-chart-card__header p {
    margin: var(--sp-1) 0 0;
    color: var(--color-fg-muted);
    font-size: var(--fs-xs);
    display: -webkit-box;
    overflow: hidden;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.dashboard-chart-card__metric {
    min-width: 92px;
    padding: var(--sp-2) var(--sp-3);
    text-align: right;
    background: color-mix(in srgb, var(--color-primary) 7%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-primary) 12%, transparent);
    border-radius: var(--r-lg, 14px);
}
.dashboard-chart-card__metric strong {
    display: block;
    color: var(--color-fg);
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    line-height: 1.05;
}
.dashboard-chart-card__metric span {
    color: var(--color-fg-muted);
    font-size: var(--fs-xs);
}
.dashboard-chart-card__body {
    min-height: 150px;
    align-self: stretch;
}
.dashboard-chart-preview {
    height: 100%;
    min-height: 150px;
}
.dashboard-chart-canvas {
    position: relative;
    height: 182px;
    min-height: 182px;
}
.dashboard-chart-canvas canvas {
    display: block;
    width: 100%;
    height: 182px;
    max-height: 182px;
}
.dashboard-chart-canvas__fallback {
    margin-top: var(--sp-2);
}
.dashboard-chart-canvas__fallback--hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.dashboard-chart-preview--rows {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--sp-2);
}
.dashboard-chart-preview--columns {
    display: flex;
    align-items: flex-end;
    gap: var(--sp-2);
    padding-top: var(--sp-4);
}
.dashboard-chart-preview__item {
    display: grid;
    grid-template-columns: minmax(78px, .8fr) minmax(80px, 1fr) auto;
    align-items: center;
    gap: var(--sp-2);
    color: var(--color-fg-muted);
    font-size: var(--fs-xs);
}
.dashboard-chart-preview--rows .dashboard-chart-preview__item {
    grid-template-columns: minmax(130px, 130px) minmax(130px, 1fr) minmax(130px, 130px);
}
.dashboard-chart-preview--columns .dashboard-chart-preview__item {
    display: flex;
    min-width: 42px;
    height: 150px;
    flex: 1;
    flex-direction: column-reverse;
    justify-content: flex-start;
    gap: var(--sp-1);
    text-align: center;
}
.dashboard-chart-preview__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-chart-preview__bar {
    position: relative;
    display: block;
    height: 10px;
    overflow: hidden;
    background: color-mix(in srgb, var(--color-fg-muted) 10%, transparent);
    border-radius: 999px;
}
.dashboard-chart-preview--columns .dashboard-chart-preview__bar {
    width: 100%;
    height: 100%;
    min-height: 12px;
}
.dashboard-chart-preview__bar i {
    display: block;
    width: var(--chart-value, 4%);
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 55%, var(--color-info, #38bdf8)));
    border-radius: inherit;
    box-shadow: 0 0 0 1px color-mix(in srgb, #fff 18%, transparent) inset;
}
.dashboard-chart-preview--columns .dashboard-chart-preview__bar i {
    width: 100%;
    height: var(--chart-value, 4%);
    margin-top: auto;
}
.dashboard-chart-preview__value {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    min-width: 0;
    text-align: right;
}
.dashboard-chart-preview__value strong {
    color: var(--color-fg);
    font-size: var(--fs-xs);
    line-height: 1.1;
}
.dashboard-chart-preview__value small {
    max-width: 100%;
    overflow: hidden;
    color: var(--color-fg-muted);
    font-size: .68rem;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-chart-preview--area {
    display: grid;
    grid-template-rows: 1fr auto;
    gap: var(--sp-2);
    min-height: 150px;
    padding: var(--sp-1) 0 0;
}
.dashboard-chart-preview__sparkline {
    width: 100%;
    height: 118px;
    overflow: visible;
    border-radius: var(--r-lg, 14px);
    background: linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 8%, transparent), transparent 75%);
}
.dashboard-chart-preview__area-fill {
    fill: color-mix(in srgb, var(--color-primary) 18%, transparent);
}
.dashboard-chart-preview__area-line {
    fill: none;
    stroke: var(--color-primary);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.8;
    vector-effect: non-scaling-stroke;
}
.dashboard-chart-preview__area-point {
    fill: var(--color-bg-surface);
    stroke: var(--color-primary);
    stroke-width: 1.8;
    vector-effect: non-scaling-stroke;
}
.dashboard-chart-preview__area-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-2);
}
.dashboard-chart-preview__area-summary span {
    min-width: 0;
    padding: var(--sp-2);
    background: color-mix(in srgb, var(--color-primary) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-primary) 10%, transparent);
    border-radius: var(--r-md, 10px);
}
.dashboard-chart-preview__area-summary small,
.dashboard-chart-preview__area-summary strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-chart-preview__area-summary small {
    color: var(--color-fg-muted);
    font-size: .68rem;
}
.dashboard-chart-preview__area-summary strong {
    color: var(--color-fg);
    font-size: var(--fs-xs);
}
.dashboard-chart-card__legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-3);
    padding: 0;
    margin: 0;
    color: var(--color-fg-muted);
    font-size: var(--fs-xs);
    list-style: none;
}
.dashboard-chart-card__legend li {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
}
.dashboard-chart-card__legend span {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--legend-color, var(--color-primary));
}
.dashboard-chart-card__legend-dot--success { background: var(--color-success, #22c55e); }
.dashboard-chart-card__legend-dot--warning { background: var(--color-warning, #f59e0b); }
.dashboard-chart-card__legend-dot--danger,
.dashboard-chart-card__legend-dot--error { background: var(--color-error, #ef4444); }
.dashboard-chart-card__legend-dot--info { background: var(--color-info, #38bdf8); }
.dashboard-chart-card__legend-dot--primary { background: var(--color-primary); }
.dashboard-chart-card__empty {
    display: grid;
    place-content: center;
    min-height: 132px;
    padding: var(--sp-4);
    color: var(--color-fg-muted);
    text-align: center;
    background: color-mix(in srgb, var(--color-fg-muted) 7%, transparent);
    border: 1px dashed var(--color-border);
    border-radius: var(--r-lg, 14px);
}
.dashboard-chart-card__empty strong {
    color: var(--color-fg);
}
.dashboard-chart-card__empty p {
    max-width: 34ch;
    margin: var(--sp-1) auto 0;
    font-size: var(--fs-sm);
    line-height: 1.45;
}
.dashboard-chart-card__insight {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    color: var(--color-fg-muted);
    background: color-mix(in srgb, var(--color-primary) 6%, var(--color-bg-muted));
    border-radius: var(--r-md, 10px);
    font-size: var(--fs-xs);
    line-height: 1.45;
}
.dashboard-chart-card__insight i {
    margin-top: 2px;
    color: var(--color-primary);
}
.dashboard-chart-card__insight--success { color: var(--color-success, #16a34a); }
.dashboard-chart-card__insight--warning { color: var(--color-warning-fg); }
.dashboard-chart-card__insight--danger,
.dashboard-chart-card__insight--error { color: var(--color-error); }
.dashboard-chart-card__link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    width: fit-content;
    color: var(--color-primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    text-decoration: none;
    border-radius: var(--r-sm, 8px);
}
.dashboard-chart-card__link:hover {
    text-decoration: underline;
}
.dashboard-chart-card__link:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--color-primary) 35%, transparent);
    outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
    .dashboard-chart-card,
    .dashboard-chart-card:hover {
        transform: none;
        transition: none;
    }
}
@media (max-width: 640px) {
    .dashboard-chart-zone__header {
        flex-direction: column;
    }
    .dashboard-chart-card__header {
        min-height: 0;
        grid-template-columns: 1fr;
    }
    .dashboard-chart-card {
        padding: var(--sp-4);
    }
    .dashboard-chart-card__metric {
        width: fit-content;
        text-align: left;
    }
    .dashboard-chart-preview--columns {
        overflow-x: auto;
        padding-bottom: var(--sp-1);
    }
    .dashboard-chart-preview--columns .dashboard-chart-preview__item {
        min-width: 56px;
    }
    .dashboard-chart-preview__item {
        grid-template-columns: minmax(72px, .85fr) 1fr;
    }
    .dashboard-chart-preview--rows .dashboard-chart-preview__value {
        grid-column: 1 / -1;
        align-items: flex-start;
        text-align: left;
    }
}

/* ── Stat card enhancements ───────────────────────────────── */

.dash-stat {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    position: relative;
    overflow: hidden;
}
a.stat-card {
    color: inherit;
    display: block;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
}
a.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--sh-md, 0 4px 12px rgba(0,0,0,.1));
}
.dash-stat::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    border-radius: var(--r-sm) 0 0 var(--r-sm);
}
.dash-stat--alert::before    { background: var(--color-error); }
.dash-stat--booking::before  { background: var(--color-primary); }
.dash-stat--pipeline::before { background: var(--color-success, #22c55e); }
.dash-stat--lead::before     { background: var(--color-warning); }
.dash-stat--tour::before     { background: var(--color-info); }
.dash-stat--success::before  { background: var(--color-success, #22c55e); }
.dash-stat--warning::before  { background: var(--color-warning); }
.dash-stat--info::before     { background: var(--color-info); }
.dash-stat--neutral::before  { background: var(--color-border-strong, var(--color-border)); }
.dash-stat--danger::before   { background: var(--color-error); }
.dash-stat--error::before    { background: var(--color-error); }

.dash-stat__icon {
    font-size: 1.1rem;
    margin-bottom: var(--sp-1);
}
.dash-stat--alert    .dash-stat__icon { color: var(--color-error); }
.dash-stat--booking  .dash-stat__icon { color: var(--color-primary); }
.dash-stat--pipeline .dash-stat__icon { color: var(--color-success, #22c55e); }
.dash-stat--lead     .dash-stat__icon { color: var(--color-warning-fg); }
.dash-stat--tour     .dash-stat__icon { color: var(--color-info-fg); }
.dash-stat--success  .dash-stat__icon { color: var(--color-success, #22c55e); }
.dash-stat--warning  .dash-stat__icon { color: var(--color-warning-fg); }
.dash-stat--info     .dash-stat__icon { color: var(--color-info-fg); }
.dash-stat--neutral  .dash-stat__icon { color: var(--color-fg-muted); }
.dash-stat--danger   .dash-stat__icon { color: var(--color-error); }
.dash-stat--error    .dash-stat__icon { color: var(--color-error); }

.dash-stat__value--alert {
    color: var(--color-error);
}

.dash-stat__sub {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    margin-top: var(--sp-1);
}
.dash-stat--placeholder .stat-card__value {
    color: var(--color-fg-muted);
}

.dash-card-group__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}
.dash-card-group__title {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
}
.dash-card-group__description {
    margin: var(--sp-1) 0 0;
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
    line-height: 1.5;
}

.dash-card-group__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-4);
}

.dash-card-group__grid--compact {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: var(--sp-3);
}

.dash-card-group__grid--compact > .dash-stat {
    flex: 0 1 220px;
    min-width: min(100%, 220px);
    max-width: 240px;
    padding: var(--sp-4);
}

.dash-card-group__grid--compact > .dash-stat .stat-card__value {
    font-size: var(--fs-2xl);
}

.dash-card-group__grid--compact > .dash-stat .dash-stat__sub {
    line-height: 1.55;
}

/* Progress bar for pipeline card */
.dash-stat__progress-wrap {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-top: var(--sp-2);
}
.dash-stat__progress {
    flex: 1;
    height: 6px;
    background: var(--color-bg-muted);
    border-radius: 3px;
    overflow: hidden;
}
.dash-stat__progress-fill {
    height: 100%;
    background: var(--color-success, #22c55e);
    border-radius: 3px;
    transition: width 0.6s ease;
    min-width: 2px;
}
.dash-stat__progress-pct {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--color-fg-muted);
    white-space: nowrap;
    min-width: 36px;
    text-align: right;
}

/* ── AI Briefing widget ───────────────────────────────────── */

.dash-briefing {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    padding: var(--sp-5) var(--sp-6);
    position: relative;
    overflow: hidden;
}
.dash-briefing::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top left, var(--color-primary-light, rgba(99,102,241,.06)) 0%, transparent 60%);
    pointer-events: none;
}
.dash-briefing--empty {
    opacity: .75;
}
.dash-briefing__header {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}
.dash-briefing__spark {
    font-size: 1.4rem;
    line-height: 1;
    color: var(--color-primary);
    flex-shrink: 0;
    margin-top: 1px;
}
.dash-briefing__meta { display: flex; flex-direction: column; gap: 2px; }
.dash-briefing__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
    line-height: 1.2;
}
.dash-briefing__age {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
}
.dash-briefing__body {
    font-size: var(--fs-sm);
    color: var(--color-fg);
    line-height: 1.65;
    white-space: pre-wrap;
    margin-bottom: var(--sp-5);
}
.dash-briefing__body--clamp {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.dash-briefing__body--muted { opacity: .45; }
.dash-briefing__spark--muted { opacity: .25; }
.dash-briefing__expand {
    align-self: flex-start;
    margin: calc(var(--sp-3) * -1) 0 var(--sp-4);
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-primary);
    cursor: pointer;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
}
.dash-briefing__expand:hover { text-decoration: underline; }
.dash-briefing__footer {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    justify-content: flex-end;
}
.dash-briefing__footer .btn {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.dash-briefing__button-icon { font-size: .85rem; }
.dash-briefing__error {
    margin-bottom: var(--sp-3);
    color: var(--color-error-fg);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
}


/* Zone 3 layout */
.dash-zone3 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--sp-4);
    margin-top: var(--sp-6);
    align-items: start;
}
@media (max-width: 640px) {
    .dash-zone3 { grid-template-columns: 1fr; }
}

/* Revenue bar chart card */
.dash-revenue-chart {
    padding: var(--sp-5);
}
.dash-revenue-chart__title {
    margin-bottom: var(--sp-4);
    color: var(--color-fg-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
}
.dash-bar-chart {
    padding: var(--sp-2) 0;
}
.dash-bar-chart__bars {
    display: flex;
    align-items: flex-end;
    gap: var(--sp-2);
    min-height: 132px;
}
.dash-bar-chart__col {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-1);
}
.dash-bar-chart__col:hover .dash-bar-chart__tooltip { opacity: 1; }
.dash-bar-chart__tooltip {
    position: absolute;
    top: -1.5rem;
    left: 50%;
    z-index: 1;
    transform: translateX(-50%);
    padding: 2px 6px;
    border-radius: var(--r-sm);
    background: var(--p-slate-800, #1e293b);
    color: #fff;
    font-size: 11px;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity .15s;
}
.dash-bar-chart__track {
    display: flex;
    height: 104px;
    align-items: flex-end;
}
.dash-bar-chart__bar {
    width: 100%;
    min-height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--color-primary);
    transition: height .3s ease;
}
.dash-bar-chart__label {
    color: var(--color-fg-subtle);
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}
.dash-revenue-chart__footer {
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    margin-top: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--color-border);
}
.dash-revenue-chart__this {
    color: var(--color-fg);
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
}
.dash-revenue-chart__pct {
    color: var(--color-fg-muted);
    font-size: var(--fs-xs);
}
.dash-revenue-chart__pct--up { color: var(--color-success, #22c55e); }
.dash-revenue-chart__pct--down { color: var(--color-error); }

@media (max-width: 640px) {
    .dash-card-group__grid--compact > .dash-stat {
        flex-basis: 100%;
        max-width: none;
    }
}

/* icon-btn extra-small variant */
.icon-btn--xs { width: 28px; height: 28px; }

/* ═══════════════════════════════════════════════════════════════
   P6 — Insight Feed sidebar
   ═══════════════════════════════════════════════════════════════ */

/* ── Context-pane tab bar ─────────────────────────────────────── */
.context-pane {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ctx-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    background: var(--color-canvas);
}

.ctx-tab {
    flex: 1;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-fg-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-1);
    transition: color .15s, border-color .15s;
    margin-bottom: -1px;
}

.ctx-tab:hover { color: var(--color-fg); }

.ctx-tab--active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: var(--fw-semibold);
}

.ctx-tab__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    background: var(--color-error);
    color: #fff;
}

/* ── Array table editor (EntityForm) ───────────────── */
.ef-array {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ef-array__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.ef-array__th {
    text-align: left;
    padding: 6px 8px;
    background: var(--surface-2, #f4f4f5);
    color: var(--text-secondary, #6b7280);
    font-weight: 500;
    border-bottom: 1px solid var(--border, #e5e7eb);
    white-space: nowrap;
}

.ef-array__th--del {
    width: 32px;
}

.ef-array__td {
    padding: 4px 6px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light, #f3f4f6);
}

.ef-array__td--del {
    text-align: center;
    width: 32px;
}

.ef-array__input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 4px;
    font-size: 13px;
    background: var(--surface, #fff);
    color: var(--text-primary, #111827);
    box-sizing: border-box;
}

.ef-array__input:focus {
    outline: none;
    border-color: var(--primary, #6366f1);
}

.ef-array__del {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #9ca3af);
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.ef-array__del:hover {
    color: var(--color-error, #ef4444);
    background: #fef2f2;
}

.ef-array__add {
    align-self: flex-start;
    background: none;
    border: 1px dashed var(--border, #e5e7eb);
    border-radius: 6px;
    color: var(--primary, #6366f1);
    cursor: pointer;
    font-size: 13px;
    padding: 6px 12px;
    transition: border-color 0.15s, background 0.15s;
}

.ef-array__add:hover {
    border-color: var(--primary, #6366f1);
    background: #eef2ff;
}

/* ── EntityForm 2-column grid ────────────────────────────────── */
.ef {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4) var(--sp-5);
}
.form-group--span2 {
    grid-column: 1 / -1;
}

/* ── EntityDetail array table ─────────────────────────────────── */.ed-array {
    overflow-x: auto;
    margin-top: var(--sp-1);
}
.ed-array__table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.ed-array__th {
    text-align: left;
    padding: var(--sp-1) var(--sp-2);
    background: var(--surface-2, #f8fafc);
    border-bottom: 2px solid var(--border, #e2e8f0);
    font-weight: 600;
    white-space: nowrap;
    color: var(--text-muted, #64748b);
}
.ed-array__td {
    padding: var(--sp-1) var(--sp-2);
    border-bottom: 1px solid var(--border, #e2e8f0);
    vertical-align: top;
}

.ed-plaintext {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

.ed-detail-empty {
    padding: var(--sp-3) var(--sp-4);
    border: 1px dashed var(--color-border);
    border-radius: var(--r-lg);
    background: var(--color-bg-muted, #f8fafc);
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
}

.ed-note-feed {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.ed-note-feed__item {
    position: relative;
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    background: var(--color-bg-surface);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.ed-note-feed__item::before {
    content: "";
    position: absolute;
    top: var(--sp-4);
    left: var(--sp-3);
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--color-primary);
}

.ed-note-feed__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: 6px;
    padding-left: var(--sp-4);
}

.ed-note-feed__when {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--color-fg-muted);
}

.ed-note-feed__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
}

.ed-note-feed__message {
    padding-left: var(--sp-4);
    color: var(--color-fg);
    font-size: var(--fs-sm);
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.ed-related-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.ed-related-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-4);
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 252, 0.96));
}

.ed-related-card__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ed-related-card__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-fg);
}

.ed-related-card__desc {
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
    line-height: 1.55;
}

.ed-related-card__actions {
    flex-shrink: 0;
}

.ed-related-tabs {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ed-related-tabs__nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-end;
    padding: 6px 6px 0;
    border: 1px solid var(--color-border);
    border-bottom: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    background: linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 6%, var(--color-bg-muted)) 0%, var(--color-bg-surface) 100%);
}

.ed-related-tabs__tab {
    position: relative;
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: calc(var(--r-lg) + 2px) calc(var(--r-lg) + 2px) 0 0;
    background: color-mix(in srgb, var(--color-bg-surface) 72%, transparent);
    color: var(--color-fg-muted);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    padding: 10px 14px;
    margin-bottom: -1px;
    transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.ed-related-tabs__tab:hover {
    background: color-mix(in srgb, var(--color-primary-light) 70%, var(--color-bg-surface));
    color: var(--color-fg);
    border-color: color-mix(in srgb, var(--color-primary) 12%, var(--color-border));
}

.ed-related-tabs__tab--active {
    background: var(--color-bg-surface);
    color: var(--color-primary);
    border-color: color-mix(in srgb, var(--color-primary) 26%, var(--color-border));
    box-shadow: 0 -1px 0 color-mix(in srgb, var(--color-primary) 10%, transparent), 0 8px 18px rgb(15 23 42 / 0.06);
    z-index: 1;
}

.ed-related-tabs__panel {
    min-width: 0;
    padding: var(--sp-4);
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--r-xl) var(--r-xl);
    background: var(--color-bg-surface);
    box-shadow: var(--sh-sm);
}

.ed-related-tabs__desc {
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
    line-height: 1.55;
    margin-bottom: var(--sp-3);
}

.ed-activity-history__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-end;
    padding: 6px 6px 0;
    border: 1px solid var(--color-border);
    border-bottom: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    background: linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 6%, var(--color-bg-muted)) 0%, var(--color-bg-surface) 100%);
}

.ed-activity-history__tab {
    position: relative;
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: calc(var(--r-lg) + 2px) calc(var(--r-lg) + 2px) 0 0;
    background: color-mix(in srgb, var(--color-bg-surface) 72%, transparent);
    color: var(--color-fg-muted);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    padding: 10px 14px;
    margin-bottom: -1px;
    transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.ed-activity-history__tab:hover {
    background: color-mix(in srgb, var(--color-primary-light) 70%, var(--color-bg-surface));
    color: var(--color-fg);
    border-color: color-mix(in srgb, var(--color-primary) 12%, var(--color-border));
}

.ed-activity-history__tab--active {
    background: var(--color-bg-surface);
    color: var(--color-primary);
    border-color: color-mix(in srgb, var(--color-primary) 26%, var(--color-border));
    box-shadow: 0 -1px 0 color-mix(in srgb, var(--color-primary) 10%, transparent), 0 8px 18px rgb(15 23 42 / 0.06);
    z-index: 1;
}

.ed-activity-history__panel {
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--r-xl) var(--r-xl);
    background: var(--color-bg-surface);
    box-shadow: var(--sh-sm);
}

.ed-activity-history__panel-body {
    padding: var(--sp-4);
    max-height: min(420px, 52vh);
    overflow: auto;
}

.ed-activity-history__activities {
    display: grid;
    gap: var(--sp-3);
}

.ed-activity-history__activity {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--sp-3);
    align-items: start;
}

.ed-activity-history__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    align-items: center;
    margin-bottom: var(--sp-3);
}

.ed-activity-history__meta a {
    color: var(--color-primary);
    text-decoration: none;
}

.ed-activity-history__meta a:hover {
    text-decoration: underline;
}

.ed-activity-history__empty {
    padding: var(--sp-3);
    border: 1px dashed var(--color-border);
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--color-bg-muted) 72%, transparent);
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
    line-height: 1.55;
}

.ed-channel-history__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.ed-channel-history__tab {
    border: 1px solid color-mix(in srgb, var(--color-primary) 14%, var(--color-border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-primary-light) 48%, var(--color-bg-surface));
    color: var(--color-fg-muted);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    padding: 8px 14px;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.ed-channel-history__tab:hover {
    color: var(--color-fg);
    border-color: color-mix(in srgb, var(--color-primary) 24%, var(--color-border));
}

.ed-channel-history__tab--active {
    background: color-mix(in srgb, var(--color-primary) 14%, var(--color-bg-surface));
    border-color: color-mix(in srgb, var(--color-primary) 34%, var(--color-border));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-primary) 12%, transparent);
    color: var(--color-primary);
}

.ed-channel-history__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    align-items: center;
    margin-bottom: var(--sp-3);
}

.ed-channel-history__messages {
    display: grid;
    gap: var(--sp-3);
}

.ed-channel-history__message {
    display: grid;
    gap: 6px;
}

.ed-channel-history__message--outbound {
    justify-items: end;
}

.ed-channel-history__message-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.ed-channel-history__bubble {
    max-width: min(100%, 680px);
    white-space: pre-wrap;
    word-break: break-word;
    padding: 12px 14px;
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--color-bg-muted) 76%, var(--color-bg-surface));
    border: 1px solid var(--color-border);
    color: var(--color-fg);
    font-size: var(--fs-sm);
    line-height: 1.6;
}

.ed-channel-history__message--outbound .ed-channel-history__bubble {
    background: color-mix(in srgb, var(--color-primary-light) 68%, var(--color-bg-surface));
    border-color: color-mix(in srgb, var(--color-primary) 20%, var(--color-border));
}

.ed-channel-history__empty {
    padding: var(--sp-3);
    border: 1px dashed var(--color-border);
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--color-bg-muted) 72%, transparent);
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
    line-height: 1.55;
}

.ed-related-table-wrap {
    border: 1px solid var(--color-border);
    border-radius: var(--r-lg);
    max-height: min(420px, 58vh);
    overflow: auto;
}

.ed-related-table {
    border-collapse: collapse;
    font-size: var(--fs-sm);
    min-width: 100%;
}

.ed-related-table th,
.ed-related-table td {
    border-bottom: 1px solid var(--color-border);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ed-related-table th {
    background: rgba(248, 250, 252, 0.96);
    color: var(--color-fg-muted);
    font-weight: var(--fw-semibold);
    position: sticky;
    top: 0;
    z-index: 1;
}

.ed-related-table__row {
    cursor: pointer;
}

.ed-related-table__row:hover {
    background: rgba(14, 165, 233, 0.08);
}

.ed-ref-chip {
    align-items: center;
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(14, 165, 233, 0.24);
    border-radius: 999px;
    color: var(--color-primary);
    cursor: pointer;
    display: inline-flex;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    line-height: 1.2;
    max-width: 100%;
    padding: 5px 10px;
    text-align: left;
}

.ed-ref-chip:hover {
    background: rgba(14, 165, 233, 0.14);
}

@media (max-width: 768px) {
    .ed-related-card {
        flex-direction: column;
        align-items: stretch;
    }

    .ed-related-card__actions .btn {
        width: 100%;
    }
}

/* ── Feed container ───────────────────────────────────────────── */
.feed-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Filter chips ─────────────────────────────────────────────── */
.feed-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.feed-filters--sub {
    border-bottom: none;
    padding-top: var(--sp-1);
    padding-bottom: var(--sp-1);
}

.feed-chip {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    border: 1px solid var(--color-border);
    background: var(--color-canvas);
    color: var(--color-fg-muted);
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.6;
    transition: background .12s, color .12s, border-color .12s;
}

.feed-chip:hover {
    background: var(--color-canvas-subtle);
    color: var(--color-fg);
}

.feed-chip--on {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.feed-chip--on:hover {
    background: var(--color-primary);
    color: #fff;
}

.feed-chip--alert.feed-chip--on  { background: var(--color-error, #ef4444);  border-color: var(--color-error, #ef4444); }
.feed-chip--warn.feed-chip--on   { background: #d97706; border-color: #d97706; }
.feed-chip--sug.feed-chip--on    { background: #6366f1; border-color: #6366f1; }

/* ── Feed list ────────────────────────────────────────────────── */
.feed-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.feed-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-8) var(--sp-4);
    color: var(--color-fg-muted);
    font-size: var(--fs-sm);
    text-align: center;
}

/* ── Load more ────────────────────────────────────────────────── */
.feed-loadmore {
    display: flex;
    justify-content: center;
    padding: var(--sp-3) var(--sp-4) var(--sp-4);
}

/* ============================================================
   ENTITY FORM — Entity Picker (ef-picker)
============================================================ */
.ef-picker {
    position: relative;
}

/* Selected chip — shown when an entity has been picked */
.ef-picker__selected {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0px var(--sp-3);
    background: var(--color-bg-muted, #f1f5f9);
    border: 1px solid var(--color-border);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    color: var(--color-fg);
}

.ef-picker__selected-name {
    flex: 1;
    font-weight: var(--fw-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ef-picker__clear {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    border-radius: var(--r-sm);
    color: var(--color-fg-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: background .12s, color .12s;
}

.ef-picker__clear:hover {
    background: var(--color-bg-subtle, #e2e8f0);
    color: var(--color-fg);
}

/* Dropdown */
.ef-picker__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,.1));
    z-index: 10;
    overflow: hidden;
    max-height: 220px;
    overflow-y: auto;
}

.ef-picker__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--sp-2) var(--sp-3);
    cursor: pointer;
    transition: background .1s;
}

.ef-picker__item:hover {
    background: var(--color-bg-muted, #f1f5f9);
}

.ef-picker__name {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--color-fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ef-picker__sub {
    font-size: var(--fs-xs);
    color: var(--color-fg-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ef-picker__hint {
    padding: var(--sp-3) var(--sp-3);
    font-size: var(--fs-sm);
    color: var(--color-fg-muted);
    text-align: center;
}



/* ============================================================
   Marketing Content Calendar
============================================================ */
.mco-page {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
    padding-bottom: calc(var(--sp-8) + 56px);
}

.mco-page__header { align-items: flex-start; }
.mco-page__alert { margin-bottom: 0; }
.mco-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4);
    margin-bottom: 0;
}
.mco-toolbar__views, .mco-toolbar__filters { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.mco-planner {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(0, 2fr);
    gap: var(--sp-4);
    align-items: end;
    padding: var(--sp-4);
}
.mco-planner__intro h2 {
    margin: var(--sp-1) 0 var(--sp-1);
    font-size: var(--fs-lg);
}
.mco-planner__meta {
    margin: var(--sp-3) 0 0;
    color: var(--color-primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
}
.mco-planner__form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(240px, 1.4fr) minmax(170px, .9fr) repeat(3, minmax(120px, .6fr));
    gap: var(--sp-3);
}
.mco-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sp-4);
    margin-bottom: 0;
}
.mco-stat { padding: var(--sp-4); }
.mco-stat span { display: block; color: var(--color-fg-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--ls-widest); }
.mco-stat strong { display: block; margin-top: var(--sp-2); font-size: 28px; color: var(--color-fg); }
.mco-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(150px, 1fr));
    gap: var(--sp-3);
    min-height: 0;
    overflow: visible;
}
.mco-day { min-height: 180px; padding: var(--sp-3); }
.mco-day__date { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--sp-3); color: var(--color-fg-muted); }
.mco-day__date strong { font-size: var(--fs-xl); color: var(--color-fg); }
.mco-kanban { display: grid; grid-template-columns: repeat(6, minmax(180px, 1fr)); gap: var(--sp-3); overflow-x: auto; padding-bottom: var(--sp-2); }
.mco-kanban__column { background: var(--color-bg-muted); border: 1px solid var(--color-border); border-radius: var(--r-lg); padding: var(--sp-3); min-height: 420px; }
.mco-kanban__heading { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-sm); font-weight: var(--fw-semibold); text-transform: capitalize; margin-bottom: var(--sp-3); }
.mco-kanban__heading span { color: var(--color-fg-muted); }
.mco-campaign { display: grid; gap: var(--sp-4); }
.mco-campaign__plan { padding: var(--sp-4); }
.mco-campaign__plan-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.mco-campaign__pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-4); }
.mco-piece-card {
    width: 100%;
    display: grid;
    gap: var(--sp-1);
    text-align: left;
    border: 1px solid var(--color-border);
    border-radius: var(--r-md);
    background: var(--color-bg-surface);
    padding: var(--sp-3);
    cursor: pointer;
    transition: border-color var(--d-fast), box-shadow var(--d-fast), transform var(--d-fast);
}
.mco-piece-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.mco-piece-card__channel { font-size: 10px; text-transform: uppercase; letter-spacing: var(--ls-widest); color: var(--color-primary); font-weight: var(--fw-bold); }
.mco-piece-card span:last-child { font-size: var(--fs-xs); color: var(--color-fg-muted); text-transform: capitalize; }
.mco-drawer-backdrop { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; left: 0; background: rgba(15, 23, 42, .35); z-index: 40; }
.mco-drawer {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(720px, 100vw);
    background: var(--color-bg-surface);
    border-left: 1px solid var(--color-border);
    box-shadow: var(--shadow-xl);
    z-index: 41;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--topbar-h));
    min-height: 0;
}
.mco-drawer__head { display: flex; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-5); border-bottom: 1px solid var(--color-border); }
.mco-drawer__head h2 { margin: 0; font-size: var(--fs-2xl); }
.mco-drawer__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--color-border); }
.mco-tabs { display: flex; gap: var(--sp-1); padding: var(--sp-3) var(--sp-5) 0; overflow-x: auto; }
.mco-tabs__tab { border: 0; background: transparent; color: var(--color-fg-muted); padding: var(--sp-3); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.mco-tabs__tab--active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: var(--fw-semibold); }
.mco-drawer__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: var(--sp-5);
    overflow-y: auto;
    overflow-x: hidden;
}
.mco-copy-block { white-space: pre-wrap; background: var(--color-bg-muted); border: 1px solid var(--color-border); border-radius: var(--r-lg); padding: var(--sp-4); color: var(--color-fg); }
@media (max-width: 1100px) {
    .mco-calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mco-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mco-toolbar { align-items: stretch; flex-direction: column; }
    .mco-planner { grid-template-columns: 1fr; align-items: stretch; }
    .mco-planner__form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .mco-calendar, .mco-summary-grid { grid-template-columns: 1fr; }
    .mco-planner__form { grid-template-columns: 1fr; }
}
.mco-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.mco-section-head h2 { margin: var(--sp-1) 0; font-size: var(--fs-xl); }
.mco-topic-board { padding: var(--sp-4); }
.mco-empty { display: grid; gap: var(--sp-3); place-items: start; padding: var(--sp-5); border: 1px dashed var(--color-border); border-radius: var(--r-lg); background: var(--color-bg-muted); }
.mco-topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
.mco-topic-card { display: grid; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--color-border); border-radius: var(--r-lg); background: var(--color-bg-surface); }
.mco-topic-card--selected { border-color: var(--color-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 16%, transparent); }
.mco-topic-card__head, .mco-topic-card__actions { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.mco-topic-card__head span { display: block; color: var(--color-fg-muted); font-size: var(--fs-xs); margin-top: var(--sp-1); }
.mco-topic-card p { margin: 0; color: var(--color-fg-muted); font-size: var(--fs-sm); white-space: pre-line; }
.mco-chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.mco-preview { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3); border: 1px solid var(--color-border); border-radius: var(--r-md); background: var(--color-bg-muted); color: var(--color-fg-muted); font-size: var(--fs-sm); }
.mco-preview strong { color: var(--color-fg); }
.mco-checklist { display: grid; gap: var(--sp-3); }
.mco-checklist label { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3); border: 1px solid var(--color-border); border-radius: var(--r-md); background: var(--color-bg-muted); }
.mco-section-head__actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }`n.mco-guidance { margin-bottom: var(--sp-4); padding: var(--sp-3); border: 1px solid var(--color-border); border-radius: var(--r-md); background: var(--color-bg-muted); color: var(--color-fg-muted); font-size: var(--fs-sm); }

/* Dynamic Entity table horizontal scroll + sticky columns */
.table-wrap--dynamic {
  isolation: isolate;
}

.table-scroll--dynamic {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.table--dynamic {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

.table--dynamic .table__cell {
  background: var(--color-bg-surface, var(--card-bg));
  vertical-align: middle;
}

.table--dynamic .table__cell--header {
  background: var(--p-slate-50);
}

.table--dynamic .table__cell--sticky-left {
  position: sticky;
  z-index: 2;
  box-shadow: 1px 0 0 var(--color-border, var(--table-border));
}

.table--dynamic .table__cell--sticky-right {
  position: sticky;
  z-index: 2;
  background: var(--color-bg-surface, var(--card-bg));
  box-shadow: -1px 0 0 var(--color-border, var(--table-border));
}

.table--dynamic thead .table__cell--sticky-left,
.table--dynamic thead .table__cell--sticky-right {
  z-index: 3;
  background: var(--p-slate-50);
}

.table--dynamic .table__cell--action {
  text-align: center;
  padding: var(--sp-1);
}

.table--dynamic .table__cell--truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table--dynamic .table__cell--nowrap { white-space: nowrap; }
.table--dynamic .table__cell--align-left { text-align: left; }
.table--dynamic .table__cell--align-center { text-align: center; }
.table--dynamic .table__cell--align-right { text-align: right; }

@media (max-width: 720px) {
  .table--dynamic .table__cell--sticky-left,
  .table--dynamic .table__cell--sticky-right {
    position: static;
    box-shadow: none;
  }
}
