/* ===========================================================
   SampleDB Refined Redesign
   Introduces: sidebar app shell, dashboard, status chips,
   fabrication timeline, data-table polish, modals, mobile.
   Layered on top of style.css — extends rather than replaces.
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --sidebar-w: 240px;
    --topbar-h: 64px;
    --radius-pill: 9999px;
    --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 30px rgba(15, 23, 42, 0.18);
    --font-family-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

:root[data-theme="dark"] {
    --shadow-lg: 0 20px 40px rgba(1, 4, 9, 0.7);
}

/* Body must flex the app shell full-height. style.css set body max-width:1200px
   and centered — override here. */
body {
    max-width: none;
    padding: 0;
    margin: 0;
    min-height: 100vh;
}

/* Force 24h time format on datetime-local inputs in WebKit (Chrome, Safari).
   lang="en-GB" on the input element handles Chromium; this hides the AM/PM
   field as a fallback for browsers that ignore the lang attribute. */
input[type="datetime-local"]::-webkit-datetime-edit-ampm-field {
    display: none;
}

/* ---------- App shell ---------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.app-shell > .app-main {
    min-width: 0;
    padding: 28px 40px 80px;
    max-width: 1400px;
    width: 100%;
}

/* Auth pages skip the shell */
.auth-body .app-shell {
    display: block;
    grid-template-columns: 1fr;
}
.auth-body .app-shell > .app-main {
    max-width: 760px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--surface-default);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 16px;
    font-weight: 800;
    font-size: 17px;
    color: var(--color-primary);
    text-decoration: none;
}

.sidebar__brand svg {
    width: 26px;
    height: 26px;
}

.sidebar__primary {
    width: 100%;
    margin-bottom: 10px;
}

.sidebar__group {
    margin-top: 8px;
}

.sidebar__group-title {
    padding: 8px 10px 4px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--neutral-700);
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar__item svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    flex: none;
    color: var(--text-muted);
}

.sidebar__item:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--color-primary);
}

.sidebar__item:hover svg {
    color: var(--color-primary);
}

:root[data-theme="dark"] .sidebar__item:hover {
    background: rgba(88, 166, 255, 0.12);
}

.sidebar__item.is-active {
    background: rgba(37, 99, 235, 0.12);
    color: var(--color-primary);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--color-primary);
}

.sidebar__item.is-active svg {
    color: var(--color-primary);
}

:root[data-theme="dark"] .sidebar__item.is-active {
    background: rgba(88, 166, 255, 0.18);
}

.sidebar__footer {
    margin-top: auto;
    padding: 12px 8px 4px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-secondary-bg);
    color: var(--color-secondary-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    flex: none;
}

.sidebar__userinfo {
    flex: 1;
    min-width: 0;
    font-size: 13px;
}

.sidebar__username {
    font-weight: 600;
    color: var(--text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.sidebar__footer-actions {
    display: flex;
    gap: 6px;
    padding: 0 8px 0;
}

.sidebar__footer-actions .icon-btn {
    flex: 1;
}

.sidebar__mobile-toggle {
    display: none;
}

/* ---------- Page topbar ---------- */
.page-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-topbar__left {
    flex: 1;
    min-width: 0;
}

.page-topbar__left h1 {
    font-size: 24px;
    color: var(--text-strong);
    margin: 0 0 4px;
}

.page-topbar__crumbs {
    font-size: 12.5px;
    color: var(--text-muted);
}

.page-topbar__actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* ---------- Sample detail page ---------- */
.sample-detail-topbar {
    align-items: flex-start;
}

.sample-detail-actions .button svg {
    width: 16px;
    height: 16px;
    flex: none;
}

.sample-detail-panel-slot[hidden] {
    display: none;
}

.sample-edit-dialog {
    max-width: 500px;
}

.sample-edit-modal .alert {
    margin: 14px 22px 0;
}

.sample-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
    gap: 18px;
    align-items: start;
}

.sample-description-card,
.sample-attachments-card {
    padding: 18px 22px;
    margin: 0;
}

.sample-description-card__chips {
    margin-top: 14px;
}

.inline-edit {
    min-width: 0;
}

.inline-edit__heading {
    margin: 0 0 4px;
}

.inline-edit__display {
    box-sizing: border-box;
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-strong);
    font: inherit;
    text-align: left;
    border-radius: 8px;
    cursor: text;
}

.inline-edit__display:hover,
.inline-edit__display:focus-visible {
    background: var(--surface-subtle);
    border-color: var(--border-subtle);
    outline: none;
}

.inline-edit__display--title {
    display: block;
    padding: 2px 6px;
    margin-left: -6px;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
}

.inline-edit__display--description {
    display: block;
    padding: 8px 10px;
    margin: -8px -10px 0;
    line-height: 1.7;
    white-space: pre-wrap;
}

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

.inline-edit__display[hidden] {
    display: none !important;
}

.inline-edit__form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.inline-edit__form[hidden] {
    display: none;
}

.inline-edit__form--title {
    max-width: min(760px, 100%);
}

.inline-edit__form--title input {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-strong);
}

.inline-edit__form textarea {
    min-height: 118px;
    resize: vertical;
    line-height: 1.6;
}

.inline-edit__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.inline-edit__alert {
    margin: 0 0 8px;
}

.readonly-field {
    min-height: 38px;
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--surface-subtle);
    color: var(--text-strong);
    font-size: 13px;
}

.fabrication-steps .flex-between .button svg,
.attachment-upload-label svg,
.attachment-drop-tile svg {
    width: 16px;
    height: 16px;
    flex: none;
}

/* Compact icon-only action buttons inside fab steps */
.fab-step__action-btn {
    min-height: 28px;
    width: 28px;
    padding: 0;
    border-radius: 6px;
}

.fab-step__action-btn svg {
    width: 14px;
    height: 14px;
    flex: none;
}

.fab-step__action-btn--delete {
    color: var(--color-destructive);
}

.fab-step__action-btn--delete:hover {
    background: var(--color-destructive-bg);
    border-color: var(--color-destructive);
}

.sample-attachments-card .attachments-header {
    align-items: center;
}

.sample-attachments-card .attachments-header .eyebrow {
    margin: 0;
}

.sample-attachment-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin: 0;
}

.sample-attachment-grid .gallery-item {
    border-color: var(--border-subtle);
    border-radius: 8px;
    background: var(--surface-subtle);
}

.sample-attachment-grid .gallery-thumb {
    aspect-ratio: 16 / 9;
}

.sample-attachment-grid .gallery-item__caption {
    padding: 6px 8px;
}

.attachment-drop-tile {
    min-height: 100px;
    height: 100%;
    margin: 0;
    padding: 0;
    border-width: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
}

.attachment-drop-tile svg {
    width: 20px;
    height: 20px;
}

.attachment-drop-tile .upload-progress {
    width: min(120px, 80%);
}

.sample-attachments-card .attachment-file-list {
    margin-top: 12px;
}

.attachment-file-list__icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* ---------- Dashboard stats ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 16px 18px;
    background: var(--surface-default);
    border: 1px solid var(--border-subtle);
    border-top: 3px solid var(--color-primary);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.stat-card__label {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stat-card__value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-strong);
    margin: 4px 0 2px;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.stat-card__delta {
    font-size: 12px;
    color: var(--color-success);
    font-weight: 600;
}

.stat-card__delta.down {
    color: var(--color-destructive);
}

.stat-card__delta.primary {
    color: var(--color-primary);
}

/* ---------- Status chips ---------- */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    white-space: nowrap;
}

.status-chip__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.status-chip--active {
    background: var(--color-success-bg);
    color: var(--color-success);
    border-color: var(--color-success-border);
}

.status-chip--progress {
    background: rgba(37, 99, 235, 0.08);
    color: var(--color-primary);
    border-color: rgba(37, 99, 235, 0.2);
}

:root[data-theme="dark"] .status-chip--progress {
    background: rgba(88, 166, 255, 0.12);
    color: var(--color-primary);
    border-color: rgba(88, 166, 255, 0.3);
}

.status-chip--archived {
    background: var(--surface-muted);
    color: var(--text-muted);
    border-color: var(--border-subtle);
}

.status-chip--pending {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

:root[data-theme="dark"] .status-chip--pending {
    background: rgba(251, 191, 36, 0.12);
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.3);
}

.status-chip--planned {
    background: rgba(139, 92, 246, 0.08);
    color: #7c3aed;
    border-color: rgba(139, 92, 246, 0.2);
}

:root[data-theme="dark"] .status-chip--planned {
    background: rgba(167, 139, 250, 0.12);
    color: #a78bfa;
    border-color: rgba(167, 139, 250, 0.3);
}

.status-chip--danger {
    background: var(--color-destructive-bg);
    color: var(--color-destructive);
    border-color: var(--color-destructive-border);
}

/* ---------- Toolbar (search + filter chips + view seg) ---------- */
.toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    background: var(--surface-default);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    margin-bottom: 20px;
}

.toolbar__row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.toolbar__row-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.toolbar__search {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: var(--surface-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    min-height: 38px;
}

.toolbar__search svg {
    color: var(--text-muted);
    width: 16px;
    height: 16px;
    flex: none;
}

.toolbar__search input {
    background: transparent;
    border: none;
    outline: none;
    flex: 1;
    font-size: 14px;
    color: var(--text-strong);
    min-height: auto;
    padding: 0;
    box-shadow: none;
}

.toolbar__search input:focus {
    box-shadow: none;
}

.toolbar__spacer {
    flex: 1;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: var(--surface-subtle);
    border: 1px dashed var(--border-subtle);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-chip:hover {
    color: var(--text-strong);
    border-color: var(--border-strong);
}

.filter-chip.is-active {
    background: var(--color-secondary-bg);
    color: var(--color-secondary-text);
    border: 1px solid var(--color-secondary-border);
}

.filter-chip svg {
    width: 14px;
    height: 14px;
}

.seg {
    display: inline-flex;
    padding: 3px;
    border-radius: 8px;
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
}

.seg button,
.seg a {
    padding: 5px 12px;
    border-radius: 6px;
    background: transparent;
    border: none;
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-family: inherit;
    min-height: 0;
}

.seg button svg,
.seg a svg {
    width: 14px;
    height: 14px;
}

.seg button.is-active,
.seg a.is-active {
    background: var(--surface-default);
    color: var(--text-strong);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ---------- Compact buttons (extra to existing .button classes) ---------- */
.button--icon {
    min-height: 38px;
    width: 38px;
    padding: 0;
}

.button--icon svg {
    width: 16px;
    height: 16px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}

.icon-btn:hover {
    background: var(--surface-muted);
    color: var(--text-strong);
}

.icon-btn svg {
    width: 14px;
    height: 14px;
}

/* ---------- Sample card refinements ---------- */
.sample-card {
    overflow: hidden;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.18s, box-shadow 0.18s;
}

.sample-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(17, 24, 39, 0.12);
}

:root[data-theme="dark"] .sample-card:hover {
    box-shadow: 0 10px 30px rgba(1, 4, 9, 0.75);
}

.sample-card__thumbnail {
    display: block;
    height: 160px;
    margin: 0;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    position: relative;
}

:root[data-theme="dark"] .sample-card__thumbnail {
    background: linear-gradient(135deg, #0c2d6b, #1f6feb);
}

.sample-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
}

.sample-card:hover .sample-card__thumbnail img {
    transform: scale(1.03);
}

.sample-card__thumbnail--empty::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.25), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.15), transparent 50%);
}

.sample-card__status {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
}

.sample-card__body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.sample-card__id {
    font-family: var(--font-family-mono);
    font-size: 11.5px;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.sample-card__name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-strong);
    margin: 0;
    line-height: 1.3;
}

.sample-card__name a {
    color: inherit;
    text-decoration: none;
}

.sample-card__name a:hover {
    color: var(--color-primary);
}

.sample-card__desc {
    font-size: 13px;
    color: var(--text-muted);
    margin: 2px 0 6px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sample-card__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.sample-card__chip {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    color: var(--text-muted);
}

.sample-card__meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
    align-items: center;
}

/* ---------- Status pill buttons (samples toolbar) ---------- */
.status-pills {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.13s ease, color 0.13s ease;
}

.status-pill:hover {
    background: var(--surface-muted);
    color: var(--text-strong);
}

.status-pill.is-active {
    background: var(--color-primary);
    color: #fff;
}

:root[data-theme="dark"] .status-pill.is-active {
    background: var(--color-primary);
    color: #fff;
}

/* ---------- Filter chip select ---------- */
.filter-chip__select {
    background: transparent;
    border: none;
    padding: 0;
    min-height: auto;
    color: inherit;
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
    outline: none;
}

/* ---------- Date range chip (details/summary) ---------- */
.date-range-chip {
    position: relative;
    display: inline-block;
}

.date-range-chip summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.date-range-chip summary::-webkit-details-marker { display: none; }

.date-range-chip.is-active > summary.filter-chip {
    background: var(--color-secondary-bg);
    color: var(--color-secondary-text);
    border: 1px solid var(--color-secondary-border);
}

.date-picker-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 100;
    background: var(--surface-default);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    min-width: 260px;
}

.date-picker-panel__field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.date-picker-panel__field input[type="date"] {
    font-size: 13px;
    padding: 5px 8px;
    min-height: auto;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-subtle);
    color: var(--text-strong);
    font-family: inherit;
}

.date-picker-panel__sep {
    color: var(--text-muted);
    padding-top: 16px;
}

/* ---------- Sample card color variants ---------- */
.sample-card__thumbnail--color-0 { background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%); }
.sample-card__thumbnail--color-1 { background: linear-gradient(135deg, #065f46 0%, #10b981 100%); }
.sample-card__thumbnail--color-2 { background: linear-gradient(135deg, #4c1d95 0%, #8b5cf6 100%); }
.sample-card__thumbnail--color-3 { background: linear-gradient(135deg, #78350f 0%, #f59e0b 100%); }
.sample-card__thumbnail--color-4 { background: linear-gradient(135deg, #1e3a5f 0%, #0ea5e9 100%); }
.sample-card__thumbnail--color-5 { background: linear-gradient(135deg, #881337 0%, #f43f5e 100%); }

:root[data-theme="dark"] .sample-card__thumbnail--color-0 { background: linear-gradient(135deg, #0c2461 0%, #1d4ed8 100%); }
:root[data-theme="dark"] .sample-card__thumbnail--color-1 { background: linear-gradient(135deg, #064e3b 0%, #059669 100%); }
:root[data-theme="dark"] .sample-card__thumbnail--color-2 { background: linear-gradient(135deg, #3b0764 0%, #7c3aed 100%); }
:root[data-theme="dark"] .sample-card__thumbnail--color-3 { background: linear-gradient(135deg, #451a03 0%, #d97706 100%); }
:root[data-theme="dark"] .sample-card__thumbnail--color-4 { background: linear-gradient(135deg, #0c1e38 0%, #0284c7 100%); }
:root[data-theme="dark"] .sample-card__thumbnail--color-5 { background: linear-gradient(135deg, #4c0519 0%, #e11d48 100%); }

/* ---------- Sample card status badge (overlay on thumbnail) ---------- */
.sample-card__status {
    background: rgba(13, 17, 23, 0.82);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
}

.sample-card__status .status-chip__dot {
    display: none;
}

/* meta dot separator */
.sample-card__meta-dot {
    color: var(--text-muted);
    opacity: 0.5;
}

/* ---------- Data table ---------- */
.data-table {
    width: 100%;
    background: var(--surface-default);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    border-collapse: collapse;
    table-layout: auto;
}

.data-table th {
    text-align: left;
    padding: 11px 16px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
    padding: 12px 16px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-strong);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

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

.data-table .mono,
.data-table .cell--mono {
    font-family: var(--font-family-mono);
    font-size: 12.5px;
    color: var(--text-muted);
}

.data-table .cell--id {
    font-family: var(--font-family-mono);
    font-size: 12.5px;
    color: var(--color-primary);
    font-weight: 600;
}

.data-table-wrap {
    background: var(--surface-default);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
}

.data-table-wrap > .data-table {
    border: none;
    border-radius: 0;
}

.data-table-wrap__head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.data-table-wrap__head strong {
    font-size: 14px;
    color: var(--text-strong);
}

/* ---------- Equipment booking timeline (.tline-* system) ---------- */
.timeline-wrap {
    background: var(--surface-default);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.timeline-wrap__scroll {
    overflow-x: auto;
}

.tline {
    --tline-equipment-col: 180px;
    --tline-hour-w: 80px;
    --tline-lane-w: calc(var(--tline-hour-w) * 24);
    min-width: calc(var(--tline-equipment-col) + var(--tline-lane-w));
}

.tline-head {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 3;
}

.tline-head__left {
    width: var(--tline-equipment-col);
    min-width: var(--tline-equipment-col);
    padding: 12px 14px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    left: 0;
    z-index: 4;
}

.tline-hours {
    display: grid;
    grid-template-columns: repeat(24, var(--tline-hour-w));
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border-subtle);
    border-left: 1px solid var(--border-subtle);
}

.tline-hour {
    padding: 12px 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    border-right: 1px solid var(--border-subtle);
}

.tline-row {
    display: flex;
}

.tline-row__left {
    width: var(--tline-equipment-col);
    min-width: var(--tline-equipment-col);
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-strong);
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-default);
    position: sticky;
    left: 0;
    z-index: 2;
    box-shadow: 1px 0 0 var(--border-subtle);
}

.tline-row__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    flex-shrink: 0;
}

.tline-row--offline .tline-row__dot { background: var(--color-destructive); }
.tline-row--maintenance .tline-row__dot { background: #f59e0b; }

.tline-row__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tline-row__status {
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tline-lane {
    position: relative;
    width: var(--tline-lane-w);
    min-width: var(--tline-lane-w);
    height: 64px;
    border-bottom: 1px solid var(--border-subtle);
    border-left: 1px solid var(--border-subtle);
    background: var(--surface-default);
    cursor: crosshair;
}

.tline-lane--locked {
    background: repeating-linear-gradient(-45deg, var(--surface-subtle) 0 10px, var(--surface-default) 10px 20px);
    cursor: not-allowed;
    display: flex;
    align-items: center;
    padding-left: 16px;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Maintenance — admin+access can book: subtle amber tint over the normal lane */
.tline-lane--maintenance {
    background: repeating-linear-gradient(
        -45deg,
        transparent 0 9px,
        rgba(245, 158, 11, 0.05) 9px 10px
    ), var(--surface-default);
}

/* Maintenance — view-only: amber crosshatch, non-interactive */
.tline-lane--maintenance-locked {
    cursor: not-allowed;
    background: repeating-linear-gradient(
        -45deg,
        transparent 0 9px,
        rgba(245, 158, 11, 0.10) 9px 10px
    ), var(--surface-default);
    display: flex;
    align-items: center;
    padding-left: 16px;
    gap: 8px;
    font-size: 12px;
    color: #b45309;
}

:root[data-theme="dark"] .tline-lane--maintenance-locked { color: #fbbf24; }

/* Offline — nobody can book: red crosshatch */
.tline-lane--offline {
    cursor: not-allowed;
    background: repeating-linear-gradient(
        -45deg,
        transparent 0 9px,
        rgba(185, 28, 28, 0.07) 9px 10px
    ), var(--surface-default);
    display: flex;
    align-items: center;
    padding-left: 16px;
    gap: 8px;
    font-size: 12px;
    color: var(--color-destructive);
}

/* Status badges in the equipment name column */
.tline-row__status-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 4px;
    flex: none;
}

.tline-row__status-badge--maintenance {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
    border: 1px solid rgba(245, 158, 11, 0.30);
}

.tline-row__status-badge--offline {
    background: rgba(185, 28, 28, 0.08);
    color: var(--color-destructive);
    border: 1px solid rgba(185, 28, 28, 0.25);
}

:root[data-theme="dark"] .tline-row__status-badge--maintenance {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.35);
}

:root[data-theme="dark"] .tline-row__status-badge--offline {
    background: rgba(240, 136, 62, 0.12);
    color: #f87171;
    border-color: rgba(240, 136, 62, 0.30);
}

.tline-lane .slots {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(24, var(--tline-hour-w));
    pointer-events: none;
}

.tline-lane .slot {
    border-right: 1px dashed var(--border-subtle);
    cursor: pointer;
    pointer-events: all;
    transition: background 0.1s;
}

.tline-lane .slot:hover {
    background: rgba(37, 99, 235, 0.08);
}

.tline-block {
    position: absolute;
    top: 8px;
    height: 48px;
    border-radius: 8px;
    background: var(--color-primary);
    color: #fff;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    overflow: hidden;
    cursor: pointer;
    z-index: 1;
}

.tline-block--own {
    background: linear-gradient(135deg, #14532d, #16a34a);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.tline-block small {
    font-size: 10.5px;
    opacity: 0.85;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Fabrication timeline ---------- */
.fab-timeline {
    position: relative;
    padding: 0;
    list-style: none;
    margin: 0;
}

.fab-step {
    display: grid;
    grid-template-columns: 44px 1fr;
    column-gap: 14px;
    padding: 14px 0;
    border-bottom: 1px dashed var(--border-subtle);
    align-items: flex-start;
}

.fab-step:last-child {
    border-bottom: none;
}

.fab-step__num {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--color-secondary-bg);
    color: var(--color-secondary-text);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-family-mono);
    font-size: 13px;
    flex: none;
    margin-top: 1px;
}

.fab-step__body {
    min-width: 0;
}

.fab-step__title {
    font-weight: 600;
    font-size: 14px;
    margin: 0 0 4px;
    color: var(--text-strong);
    line-height: 1.45;
}

.fab-step__meta {
    font-size: 12.5px;
    color: var(--text-muted);
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 2px;
}

.fab-step__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.fab-step__meta-item svg {
    width: 13px;
    height: 13px;
    flex: none;
}

.fab-step__actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s ease;
    margin-top: 8px;
}

.fab-step:hover .fab-step__actions,
.fab-step:focus-within .fab-step__actions {
    opacity: 1;
}

/* ---------- Page details panel (collapsible section wrapper) ---------- */
.panel-details > summary {
    list-style: none;
}

.panel-details > summary::-webkit-details-marker {
    display: none;
}

.panel-details > summary {
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.panel-details > summary::before {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}

.panel-details[open] > summary::before {
    transform: rotate(45deg);
}

/* ---------- Dashboard layout ---------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
}

.dashboard-grid > .card {
    padding: 20px 24px;
    margin: 0;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel-head h2,
.panel-head h3 {
    margin: 0;
    font-size: 15px;
    color: var(--text-strong);
}

.panel-head__link {
    font-size: 12.5px;
    color: var(--color-primary);
    cursor: pointer;
    text-decoration: none;
}

.panel-head__link:hover {
    color: var(--color-primary-active);
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.12s ease;
}

.recent-item:hover {
    background: var(--surface-subtle);
}

.recent-item__thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    flex: none;
}

.recent-item__thumb--color-0 { background: linear-gradient(135deg, #1e3a8a, #3b82f6); }
.recent-item__thumb--color-1 { background: linear-gradient(135deg, #065f46, #10b981); }
.recent-item__thumb--color-2 { background: linear-gradient(135deg, #4c1d95, #8b5cf6); }
.recent-item__thumb--color-3 { background: linear-gradient(135deg, #78350f, #f59e0b); }
.recent-item__thumb--color-4 { background: linear-gradient(135deg, #1e3a5f, #0ea5e9); }
.recent-item__thumb--color-5 { background: linear-gradient(135deg, #881337, #f43f5e); }

:root[data-theme="dark"] .recent-item__thumb--color-0 { background: linear-gradient(135deg, #0c2461, #1d4ed8); }
:root[data-theme="dark"] .recent-item__thumb--color-1 { background: linear-gradient(135deg, #064e3b, #059669); }
:root[data-theme="dark"] .recent-item__thumb--color-2 { background: linear-gradient(135deg, #3b0764, #7c3aed); }
:root[data-theme="dark"] .recent-item__thumb--color-3 { background: linear-gradient(135deg, #451a03, #d97706); }
:root[data-theme="dark"] .recent-item__thumb--color-4 { background: linear-gradient(135deg, #0c1e38, #0284c7); }
:root[data-theme="dark"] .recent-item__thumb--color-5 { background: linear-gradient(135deg, #4c0519, #e11d48); }

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

.recent-item__body {
    flex: 1;
    min-width: 0;
}

.recent-item__name {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-item__meta {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-family-mono);
}

.recent-item__time {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-family-mono);
    flex: none;
}

/* ---------- Key-value list (sidebar details) ---------- */
.kv-list {
    display: flex;
    flex-direction: column;
}

.kv-list__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
}

.kv-list__row:last-child {
    border-bottom: none;
}

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

.kv-list__value {
    font-weight: 500;
    color: var(--text-strong);
    text-align: right;
}

/* ---------- Eyebrow ---------- */
.eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 10px;
}

/* ---------- Modal dialogs ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 22, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: modalFade 0.15s ease-out;
}

.modal-backdrop[hidden] {
    display: none;
}

@keyframes modalFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modalPop {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

.modal {
    background: var(--surface-default);
    color: var(--text-strong);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    border-top: 3px solid var(--color-primary);
    display: flex;
    flex-direction: column;
    animation: modalPop 0.18s ease-out;
}

.modal__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 22px 14px;
    border-bottom: 1px solid var(--border-subtle);
    gap: 10px;
}

.modal__head h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-strong);
    letter-spacing: -0.01em;
}

.modal__sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.5;
}

.modal__close {
    width: 30px;
    height: 30px;
    min-height: 0;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    flex: none;
    padding: 0;
}

.modal__close:hover {
    background: var(--surface-muted);
    color: var(--text-strong);
}

.modal__body {
    padding: 18px 22px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal__body .form-group {
    margin: 0;
}

.modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-subtle);
    flex-wrap: wrap;
}

/* ---------- Form utilities ---------- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.form-group label {
    font-weight: 600;
    color: var(--neutral-700);
}

.form-group input {
    border: 1px solid var(--neutral-200);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.95rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

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

/* ---------- Wiki attachment styling ---------- */
.wiki-attachments {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
}

.wiki-attach-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wiki-attach {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--surface-subtle);
    text-decoration: none;
    color: inherit;
}

.wiki-attach:hover {
    border-color: var(--color-primary);
    background: var(--surface-default);
}

.wiki-attach__icon {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    flex: none;
    letter-spacing: 0.04em;
    background: var(--color-primary);
    text-transform: uppercase;
}

.wiki-attach__icon--pdf   { background: #dc2626; }
.wiki-attach__icon--video { background: #7c3aed; }
.wiki-attach__icon--xlsx  { background: #15803d; }
.wiki-attach__icon--docx  { background: #2563eb; }
.wiki-attach__icon--png,
.wiki-attach__icon--jpg,
.wiki-attach__icon--jpeg,
.wiki-attach__icon--image { background: #d97706; }
.wiki-attach__icon--zip   { background: #6b7280; }

.wiki-attach__meta {
    flex: 1;
    min-width: 0;
}

.wiki-attach__meta strong {
    display: block;
    font-size: 13.5px;
    color: var(--text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wiki-attach__meta div {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
}

.wiki-attach__actions {
    display: flex;
    gap: 4px;
    flex: none;
}

/* ---------- Inline keyword chips (detail view) ---------- */
.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--color-secondary-bg);
    color: var(--color-secondary-text);
    font-weight: 500;
    border: 1px solid transparent;
}

.chip--dashed {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border-subtle);
    border-style: dashed;
    cursor: pointer;
}

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

/* ---------- Utility tiny helpers ---------- */
.flex { display: flex; }
.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.flex-center {
    display: flex;
    align-items: center;
}
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.muted  { color: var(--text-muted); }
.mono   { font-family: var(--font-family-mono); }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-md { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }

.back-link-quiet {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 10px;
}

.back-link-quiet:hover {
    color: var(--color-primary);
}

.back-link-quiet svg {
    width: 14px;
    height: 14px;
}

/* ---------- Activity feed items ---------- */
.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    transition: background 0.12s ease;
}

.activity-item:hover {
    background: var(--surface-subtle);
}

.activity-item__dot-col {
    flex: none;
    width: 8px;
    display: flex;
    justify-content: center;
    padding-top: 6px;
    position: relative;
}

.activity-item__dot-col::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    bottom: -10px;
    width: 1px;
    background: var(--border-subtle);
    transform: translateX(-50%);
}

.activity-item:last-child .activity-item__dot-col::before {
    display: none;
}

.activity-item__dot-col::after {
    content: '';
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
}

.activity-item__body {
    flex: 1;
    min-width: 0;
}

.activity-item__text {
    font-size: 13px;
    color: var(--text-strong);
    line-height: 1.4;
}

.activity-item__meta {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-family-mono);
    margin-top: 2px;
}

.activity-item__time {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: auto;
    white-space: nowrap;
    font-family: var(--font-family-mono);
    flex: none;
    padding-top: 1px;
}

.activity-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.activity-link:hover {
    text-decoration: underline;
}

/* ---------- Admin notification banner ---------- */
.notif-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.notif-banner {
    display: flex;
    align-items: flex-start;
    gap: 0;
    border-radius: 10px;
    border: 1px solid transparent;
    overflow: hidden;
    position: relative;
    animation: notifSlideIn 0.2s ease-out;
}

@keyframes notifSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

.notif-banner__bar {
    width: 4px;
    align-self: stretch;
    flex: none;
}

.notif-banner__body {
    flex: 1;
    padding: 12px 14px;
    min-width: 0;
}

.notif-banner__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.notif-banner__level {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid;
    flex: none;
}

.notif-banner__msg {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-strong);
}

.notif-banner__meta {
    font-size: 11.5px;
    color: var(--text-muted);
    font-family: var(--font-family-mono);
}

.notif-banner__close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 12px;
    font-size: 18px;
    line-height: 1;
    align-self: flex-start;
    flex: none;
    border-radius: 6px;
    margin-top: 4px;
    margin-right: 4px;
}

.notif-banner__close:hover {
    background: var(--surface-muted);
    color: var(--text-strong);
}

/* Level variants */
.notif-banner--info {
    background: rgba(37, 99, 235, 0.05);
    border-color: rgba(37, 99, 235, 0.2);
}
.notif-banner--info .notif-banner__bar { background: #2563eb; }
.notif-banner--info .notif-banner__level { color: #1d4ed8; border-color: rgba(37,99,235,0.25); background: rgba(37,99,235,0.08); }
:root[data-theme="dark"] .notif-banner--info { background: rgba(68,147,248,0.07); border-color: rgba(68,147,248,0.25); }
:root[data-theme="dark"] .notif-banner--info .notif-banner__level { color: #79c0ff; border-color: rgba(68,147,248,0.3); background: rgba(68,147,248,0.12); }

.notif-banner--warning {
    background: rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.25);
}
.notif-banner--warning .notif-banner__bar { background: #d97706; }
.notif-banner--warning .notif-banner__level { color: #b45309; border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.1); }
:root[data-theme="dark"] .notif-banner--warning { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.3); }
:root[data-theme="dark"] .notif-banner--warning .notif-banner__level { color: #fbbf24; border-color: rgba(245,158,11,0.4); }

.notif-banner--critical {
    background: rgba(220, 38, 38, 0.06);
    border-color: rgba(220, 38, 38, 0.25);
}
.notif-banner--critical .notif-banner__bar { background: #dc2626; }
.notif-banner--critical .notif-banner__level { color: #b91c1c; border-color: rgba(220,38,38,0.3); background: rgba(220,38,38,0.08); }
:root[data-theme="dark"] .notif-banner--critical { background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.3); }
:root[data-theme="dark"] .notif-banner--critical .notif-banner__level { color: #f87171; border-color: rgba(220,38,38,0.4); }

/* ---------- Admin notification panel ---------- */
.notif-admin {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notif-composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.notif-composer textarea {
    flex: 1;
    min-height: 60px;
    resize: vertical;
}

.notif-composer select {
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--surface-default);
    color: var(--text-strong);
    font-family: inherit;
    font-size: 13px;
}

.notif-composer-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: none;
}

.notif-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.notif-list__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--surface-subtle);
    font-size: 13px;
}

.notif-list__level {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 4px;
    flex: none;
}

.notif-list__level--info     { background: rgba(37,99,235,0.1); color: #1d4ed8; }
.notif-list__level--warning  { background: rgba(245,158,11,0.1); color: #b45309; }
.notif-list__level--critical { background: rgba(220,38,38,0.1); color: #b91c1c; }

:root[data-theme="dark"] .notif-list__level--info     { background: rgba(68,147,248,0.15); color: #79c0ff; }
:root[data-theme="dark"] .notif-list__level--warning  { background: rgba(245,158,11,0.15); color: #fbbf24; }
:root[data-theme="dark"] .notif-list__level--critical { background: rgba(220,38,38,0.15); color: #f87171; }

.notif-list__msg {
    flex: 1;
    min-width: 0;
    color: var(--text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notif-list__meta {
    font-size: 11.5px;
    color: var(--text-muted);
    font-family: var(--font-family-mono);
    flex: none;
}

.notif-list__empty {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    padding: 12px 0;
}

/* Small card helper used in dashboards */
.danger-card {
    border-top-color: var(--color-destructive) !important;
}

.danger-card .eyebrow {
    color: var(--color-destructive);
}

/* ---------- Mobile responsive ---------- */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(280px, 85vw);
        height: 100vh;
        z-index: 500;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar__mobile-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 400;
        width: 44px;
        height: 44px;
        border-radius: 10px;
        border: 1px solid var(--border-subtle);
        background: var(--surface-default);
        color: var(--text-strong);
        cursor: pointer;
        box-shadow: var(--shadow-sm);
    }

    .sidebar__mobile-toggle svg {
        width: 20px;
        height: 20px;
    }

    .sidebar-scrim {
        position: fixed;
        inset: 0;
        background: rgba(8, 12, 22, 0.5);
        z-index: 450;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .sidebar-scrim.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    .app-shell > .app-main {
        padding: 64px 16px 80px;
    }

    .page-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .page-topbar__actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .sample-detail-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .samples-grid {
        grid-template-columns: 1fr !important;
    }

    .toolbar {
        padding: 10px 12px;
        gap: 8px;
    }

    .toolbar__row {
        flex-wrap: wrap;
        gap: 6px;
    }

    .toolbar__search {
        flex: 1 1 100%;
        min-width: 0;
    }

    .status-pills {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex: 1;
        min-width: 0;
    }

    .status-pills::-webkit-scrollbar {
        display: none;
    }

    .toolbar__row-right {
        flex-shrink: 0;
    }

    .data-table-wrap {
        overflow-x: auto;
    }

    .data-table {
        min-width: 520px;
    }

    .modal {
        max-width: calc(100vw - 32px) !important;
    }

    .modal__foot .button {
        flex: 1;
        min-width: 110px;
    }
}

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

    .page-topbar__left h1 {
        font-size: 20px;
    }

    .inline-edit__form--title input {
        font-size: 20px;
    }

    .sample-description-card,
    .sample-attachments-card,
    .fabrication-steps {
        padding: 16px;
    }

    .sample-attachment-grid {
        grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    }

    .fab-step__actions {
        opacity: 1;
    }

    .app-shell > .app-main {
        padding: 64px 12px 60px;
    }
}

/* --- Wiki list: tag filter chips + article cards ----------------------- */

.wiki-tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.filter-chip--tag {
    padding: 6px 14px;
    border-style: solid;
    border-color: var(--border-subtle);
    font-weight: 600;
}

.wiki-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.article-tile {
    padding: 18px 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    min-height: 160px;
}

.article-tile__link {
    color: inherit;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
}

.article-tile__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: var(--color-secondary-bg);
    color: var(--color-secondary-text);
    border: 1px solid var(--color-secondary-border);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.article-tile__title {
    margin: 0;
    font-size: 16px;
    color: var(--color-primary);
    line-height: 1.3;
}

.article-tile__excerpt {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-tile__meta {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.article-tile__author {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.avatar-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--text-on-accent);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

/* === Admin === */

.admin-page {
    padding: var(--space-lg);
    max-width: 1280px;
    margin: 0 auto calc(var(--space-2xl) + var(--space-md));
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.flash-region .alert {
    margin-bottom: 0;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--space-lg);
}

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

.admin-page .card {
    --card-padding: 0;
}

.card-header {
    padding: calc(var(--space-md) + var(--space-xs)) var(--space-lg);
    border-bottom: 1px solid var(--neutral-200);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
}

.card-header.column {
    flex-direction: column;
}

.card-header h2 {
    margin: 0;
    font-size: var(--font-size-xl);
    color: var(--color-primary);
}

.card-subtitle {
    margin: var(--space-xs) 0 0;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.add-inline {
    display: flex;
    gap: calc(var(--space-sm) + var(--space-xs));
    align-items: center;
    flex-wrap: wrap;
}

.add-inline input {
    flex: 1;
    min-width: 160px;
}

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

.equipment-cell {
    display: inline-flex;
    align-items: center;
    gap: calc(var(--space-sm) + var(--space-xs));
}

.equipment-cell__name {
    font-weight: 600;
    color: var(--text-strong);
}

.equipment-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success, #10b981);
    display: inline-block;
    flex: none;
}

.equipment-status-dot--offline {
    background: var(--color-destructive, #ef4444);
}

.equipment-status-dot--maintenance {
    background: #f59e0b;
}

.status-select {
    width: auto;
    min-width: 120px;
    font-size: var(--font-size-sm);
    padding: var(--space-xs) var(--space-sm);
}

.equipment-groups {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: center;
}

.group-badge-form {
    display: inline-flex;
    margin: 0;
}

.group-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px calc(var(--space-sm) - 2px) 2px var(--space-sm);
    border-radius: 9999px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--color-primary-active);
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    line-height: 1.4;
}

.group-badge:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--color-destructive, #dc2626);
}

.group-badge__remove {
    font-size: 1rem;
    line-height: 1;
}

.group-badge-empty {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
}

.add-group-form {
    display: inline-flex;
    gap: var(--space-xs);
    align-items: center;
}

.group-add-select {
    min-width: 120px;
    width: auto;
    font-size: var(--font-size-sm);
    padding: var(--space-xs) var(--space-sm);
}

.equipment-table .col-actions {
    width: 180px;
}

.user-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.user-card__equipment-count {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-xs);
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.equipment-count-value {
    color: var(--text-strong);
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.col-actions {
    width: 160px;
    text-align: right;
}

.account-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    align-items: flex-start;
}

.account-actions .inline-form {
    justify-content: flex-end;
}

.remove-user-btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.inline-form input[type="text"] {
    min-width: 0;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--neutral-700);
}

.toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.admin-page .group-select,
.admin-page .equipment-select,
.admin-page input[type="text"],
.admin-page input[type="date"],
.admin-page textarea,
.admin-page select {
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) calc(var(--space-sm) + var(--space-xs));
    font-size: var(--font-size-sm);
    width: 100%;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

.admin-page .group-select:focus,
.admin-page .equipment-select:focus,
.admin-page input:focus,
.admin-page textarea:focus,
.admin-page select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.equipment-access select {
    min-height: 120px;
}

.hint {
    display: inline-block;
    margin-top: calc(var(--space-sm) - var(--space-xs));
    color: var(--neutral-400);
    font-size: 0.75rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-sm);
    border-radius: 9999px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--color-primary-active);
    font-size: 0.75rem;
    margin-left: calc(var(--space-sm) - var(--space-xs));
}

.empty-state {
    text-align: center;
    color: var(--neutral-400);
    font-style: italic;
    padding: var(--space-xl) var(--space-md);
}

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

    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
    }

    .add-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .add-inline input,
    .add-inline .button {
        width: 100%;
    }

    .col-actions {
        width: auto;
        text-align: left;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .button {
        width: 100%;
    }

    .account-actions {
        width: 100%;
    }

    .account-actions .inline-form {
        width: 100%;
        justify-content: flex-start;
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
    }

    .account-actions .inline-form .button,
    .account-actions .button {
        width: 100%;
    }
}

/* === Auth === */

.auth-body {
    background: var(--surface-subtle);
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.auth-page {
    max-width: 720px;
    margin: 0 auto;
    display: grid;
    gap: 24px;
}

.auth-card {
    background: var(--surface-default);
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 12px 30px rgba(17, 24, 39, 0.12);
    border: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-card h2 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.75rem;
    color: var(--color-primary);
}

.auth-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    margin-bottom: 12px;
}

.auth-card__heading {
    margin: 0;
    font-size: 1.8rem;
}

.auth-subtitle {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.auth-messages .alert {
    margin-bottom: 16px;
}

.auth-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.auth-actions .button {
    flex: 1;
}

.auth-toggle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.auth-toggle a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-toggle a:hover {
    color: var(--color-primary-active);
}

.auth-note {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.auth-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.45rem 0.9rem;
    border-radius: 9999px;
    border: 1px solid var(--color-secondary-border);
    background: var(--surface-default);
    color: var(--text-strong);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.auth-theme-toggle:hover {
    background: var(--color-secondary-hover-bg);
    border-color: var(--color-secondary-hover-border);
}

.auth-theme-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-button-focus);
}

.auth-theme-toggle__icon {
    width: 16px;
    height: 16px;
}

html[data-theme="dark"] .auth-theme-toggle__icon--sun {
    display: none;
}

html[data-theme="light"] .auth-theme-toggle__icon--moon {
    display: none;
}

@media (max-width: 600px) {
    .auth-card {
        padding: 24px;
    }

    .auth-actions {
        flex-direction: column;
    }
}

/* === Wiki === */

.wiki-article-grid {
    display: grid;
    grid-template-columns: minmax(0, 3fr) 240px;
    gap: 18px;
    align-items: start;
}

@media (max-width: 900px) {
    .wiki-article-grid {
        grid-template-columns: 1fr;
    }
    .wiki-toc {
        display: none;
    }
}

.article-content-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: 0;
}

.article-content-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: 18px 22px 0;
}

.article-content-panel__header .eyebrow {
    margin: 0;
}

.article-content-panel__body {
    padding: 0 22px 22px;
}

.markdown-body {
    color: var(--text-strong) !important;
    font-family: var(--font-family-base);
    font-size: var(--font-size-base);
    line-height: var(--line-height-body);
}

.markdown-body > *:first-child {
    margin-top: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table {
    margin-bottom: var(--space-md);
}

.markdown-body ul,
.markdown-body ol {
    padding-left: var(--space-xl);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    font-weight: 600;
    line-height: var(--line-height-heading);
    color: var(--text-strong) !important;
}

.markdown-body h1 { font-size: var(--font-size-3xl) !important; }
.markdown-body h2 { font-size: var(--font-size-2xl) !important; }
.markdown-body h3 { font-size: var(--font-size-xl) !important; }
.markdown-body h4 { font-size: var(--font-size-lg) !important; }
.markdown-body h5 { font-size: var(--font-size-base) !important; }
.markdown-body h6 {
    font-size: var(--font-size-sm) !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.markdown-body a {
    color: var(--color-primary) !important;
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
    color: var(--color-primary-active) !important;
}

.markdown-body strong {
    font-weight: 600;
}

.markdown-body code {
    padding: 0.2em 0.4em;
    font-size: 0.85em;
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: var(--radius-sm);
    font-family: var(--font-family-mono);
    color: var(--text-strong) !important;
}

.markdown-body pre {
    background-color: var(--surface-subtle);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    overflow: auto;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: var(--text-strong) !important;
}

.markdown-body blockquote {
    padding: 0 var(--space-md);
    border-left: 0.25em solid var(--neutral-200);
    color: var(--neutral-600) !important;
}

.markdown-body table {
    border-spacing: 0;
    border-collapse: collapse;
    display: block;
    width: max-content;
    max-width: 100%;
    overflow: auto;
}

.markdown-body table th,
.markdown-body table td {
    padding: calc(var(--space-sm) - 2px) var(--space-sm);
    border: 1px solid var(--neutral-200);
}

.markdown-body table th {
    font-weight: 600;
    background-color: var(--surface-subtle);
}

.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    background-color: var(--surface-default);
}

/* TOC sidebar */
.wiki-toc .card {
    padding: 18px 20px;
    position: sticky;
    top: 16px;
}

.wiki-toc .eyebrow {
    margin-bottom: 10px;
}

.wiki-toc nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wiki-toc__item--l3 {
    padding-left: 12px;
}

.wiki-toc nav a {
    display: block;
    padding: 4px 0 4px 8px;
    margin-left: -8px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
}

.wiki-toc nav a:hover {
    color: var(--color-primary);
    border-left-color: var(--color-primary);
}

/* Wiki attachments card */
.wiki-attachments-card {
    padding: 18px 22px;
}

.wiki-attachments-card .eyebrow {
    margin: 0;
}

.wiki-attach-count {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    font-size: 12px;
}

.wiki-attachments-card .upload-drop-zone {
    margin-top: 12px;
}

/* EasyMDE editor */
.EasyMDEContainer {
    display: block;
    width: 100%;
}

.editor-toolbar {
    display: flex !important;
    opacity: 1 !important;
    border: 1px solid var(--neutral-200);
    background-color: var(--surface-default);
    padding: 5px;
}

.editor-toolbar a {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin: 0 2px;
    padding: 3px;
    color: var(--neutral-600) !important;
    border: 1px solid transparent;
    border-radius: 3px;
    text-decoration: none !important;
}

.editor-toolbar a:hover {
    background-color: var(--surface-subtle);
    border-color: var(--neutral-200);
    color: var(--color-primary) !important;
}

.editor-toolbar a.active {
    background-color: var(--color-primary);
    border-color: var(--color-primary-active);
    color: var(--text-on-accent) !important;
}

.CodeMirror {
    height: 500px !important;
    border: 1px solid var(--neutral-200);
    border-top: none;
}

.editor-toolbar i.separator {
    display: inline-block;
    width: 1px;
    height: 20px;
    margin: 0 5px;
    background-color: var(--neutral-200);
}

.editor-statusbar {
    padding: 8px;
    color: var(--text-muted);
    background-color: var(--surface-subtle);
    border: 1px solid var(--neutral-200);
    border-top: none;
}

/* Wiki image picker panel */
.wiki-image-picker {
    margin-top: var(--space-md);
    background: var(--surface-default);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
}

.wiki-image-picker__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--neutral-200);
}

.wiki-image-picker__title {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-strong);
}

.wiki-image-picker__close {
    background: none;
    border: none;
    font-size: var(--font-size-lg);
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
}

.wiki-image-picker__close:hover {
    color: var(--text-strong);
}

.wiki-image-picker__body {
    padding: var(--space-md);
    max-height: 280px;
    overflow-y: auto;
}

.wiki-image-picker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--space-sm);
}

.wiki-image-picker__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm);
    background: var(--surface-subtle);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
}

.wiki-image-picker__item:hover {
    border-color: var(--color-primary);
    background: var(--surface-hover, var(--surface-subtle));
}

.wiki-image-picker__item img {
    max-width: 100%;
    max-height: 80px;
    object-fit: contain;
}

.wiki-image-picker__name {
    font-size: var(--font-size-xs, 0.75rem);
    color: var(--text-muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.wiki-image-picker__empty {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    text-align: center;
    padding: var(--space-md) 0;
    margin: 0;
}

/* === Profile === */

.account-page {
    max-width: 520px;
}

.account-page .card {
    padding: 24px;
}

.account-page .alert {
    margin-bottom: 16px;
}

.account-page .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.account-page label {
    font-weight: 600;
    color: var(--neutral-700);
}

.account-page input[type="password"] {
    border: 1px solid var(--neutral-200);
    border-radius: 6px;
    padding: 10px;
    font-size: 1rem;
}

.account-page input[type="password"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.account-page .form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.account-page .button {
    min-width: 160px;
}

@media (max-width: 480px) {
    .account-page .form-actions {
        flex-direction: column-reverse;
    }
}

/* === Tokens === */

.tokens-page { display: flex; flex-direction: column; gap: 18px; }
.tokens-page .card { padding: 20px 24px; margin: 0; }
.tokens-page h2 { font-size: 15px; margin: 0; color: var(--text-strong); }

.tokens-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    gap: 18px;
    align-items: start;
}

.tokens-generate__head { margin-bottom: 14px; }
.tokens-generate__hint {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12.5px;
}
.tokens-generate__form { display: flex; flex-direction: column; gap: 14px; }
.tokens-generate__form .form-group { display: flex; flex-direction: column; gap: 6px; }
.tokens-generate__form .form-group label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.tokens-generate__form .form-group input,
.tokens-generate__form .form-group select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--surface-subtle);
    color: var(--text-strong);
    font-size: 14px;
}
.tokens-generate__form .form-group select[disabled] { opacity: 0.65; cursor: not-allowed; }
.tokens-generate__submit { align-self: stretch; margin-top: 4px; }

.tokens-list__head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.tokens-list__count { color: var(--text-muted); font-weight: 500; font-size: 13px; }
.tokens-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tokens-table th,
.tokens-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border-subtle); }
.tokens-table th {
    font-weight: 600;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.tokens-table__name { font-weight: 600; color: var(--text-strong); }
.tokens-table__muted { color: var(--text-muted); }
.tokens-table__actions { text-align: right; width: 1%; white-space: nowrap; }
.tokens-table__row--revoked { opacity: 0.6; }
.tokens-empty { color: var(--text-muted); font-style: italic; margin: 0; }

.tokens-usage__head { margin-bottom: 10px; }
.tokens-usage__code {
    margin: 10px 0 0;
    padding: 14px 16px;
    background: var(--surface-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    overflow-x: auto;
}

.token-reveal { word-break: break-all; }
.token-value {
    display: block;
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--surface-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
}

.alert-info {
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    color: var(--text-strong);
}

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

/* === Booking === */
.booking-date-form { display:flex; align-items:center; gap:8px; }
.booking-date-form input[type="date"] {
    border:1px solid var(--border-subtle); border-radius:8px; padding:8px 10px;
    font-size:13.5px; font-weight:500; background:var(--surface-default);
    color:var(--text-strong); min-height:38px; font-family:inherit;
}
.booking-legend { display:flex; align-items:center; gap:20px; font-size:12px; color:var(--text-muted); }
.booking-legend__item { display:inline-flex; align-items:center; gap:6px; }
.tline-drag-preview {
    position:absolute; top:6px; bottom:6px; pointer-events:none; z-index:10;
    background:rgba(37,99,235,0.15); border:1.5px dashed var(--color-primary);
    border-radius:6px; display:flex; align-items:center; justify-content:center;
    font-size:11px; font-weight:700; color:var(--color-primary);
    font-family:var(--font-family-mono);
}
.datetime-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.datetime-picker__date {
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    background: var(--surface-default);
    color: var(--text-strong);
    min-height: 38px;
    font-family: inherit;
    flex: 1;
    min-width: 130px;
}
.time-picker {
    display: flex;
    align-items: center;
    gap: 4px;
}
.time-picker__h,
.time-picker__m {
    padding: 8px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--surface-default);
    color: var(--text-strong);
    font-size: 14px;
    font-family: var(--font-family-mono);
    min-height: 38px;
    cursor: pointer;
}
.time-picker__h { width: 72px; }
.time-picker__m { width: 68px; }
.time-picker__sep {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-muted);
    font-family: var(--font-family-mono);
    line-height: 1;
}
.tline-lane[data-can-book="1"] { touch-action: none; }
.tline-lane--admin { cursor:not-allowed; }
.tline-lane--admin .slot { pointer-events:none; }
@media (max-width: 900px) {
    .booking-date-form input[type="date"] { width:130px; }
    .booking-legend { display:none; }
}
