/* =========================================================================
   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; }

.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; }
/* List pages use the whole width; the item page a bit more than forms. */
.main-inner:has(.wide-page-marker) { max-width: none; }
.main-inner:has(.item-columns) { max-width: 1640px; }

/* ---------- 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; }




/* ---------- 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; }


.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(var(--cols, 2), minmax(0, 1fr)); gap: 16px 24px; }
.side-card-body.form-grid { gap: 10px 14px; }
.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-tag { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--ink); }

/* ---------- State, badges, notices ---------- */










.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; }




.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-warning { background: var(--warn-soft); color: var(--ink); border-color: var(--warn); }
.notice-warning .ficon { color: var(--warn); }
.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-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; }


/* ---------- 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%; }

.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; }


/* ---------- 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 ---------- */






.create-layout { max-width: 1280px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }



.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; }


.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{
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px;
    list-style: none; cursor: pointer; user-select: none;
}

.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); }



/* ---------- 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-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 ---------- */







.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); }
/* Long text on the item page: ~15 lines fading out; the button opens it in a large window over the page */
.rte-expandable { position: relative; }
.rte-expandable .rte-area { max-height: 22.5em; overflow-y: auto; overscroll-behavior: contain; }
.rte-fade { display: none; position: absolute; left: 1px; right: 1px; bottom: 1px; height: 56px; pointer-events: none; border-radius: 0 0 var(--r-sm) var(--r-sm);
    background: linear-gradient(to bottom, transparent, var(--surface) 85%); }
.rte-expandable.has-more .rte-fade { display: block; }
.rte-expandable.at-end .rte-fade { display: none; }
.rte-expand { display: none; position: absolute; right: 8px; bottom: 8px; z-index: 1; width: 30px; height: 30px; place-items: center; padding: 0;
    border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow-1); cursor: pointer; }
.rte-expand:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.rte-expandable.has-more .rte-expand { display: inline-grid; }
.rte-expandable.is-expanded .rte-fade, .rte-expandable.is-expanded .rte-expand { display: none; }
.rte-window-layer { position: fixed; inset: 0; z-index: 300; display: flex; align-items: stretch; justify-content: center; padding: 4vh 24px; }
.rte-backdrop { position: absolute; inset: 0; background: var(--backdrop); animation: rte-fade-in .16s ease-out; }
.rte-window {
    position: relative; width: min(1180px, 100%); min-height: 0;
    display: flex; flex-direction: column;
    border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-pop);
    animation: rte-window-in .16s ease-out;
}
.rte-window-head { display: flex; align-items: center; gap: 12px; flex: none; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--line); }
.rte-window-title { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rte-window-close { width: 34px; height: 34px; flex: none; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.rte-window-close:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.rte-window .rte-toolbar { flex: none; border-radius: 0; }
.rte-window .rte-area { flex: 1; min-height: 0; max-height: none; overflow-y: auto; padding: 20px 28px; }
html.rte-window-open, html.rte-window-open body { overflow: hidden; }
@keyframes rte-window-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes rte-fade-in { from { opacity: 0; } to { opacity: 1; } }
.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; min-height: 36px; padding: 4px 4px 4px 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.link-chip:hover { border-color: var(--line-strong); }
.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; top: calc(100% + 4px); z-index: 30; width: max(100%, 340px); max-height: 360px; overflow-y: auto; padding: 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow-pop); animation: pop-in .12s ease-out; }
.item-col-side .picker-menu { left: auto; right: -86px; }
.picker-option { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 5px 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; line-height: 1.3; }
.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; }


/* ---------- 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: 220px minmax(0, 1fr) 300px; gap: 14px; 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-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(var(--cols, 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-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; }










.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; }








.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); }

/* Views menu as a tree: folders, sub-views, drag and drop */
.nav-section-actions { display: inline-flex; gap: 2px; }
button.nav-section-action { border: 0; background: none; padding: 0; cursor: pointer; }
.nav-tree-row { position: relative; }
.nav-children { margin-left: 18px; padding-left: 6px; border-left: 1px solid var(--line); }
.nav-tree-row.is-child .nav-view { height: 30px; }
.nav-folder { cursor: pointer; user-select: none; }
.nav-folder .nav-view-icon { color: var(--ink-3); }
.nav-chevron { margin-left: auto; color: var(--ink-3); flex: none; }
.nav-row-action { display: none; width: 22px; height: 22px; place-items: center; border: 0; background: none; border-radius: var(--r-sm); color: var(--ink-3); cursor: pointer; flex: none; margin-left: auto; }
.nav-row-action + .nav-chevron { margin-left: 2px; }
.nav-folder:hover .nav-row-action, .nav-folder:focus-within .nav-row-action { display: inline-grid; }
.nav-row-action:hover { background: var(--pressed); color: var(--ink); }
.nav-view-wrap { position: relative; }
.nav-view-wrap.has-toggle .nav-link { padding-right: 30px; }
.nav-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; display: inline-grid; place-items: center; border: 0; background: none; border-radius: var(--r-sm); color: var(--ink-3); cursor: pointer; }
.nav-toggle:hover { background: var(--pressed); color: var(--ink); }
.nav-empty-sub { padding-left: 10px; font-style: italic; }
.nav-problem { margin: 2px 10px 6px; padding: 6px 8px; font-size: 12px; color: var(--danger); background: var(--danger-soft); border-radius: var(--r-sm); }
.nav-drop { display: none; }
.nav.is-dragging .nav-drop { display: block; position: relative; height: 6px; margin: -3px 0; z-index: 2; }
.nav.is-dragging .nav-drop-end { height: 12px; margin: 0 0 -6px; }
.nav-drop.is-hot::after { content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 2px; margin-top: -1px; background: var(--accent); border-radius: 1px; }
.nav.is-dragging .nav-link * { pointer-events: none; }
.nav.is-dragging .nav-toggle, .nav.is-dragging .nav-row-action { pointer-events: none; }
.is-drop-into > .nav-link, .nav-link.is-drop-into { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.nav-group-head { display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px; border: 0; background: none; border-radius: var(--r-sm); color: var(--ink-2); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.nav-group-head:hover { background: var(--hover); color: var(--ink); }
.nav-group-head .ficon:first-child { color: var(--ink-3); }

/* =========================================================================
   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; }


/* 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; }
.comments-block .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; }
.comments-block .comment-actions { flex-wrap: wrap; }
.comments-block .composer-hint { margin-top: 0; }
.activity-empty { padding: 8px 0 4px 44px; }
/* Comments: the ticket's progress, right after the description */
.comments-block { margin-top: 24px; padding: 16px 18px 6px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.comments-block .main-block-title .ficon { color: var(--accent); }
.comments-block .composer-fake, .comments-block .rte { background: var(--surface); }
/* History: folded at the bottom */
.history-block { margin-top: 28px; border-top: 1px solid var(--line); }
.history-head { display: flex; align-items: center; gap: 8px; }
.history-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 12px 0; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.history-toggle .main-block-title { margin: 0; }
.history-toggle:hover .main-block-title { color: var(--accent); }
.history-toggle > .ficon:nth-child(2) { color: var(--ink-3); }
.history-block.is-open .history-toggle .section-chevron { transform: rotate(90deg); }
.history-sub { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.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); }
    
    .finder-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 860px) {
    .main-inner { padding: 16px 16px 56px; }
    .form-grid{ 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; }
}

/* Step 4: receiving */
.settings-group { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.settings-group h3 { font-size: 14px; }
.avatar-customer { background: color-mix(in srgb, #038387 18%, var(--surface)) !important; color: #038387 !important; }
.mail-status-in, .mail-status-processed { background: var(--ok-soft); color: var(--ok); }
.mail-status-unmatched { background: var(--warn-soft); color: var(--warn); }
.mail-status-ignored, .mail-status-blocked, .mail-status-dismissed, .mail-status-cancelled { background: var(--sunken); color: var(--ink-3); }
.mail-headers { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 14px; margin: 0 0 12px; font-size: 13px; }
.mail-headers dt { color: var(--ink-3); }
.mail-headers dd { margin: 0; overflow-wrap: anywhere; }
.mail-view { margin-top: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); max-height: 60vh; overflow: auto; }
.mail-view table { border-collapse: collapse; max-width: 100%; }
.mail-view td, .mail-view th { padding: 2px 6px; vertical-align: top; }
.mail-view hr { border: 0; border-top: 1px solid var(--line); }

/* =========================================================================
   SelectPicker: requester, team, assignee, level
   ========================================================================= */
.sp { position: relative; display: flex; align-items: center; min-width: 0; }
.sp-trigger {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
    height: 34px; padding: 0 28px 0 8px;
    border: 1px solid var(--input-border); border-radius: var(--r-sm); background: var(--surface);
    color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.sp-trigger:hover { border-color: var(--ink-3); }
.sp-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.is-quiet .sp-trigger { border-color: transparent; background: transparent; }
.is-quiet .sp-trigger:hover { border-color: transparent; background: var(--hover); }
.sp.is-open .sp-trigger { border-color: var(--input-border); border-bottom-color: var(--accent); background: var(--surface); }
.sp.is-invalid .sp-trigger { border-color: var(--danger); }
.sp-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-placeholder { color: var(--ink-3); }
.sp-caret { position: absolute; right: 10px; color: var(--ink-3); pointer-events: none; }
.is-quiet .sp:not(:hover):not(.is-open) .sp-caret { opacity: 0; }
.sp-clear { position: absolute; right: 26px; width: 20px; height: 20px; display: none; place-items: center; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink-3); cursor: pointer; }
.sp:hover .sp-clear { display: inline-grid; }
.sp:hover:not(.is-empty) .sp-trigger { padding-right: 50px; }
.sp-clear:hover { background: var(--pressed); color: var(--ink); }

.sp-visual { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; }
.sp-visual.is-small { width: 22px; height: 22px; }
.sp-avatar { border-radius: 50%; background: var(--av, var(--accent)); color: #FFFFFF; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; }
.sp-avatar.is-small { font-size: 9.5px; }
.sp-visual-icon { border-radius: var(--r-sm); background: var(--sunken); color: var(--ink-2); }
.sp-visual-icon.is-small { background: transparent; color: var(--ink-3); }
.sp-visual-none { color: var(--ink-3); }

.sp-backdrop { position: fixed; inset: 0; z-index: 240; }
.sp-pop {
    position: fixed; z-index: 250; display: flex; flex-direction: column; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow-pop);
    animation: pop-in .12s ease-out;
}
.sp-search { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.sp-pop .sp-search input,
.is-quiet :is(.form-section, .side-card) .sp-pop .sp-search input {
    flex: 1; min-width: 0; height: 30px; padding: 0; border: 0 !important; outline: none; box-shadow: none;
    background: transparent !important; color: var(--ink); font: inherit;
}
.sp-list { min-height: 0; overflow-y: auto; padding: 4px; }
.sp-option {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 5px 8px;
    border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.sp-option.is-active { background: var(--hover); }
.sp-option.is-selected { background: var(--accent-soft); }
.sp-option.is-selected.is-active { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.sp-option.is-selected .sp-label { font-weight: 600; }
.sp-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sp-label, .sp-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-sub { font-size: 12px; color: var(--ink-3); }
.sp-check { flex: none; color: var(--accent); }
.sp-badge { flex: none; padding: 1px 7px; border-radius: 9px; background: var(--sunken); color: var(--ink-3); font-size: 11px; }
.sp-action { min-height: 38px; }
.sp-action .sp-label { color: var(--accent); font-weight: 600; }
.sp-action .sp-visual-icon { background: var(--accent-soft); color: var(--accent); }
.sp-none { min-height: 36px; }
.sp-none .sp-label { color: var(--ink-2); }
.sp-sep { height: 1px; margin: 4px 6px; background: var(--line); }
.sp-nothing { padding: 16px 10px; color: var(--ink-3); font-size: 13px; text-align: center; }
.sp-foot { flex: none; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); }

/* Form designer: main column + side panel, sections as grids */
.canvas-columns { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(220px, 1fr); gap: 14px; align-items: start; }
.canvas-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 10px; border-radius: var(--r-lg); background: var(--sunken); }
.canvas-col-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-3); padding: 2px 2px 0; }
.canvas-fixed { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--ink-3); font-size: 12.5px; background: var(--surface-2); }
.canvas-fixed-label { margin-right: 2px; }
.canvas-section-head .spacer { flex: 1; }
.canvas-section.is-dragged { opacity: .45; }
.cols-picker { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.cols-picker button { display: inline-grid; place-items: center; width: 26px; height: 22px; padding: 0; border: 0; border-radius: 3px; background: none; color: var(--ink-3); cursor: pointer; }
.cols-picker button:hover { background: var(--hover); color: var(--ink); }
.cols-picker button.is-active { background: var(--accent-soft); color: var(--accent); }
.cols-glyph { display: inline-flex; gap: 2px; height: 12px; }
.cols-glyph i { display: block; width: 3px; height: 12px; border-radius: 1px; background: currentColor; }
.segmented .cols-glyph { margin-right: 2px; }
.chip-span { flex: none; padding: 0 5px; border-radius: 8px; background: var(--sunken); color: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.canvas-field.is-selected .chip-span { background: var(--surface); color: var(--accent); }
.canvas-comments { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1.5px dashed var(--accent-line); border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent); cursor: grab; }
.canvas-comments.is-dragged { opacity: .45; }
.canvas-comments-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.canvas-comments-text strong { color: var(--ink); }
.canvas-comments-text .muted { font-size: 12px; }
.col-drop { display: none; padding: 10px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); color: var(--ink-3); font-size: 12.5px; text-align: center; }
.designer.is-dragging .col-drop { display: block; }
.canvas-col-side .col-drop:only-of-type { display: block; }
.col-drop.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.span-picker { flex-wrap: wrap; }
.add-section { align-self: flex-start; }
.designer-canvas { container-type: inline-size; }
@container (max-width: 600px) {
    .canvas-columns { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
    .form-grid > *, .canvas-drop > * { grid-column: 1 / -1 !important; }
}
.canvas-section-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canvas-section:not(:hover):not(.is-selected) .cols-picker { border-color: transparent; background: transparent; }
.canvas-section:not(:hover):not(.is-selected) .cols-picker button:not(.is-active) { display: none; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 10px; border: 1px solid var(--accent-line); border-radius: 16px; background: var(--accent-soft); color: var(--accent); font-size: 13px; white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 8px; }
.pager-page { font-variant-numeric: tabular-nums; }
.side-times { margin: 4px 2px 0; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.side-times > div { display: grid; grid-template-columns: 38% 1fr; gap: 10px; }
.side-times dt { color: var(--ink-3); }
.side-times dd { margin: 0; color: var(--ink-2); }
.side-times dd.is-waiting { color: var(--warn); }
.settings-panel { max-width: 720px; }
.side-nostate { font-size: 12.5px; color: var(--ink-3); padding: 6px 2px; }

/* Item type: states */
.states-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.state-list { list-style: none; margin: 0; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.state-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.state-move { display: inline-flex; flex-direction: column; }
.state-move .icon-btn { height: 16px; }
.state-color { position: relative; flex: none; }
.state-swatch { width: 22px; height: 22px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; }
.state-swatch.is-active { box-shadow: 0 0 0 2px var(--accent); }
.state-palette { position: absolute; z-index: 20; top: 28px; left: -6px; display: flex; flex-wrap: wrap; gap: 6px; width: 196px; padding: 8px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-pop); }
.state-palette input[type="color"] { width: 40px; height: 24px; padding: 0; border: 0; background: none; }
.state-name { flex: 1; min-width: 120px; }
.state-category { width: 140px; flex: none; }
.state-count { width: 64px; flex: none; text-align: right; font-size: 12.5px; }
.states-hint { margin: 0 14px 14px; display: flex; gap: 6px; align-items: center; }
.category-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; font-size: 13px; }
.category-list dd { margin: 0; color: var(--ink-2); }
@media (max-width: 1100px) { .states-layout { grid-template-columns: minmax(0, 1fr); } }

/* Admin: list + editor side by side (calendars, SLAs) */
.split-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.pick-list { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.pick-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.pick-row:hover { background: var(--hover); }
.pick-row.is-active { background: var(--accent-soft); }
.pick-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.pick-text .muted { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hours-grid { display: grid; grid-template-columns: 110px minmax(0, 360px); gap: 6px 12px; align-items: center; }
.hours-day { font-size: 13px; color: var(--ink-2); }
@media (max-width: 1000px) { .split-layout { grid-template-columns: minmax(0, 1fr); } }

/* SLA editor */
.sla-edit { display: flex; flex-direction: column; gap: 16px; max-width: 1180px; }
.sla-levels { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sla-levels li { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sla-levels select { width: 280px; }
.sla-rules { display: flex; flex-direction: column; gap: 12px; }
.sla-rule { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.sla-rule-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-md) var(--r-md) 0 0; }
.sla-rule-no { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 12px; flex: none; }
.sla-rule-name { max-width: 320px; font-weight: 600; }
.sla-rule-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; padding: 12px 14px 14px; }
.sla-sub { font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.sla-sub .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.sla-targets { width: 100%; border-collapse: collapse; font-size: 13px; }
.sla-targets th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 12px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.sla-targets td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.sla-targets .sla-total td { border-bottom: 0; padding-top: 10px; }
.sla-time { width: 120px; height: 30px; }
@media (max-width: 1100px) { .sla-rule-body { grid-template-columns: minmax(0, 1fr); } }

/* SLA on the item page */
.sla-badge { margin-left: auto; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; background: var(--sunken); color: var(--ink-2); }
.sla-badge.sla-ok, .sla-badge.sla-met { background: var(--ok-soft); color: var(--ok); }
.sla-badge.sla-risk { background: var(--warn-soft); color: var(--warn); }
.sla-badge.sla-breach { background: var(--danger-soft); color: var(--danger); }
.sla-body { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.sla-which { font-size: 13px; }
.sla-line { display: flex; flex-direction: column; gap: 4px; }
.sla-line-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.sla-line-head .spacer { flex: 1; }
.sla-line-text { color: var(--ink-2); white-space: nowrap; }
.sla-line-text.sla-breach { color: var(--danger); font-weight: 600; }
.sla-line-text.sla-risk { color: var(--warn); font-weight: 600; }
.sla-bar { height: 5px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.sla-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.sla-bar > .sla-ok { background: var(--ok); }
.sla-bar > .sla-met { background: var(--ok); opacity: .6; }
.sla-bar > .sla-risk { background: var(--warn); }
.sla-bar > .sla-breach { background: var(--danger); }
.sla-bar > .sla-paused { background: var(--ink-3); }
.sla-line:not(.is-current) .sla-line-head { opacity: .8; }
.sla-card.sla-breach { border-color: var(--danger); }
.slastatus { padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.slastatus.sla-ok, .slastatus.sla-met { background: var(--ok-soft); color: var(--ok); }
.slastatus.sla-risk { background: var(--warn-soft); color: var(--warn); }
.slastatus.sla-breach { background: var(--danger-soft); color: var(--danger); }
.slastatus.sla-paused { background: var(--sunken); color: var(--ink-2); }

/* =========================================================================
   Phones and small tablets (reference: Galaxy S25+, 384 × 832)
   ========================================================================= */
.topbar-menu, .topbar-search-btn, .topbar-search-close, .menu-theme, .nav-backdrop { display: none; }

@media (max-width: 860px) {
    /* Top bar: ☰, logo, level, search icon, +, avatar */
    .topbar { gap: 6px; padding: 0 8px; }
    .topbar-menu { display: inline-grid; color: var(--topbar-ink); }
    .topbar-brand { width: auto; }
    .brand-name { display: none; }
    .topbar-search { display: none; }
    .topbar-search-btn { display: inline-grid; color: var(--topbar-ink); }
    .topbar-new { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 50%; }
    .topbar-new span { display: none; }
    .topbar-theme { display: none; }
    .menu-theme { display: flex; }
    .topbar.is-searching .topbar-search { display: flex; align-items: center; position: absolute; inset: 0; z-index: 2; padding: 8px; background: var(--topbar); }
    .topbar.is-searching .topbar-search input { height: 34px; font-size: 16px; }
    .topbar.is-searching .topbar-search .ficon { left: 18px; }
    .topbar.is-searching .topbar-search-close { display: inline-grid; margin-left: 4px; color: var(--topbar-ink); }

    /* Menu: a drawer from the left */
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        /* align-self: stretch: the desktop "start" would size the drawer to its content (newer browsers apply it
           to fixed boxes too), so it ran off the screen and couldn't scroll. */
        position: fixed; top: 48px; left: 0; bottom: 0; z-index: 55; height: auto; align-self: stretch;
        max-height: calc(100dvh - 48px); overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
        width: min(320px, 86vw); border-right: 1px solid var(--line); box-shadow: var(--shadow-pop);
        transform: translateX(-102%); transition: transform .18s ease-out; visibility: hidden;
    }
    html.nav-open .sidebar { transform: none; visibility: visible; }
    html.nav-open .nav-backdrop { display: block; position: fixed; inset: 48px 0 0 0; z-index: 54; background: var(--backdrop); }
    html.nav-open, html.nav-open body { overflow: hidden; }
    .nav-link, .nav-group-head { min-height: 40px; }
    .nav-row-action { display: inline-grid; }

    /* Page */
    .main-inner { padding: 14px 12px 72px; }
    .page-header { flex-wrap: wrap; gap: 10px; }
    .modal { max-width: none; margin: 0 8px; }
    .drawer { width: 100%; }
    input, select, textarea { font-size: 16px; } /* no zoom-in on focus */
}

@media (max-width: 720px) {
    /* Item tables become cards: title on top, then key, level, state, people, time */
    .table-scroll:has(> .item-cards) { overflow-x: visible; }
    table.item-cards, .item-cards tbody { display: block; width: 100%; }
    .item-cards thead { display: none; }
    .item-cards tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
    .item-cards tbody tr:last-child { border-bottom: 0; }
    .data.item-cards td { display: block; height: auto; padding: 0; border: 0; white-space: normal; min-width: 0; max-width: 100%; font-size: 13px; background: none; }
    .data.item-cards .col-id { width: auto; white-space: nowrap; }
    .data.item-cards tbody tr:hover td { background: none; }
    .data.item-cards tbody tr.row-link:active { background: var(--hover); }
    .item-cards td:empty { display: none; }
    .item-cards td.col-title { order: -2; flex: 1 0 100%; font-size: 14.5px; }
    .item-cards td.col-title a { font-weight: 600; }
    .item-cards td.col-id { order: -1; font-size: 12.5px; color: var(--ink-3); }
    .item-cards td[data-label]::before { content: attr(data-label) " "; color: var(--ink-3); font-size: 12px; }
    .item-cards .person .avatar { display: none; }
    .item-cards td.muted { margin-left: auto; font-size: 12px; }
    .item-cards input[type="checkbox"] { margin-right: 4px; }
    .table-foot.pager { flex-wrap: wrap; }

    /* Other tables keep scrolling sideways, but tighter */
    table.data:not(.item-cards) th, table.data:not(.item-cards) td { padding-left: 10px; padding-right: 10px; }

    /* Page headers and toolbars */
    .page-header .actions{ flex-wrap: wrap; }
    .toolbar { flex-wrap: wrap; gap: 8px; }
    .toolbar .search { flex: 1 1 100%; }
    .pills { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
    .kpis { gap: 8px; }
    .kpi { padding: 10px 12px; }
}

@media (max-width: 860px) {
    /* Item page: one column; what matters on the go comes first */
    .item-columns { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
    .item-col-main > *, .item-col-side > * { min-width: 0; max-width: 100%; }
    .history-sub { display: none; }
    .item-col-main, .item-col-side { display: contents; }
    .item-col-main > * { order: 5; }
    .item-col-main > .item-crumbs { order: 0; }
    .item-col-main > .notice { order: 1; }
    .item-col-main > .item-title-field { order: 1; }
    .item-col-side > .side-status { order: 2; margin: 4px 0 10px; }
    .item-col-side > section.side-card:not(.sla-card) { order: 3; }
    .item-col-side > details.side-card { order: 3; }
    .item-col-side > .sla-card { order: 4; }
    .item-col-side > .side-card { margin-bottom: 10px; }
    .item-col-main > .history-block { order: 7; }
    .item-col-side > .side-times { order: 8; margin-top: 16px; }
    .item-col-main > .save-bar { order: 9; position: sticky; bottom: 8px; }
    .side-status { display: flex; gap: 8px; }
    .side-status .status-button { flex: 1; }
    .item-crumbs { flex-wrap: wrap; gap: 6px; }
    .item-title-field .input-headline { font-size: 20px; }
    .comments-block { padding: 12px 12px 4px; }
    .composer-closed { flex-wrap: wrap; }
    .composer .avatar { display: none; }
    .feed-item .avatar { width: 28px; height: 28px; }
    .side-card .field-row { grid-template-columns: minmax(0, 34%) minmax(0, 1fr); }

    /* The large text window fills the screen */
    .rte-window-layer { padding: 0; }
    .rte-window { border-radius: 0; border: 0; }
}

@media (max-width: 600px) {
    /* Level menu: full width under the top bar */
    .level-pop { position: fixed; left: 8px; right: 8px; top: 52px; width: auto; max-height: calc(100vh - 64px); overflow-y: auto; }

    /* Pickers open as a sheet from the bottom (easy to reach, room for the keyboard) */
    .sp-pop {
        left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important; width: auto !important;
        max-height: 72vh !important; border-radius: 14px 14px 0 0; border-bottom: 0;
        animation: sp-sheet-in .16s ease-out;
    }
    .sp-pop::before { content: ""; align-self: center; width: 36px; height: 4px; margin: 8px 0 2px; border-radius: 2px; background: var(--line-strong); flex: none; }
    .sp-backdrop { background: var(--backdrop); }
    .sp-option { min-height: 48px; }
    .sp-search input { height: 36px !important; font-size: 16px; }
}
@keyframes sp-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 720px) {
    .pills .pill { white-space: nowrap; flex: none; }
    .item-cards td.col-assigned:has(.person)::before { content: "Assigned "; color: var(--ink-3); font-size: 12px; }
}
@media (max-width: 720px) {
    /* New item: item types as a row to swipe through */
    .tile-grid-compact { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; scroll-snap-type: x proximity; }
    .tile-grid-compact .tile { flex: none; padding: 8px 12px; scroll-snap-align: start; }
    .tile-grid-compact .tile-meta { display: none; }
    .create-layout .section { margin-bottom: 12px; }
}
@media (max-width: 720px) {
    .subtabs { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; scrollbar-width: none; }
    .subtabs .subtab { flex: none; }
    .toolbar .segmented { max-width: 100%; overflow-x: auto; }
    .toolbar .segmented button { flex: none; }
}

/* ---------- Recurring items ---------- */
.rec-schedule { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: start; }
.rec-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-radio { min-height: 36px; cursor: pointer; }
.rec-radio input[type=radio] { margin: 0; }
.rec-num { width: 72px; }
.rec-auto { width: auto; min-width: 0; }
.rec-days { display: flex; flex-wrap: wrap; gap: 4px; }
.rec-days .chip-toggle { height: 30px; min-width: 46px; justify-content: center; font-size: 13px; margin: 0; }
.rec-preview { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md, 8px); background: var(--sunken); }
.rec-preview ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }
.rec-preview-day { display: inline-block; width: 34px; color: var(--ink-3); }
.rec-levels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; max-width: 760px; }
.rec-levels-head { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.rec-tokens { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.rec-tokens .chip-toggle { margin: 0; }
.rec-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
.rec-field.is-wide { grid-column: 1 / -1; }
.rec-date-mode { margin-top: 4px; font-size: 12px; }
.rec-skipped { margin: 12px 0 0; font-size: 13px; }
.rec-recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rec-recent li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--line); }
.rec-recent li:first-child { border-top: 0; }
.rec-recent a { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
@media (max-width: 720px) {
    .rec-schedule { grid-template-columns: 1fr; }
    .rec-fields { grid-template-columns: 1fr; }
    .rec-levels { gap: 8px 6px; }
}

/* ---------- Wide screens: tables scroll in their own frame, so the header row stays visible ---------- */
@media (min-width: 861px) {
    .main-inner:has(.wide-page-marker) .table-scroll { max-height: calc(100vh - 48px - 32px); max-height: calc(100dvh - 48px - 32px); overflow: auto; }
    .main-inner:has(.wide-page-marker) .data th { z-index: 2; }
}
@media (min-width: 1700px) {
    .data .col-title { min-width: 320px; }
}

/* ---------- Teams integration ---------- */
.teams-icons { display: flex; flex-wrap: wrap; gap: 16px 32px; }
.teams-icon { display: flex; align-items: center; gap: 12px; }
.teams-icon img { border-radius: 8px; border: 1px solid var(--line); }
.teams-outline-preview { background: #444; padding: 6px; box-sizing: content-box; }
.teams-icon .btn-row { margin-top: 6px; }
.teams-perm { align-items: flex-start; padding: 3px 0; }
.teams-perm input { margin-top: 3px; }
.step-no { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; vertical-align: 1px; }
.teams-install { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--sunken); }
.teams-install pre { margin: 6px 0; padding: 8px 10px; background: var(--surface); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.teams-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.teams-checks li { display: flex; gap: 6px; align-items: baseline; }
.teams-checks li.is-ok .ficon { color: var(--ok, #2e7d32); }
.teams-checks li.is-bad .ficon { color: var(--danger); }
.teams-checks li span { color: var(--ink-2); }
.teams-mappings { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px 8px; align-items: center; max-width: 980px; }
.teams-reactions { display: grid; grid-template-columns: auto 90px auto minmax(0, 160px) auto minmax(0, 1fr) auto; gap: 6px 8px; align-items: center; max-width: 900px; }
.teams-emoji { text-align: center; font-size: 16px; }
@media (max-width: 720px) {
    .teams-mappings, .teams-reactions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .teams-mappings > .muted, .teams-reactions > .muted { display: none; }
}
.sla-left { font-variant-numeric: tabular-nums; }
.sla-left.sla-breach { color: var(--danger); font-weight: 600; }
.sla-left.sla-risk { color: var(--warn, #b26a00); font-weight: 600; }
.sla-left.sla-paused, .sla-left.sla-met { color: var(--ink-3); }
.emoji-pick { position: relative; }
.emoji-trigger { display: inline-flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; height: 34px; padding: 0 8px 0 10px;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); cursor: pointer; }
.emoji-trigger:hover { border-color: var(--ink-3); }
.emoji-current { font-size: 18px; line-height: 1; }
.emoji-pop { position: absolute; z-index: 250; top: calc(100% + 4px); left: 0; width: 336px; max-width: calc(100vw - 32px);
    border: 1px solid var(--line-strong); border-radius: var(--r-md, 8px); background: var(--surface); box-shadow: var(--shadow-2, 0 8px 24px rgba(0,0,0,.25)); }
.emoji-pop .sp-search { margin: 8px; }
.emoji-body { max-height: 300px; overflow-y: auto; padding: 0 8px 8px; overscroll-behavior: contain; }
.emoji-sub { margin: 6px 4px 4px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-cell { height: 36px; border: 0; border-radius: var(--r-sm); background: transparent; font-size: 20px; line-height: 1; cursor: pointer; }
.emoji-cell:hover { background: var(--hover); }
.emoji-cell.is-selected { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.emoji-use { margin: 2px 4px 6px; }
.emoji-big { font-size: 18px; }
.comment-card.is-deleted { opacity: .55; text-decoration: line-through; text-decoration-color: var(--ink-3); }
/* Theme page and branding */
.brand-logo { height: 28px; width: auto; max-width: 140px; object-fit: contain; flex: none; }
.brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-row { display: flex; gap: 8px; align-items: center; }
.theme-row input { flex: 1; min-width: 0; }
.theme-image { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.theme-image + .theme-image { padding-top: 14px; border-top: 1px solid var(--line); }
.theme-image-text .help { margin-top: 2px; }
.theme-thumb { width: 72px; height: 48px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r-sm);
    background: repeating-conic-gradient(var(--sunken) 0 25%, var(--surface) 0 50%) 0 0 / 12px 12px; }
.theme-thumb img { max-width: 60px; max-height: 36px; object-fit: contain; }
.theme-tab { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; height: 34px; padding: 0 14px; border: 1px solid var(--line-strong);
    border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface); font-size: 12.5px; }
.theme-tab img { width: 16px; height: 16px; flex: none; }
.theme-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-header { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; border-radius: var(--r-sm);
    background: var(--topbar); color: var(--topbar-ink); font-weight: 600; font-size: 15px; }
.theme-appicon img { width: 72px; height: 72px; border-radius: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
@media (max-width: 640px) {
    .theme-image { grid-template-columns: 72px minmax(0, 1fr); }
    .theme-image .btn-row { grid-column: 1 / -1; }
}
/* Live connection lost (App.razor): a transparent layer stops clicks that would be lost; a small bar after 1 s. */
.reconnect { display: none; position: fixed; inset: 0; z-index: 10000; }
.reconnect.components-reconnect-show, .reconnect.components-reconnect-failed, .reconnect.components-reconnect-paused,
.reconnect.components-reconnect-rejected, .reconnect.components-reconnect-resume-failed { display: block; }
.reconnect-bar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
    max-width: calc(100vw - 32px); padding: 8px 14px; border-radius: 18px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
    font-size: 13px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.25); opacity: 0; animation: reconnect-in .2s ease 1s forwards; }
.reconnect.components-reconnect-failed .reconnect-bar, .reconnect.components-reconnect-rejected .reconnect-bar,
.reconnect.components-reconnect-resume-failed .reconnect-bar { animation-delay: 0s; }
.reconnect-bar > span[class^="reconnect-text"] { display: none; }
.reconnect.components-reconnect-show .reconnect-text-show,
.reconnect.components-reconnect-paused .reconnect-text-show,
.reconnect.components-reconnect-resume-failed .reconnect-text-rejected,
.reconnect.components-reconnect-failed .reconnect-text-failed,
.reconnect.components-reconnect-rejected .reconnect-text-rejected { display: inline; }
.reconnect-spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: reconnect-spin .8s linear infinite; }
@keyframes reconnect-in { to { opacity: 1; } }
@keyframes reconnect-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .reconnect-spinner { animation: none; } }
.draft-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; padding: 6px 10px; border-radius: var(--r-sm);
    background: var(--accent-soft); color: var(--ink-2); font-size: 13px; }
.theme-warn { display: block; margin-top: 2px; color: var(--warn); }
.theme-home { display: flex; gap: 22px; padding: 14px; border-radius: var(--r-sm); background: linear-gradient(160deg, #2B4A6F, #4E2F5E); }
.theme-home-app { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 76px; color: #FFFFFF; font-size: 12px; text-align: center; }
.theme-home-app > span { max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-home-app small { color: rgba(255,255,255,.7); font-size: 10.5px; }
.theme-home-app .is-ios { width: 60px; height: 60px; border-radius: 14px; }
.theme-home-app .is-android { width: 60px; height: 60px; border-radius: 50%; }
.theme-maskable-guess { display: grid; place-items: center; background: var(--topbar); overflow: hidden; }
.theme-maskable-guess img { width: 80%; height: 80%; object-fit: contain; }
/* Notification bell (Layout/NotificationBell.razor) */
.notif-bell .topbar-icon { position: relative; }
.notif-count { position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    background: #D13438; color: #FFFFFF; font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center; }
.notif-panel { width: 360px; max-width: calc(100vw - 16px); padding: 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.notif-empty { margin: 0; padding: 16px 12px; }
.notif-list { list-style: none; margin: 0; padding: 4px; max-height: min(70vh, 520px); overflow-y: auto; }
.notif-entry { display: flex; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: var(--r-sm); background: transparent;
    color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.notif-entry:hover { background: var(--hover); }
.notif-dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: transparent; }
.notif-entry.is-unread .notif-dot { background: var(--accent); }
.notif-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-title { font-weight: 600; overflow-wrap: anywhere; }
.notif-entry:not(.is-unread) .notif-title { font-weight: 500; color: var(--ink-2); }
.notif-body { color: var(--ink-2); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-time { color: var(--ink-3); font-size: 12px; }
@media (max-width: 640px) { .notif-panel { position: fixed; top: 52px; right: 8px; left: 8px; width: auto; } }
/* Notification rule editor */
.notif-edit { display: flex; flex-direction: column; gap: 16px; max-width: 900px; }
.notif-edit .panel + .panel { margin-top: 0; }
.notif-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.notif-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.notif-tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.token-chip { height: 26px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface);
    color: var(--ink-2); font: inherit; font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; cursor: pointer; }
.token-chip:hover { background: var(--hover); color: var(--ink); }
.notif-preview { display: flex; gap: 10px; max-width: 380px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface); box-shadow: var(--shadow-pop); }
.notif-preview .notif-dot { background: var(--accent); }
@media (max-width: 640px) { .notif-options { grid-template-columns: minmax(0, 1fr); } }
/* My notifications */
.push-on { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--ok); font-weight: 600; }
.push-devices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.push-devices li { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr) auto; gap: 10px; align-items: center; }
@media (max-width: 640px) { .push-devices li { grid-template-columns: minmax(0, 1fr) auto; } .push-devices li .muted { grid-column: 1 / -1; grid-row: 2; } }
/* Type filter pills: long press adds a type, so no text selection / callout on touch */
.type-pills .pill { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* Type multi-select (Shared/TypeMultiPicker.razor) */
.type-pick { position: relative; }
.type-pick-trigger { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; min-height: 34px; padding: 0 8px 0 10px;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.type-pick-trigger:hover { border-color: var(--ink-3); }
.type-pick-value { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.type-pick-value > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-pick-pop { position: absolute; z-index: 250; top: calc(100% + 4px); left: 0; right: 0; max-height: 320px; overflow-y: auto; padding: 4px;
    border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-pop); }
.type-pick-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer; }
.type-pick-row:hover { background: var(--hover); }
.type-pick-all { border-bottom: 1px solid var(--line); border-radius: var(--r-sm) var(--r-sm) 0 0; margin-bottom: 2px; }
/* The badge is white: show it on the dark top bar colour, as the shape Android will draw (white). */
.theme-thumb.is-badge { background: var(--topbar); }
.theme-thumb.is-badge img { filter: brightness(0) invert(1); }
.canvas-comments.is-off { border-color: var(--line-strong); background: var(--sunken); color: var(--ink-3); }
.canvas-comments-mode { width: auto; height: 30px; font-size: 13px; cursor: pointer; }
.mail-route-note { margin: 4px 0 0 52px; font-size: 12.5px; }
/* ---------- View blocks (Shared/ViewBlockView.razor) ---------- */
.vgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; align-items: start; }
.vblock { grid-column: span var(--span, 12); min-width: 0; }
.vblock .kpi { height: 100%; }
.kpi.is-static:hover { border-color: var(--line); }
.vblock-head { margin-bottom: 8px; }
.vblock-head h2 { display: flex; align-items: center; gap: 8px; }
.vblock-empty { margin: 0; padding: 14px 16px; }
.data.is-compact td, .data.is-compact th { padding-top: 7px; padding-bottom: 7px; }
.vchart { padding: 12px 16px 14px; }
.vchart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.vchart-head h2 { font-size: 15px; margin: 0; }
.vchart-head .muted { font-size: 12.5px; }
/* Bars: one hue (a count per group), rounded data end, 2px gaps, value labelled directly. */
.vbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.vbar-row { display: grid; grid-template-columns: minmax(80px, 34%) minmax(0, 1fr) 3.2em; align-items: center; gap: 10px; min-height: 28px;
    padding: 0 4px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; }
a.vbar-row[href]:hover { background: var(--hover); text-decoration: none; }
a.vbar-row[href]:hover .vbar { background: var(--accent-hover, var(--accent)); }
.vbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.vbar-track { height: 14px; display: flex; align-items: center; }
.vbar { display: block; height: 14px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--accent); }
.vbar-value { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-2); }
/* Columns over time */
.vcols { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 180px; padding: 16px 0 0; border-bottom: 1px solid var(--line-strong); }
.vcols-max { position: absolute; top: 0; left: 0; right: 0; border-top: 1px dashed var(--line); font-size: 11px; color: var(--ink-3); line-height: 1; padding-top: 2px; }
.vcol { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; position: relative; text-decoration: none; border-radius: 4px 4px 0 0; }
a.vcol[href]:hover { background: var(--hover); }
a.vcol[href]:hover .vcol-bar { background: var(--accent-hover, var(--accent)); }
.vcol-bar { display: block; margin: 0 15%; border-radius: 4px 4px 0 0; background: var(--accent); }
.vcol.is-zero .vcol-bar { height: 2px !important; background: var(--line-strong); }
.vcol-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); padding-top: 4px; font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.vchart .vcols { margin-bottom: 20px; }
@media (max-width: 860px) {
    .vblock { grid-column: span 12; }
    .vblock-number { grid-column: span 6; }
}
/* ---------- View editor (Pages/ViewEdit.razor) ---------- */
.vdesigner { display: grid; grid-template-columns: 200px minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.vdesigner-palette, .vdesigner-props { position: sticky; top: 64px; max-height: calc(100vh - 80px); display: flex; flex-direction: column; }
.vdesigner-props { overflow-y: auto; }
.vdesigner-props .panel-body { padding-top: 4px; }
.vpalette { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.vpalette-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 8px 8px 4px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-align: left; cursor: grab; }
.vpalette-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.vpalette-help { margin: 4px 12px 10px; }
.vpalette-settings { margin: 0 10px 12px; justify-content: center; }
.vpalette-settings.is-active { border-color: var(--accent); color: var(--accent); }
.vdesigner-canvas { min-width: 0; padding: 12px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); background: var(--sunken); }
.vdesigner-title { cursor: pointer; margin-bottom: 10px; }
.vblock-frame { grid-column: span var(--span, 12); min-width: 0; border: 1.5px solid transparent; border-radius: var(--r-md); padding: 4px; cursor: pointer; position: relative; }
.vblock-frame:hover { border-color: var(--line-strong); }
.vblock-frame.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.vblock-frame.is-over::before { content: ""; position: absolute; left: -9px; top: 4px; bottom: 4px; width: 4px; border-radius: 2px; background: var(--accent); }
.vblock-frame.is-dragged { opacity: .4; }
.vblock-bar { display: flex; align-items: center; gap: 4px; padding: 2px 4px 6px; cursor: grab; }
.vblock-bar-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.vblock-bar-width { font-size: 11.5px; color: var(--ink-3); padding: 0 6px; border: 1px solid var(--line); border-radius: 9px; }
.vblock-preview { pointer-events: none; }
.vblock-preview .vblock { grid-column: auto; }
.vblock-end { grid-column: span 12; display: grid; place-items: center; min-height: 52px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); color: var(--ink-3); font-size: 13px; }
.vdesigner.is-dragging .vblock-end { border-color: var(--accent-line); color: var(--accent); }
.vblock-end.is-over { background: var(--accent-soft); border-color: var(--accent); }
@media (max-width: 1280px) {
    .vdesigner { grid-template-columns: 200px minmax(0, 1fr); }
    .vdesigner-props { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 860px) {
    .vdesigner { grid-template-columns: minmax(0, 1fr); }
    .vdesigner-palette { position: static; max-height: none; }
    .vpalette { flex-direction: row; flex-wrap: wrap; }
    .vpalette li { flex: 1 1 45%; }
    .vblock-frame { grid-column: span 12; }
}
.load-more { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; border-top: 1px solid var(--line); }

/* ---------- Translations in editors ---------- */
.lang-grid { display: grid; gap: 4px; }
.lang-row { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 6px; }
.lang-code { font-size: 11px; font-weight: 600; color: var(--text-3, #6b7280); letter-spacing: .04em; text-align: center;
  border: 1px solid var(--border, #d6d9de); border-radius: 4px; padding: 2px 0; }
.opt-table { display: grid; gap: 4px; }
.opt-row { display: grid; grid-template-columns: minmax(0, 1.1fr) repeat(2, minmax(0, 1fr)) auto; gap: 4px; align-items: center; }
.opt-row input { min-width: 0; }
.opt-head { font-size: 12px; color: var(--text-3, #6b7280); font-weight: 600; }
.opt-key { display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 0 6px; font-size: 13px; }
.opt-actions { display: flex; gap: 2px; }
.lang-help { margin-top: 8px; }
.lang-help > summary { cursor: pointer; font-size: 13px; margin-bottom: 6px; }
@media (max-width: 640px) {
  .opt-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .opt-head { display: none; }
  .opt-row .opt-key, .opt-row > input:first-child { grid-column: 1 / -1; font-weight: 600; }
  .opt-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

.menu-langs { display: flex; align-items: center; gap: 4px; padding: 6px 12px; color: var(--text-2, #4b5563); }
.menu-lang { border: 1px solid var(--border, #d6d9de); background: transparent; color: inherit; border-radius: 999px;
  padding: 2px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.menu-lang.is-selected { border-color: var(--accent, #0F6CBD); color: var(--accent, #0F6CBD); font-weight: 600; }
.state-names { flex: 1; display: flex; gap: 6px; min-width: 0; }
.state-names .state-name { min-width: 0; }
.state-name-tr { font-size: 13px; }
@media (max-width: 640px) { .state-names { flex-direction: column; } }
.tr-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: 12px; }
.tr-areas { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tr-area { border: 1px solid var(--line); background: var(--surface); color: inherit; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.tr-area.is-active { border-color: var(--accent, #0F6CBD); color: var(--accent, #0F6CBD); }
.tr-count { font-size: 11px; font-weight: 600; background: var(--surface-2, #f1f3f5); border-radius: 999px; padding: 0 6px; }
.tr-count.is-done { color: #107C10; }
.tr-table td { vertical-align: middle; }
.tr-table input { width: 100%; min-width: 160px; }
.tr-internal { font-size: 12px; }
.tr-what { font-weight: 600; }
.tr-builtin { margin: 0; padding-left: 18px; columns: 2; font-size: 13px; }
@media (max-width: 640px) { .tr-builtin { columns: 1; } }
.setup-details > summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.setup-details .rich { margin-top: 6px; font-size: 13px; }
.badge-error { background: var(--danger-soft); color: var(--danger); }
.col-order { width: 64px; white-space: nowrap; }
.state-checks { display: grid; gap: 6px; }
.state-group { display: grid; gap: 2px; }
.state-group-name { font-size: 12px; font-weight: 600; color: var(--text-3, #6b7280); margin-top: 4px; }
.ir-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ir-row > select { flex: 0 1 auto; max-width: 220px; }
.ir-row .ir-header { flex: 0 1 160px; min-width: 0; }
.ir-row .ir-value { flex: 1 1 220px; min-width: 0; }
.ir-test { margin: 0; padding-left: 18px; display: grid; gap: 2px; font-size: 13px; }
.create-mode { margin-bottom: 14px; }
.create-nomail { margin-top: 10px; font-size: 13px; }
.multi-create { display: flex; flex-direction: column; gap: 16px; }
tr.is-muted td { opacity: .5; }
.col-check { width: 32px; }
.level-pick { max-width: 760px; }
.level-pick .type-pick-pop { max-height: 360px; }
.level-pick-search { padding: 4px 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.level-pick-search input { width: 100%; }
.level-pick-row { justify-content: space-between; }
.level-pick-row label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; cursor: pointer; }
.level-pick-below { font-size: 12px; white-space: nowrap; }
.level-pick-name { min-height: 34px; display: flex; align-items: center; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.nav-section-toggle { display: flex; align-items: center; justify-content: space-between; width: calc(100% - 20px); padding: 2px 4px; margin-left: 10px; margin-right: 10px;
    background: none; border: 0; border-radius: var(--r-sm); font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-3); cursor: pointer; text-align: left; }
button.nav-section-toggle:hover { background: var(--hover); color: var(--ink); }

/* ---------- Webhooks: copy rows, code blocks, JSON tree ---------- */
.copy-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.copy-row code { flex: 1; min-width: 0; padding: 6px 8px; background: var(--sunken); border-radius: var(--r-sm); overflow-wrap: anywhere; }
.addr-input { display: flex; align-items: center; gap: 2px; min-width: 0; }
.addr-input > span { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; }
.addr-input input { flex: 1 1 140px; min-width: 120px; }
.code-block { margin: 6px 0; padding: 8px 10px; background: var(--sunken); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.json-tree { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; overflow-x: auto; }
.json-tree ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dotted var(--line-strong); }
.json-tree > ul { padding-left: 0; border-left: 0; }
.json-tree li { white-space: nowrap; }
.json-tree .jt-toggle { display: inline-flex; width: 16px; justify-content: center; padding: 0; background: none; border: 0; color: var(--ink-3); cursor: pointer; font: inherit; }
.json-tree .jt-spacer { display: inline-block; width: 16px; }
.json-tree .jt-key { color: var(--ink-2); }
.json-tree .jt-count { color: var(--ink-3); font-size: 11.5px; }
.json-tree .jt-value { border-radius: var(--r-xs); padding: 0 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.json-tree .jt-string { color: var(--ok); }
.json-tree .jt-number { color: var(--accent); }
.json-tree .jt-bool { color: var(--warn); }
.json-tree .jt-null { color: var(--ink-3); font-style: italic; }
.json-tree .jt-pickable { cursor: pointer; }
.json-tree .jt-pickable:hover { background: var(--accent-soft); outline: 1px solid var(--accent-line); }
.json-tree .jt-path { display: none; margin-left: 8px; color: var(--ink-3); font-size: 11px; }
.json-tree li:hover > .jt-path { display: inline; }
.wh-detail { display: grid; gap: 14px; }
.wh-section-title { font-size: 13px; font-weight: 600; margin: 0 0 6px; }

/* ---------- Webhook rule editor: form left, sample and result right ---------- */
.wh-edit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); gap: 16px; align-items: start; }
.wh-form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.wh-form .panel + .panel, .wh-sample .panel + .panel { margin-top: 0; }
.wh-sample { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 24px); overflow-y: auto; min-width: 0; }
.wh-tree { max-height: 46vh; overflow: auto; padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.wh-json-input { font-family: var(--font-mono); font-size: 12px; }
.wh-path { font-family: var(--font-mono); font-size: 12.5px; }
.is-pick-target { outline: 2px solid var(--accent); outline-offset: 1px; }
.wh-mapping { display: grid; gap: 6px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.wh-mapping:last-of-type { border-bottom: 0; }
.wh-mapping-more { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-left: 12px; }
.wh-map { display: grid; gap: 6px; padding: 8px 10px; margin-left: 12px; background: var(--surface-2); border-radius: var(--r-sm); }
.wh-preview { display: grid; gap: 8px; font-size: 13px; }
.wh-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.wh-checks li { overflow-wrap: anywhere; }
.wh-checks li.is-ok .ficon { color: var(--ok); }
.wh-checks li.is-bad .ficon { color: var(--danger); }
.wh-verdict { margin: 0; font-weight: 600; }
.wh-verdict.is-bad { color: var(--warn); }
@media (max-width: 1100px) {
    .wh-edit { grid-template-columns: minmax(0, 1fr); }
    .wh-sample { position: static; max-height: none; }
}

/* ---------- Webhook page ---------- */
.wh-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.wh-page { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.wh-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.wh-col .panel + .panel { margin-top: 0; }
.wh-list { list-style: none; margin: 0; padding: 0; }
.wh-list li { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-top: 1px solid var(--line); min-width: 0; }
.wh-list li:first-child { border-top: 0; }
.wh-list li.row-link { cursor: pointer; }
.wh-list li.row-link:hover { background: var(--hover); }
.wh-list li.is-muted { opacity: .65; }
.wh-list-main { flex: 1; min-width: 0; }
.wh-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-pos { width: 18px; text-align: center; color: var(--ink-3); font-size: 12px; }
@media (max-width: 1000px) { .wh-page { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Webhook rule editor (sample left, recipe right) ---------- */
.rx-top { margin-bottom: 16px; }
.rx-top-grid { display: grid; grid-template-columns: minmax(200px, 320px) minmax(0, 1fr) auto; gap: 16px; align-items: start; }
.rx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rx-toggle { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font: inherit; font-size: 12.5px; cursor: pointer; }
.rx-toggle:hover { background: var(--hover); }
.rx-toggle.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.rx { display: grid; grid-template-columns: minmax(320px, 5fr) minmax(0, 6fr); gap: 16px; align-items: start; }
.rx-sample { position: sticky; top: 12px; min-width: 0; }
.rx-sample .panel-body { max-height: calc(100vh - 150px); overflow-y: auto; }
.rx-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.rx-main .panel + .panel { margin-top: 0; }
.rx-rows { display: grid; gap: 8px; }
.rx-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.rx-row select, .rx-row input { width: auto; }
/* An empty slot for one value from the sample (rule editor: find by, external reference). */
.rx-slot { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); background: transparent; color: var(--ink-3); font: inherit; cursor: pointer; }
.rx-slot:hover, .rx-slot.is-pick-target { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.rx-op { max-width: 170px; }
.rx-value { flex: 1; min-width: 120px; max-width: 280px; }
.rx-pattern { width: 150px; font-family: var(--font-mono); font-size: 12px; }
.rx-field { max-width: 200px; }
.rx-x { margin-left: auto; }
.rx-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.rx-mapping { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.rx-mapping:last-child { border-bottom: 0; }
.rx-translate { display: grid; gap: 6px; margin: 8px 0 0 16px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--r-sm); }
.rx-translate code { min-width: 70px; }
/* Existing item: what each meaning does, for an open and for a resolved/closed item. */
.rx-cases { display: grid; grid-template-columns: max-content minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; align-items: center; }
.rx-case { font-weight: 600; }
@media (max-width: 640px) { .rx-cases { grid-template-columns: max-content minmax(0, 1fr); } .rx-cases > :nth-child(3n) { grid-column: 2; } }
.rx-target { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--r-sm); font-size: 13px; }
.rx-preview { border-color: var(--accent-line); }
.rx-verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.rx-ticket { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); margin-bottom: 8px; }
.rx-ticket-title { font-weight: 600; font-size: 15px; margin-bottom: 8px; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
    .rx, .rx-top-grid { grid-template-columns: minmax(0, 1fr); }
    .rx-sample { position: static; }
    .rx-sample .panel-body { max-height: none; }
}

/* Value chips */
.vchip { display: inline-flex; align-items: center; max-width: 100%; border-radius: 999px; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent); font-size: 12px; line-height: 1; }
.vchip.is-active { outline: 2px solid var(--accent); outline-offset: 1px; }
.vchip-main { display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding: 4px 8px; background: none; border: 0; color: inherit; font: inherit; font-family: var(--font-mono); cursor: pointer; }
.vchip-main > span:not(.vchip-sample) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vchip-sample { color: var(--ink-3); font-family: var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.vchip-x { display: inline-flex; padding: 4px 7px 4px 2px; background: none; border: 0; color: inherit; cursor: pointer; }

/* Text with values from a request (TemplateBuilder): one text, values and links as bubbles inside it */
.tpl { position: relative; display: grid; gap: 4px; }
.tpl-area { min-height: 36px; padding: 6px 10px; border: 1px solid var(--input-border); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
            line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; outline: none; cursor: text; }
.tpl:not(.tpl-multi) .tpl-area { white-space: normal; }
.tpl-multi .tpl-area { min-height: 160px; max-height: 70vh; overflow-y: auto; resize: vertical; }
.tpl-area:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tpl.is-pick-target .tpl-area { border-color: var(--accent); }
.tpl-area.is-empty::before { content: attr(data-placeholder); color: var(--ink-3); pointer-events: none; }
.tpl-area.is-hidden { display: none; }
.tpl-rte.is-hidden { display: none; }
.tpl-rte .tpl-area { min-height: 160px; max-height: 70vh; padding: 10px 12px; border: 0; border-radius: 0 0 var(--r-sm) var(--r-sm); box-shadow: none; line-height: 1.55; white-space: normal; resize: vertical; }
.tpl-rte .tpl-area:focus { box-shadow: none; }
.tpl.is-pick-target .tpl-rte { border-color: var(--accent); }
.tpl-rte .tpl-area.is-empty::before { position: absolute; }
.tpl-raw { font-family: var(--font-mono); font-size: 12.5px; }
.tpl-chip, .tpl-link { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; margin: 0 1px; padding: 1px 4px 1px 8px; vertical-align: baseline;
                       border-radius: 999px; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent);
                       font-size: 12px; line-height: 1.5; white-space: nowrap; cursor: pointer; user-select: none; }
.tpl-chip:hover, .tpl-link:hover { border-color: var(--accent); }
.tpl-chip .tpl-ico { font-family: var(--font-mono); font-size: 10px; opacity: .7; }
.tpl-chip .tpl-lbl { font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; }
.tpl-link .tpl-lbl { text-decoration: underline; overflow: hidden; text-overflow: ellipsis; }
.tpl-fmt { color: var(--ink-2); font-size: 11px; }
.tpl-fmt:empty, .tpl-sample:empty { display: none; }
.tpl-fmt::before { content: "· "; }
.tpl-sample { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.tpl-x { padding: 0 4px; border-radius: 999px; font-size: 13px; line-height: 1; }
.tpl-x:hover { background: var(--accent-line); }
.tpl-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 12px; font-size: 12px; }
.tpl-tools .link-btn { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.tpl-hint { margin-right: auto; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; }
.tpl-pop { position: absolute; z-index: 30; display: grid; gap: 10px; width: min(420px, calc(100vw - 48px)); padding: 12px; border: 1px solid var(--line-strong);
           border-radius: var(--r-md, 8px); background: var(--surface); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.tpl-pop .field { margin: 0; }
.tpl-pop-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.tpl-pop-title code { font-size: 12px; font-weight: 400; }
.tpl-pop-sample { color: var(--ink-2); font-size: 12.5px; overflow-wrap: anywhere; }
.tpl-pop-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-pop .tpl-multi .tpl-area { min-height: 36px; }
.tpl-help { font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }
.tpl-help.is-warning { color: var(--warn); }

/* Payload explorer */
.px { display: grid; gap: 8px; }
.px-search { display: flex; align-items: center; gap: 6px; padding: 0 8px; border: 1px solid var(--input-border); border-radius: var(--r-sm); }
.px-search input { border: 0; box-shadow: none; padding-left: 0; background: transparent; }
.px-tree { font-size: 13px; }
.px-head { display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 6px; background: none; border: 0; border-radius: var(--r-sm); font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.px-head:hover { background: var(--hover); }
.px-children { margin-left: 12px; padding-left: 8px; border-left: 1px solid var(--line); }
.px-key { color: var(--ink-2); flex: 0 0 auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.px-count { color: var(--ink-3); font-size: 11.5px; }
.px-row { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 4px 6px; background: none; border: 0; border-radius: var(--r-sm); font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.px-row:hover { background: var(--hover); }
.px-val { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }
.px-str { color: var(--ok); }
.px-num { color: var(--accent); }
.px-bool { color: var(--warn); }
.px-null { color: var(--ink-3); font-style: italic; }
.px-leaf.is-used .px-val { text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
.px-leaf.is-used .px-row .ficon { color: var(--accent); }
.px-leaf.is-focus .px-row, .px-leaf.is-open .px-row { background: var(--accent-soft); }
.px-menu { margin: 2px 0 6px 10px; padding: 4px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); }
.px-actions { display: grid; }
.px-menu-title { padding: 6px 8px; font-size: 12px; color: var(--ink-3); }
.px-action { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; background: none; border: 0; border-radius: var(--r-sm); font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; text-align: left; }
.px-action:hover { background: var(--hover); }
.px-action.is-primary { color: var(--accent); font-weight: 600; }
.px-action.muted { color: var(--ink-3); }
.px-action code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.px-more { padding: 4px 6px; font-size: 12px; }

/* ---------- First-start setup ---------- */
.setup-card { max-width: 440px; }
.setup-count { font-size: 12.5px; color: var(--ink-3); margin-bottom: 10px; }
.setup-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.setup-steps li { display: flex; align-items: center; gap: 10px; color: #8F9AA7; font-size: 14px; }
.setup-steps li.is-current { color: #FFFFFF; font-weight: 600; }
.setup-steps li.is-done { color: #C9D2DC; }
.setup-step-dot { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; border: 1px solid #4A5868; flex: none; }
.setup-steps li.is-current .setup-step-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.setup-steps li.is-done .setup-step-dot { border-color: #6B7A8B; }
.setup-checks { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.setup-checks li { display: flex; align-items: flex-start; gap: 6px; }
.setup-checks li.is-ok .ficon { color: var(--ok, #107C10); }
.setup-checks li.is-warn { color: var(--danger, #C50F1F); }
.setup-actions { margin-top: 20px; justify-content: flex-end; }
.setup-image { display: grid; gap: 4px; }
.setup-preview { height: 32px; width: auto; max-width: 120px; border-radius: var(--r-sm); background: var(--sunken); }
.setup-summary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 12px; font-size: 14px; }
.setup-summary dt { color: var(--ink-3); }
.setup-summary dd { margin: 0; overflow-wrap: anywhere; }
.setup-note { font-size: 13px; }
.setup-card .segmented { align-self: flex-start; width: max-content; max-width: 100%; }
