/* =========================================================================
   Simple ITSM: enterprise design system
   Fluent neutrals + blue accent (DevOps), focused item view (Jira),
   dense tables and visible work notes (ServiceNow).
   Light by default; dark via the OS setting or the toggle (html[data-theme]).
   ========================================================================= */

:root {
    --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

    --bg: #FFFFFF;
    --sidebar: #F7F8F9;
    --surface: #FFFFFF;
    --surface-2: #FAFAFA;
    --sunken: #F0F1F3;
    --hover: #F2F3F5;
    --pressed: #E6E8EB;

    --ink: #1B1D21;
    --ink-2: #4A4F57;
    --ink-3: #6E747D;
    --line: #E1E3E6;
    --line-strong: #C9CDD2;
    --input-border: #C2C6CC;
    --input-underline: #6E747D;

    --accent: #0F6CBD;
    --accent-hover: #115EA3;
    --accent-pressed: #0C3B5E;
    --accent-ink: #FFFFFF;
    --accent-soft: #EBF3FC;
    --accent-line: #B4D6FA;

    --danger: #C50F1F;
    --danger-soft: #FDE7E9;
    --ok: #107C10;
    --ok-soft: #E9F5E9;
    --warn: #BC4B09;
    --warn-soft: #FFF4CE;
    --warn-line: #F2C661;

    --topbar: #18222F;
    --topbar-ink: #E7ECF2;
    --topbar-ink-2: #A8B3C0;
    --topbar-field: #253243;
    --topbar-field-hover: #2E3D51;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .06);
    --shadow-pop: 0 8px 24px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .08);
    --backdrop: rgba(15, 20, 28, .40);

    --r-xs: 2px;
    --r-sm: 4px;
    --r-md: 6px;
    --r-lg: 8px;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --sidebar: #1A1B1E;
    --bg: #161719; --surface: #1F2023; --surface-2: #232428; --sunken: #18191B; --hover: #2A2B2F; --pressed: #323338;
    --ink: #EDEEF0; --ink-2: #BCC0C6; --ink-3: #8D939B; --line: #33353A; --line-strong: #45484E;
    --input-border: #4A4D54; --input-underline: #8D939B;
    --accent: #479EF5; --accent-hover: #62ABF5; --accent-pressed: #96C6FA; --accent-ink: #0B1B2B; --accent-soft: rgba(71, 158, 245, .14); --accent-line: rgba(71, 158, 245, .45);
    --danger: #F1707B; --danger-soft: rgba(241, 112, 123, .14); --ok: #54B054; --ok-soft: rgba(84, 176, 84, .14);
    --warn: #F7A24D; --warn-soft: rgba(247, 162, 77, .12); --warn-line: rgba(247, 162, 77, .55);
    --topbar: #0E1116; --topbar-ink: #E7ECF2; --topbar-ink-2: #8F9AA7; --topbar-field: #1C222B; --topbar-field-hover: #252D38;
    --shadow-pop: 0 8px 28px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .35);
    --backdrop: rgba(0, 0, 0, .55);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --sidebar: #1A1B1E;
        --bg: #161719; --surface: #1F2023; --surface-2: #232428; --sunken: #18191B; --hover: #2A2B2F; --pressed: #323338;
        --ink: #EDEEF0; --ink-2: #BCC0C6; --ink-3: #8D939B; --line: #33353A; --line-strong: #45484E;
        --input-border: #4A4D54; --input-underline: #8D939B;
        --accent: #479EF5; --accent-hover: #62ABF5; --accent-pressed: #96C6FA; --accent-ink: #0B1B2B; --accent-soft: rgba(71, 158, 245, .14); --accent-line: rgba(71, 158, 245, .45);
        --danger: #F1707B; --danger-soft: rgba(241, 112, 123, .14); --ok: #54B054; --ok-soft: rgba(84, 176, 84, .14);
        --warn: #F7A24D; --warn-soft: rgba(247, 162, 77, .12); --warn-line: rgba(247, 162, 77, .55);
        --topbar: #0E1116; --topbar-ink: #E7ECF2; --topbar-ink-2: #8F9AA7; --topbar-field: #1C222B; --topbar-field-hover: #252D38;
        --shadow-pop: 0 8px 28px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .35);
        --backdrop: rgba(0, 0, 0, .55);
        color-scheme: dark;
    }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; line-height: 1.3; font-weight: 600; margin: 0; }
h2 { font-size: 14px; line-height: 1.4; font-weight: 600; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }
h1:focus { outline: none; }
p { margin: 0; }
code { font-family: var(--font-mono); font-size: 12.5px; }

.ficon { flex: none; display: inline-block; vertical-align: middle; }
.ficon-color { object-fit: contain; }

:where(a, button, [tabindex], summary):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-radius: var(--r-sm);
}

.muted { color: var(--ink-3); }
.tabular { font-variant-numeric: tabular-nums; }
.inline-form { display: contents; }
.spacer { flex: 1; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.show-dark { display: none; }
:root[data-theme="dark"] .show-dark { display: inline-flex; }
:root[data-theme="dark"] .show-light { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .show-dark { display: inline-flex; }
    :root:not([data-theme="light"]) .show-light { display: none; }
}

/* ---------- App shell: top bar + sidebar ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 60;
    display: flex; align-items: center; gap: 12px;
    height: 48px;
    padding: 0 12px 0 14px;
    background: var(--topbar);
    color: var(--topbar-ink);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; color: var(--topbar-ink); font-weight: 600; font-size: 15px; width: 206px; flex: none; }
.topbar-brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--r-sm); background: #0F6CBD; color: #FFFFFF; }
.topbar-search { position: relative; flex: 0 1 460px; min-width: 160px; }
.topbar-search .ficon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--topbar-ink-2); pointer-events: none; }
.topbar-search input {
    width: 100%; height: 32px; padding: 0 12px 0 34px;
    border: 1px solid transparent; border-radius: var(--r-sm);
    background: var(--topbar-field); color: var(--topbar-ink);
    font: inherit;
}
.topbar-search input::placeholder { color: var(--topbar-ink-2); }
.topbar-search input:hover { background: var(--topbar-field-hover); }
.topbar-search input:focus { outline: none; border-color: #479EF5; background: var(--topbar-field-hover); }
.topbar-spacer { flex: 1; }
.topbar-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 32px; padding: 0 12px;
    border-radius: var(--r-sm);
    background: #0F6CBD; color: #FFFFFF; font-weight: 600;
}
.topbar-btn:hover { background: #115EA3; text-decoration: none; }
.topbar-icon {
    width: 32px; height: 32px; display: inline-grid; place-items: center;
    border: 0; border-radius: var(--r-sm); background: transparent; color: var(--topbar-ink-2); cursor: pointer;
}
.topbar-icon:hover { background: var(--topbar-field-hover); color: var(--topbar-ink); }
.topbar-user { position: relative; }
.topbar-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    border: 0; background: #8764B8; color: #FFFFFF;
    font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.menu-scrim { position: fixed; inset: 0; z-index: 70; }
.menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 71;
    min-width: 220px; padding: 4px;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
}
.menu-header { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 7px 10px; border: 0; border-radius: var(--r-sm);
    background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--hover); }

.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); flex: 1; min-height: 0; }
.sidebar {
    position: sticky; top: 48px; align-self: start;
    height: calc(100vh - 48px); overflow-y: auto;
    background: var(--sidebar);
    border-right: 1px solid var(--line);
}
.nav { display: flex; flex-direction: column; padding: 8px 8px 16px; }
.nav-section { margin: 14px 10px 4px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.nav-section:first-child { margin-top: 6px; }
.nav-link {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    height: 34px; padding: 0 10px;
    border-radius: var(--r-sm);
    color: var(--ink-2);
}
.nav-link:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.nav-link.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--accent); }
.nav-link.active .ficon { color: var(--accent); }

.main { min-width: 0; }
.main-inner { max-width: 1400px; margin: 0 auto; padding: 20px 28px 64px; }

/* ---------- Page header & command bar ---------- */
.page-header {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    margin-bottom: 16px;
}
.page-header-text { min-width: 0; }
.page-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-title h1 { overflow-wrap: anywhere; }
.page-sub { margin-top: 4px; color: var(--ink-3); max-width: 90ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; color: var(--ink-3); font-size: 13px; }
.back-link:hover { color: var(--accent); text-decoration: none; }
.item-key { color: var(--ink-3); font-weight: 400; font-variant-numeric: tabular-nums; }

.commandbar {
    display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
    min-height: 40px; padding: 4px 6px;
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-md);
    margin-bottom: 12px;
}
.commandbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); min-width: 0; }
.panel + .panel { margin-top: 16px; }
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 44px; padding: 8px 16px;
    border-bottom: 1px solid var(--line);
}
.panel-head-text { min-width: 0; }
.panel-head h2 { font-size: 14px; }
.panel-head p { color: var(--ink-3); font-size: 12.5px; margin-top: 1px; }
.panel-body { padding: 16px; }
.panel-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); }

.section + .section { margin-top: 24px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-head h2 { font-size: 15px; }
.section-head a { font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink);
    font: inherit; font-weight: 600; white-space: nowrap;
    cursor: pointer;
    transition: background-color .1s, border-color .1s;
}
.btn:hover { background: var(--hover); border-color: var(--ink-3); text-decoration: none; }
.btn:active { background: var(--pressed); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { background: var(--accent-pressed); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #FFFFFF; }
.btn-danger-solid:hover { background: var(--danger); filter: brightness(.92); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); font-weight: 400; }
.btn-ghost:hover { background: var(--hover); border-color: transparent; color: var(--ink); }
.btn-ghost.btn-danger { color: var(--danger); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 40px; padding: 0 16px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.icon-btn {
    width: 32px; height: 32px; flex: none;
    display: inline-grid; place-items: center;
    border: 1px solid transparent; border-radius: var(--r-sm);
    background: transparent; color: var(--ink-2);
    cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn-sm { width: 26px; height: 26px; }

/* ---------- Forms (Fluent-style inputs) ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); font-size: 13.5px; }
.field-label .ficon { color: var(--ink-3); }
.req { color: var(--danger); font-weight: 600; }
.help { font-size: 12px; color: var(--ink-3); }
.field-error, .validation-message { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--danger); }

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea) {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--input-border);
    border-bottom-color: var(--input-underline);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    transition: border-color .1s, box-shadow .1s;
}
textarea { height: auto; min-height: 96px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
select {
    appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='%236E747D'%3E%3Cpath d='M15.85 7.65a.5.5 0 0 1 0 .7l-5.5 5.5a.5.5 0 0 1-.7 0l-5.5-5.5a.5.5 0 1 1 .7-.7L10 12.79l5.15-5.14a.5.5 0 0 1 .7 0Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:focus) { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--input-border);
    border-bottom-color: var(--accent);
    box-shadow: inset 0 -1px 0 0 var(--accent);
}
input:disabled, select:disabled { background: var(--sunken); color: var(--ink-3); cursor: not-allowed; }
.has-error input, .has-error select, .has-error textarea, input.invalid { border-color: var(--danger); }
.has-error input:focus, .has-error select:focus, .has-error textarea:focus { box-shadow: inset 0 -1px 0 0 var(--danger); border-bottom-color: var(--danger); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.select-auto { width: auto !important; min-width: 160px; }

/* Toggle switch */
.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch-row.is-disabled { cursor: not-allowed; color: var(--ink-3); }
.switch { position: relative; width: 40px; height: 20px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; z-index: 1; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; border: 1px solid var(--input-underline); background: var(--surface); transition: background-color .12s, border-color .12s; }
.switch-track::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--ink-2); transition: transform .12s, background-color .12s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(20px); background: #FFFFFF; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .45; }
.switch-field { padding-top: 24px; }

/* Field label with icon and help */
.field-label-row { display: flex; align-items: center; gap: 4px; min-height: 20px; }
.switch-field .help-anchor { margin-left: 4px; }
.switch-field { flex-direction: row; align-items: center; flex-wrap: wrap; }

/* Help "?" popover */
.help-btn {
    width: 18px; height: 18px; padding: 0;
    display: inline-grid; place-items: center;
    border: 0; border-radius: 50%;
    background: transparent; color: var(--ink-3);
    cursor: pointer;
}
.help-btn:hover, .help-btn[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }
.help-anchor { position: relative; display: inline-flex; }
.help-scrim { position: fixed; inset: 0; z-index: 80; }
.help-pop {
    position: absolute; left: -8px; top: calc(100% + 6px); z-index: 81;
    width: min(380px, 80vw);
    padding: 12px 14px 12px;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line-strong); border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
    font-weight: 400; font-size: 13.5px;
}
.help-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-weight: 600; }

/* ---------- Type identity ---------- */
.type-icon { display: inline-grid; place-items: center; flex: none; color: var(--type-color); }
.type-icon-sm { width: 18px; height: 18px; }
.type-icon-md { width: 24px; height: 24px; }
.type-icon-lg {
    width: 40px; height: 40px;
    border-radius: var(--r-md);
    background: color-mix(in srgb, var(--type-color) 12%, var(--surface));
}
.type-tag { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--ink); }

/* ---------- State, badges, notices ---------- */
.st-new { --st: #8A8886; }
.st-progress { --st: #0F6CBD; }
.st-hold { --st: #CA5010; }
.st-resolved { --st: #107C10; }
.st-closed { --st: #4A4F57; }
:root[data-theme="dark"] .st-progress { --st: #479EF5; }
:root[data-theme="dark"] .st-resolved { --st: #54B054; }
:root[data-theme="dark"] .st-closed { --st: #A8ADB4; }
:root[data-theme="dark"] .st-hold { --st: #F7A24D; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .st-progress { --st: #479EF5; }
    :root:not([data-theme="light"]) .st-resolved { --st: #54B054; }
    :root:not([data-theme="light"]) .st-closed { --st: #A8ADB4; }
    :root:not([data-theme="light"]) .st-hold { --st: #F7A24D; }
}
.status-pill { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--ink); }
.status-pill::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--st); flex: none; }
.status-pill-sm { font-size: 12.5px; gap: 6px; }
.status-pill-sm::before { width: 8px; height: 8px; }
.status-select { position: relative; }
.status-select .status-dot { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 9px; height: 9px; border-radius: 50%; background: var(--st); pointer-events: none; }
.status-select select { padding-left: 28px; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    height: 20px; padding: 0 6px;
    border-radius: var(--r-xs);
    background: var(--sunken); color: var(--ink-2);
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

.notice { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 12px; border-radius: var(--r-sm); border-left: 3px solid; }
.notice-success { background: var(--ok-soft); color: var(--ink); border-color: var(--ok); }
.notice-success .ficon { color: var(--ok); }
.notice-error { background: var(--danger-soft); color: var(--ink); border-color: var(--danger); }
.notice-error .ficon { color: var(--danger); }
.notice-info { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }
.notice-info .ficon { color: var(--accent); }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; padding: 40px 24px; text-align: center; color: var(--ink-2); }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 12px; color: var(--ink-3); }
.empty h3 { font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.empty p { max-width: 52ch; margin-bottom: 16px; }

/* ---------- Tiles ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.tile-grid-compact { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tile {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface); color: var(--ink);
    font: inherit; text-align: left; cursor: pointer;
}
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.tile-text { min-width: 0; }
.tile-name { font-weight: 600; }
.tile-desc { margin-top: 2px; color: var(--ink-2); font-size: 13px; }
.tile-meta { margin-top: 4px; color: var(--ink-3); font-size: 12.5px; }

/* KPI tiles on the overview */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); color: var(--ink); }
.kpi:hover { border-color: var(--accent); text-decoration: none; }
.kpi-label { color: var(--ink-3); font-size: 13px; }
.kpi-value { font-size: 26px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }

/* ---------- Lists ---------- */
.list-row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--hover); text-decoration: none; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-aside { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }

/* ---------- Data tables (dense) ---------- */
.table-scroll { overflow-x: auto; }
.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data th {
    position: sticky; top: 0;
    height: 34px; padding: 0 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line-strong);
    color: var(--ink-2); font-size: 12.5px; font-weight: 600; text-align: left; white-space: nowrap;
}
.data th.sortable { cursor: pointer; user-select: none; }
.data th.sortable:hover { color: var(--ink); background: var(--hover); }
.data th .sort-ind { display: inline-flex; vertical-align: middle; margin-left: 4px; color: var(--accent); }
.data td { height: 36px; padding: 4px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr:hover td { background: var(--hover); }
.data tbody tr.row-link { cursor: pointer; }
.data tbody tr.is-selected td { background: var(--accent-soft); }
.data .col-id { width: 1%; white-space: nowrap; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.data .col-title { min-width: 240px; }
.data .col-title a { color: var(--ink); font-weight: 600; }
.data .col-title a:hover { color: var(--accent); }
.data .col-nowrap { white-space: nowrap; }
.data .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.data .col-check { width: 1%; }
.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.title-cell { display: flex; align-items: center; gap: 8px; }
.person { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.avatar {
    width: 28px; height: 28px; flex: none;
    display: inline-grid; place-items: center;
    border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    font-weight: 600; font-size: 12px;
}
.avatar-sm { width: 22px; height: 22px; font-size: 10.5px; }
.customer-path { color: var(--ink-2); white-space: nowrap; }

/* ---------- Toolbar & filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search .ficon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 32px !important; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 10px;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink-2);
    font: inherit; cursor: pointer;
}
.pill:hover { border-color: var(--ink-3); color: var(--ink); }
.pill.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.pill .dot { display: none; }

/* ---------- Tabs ---------- */
.tabs { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-sm); background: var(--sunken); border: 1px solid var(--line); }
.tab {
    display: inline-flex; align-items: center; gap: 6px;
    height: 26px; padding: 0 10px;
    border: 0; border-radius: 3px;
    background: transparent; color: var(--ink-2);
    font: inherit; font-size: 13px; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1); }

/* ---------- Item page ---------- */
.item-topbar { margin-bottom: 12px; }
.item-topbar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 32px; }
.item-updated { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.item-topbar .type-tag { font-size: 15px; }
.item-layout { display: block; }
.item-main { min-width: 0; }
.create-layout { max-width: 1280px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }

.item-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.item-form-head { display: flex; flex-direction: column; gap: 14px; padding: 16px 20px 18px; border-bottom: 1px solid var(--line); }
.input-headline {
    height: auto !important;
    padding: 4px 8px !important;
    margin: 0 -8px;
    width: calc(100% + 16px) !important;
    border-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 22px !important;
    font-weight: 600;
    line-height: 1.3;
}
.input-headline:hover { border-color: var(--line-strong) !important; }
.input-headline:focus { border-color: var(--input-border) !important; border-bottom-color: var(--accent) !important; box-shadow: inset 0 -1px 0 0 var(--accent) !important; background: var(--surface) !important; }
.has-error .input-headline { border-color: var(--danger) !important; }
.system-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 240px)); gap: 12px 20px; }

.form-section { border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section > summary {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 20px;
    cursor: pointer; list-style: none; user-select: none;
}
.form-section > summary::-webkit-details-marker { display: none; }
.form-section > summary:hover { background: var(--hover); }
.section-chevron { color: var(--ink-3); transition: transform .12s; }
.form-section[open] > summary .section-chevron { transform: rotate(90deg); }
.section-title { font-weight: 600; font-size: 14.5px; }
.section-meta { color: var(--ink-3); font-size: 12.5px; }
.section-body { padding: 4px 20px 20px 46px; }

.save-bar {
    position: sticky; bottom: 12px; z-index: 20;
    display: flex; align-items: center; gap: 8px;
    margin-top: 12px; padding: 8px 10px 8px 16px;
    background: var(--surface);
    border: 1px solid var(--accent-line); border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
    opacity: 0; transform: translateY(6px); pointer-events: none;
    transition: opacity .12s, transform .12s;
}
.save-bar.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.save-bar-text { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* Collapsible blocks below the form (Discussion, History, Related) */
.block { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.block > summary, .block-head {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px;
    list-style: none; cursor: pointer; user-select: none;
}
.block-head { cursor: default; border-bottom: 1px solid var(--line); }
.block > summary::-webkit-details-marker { display: none; }
.block > summary:hover { background: var(--hover); }
.block[open] > summary { border-bottom: 1px solid var(--line); }
.block[open] > summary .section-chevron { transform: rotate(90deg); }
.block-title { font-weight: 600; font-size: 15px; }
.block-count { color: var(--ink-3); font-size: 13px; }

/* ---------- Discussion ---------- */
.composer { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.composer-tabs { display: flex; gap: 0; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.composer-tab {
    display: inline-flex; align-items: center; gap: 6px;
    height: 34px; padding: 0 12px; margin-bottom: -1px;
    border: 0; border-bottom: 2px solid transparent;
    background: transparent; color: var(--ink-2); font: inherit; cursor: pointer;
}
.composer-tab:hover { color: var(--ink); }
.composer-tab.is-active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.composer-tab.is-internal.is-active { border-bottom-color: var(--warn); }
.composer.is-internal .rte { border-color: var(--warn-line); background: var(--warn-soft); }
.composer.is-internal .rte-area { background: transparent; }
.composer-hint { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }
.composer.is-internal .composer-hint { color: var(--warn); }
.comment-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

.comments { list-style: none; margin: 0; padding: 4px 16px 12px; }
.comment { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.comment-head .tl-action { margin-left: auto; }
.comment-card { margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--accent-line); border-radius: var(--r-sm); background: var(--surface); }
.comment.is-internal .comment-card { background: var(--warn-soft); border-color: var(--warn-line); border-left-color: var(--warn); }
.visibility { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: var(--r-xs); font-size: 12px; font-weight: 600; }
.visibility-public { background: var(--accent-soft); color: var(--accent); }
.visibility-internal { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }

/* ---------- History ---------- */
.timeline { list-style: none; margin: 0; padding: 4px 16px 12px; }
.tl-item { position: relative; display: flex; gap: 12px; padding: 10px 0; }
.tl-item + .tl-item { border-top: 1px solid var(--line); }
.tl-body { flex: 1; min-width: 0; }
.tl-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.tl-dot { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--sunken); color: var(--ink-3); }
.tl-dot-accent { background: var(--accent-soft); color: var(--accent); }
.change-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; font-size: 13px; }
.change-list li { display: contents; }
.change-field { font-weight: 600; color: var(--ink); }
.change-values { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.change-old { color: var(--ink-3); text-decoration: line-through; overflow-wrap: anywhere; }
.change-new { color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Rich text ---------- */
.rich { line-height: 1.55; overflow-wrap: anywhere; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p, .rich div { margin: 0 0 .45em; }
.rich ul, .rich ol { margin: 0 0 .5em; padding-left: 1.4em; }
.rich pre { margin: 0 0 .5em; padding: 8px 10px; background: var(--sunken); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 12.5px; white-space: pre-wrap; }
.rich img { display: block; max-width: 100%; height: auto; max-height: 520px; margin: 6px 0; border: 1px solid var(--line); border-radius: var(--r-sm); }
.rich-view img { cursor: zoom-in; }
.rich a { text-decoration: underline; }

.rte { border: 1px solid var(--input-border); border-bottom-color: var(--input-underline); border-radius: var(--r-sm); background: var(--surface); }
.rte:focus-within { border-bottom-color: var(--accent); box-shadow: inset 0 -1px 0 0 var(--accent); }
.rte.is-invalid { border-color: var(--danger); }
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; padding: 3px 4px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.rte-btn { width: 28px; height: 26px; display: inline-grid; place-items: center; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); cursor: pointer; }
.rte-btn:hover { background: var(--hover); color: var(--ink); }
.rte-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.rte-sep { width: 1px; height: 16px; margin: 0 4px; background: var(--line); }
.rte-area { position: relative; min-height: 140px; max-height: 560px; overflow-y: auto; padding: 10px 12px; outline: none; }
.rte-compact .rte-area { min-height: 72px; }
.rte-area.is-empty::before { content: attr(data-placeholder); color: var(--ink-3); pointer-events: none; position: absolute; }
.rte-area.is-dragover { background: var(--accent-soft); }
.rte-status { padding: 0 12px; font-size: 12.5px; color: var(--ink-3); }
.rte-status:not(:empty) { padding-bottom: 8px; }
.rte-status.is-error { color: var(--danger); }

/* ---------- Item links ---------- */
.picker { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.picker-row { display: flex; gap: 4px; }
.picker-row .picker-search { flex: 1; }
.link-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.link-chip { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 4px 4px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.link-chip-title { flex: 1; min-width: 0; color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.link-chip-title:hover { color: var(--accent); }
.picker.is-invalid .picker-search input { border-color: var(--danger); }
.picker-search { position: relative; }
.picker-search > .ficon { position: absolute; left: 10px; top: 8px; color: var(--ink-3); pointer-events: none; }
.picker-search input { padding-left: 32px !important; }
.picker-menu { position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 30; max-height: 320px; overflow-y: auto; padding: 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); box-shadow: var(--shadow-pop); }
.picker-option { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.picker-option.is-active { background: var(--hover); }
.picker-option-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-option-sub { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-empty { padding: 10px 8px; color: var(--ink-3); font-size: 13px; }

/* Find items dialog */
.finder-filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; margin-bottom: 10px; }
.finder-results { border: 1px solid var(--line); border-radius: var(--r-sm); max-height: 52vh; overflow: auto; }
.finder-foot { display: flex; align-items: center; gap: 8px; }

/* ---------- Modal ---------- */
.modal-layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); }
.modal {
    position: relative; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
    box-shadow: var(--shadow-pop);
    animation: pop-in .14s ease-out;
}
.modal-wide { max-width: 620px; }
.modal-xl { max-width: 1080px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 12px 6px 20px; }
.modal-head h2 { font-size: 16px; }
.modal-body { display: flex; flex-direction: column; gap: 14px; padding: 10px 20px 18px; }
.modal-text { color: var(--ink-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Icon picker ---------- */
.icon-field { display: flex; align-items: center; gap: 10px; }
.icon-preview { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; max-height: 320px; overflow-y: auto; padding: 2px; }
.icon-cell { height: 44px; display: grid; place-items: center; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--ink); cursor: pointer; }
.icon-cell:hover { background: var(--hover); border-color: var(--line); }
.icon-cell.is-selected { background: var(--accent-soft); border-color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; padding: 0; }
.swatch.is-selected { box-shadow: 0 0 0 2px var(--ink); }

/* ---------- Sign in ---------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); background: var(--surface); }
.auth-brand { display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px; background: #18222F; color: #E7ECF2; }
.auth-brand .topbar-brand { width: auto; }
.auth-brand-text { max-width: 420px; }
.auth-brand-text h2 { font-size: 26px; line-height: 1.25; font-weight: 600; margin-bottom: 10px; }
.auth-brand-text p { color: #A8B3C0; font-size: 15px; }
.auth-brand-foot { color: #8F9AA7; font-size: 12.5px; }
.auth-main { display: grid; place-items: center; padding: 32px 24px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .page-sub { margin: 0 0 20px; }

/* ---------- Blazor error bar ---------- */
#blazor-error-ui {
    display: none; position: fixed; left: 50%; bottom: 20px; z-index: 1000; transform: translateX(-50%);
    padding: 10px 44px 10px 16px; border-radius: var(--r-md);
    background: var(--ink); color: var(--surface); box-shadow: var(--shadow-pop);
}
#blazor-error-ui a { color: inherit; text-decoration: underline; }
#blazor-error-ui .dismiss { position: absolute; right: 14px; top: 10px; cursor: pointer; text-decoration: none; }

/* =========================================================================
   Admin: form designer, field library, customers
   ========================================================================= */
.tag-list { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.tag-list .type-tag { color: var(--ink); }
.dt-fixed { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.dt-icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--sunken); color: var(--ink-2); }
.dt-icon-sm { width: 24px; height: 24px; }
.dt-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.dt-option { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-2); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.dt-option:hover:not(:disabled) { border-color: var(--ink-3); color: var(--ink); }
.dt-option.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.dt-option.is-selected .ficon { color: var(--accent); }
.dt-option:disabled { cursor: default; opacity: .45; }
.dt-option.is-selected:disabled { opacity: 1; }
.grip { color: var(--ink-3); cursor: grab; display: inline-grid; place-items: center; }

.designer { display: grid; grid-template-columns: 260px minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.designer-library, .designer-props { position: sticky; top: 64px; max-height: calc(100vh - 80px); display: flex; flex-direction: column; }
.designer-props { overflow-y: auto; }
.library-search { padding: 10px 10px 4px; }
.library-search .search { max-width: none; }
.library-list { list-style: none; margin: 0; padding: 4px 6px 8px; overflow-y: auto; flex: 1; }
.lib-field { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 4px; border-radius: var(--r-sm); cursor: grab; }
.lib-field:hover { background: var(--hover); }
.lib-field.is-used { cursor: default; opacity: .55; }
.lib-field.is-used .grip { visibility: hidden; }
.lib-field-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lib-field-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-field-type { font-size: 12px; color: var(--ink-3); }
.lib-check { color: var(--ok); margin-right: 6px; }
.lib-empty { padding: 12px 8px; color: var(--ink-3); font-size: 13px; }
.remove-hint { display: flex; align-items: center; gap: 8px; margin: 8px 10px 0; padding: 10px; border: 1px dashed var(--danger); border-radius: var(--r-sm); color: var(--danger); font-weight: 600; font-size: 13px; }
.designer-library.is-over .remove-hint { background: var(--danger-soft); }

.designer-canvas { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.canvas-system { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--ink-3); font-size: 13px; }
.canvas-system-label { margin-right: 4px; }
.canvas-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.canvas-section.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.canvas-section.is-section-over { box-shadow: 0 -3px 0 0 var(--accent); }
.canvas-section-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: grab; background: var(--surface-2); border-radius: var(--r-md) var(--r-md) 0 0; }
.canvas-section-head:hover { background: var(--hover); }
.canvas-section-head.is-static { cursor: default; }
.canvas-section-head.is-static:hover { background: var(--surface-2); }
.canvas-section-name { font-weight: 600; }
.section-count { margin-left: auto; font-size: 12.5px; }
.canvas-section-loose { border-style: dashed; }
.canvas-drop { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 10px; min-height: 56px; }
.canvas-field { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 8px 6px 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); cursor: grab; }
.canvas-field:hover { border-color: var(--ink-3); }
.canvas-field.is-wide { grid-column: 1 / -1; }
.canvas-field.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.canvas-field.is-over { box-shadow: -3px 0 0 0 var(--accent); }
.canvas-field.is-dragged { opacity: .4; }
.canvas-field-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.canvas-field .req { margin-left: -4px; }
.chip-flag { color: var(--ink-3); display: inline-grid; place-items: center; }
.drop-end { grid-column: 1 / -1; min-height: 6px; border-radius: var(--r-sm); color: var(--ink-3); font-size: 13px; text-align: center; }
.drop-end:not(:empty) { padding: 12px; border: 1px dashed var(--line-strong); }
.designer.is-dragging .drop-end { min-height: 32px; border: 1px dashed var(--line-strong); }
.canvas-drop.is-over .drop-end { border-color: var(--accent); background: var(--accent-soft); }
.add-section { align-self: flex-start; }
[data-dnd], .lib-field, .canvas-field, .canvas-section-head { user-select: none; -webkit-user-select: none; }

.props-group-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); border-top: 1px solid var(--line); }
.props-group-title:first-child { border-top: 0; padding-top: 0; }
.props-shared { font-weight: 600; color: var(--accent); }
.props-empty { padding: 24px 20px; color: var(--ink-2); display: flex; flex-direction: column; gap: 10px; }
.props-empty .ficon { color: var(--ink-3); }
.props-empty strong { color: var(--ink); }

.tree { list-style: none; margin: 0; padding: 0; }
.tree-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-left: calc(12px + var(--depth, 0) * 28px); border-bottom: 1px solid var(--line); }
.tree-row:last-child { border-bottom: 0; }
.tree-row:hover { background: var(--hover); }
.tree-row.is-root { background: var(--surface-2); }
.tree-icon { width: 28px; display: inline-grid; place-items: center; color: var(--accent); }
.tree-main { flex: 1; min-width: 0; }
.tree-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* =========================================================================
   Queries
   ========================================================================= */
.queries { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.query-nav { position: sticky; top: 64px; }
.query-nav-group { padding: 6px 0; }
.query-nav-group + .query-nav-group { border-top: 1px solid var(--line); }
.query-nav-title { padding: 6px 14px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.query-nav-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 14px; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.query-nav-item:hover { background: var(--hover); }
.query-nav-item.is-active { background: var(--accent-soft); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.query-nav-item .ficon { color: var(--ink-3); }
.query-nav-empty { padding: 4px 14px 8px; font-size: 12.5px; color: var(--ink-3); }

.clauses { width: 100%; border-collapse: collapse; }
.clauses th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 0 6px 6px; }
.clauses td { padding: 3px 6px; vertical-align: middle; }
.clauses .c-andor { width: 90px; }
.clauses .c-field { width: 28%; }
.clauses .c-op { width: 170px; }
.clauses .c-remove { width: 36px; }
.clause-first { color: var(--ink-3); font-size: 13px; padding-left: 10px; }
.query-columns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.col-chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 8px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); font-size: 13px; }
.col-chip .icon-btn { width: 22px; height: 22px; }
.result-meta { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 13px; }


/* =========================================================================
   Level picker (top bar)
   ========================================================================= */
.level-picker { position: relative; flex: none; }
.level-btn {
    display: flex; align-items: center; gap: 8px;
    height: 36px; max-width: 320px; padding: 0 10px;
    border: 1px solid transparent; border-radius: var(--r-sm);
    background: var(--topbar-field); color: var(--topbar-ink);
    font: inherit; cursor: pointer;
}
.level-btn:hover { background: var(--topbar-field-hover); }
.level-btn[aria-expanded="true"] { border-color: #479EF5; }
.level-btn > .ficon { color: var(--topbar-ink-2); }
.level-btn-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.15; }
.level-btn-label { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--topbar-ink-2); }
.level-btn-name { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.level-btn-sub { font-size: 11.5px; color: var(--topbar-ink-2); white-space: nowrap; }
.level-pop {
    position: absolute; left: 0; top: calc(100% + 6px); z-index: 71;
    display: flex; flex-direction: column;
    width: 340px; max-height: 70vh;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
}
.level-pop-search { position: relative; padding: 8px; border-bottom: 1px solid var(--line); }
.level-pop-search .ficon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.level-pop-search input { padding-left: 32px; }
.level-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; }
.level-option {
    display: flex; align-items: center; gap: 8px; width: 100%;
    height: 32px; padding-right: 10px;
    border: 0; border-radius: var(--r-sm);
    background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.level-option:hover { background: var(--hover); }
.level-option.is-selected { background: var(--accent-soft); font-weight: 600; }
.level-option .ficon { color: var(--ink-3); }
.level-option-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level-option-count { font-size: 11.5px; color: var(--ink-3); }
.level-option .level-check { color: var(--accent); }
.level-empty { padding: 10px; color: var(--ink-3); }
.level-pop-foot { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); }
.level-tag {
    display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
    border-radius: var(--r-xs); background: var(--sunken); color: var(--ink-2);
    font-size: 12px; white-space: nowrap;
}

/* =========================================================================
   Menu: views
   ========================================================================= */
.nav-section-views { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.nav-section-views > span { display: inline-flex; align-items: center; gap: 6px; }
.nav-section-views > span .ficon { color: var(--accent); }
.nav-section-views.is-mine > span .ficon { color: #8764B8; }
.nav-section-action { width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: var(--r-sm); color: var(--ink-3); }
.nav-section-action:hover { background: var(--hover); color: var(--ink); }
.nav-view { height: 32px; }
.nav-view-icon { width: 18px; flex: none; display: inline-grid; place-items: center; color: var(--ink-3); }
.nav-view.is-mine .nav-view-icon { color: #8764B8; }
.nav-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-empty { display: block; padding: 4px 10px 4px 38px; font-size: 12.5px; color: var(--ink-3); }
a.nav-empty-link:hover { color: var(--accent); }

/* =========================================================================
   Item page: main column + side panel
   ========================================================================= */
.item-columns { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: start; }
.item-col-main { min-width: 0; }
.item-col-side { position: sticky; top: 64px; min-width: 0; max-height: calc(100vh - 80px); overflow-y: auto; padding-bottom: 8px; }

.item-crumbs { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; margin-bottom: 4px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; font-size: 13px; color: var(--ink-3); }
.crumb-sep { color: var(--ink-3); }
.crumb-item { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-weight: 600; }
.item-actions { display: flex; gap: 2px; }
.item-actions a.icon-btn:hover { text-decoration: none; }

.item-title-field { margin-bottom: 12px; }
textarea.input-headline {
    min-height: 0 !important; resize: none; overflow: hidden;
    field-sizing: content;
    font-size: 24px !important; line-height: 1.3;
}

/* Sections in the main column: headings, no boxes */
.item-columns .form-section { border: 0; margin-top: 6px; }
.item-columns .form-section > summary { padding: 8px 0; gap: 6px; border-bottom: 1px solid var(--line); }
.item-columns .form-section > summary:hover { background: transparent; }
.item-columns .form-section > summary:hover .section-title { color: var(--accent); }
.item-columns .section-title { font-size: 15px; }
.item-columns .section-body { padding: 14px 0 18px; }
.item-columns .section-meta { margin-left: 2px; font-variant-numeric: tabular-nums; }

/* Side panel */
.side-status { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.side-save { margin-left: auto; }
.status-button { position: relative; }
.status-button .status-dot { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 9px; height: 9px; border-radius: 50%; background: var(--st); pointer-events: none; }
.status-button select {
    width: auto; min-width: 170px; height: 36px; padding-left: 30px;
    border-color: color-mix(in srgb, var(--st) 45%, var(--surface));
    background-color: color-mix(in srgb, var(--st) 12%, var(--surface));
    font-weight: 600;
}
.side-card { margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.side-card > summary, .side-card-head {
    display: flex; align-items: center; gap: 6px;
    min-height: 42px; padding: 0 14px;
    list-style: none; cursor: pointer; user-select: none;
}
.side-card-head { cursor: default; border-bottom: 1px solid var(--line); }
.side-card > summary::-webkit-details-marker { display: none; }
.side-card[open] > summary { border-bottom: 1px solid var(--line); }
.side-card[open] > summary .section-chevron { transform: rotate(90deg); }
.side-card-title { font-weight: 600; }
.side-card > summary .section-meta { margin-left: auto; }
.side-card-body { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px 14px; }
.side-card-body > .field:not(.field-row) { padding: 6px 0; }
.side-meta { display: flex; flex-direction: column; gap: 2px; padding: 4px 2px; font-size: 12.5px; color: var(--ink-3); }

/* Label left, value right */
.field-row { display: grid; grid-template-columns: minmax(0, 38%) minmax(0, 1fr); align-items: center; gap: 2px 10px; min-height: 36px; }
.field-row > .field-label-row { min-width: 0; }
.field-row .field-label { font-weight: 400; color: var(--ink-2); font-size: 13px; }
.field-row .field-label > span:not(.req) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-row > .field-error { grid-column: 2; }
.field-row > .switch-row { justify-self: start; height: 32px; }

/* Quiet inputs on the item page: no borders until hovered */
.is-quiet :is(.form-section, .side-card) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    border-color: transparent;
    background-color: transparent;
}
.is-quiet :is(.form-section, .side-card) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea):hover:not(:focus) {
    border-color: transparent;
    background-color: var(--hover);
}
.is-quiet :is(.form-section, .side-card) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus {
    border-color: var(--input-border);
    border-bottom-color: var(--accent);
    background-color: var(--surface);
}
.is-quiet :is(.form-section, .side-card) select:not(:hover):not(:focus) { background-image: none; }
.is-quiet :is(.form-section, .side-card) .has-error :is(input, select, textarea) { border-color: var(--danger); }
.is-quiet .form-section .rte { border-color: transparent; }
.is-quiet .form-section .rte:hover { border-color: var(--line); }
.is-quiet .form-section .rte:focus-within { border-color: var(--input-border); border-bottom-color: var(--accent); }
.is-quiet .form-section .rte-toolbar { display: none; }
.is-quiet .form-section .rte:focus-within .rte-toolbar { display: flex; }
.is-quiet .form-section .rte-area { min-height: 64px; }
.is-quiet textarea.input-headline:hover:not(:focus) { background: var(--hover) !important; border-color: transparent !important; }

/* Blocks under the form */
.main-block { margin-top: 32px; }
.main-block-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.main-block-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--sunken); color: var(--ink-2); font-size: 12px; }
.linked-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-md); }
.linked-row { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 12px; }
.linked-row + .linked-row { border-top: 1px solid var(--line); }
.linked-key { color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.linked-title { flex: 1; min-width: 0; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linked-title:hover { color: var(--accent); }
.linked-via { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* Activity */
.activity-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.activity-head .main-block-title { margin: 0; }
.segmented { display: inline-flex; overflow: hidden; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); }
.segmented button {
    display: inline-flex; align-items: center; gap: 6px;
    height: 32px; padding: 0 12px;
    border: 0; background: transparent; color: var(--ink-2);
    font: inherit; cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button:hover { background: var(--hover); color: var(--ink); }
.segmented button.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.segmented-sm button { height: 28px; padding: 0 10px; font-size: 13px; }
.seg-count { padding: 0 6px; border-radius: 9px; background: var(--sunken); color: var(--ink-3); font-size: 11.5px; font-weight: 600; }
.activity .composer { display: flex; gap: 12px; padding: 0 0 16px; border-bottom: 0; }
.composer-closed { flex: 1; display: flex; gap: 8px; min-width: 0; }
.composer-fake {
    flex: 1; height: 40px; padding: 0 12px; text-align: left;
    border: 1px solid var(--input-border); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink-3); font: inherit; cursor: text;
}
.composer-fake:hover { border-color: var(--ink-3); }
.composer-note-btn { height: 40px; color: var(--warn); }
.composer-main { flex: 1; min-width: 0; }
.activity .comment-actions { flex-wrap: wrap; }
.activity .composer-hint { margin-top: 0; }
.activity-empty { padding: 8px 0 4px 44px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { display: flex; gap: 12px; padding: 12px 0; border: 0; }
.feed-main { flex: 1; min-width: 0; }
.feed-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.feed-head .feed-action { margin-left: auto; }
.feed .comment { border-bottom: 0; }
.feed .comment-card { margin-top: 6px; }
.feed-change .change-list { margin-top: 6px; }
.avatar-muted { background: var(--sunken) !important; color: var(--ink-3) !important; }

/* =========================================================================
   Views
   ========================================================================= */
.section-head h2 { display: inline-flex; align-items: center; gap: 6px; }
.section-head h2 .ficon { color: var(--ink-3); }
.view-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.view-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--r-md);
}
.view-card:hover { background: var(--hover); border-color: var(--line-strong); text-decoration: none; }
.view-card-icon { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--sunken); color: var(--ink-2); }
.view-card-text { display: flex; flex-direction: column; min-width: 0; }
.view-card-name { font-weight: 600; }
.view-card-sub { font-size: 12.5px; color: var(--ink-3); }
.view-card-new { justify-content: center; gap: 6px; border-style: dashed; color: var(--ink-2); font-weight: 600; }

.view-page.is-editing { margin-right: 420px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.view-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.view-title-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: var(--r-md); background: var(--sunken); color: var(--ink-2); }
.view-title-text { min-width: 0; }
.view-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 3px; font-size: 13px; }
.view-kind { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.view-kind-shared { background: var(--accent-soft); color: var(--accent); }
.view-kind-mine { background: color-mix(in srgb, #8764B8 14%, var(--surface)); color: #8764B8; }
.view-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-sm input { height: 28px !important; }
.table-foot { padding: 8px 12px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12.5px; }

.drawer {
    position: fixed; top: 48px; right: 0; bottom: 0; z-index: 50;
    display: flex; flex-direction: column;
    width: 400px;
    background: var(--surface);
    border-left: 1px solid var(--line);
    box-shadow: -8px 0 24px rgba(15, 23, 42, .08);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 24px; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.drawer-group { display: flex; align-items: baseline; gap: 8px; margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); font-weight: 600; }
.drawer-group .muted { font-weight: 400; font-size: 12.5px; }
.field-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.conditions { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.condition { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.condition-line { display: flex; align-items: center; gap: 6px; }
.condition-line > select, .condition-line > input { flex: 1; min-width: 0; }
.condition-line > .condition-op { flex: 0 0 42%; }
.column-list { list-style: none; margin: 0 0 8px; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); }
.column-row { display: flex; align-items: center; gap: 2px; min-height: 38px; padding: 3px 4px 3px 10px; }
.column-row + .column-row { border-top: 1px solid var(--line); }
.column-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-toggle {
    display: inline-flex; align-items: center; gap: 4px;
    height: 24px; margin-right: 4px; padding: 0 8px;
    border: 1px dashed var(--line-strong); border-radius: 12px;
    background: transparent; color: var(--ink-3);
    font: inherit; font-size: 11.5px; white-space: nowrap; cursor: pointer;
}
.chip-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
.chip-toggle.is-on { border-style: solid; border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
    .designer { grid-template-columns: 240px minmax(0, 1fr); }
    .designer-props { grid-column: 1 / -1; position: static; max-height: none; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
    .queries { grid-template-columns: minmax(0, 1fr); }
    .query-nav { position: static; }
    .finder-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 860px) {
    .topbar-brand { width: auto; }
    .brand-name, .topbar-new span { display: none; }
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 6px; gap: 2px; }
    .nav-section { display: none; }
    .nav-link { flex: none; }
    .nav-link span { display: none; }
    .main-inner { padding: 16px 16px 56px; }
    .form-grid, .system-fields { grid-template-columns: minmax(0, 1fr); }
    .section-body { padding: 4px 16px 16px; }
    .switch-field { padding-top: 0; }
    .search { max-width: none; }
    .designer { grid-template-columns: minmax(0, 1fr); }
    .designer-library { position: static; max-height: 360px; }
    .canvas-drop { grid-template-columns: minmax(0, 1fr); }
    .auth-shell { grid-template-columns: minmax(0, 1fr); }
    .auth-brand { display: none; }
    .change-list { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 1100px) {
    .item-columns { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .item-col-side { position: static; max-height: none; overflow: visible; }
    .view-page.is-editing { margin-right: 0; }
    .drawer { width: 100%; top: 48px; }
}
@media (max-width: 860px) {
    .level-btn-label, .level-btn-sub { display: none; }
    .level-btn-name { max-width: 110px; }
}
.view-actions .search { flex: 0 1 220px; }

/* Step 1: people */
tr.is-muted td { opacity: .6; }
.tree-meta { display: inline-flex; align-items: center; gap: 4px; }
.tree-meta + .tree-meta::before { content: "·"; margin: 0 6px; color: var(--ink-3); }
.tree-name .level-tag { margin-left: 4px; font-weight: 400; }
.pending-move { flex-wrap: wrap; }
.person .list-sub { display: block; }

/* Step 2: files */
.file-chips { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.file-chips.is-compact { flex-direction: row; flex-wrap: wrap; margin-top: 6px; }
.file-chip {
    display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%;
    padding: 4px 4px 4px 8px; min-height: 34px;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.file-chip > .ficon { color: var(--ink-3); }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; }
a.file-name:hover { color: var(--accent); }
.file-size { font-size: 12px; color: var(--ink-3); white-space: nowrap; margin-right: 4px; }
.file-thumb { display: inline-grid; place-items: center; width: 36px; height: 28px; flex: none; overflow: hidden; border-radius: 3px; border: 1px solid var(--line); background: var(--sunken); }
.file-thumb img { max-width: 100%; max-height: 100%; object-fit: cover; }
.file-field { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.file-field.is-invalid .file-chips + .upload-button .btn, .file-field.is-invalid .btn { border-color: var(--danger); }
.upload-button { display: inline-flex; align-items: center; gap: 8px; }
.upload-button .btn.is-busy { opacity: .6; pointer-events: none; }
.file-uses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.file-uses li { display: flex; gap: 6px; flex-wrap: wrap; }

/* Step 3: mail */
.subtabs { display: flex; gap: 2px; margin: -4px 0 16px; border-bottom: 1px solid var(--line); }
.subtab { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; margin-bottom: -1px; color: var(--ink-2); border-bottom: 2px solid transparent; }
.subtab:hover { color: var(--ink); text-decoration: none; }
.subtab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 20px; align-items: start; }
.setup-help { position: sticky; top: 64px; }
.setup-help ol { padding-left: 1.2em; margin: 0; }
.setup-help li { margin-bottom: 8px; }
.setup-help pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11.5px; }
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; }
.choice:hover { background: var(--hover); }
.choice.is-selected { border-color: var(--accent-line); background: var(--accent-soft); }
.choice input { margin-top: 3px; }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.test-mail { padding-top: 14px; border-top: 1px solid var(--line); }
.template-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.template-picker { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.template-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.template-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.template-item:hover { background: var(--hover); }
.template-item.is-active { background: var(--accent-soft); font-weight: 600; }
.placeholder-list { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; font-size: 12.5px; }
.placeholder-list .field-label { width: 100%; }
.mail-options { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.mail-extra { display: flex; flex-direction: column; gap: 6px; padding-left: 50px; }
.check-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.mail-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12.5px; }
.mail-status { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--sunken); color: var(--ink-2); }
.mail-status-sent { background: var(--ok-soft); color: var(--ok); }
.mail-status-failed { background: var(--danger-soft); color: var(--danger); }
.mail-status-queued, .mail-status-sending { background: var(--accent-soft); color: var(--accent); }
.mail-error { color: var(--danger); max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) {
    .settings-layout, .template-layout { grid-template-columns: minmax(0, 1fr); }
    .setup-help { position: static; }
}
