/* ============================================================
   Tessellate OS Helpdesk — theme.css
   Same palette as portal.tess-os.com (welcome/incs/theme.css).
   Re-skin by editing the tokens in :root.
   ============================================================ */

:root {
    --bg:          #FAF6EF;   /* warm sand */
    --surface:     #FFFFFF;
    --ink:         #33291F;   /* espresso text */
    --muted:       #6E5E4C;   /* secondary text (passes 4.5:1 on sand) */
    --border:      #E6DCCB;
    --border-soft: #F0E8DA;
    --navbar:      #33291F;
    --accent:      #C4701E;   /* burnt amber — logo, outlines, focus */
    --accent-ink:  #8F4E10;   /* amber text/links (4.5:1+) */
    --accent-btn:  #A85D15;   /* amber button fill under white text (4.9:1) */
    --accent-tint: #FFF4E3;
    --radius:      14px;
    --radius-sm:   10px;
    --shadow:      0 1px 2px rgba(51,41,31,.04), 0 8px 24px rgba(51,41,31,.06);
    --font-body:   'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-head:   'Space Grotesk', 'Inter', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 17px; }
p { margin: 0; }
a { color: var(--accent-ink); }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
    font-size: 12px; font-weight: 600; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted);
}
.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---- Buttons & fields ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 600; font-size: 14px; text-decoration: none;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    padding: 10px 18px; cursor: pointer; min-height: 44px;
}
.btn--primary { background: var(--accent-btn); color: #fff; }
.btn--primary:hover { background: var(--ink); color: #fff; }
.btn--secondary { background: var(--surface); border-color: #D9CBB6; color: var(--ink); }
.btn--secondary:hover { border-color: var(--accent); color: var(--ink); }
.btn--danger { background: #9B2C2C; color: #fff; }
.btn--danger:hover { background: #6E1D1D; color: #fff; }
.btn--danger-outline { background: var(--surface); border-color: #E2B4B4; color: #8A2323; }
.btn--danger-outline:hover { border-color: #9B2C2C; color: #6E1D1D; }
.btn--ghost-dark { background: transparent; color: #E7DCCB; border-color: rgba(250,246,239,.25); min-height: 36px; padding: 6px 12px; }
.btn--ghost-dark:hover { background: rgba(250,246,239,.1); color: #fff; }
.btn--block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; }
.input {
    font: inherit; color: var(--ink); background: #FFFDF9;
    border: 1px solid #D9CBB6; border-radius: var(--radius-sm);
    padding: 11px 12px; min-height: 44px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

/* ---- Brand ---- */
.brand { display: flex; align-items: center; gap: 10px; color: #FAF6EF; text-decoration: none; }
.brand:hover { color: #fff; }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__text strong { font-family: var(--font-head); font-size: 17px; }
.brand__text span { font-size: 12px; color: #D9CBB6; }
.brand--dark, .brand--dark:hover { color: var(--ink); }
.brand--dark .brand__text span { color: var(--muted); }

/* ---- Console top bar ---- */
.topbar {
    background: var(--navbar); color: #FAF6EF;
    display: flex; flex-wrap: wrap; align-items: center; gap: 24px;
    padding: 12px 28px;
}
.topnav { display: flex; flex-wrap: wrap; gap: 4px; }
.topnav__link { color: #D9CBB6; text-decoration: none; padding: 8px 14px; border-radius: var(--radius-sm); }
.topnav__link:hover, .topnav__link.is-active { color: #FAF6EF; background: rgba(250,246,239,.12); }
.topnav__link.is-active { font-weight: 600; }
.topbar__tools { flex: 1 1 260px; display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.search {
    display: flex; align-items: center; gap: 8px; color: #D9CBB6;
    background: rgba(250,246,239,.1); border: 1px solid rgba(250,246,239,.2);
    border-radius: var(--radius-sm); padding: 8px 12px; min-width: 240px;
}
.search input { background: transparent; border: 0; outline: none; color: #FAF6EF; font: inherit; width: 100%; }
.search input::placeholder { color: #BFAF98; }

.avatar {
    width: 32px; height: 32px; border-radius: 50%; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; background: var(--ink); color: #FAF6EF;
}
.avatar--light { background: #FAF6EF; color: var(--ink); width: 36px; height: 36px; }

/* ---- Flash messages ---- */
.flash { padding: 12px 28px; font-size: 14px; border-bottom: 1px solid var(--border); background: var(--accent-tint); }
.flash--error { background: #F6DCDC; color: #6E1C1C; }
.flash--info { background: #E8F0F7; color: #1F4E79; }
.flash--inline { border: 0; border-radius: var(--radius-sm); padding: 10px 14px; }

/* ---- Console layout ---- */
.console-body { max-width: 1600px; margin: 0 auto; padding: 24px 28px; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split__side { flex: 1 1 220px; max-width: 260px; display: flex; flex-direction: column; gap: 8px; }
.split__side .eyebrow { padding: 4px 12px; }
.split__main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head p { margin-top: 4px; }

/* Views sidebar fold: only the toggle shows on narrow screens, where the sidebar stacks above the queue. */
.views-fold { display: flex; flex-direction: column; gap: 8px; }
.views-fold__label { padding: 4px 12px; }
.views-fold__toggle { display: none; }
@media (max-width: 900px) {
    .views-fold__label { display: none; }
    .views-fold__toggle {
        display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none;
        padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    }
    .views-fold__toggle::-webkit-details-marker { display: none; }
    .split__side .views-fold__toggle .eyebrow { padding: 0; }
    .views-fold__toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .views-fold__toggle::after { content: ""; flex: none; width: 7px; height: 7px; margin: -3px 2px 0 0; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s; }
    .views-fold[open] > .views-fold__toggle::after { transform: rotate(-135deg); margin-top: 3px; }
    .views-fold__peek { margin-left: auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
.views { display: flex; flex-direction: column; gap: 4px; }
.views__item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px solid transparent; color: var(--ink); text-decoration: none;
}
.views__item:hover { background: rgba(255,255,255,.6); color: var(--ink); }
.views__item.is-active { background: var(--surface); border-color: var(--border); font-weight: 600; }
.count { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #EFE6D7; color: #4F3F2E; }
.views__item.is-active .count { background: var(--accent-btn); color: #fff; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap { overflow-x: auto; }

/* ---- Queue table ---- */
.queue { min-width: 920px; }
.queue__row {
    display: grid; grid-template-columns: 110px minmax(0, 1fr) 210px 170px 90px 70px 120px;
    gap: 16px; align-items: center; padding: 14px 20px;
    border-bottom: 1px solid var(--border-soft); color: var(--ink); text-decoration: none;
}
.queue__row--head {
    padding: 12px 20px; border-bottom-color: var(--border);
    font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.empty { padding: 56px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty h2 { color: var(--ink); }

/* ---- Status pills (TicketStatus::cssClass) ---- */
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill--new                  { background: #DCE8F5; color: #1F4E79; }
.pill--open                 { background: #F6E3CC; color: #7A4310; }
.pill--in-progress          { background: #D9EEF0; color: #1D5A60; }
.pill--awaiting-customer    { background: #EDE6DA; color: #4F3F2E; }
.pill--awaiting-third-party { background: #E4E0F0; color: #40356E; }
.pill--on-hold              { background: #ECECEC; color: #444444; }
.pill--pending-verification { background: #F6DCDC; color: #8A2323; }
.pill--resolved             { background: #DDEEDF; color: #245C2E; }
.pill--closed               { background: #ECECEC; color: #444444; }
/* Awaiting customer after an automatic chase-up (TicketStatus::operatorCssClass) */
.pill--chase                { background: var(--accent-tint); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.pill--chase-2              { background: var(--accent-btn); color: #FFFFFF; box-shadow: none; }

/* ---- Sign-in & error pages ---- */
.signin__page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
    background-color: var(--bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='139' viewBox='0 0 80 139'%3E%3Cg fill='none' stroke='%23E8DFD2'%3E%3Cpolygon points='40,0 80,23 80,70 40,93 0,70 0,23'/%3E%3Cpolygon points='40,93 80,116 80,163 40,186 0,163 0,116'/%3E%3C/g%3E%3C/svg%3E");
}
.signin__card {
    width: 100%; max-width: 400px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 36px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 16px;
}
.signin__card .brand { margin-bottom: 8px; }
.signin__card h1 { font-size: 24px; }
.signin__foot { font-size: 13px; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
    .topbar, .console-body { padding-left: 16px; padding-right: 16px; }
    .search { min-width: 0; flex: 1; }
    .split__side { max-width: none; }
}

/* ============================================================
   Phase 3 — operator console: queue, ticket page, team, admin
   ============================================================ */

/* ---- Small buttons, fields and tags ---- */
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn--link { background: none; border: 0; color: var(--accent-ink); padding: 6px 4px; min-height: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.btn--link:hover { color: var(--ink); }
.btn--icon { background: none; border: 1px solid transparent; border-radius: 8px; width: 30px; height: 30px; min-height: 0; padding: 0; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; }
.btn--icon:hover { border-color: var(--border); color: #8A2323; }
.btn--note { background: #6B5A1E; color: #fff; }
.btn--note:hover { background: var(--ink); color: #fff; }
.btn--resolve { background: #2F6B3A; color: #fff; }
.btn--resolve:hover { background: #1F4A28; color: #fff; }
.btn[disabled], .btn[aria-disabled=true] { opacity: .5; cursor: default; }
.btn.is-busy { pointer-events: none; }
.input--sm { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.input--num { max-width: 140px; }
.input--mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; width: 100%; }
.field--sm { gap: 4px; }
.field--sm .field__label { font-size: 12px; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.warn { color: #8A2323; }
code, .code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.code { background: #FBF8F3; border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 8px 0 0; }
.code--wrap { white-space: pre-wrap; word-break: break-word; }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: #EFE6D7; color: #4F3F2E; }
.tag--muted { background: #F1EEE9; color: #5B5148; }
.tag--note { background: #FBEFC9; color: #6B5A1E; }
.tag--danger { background: #F6DCDC; color: #8A2323; }
.tag--away { background: #FBEFC9; color: #6B5A1E; }
.tag--ok { background: #DDEEDF; color: #245C2E; }
.tag--snooze { background: #E8E3F5; color: #463A73; }
.pill--xs { padding: 1px 7px; font-size: 11px; }
.prio { font-size: 12px; font-weight: 600; color: var(--muted); }
.prio--high { color: #A85D15; }
.prio--urgent { color: #fff; background: #A32B2B; padding: 2px 8px; border-radius: 999px; }
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--customer { background: #E4DCCD; color: var(--ink); }
.back-link { font-size: 13px; text-decoration: none; }
.page-head--spaced { margin-bottom: 20px; }
.page-head--spaced p { max-width: 70ch; }
.page-head__action { margin-top: 12px; }

/* ---- Queue ---- */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.filters__item { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.filters__item--grow { flex: 1 1 220px; }
.filters__item--grow .input { width: 100%; }
.queue__row:not(.queue__row--head):hover { background: #FFFBF4; }
.queue__row.is-unread .queue__subject strong { font-weight: 700; }
.queue__ref { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.queue__subject, .queue__who { display: flex; flex-direction: column; min-width: 0; }
.queue__subject strong, .queue__who span { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue__subject small, .queue__who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; }

/* ---- Ticket page ---- */
.ticket-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.ticket-head__row { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; align-items: flex-end; }
.ticket-head h1 { font-size: 24px; overflow-wrap: anywhere; }
.ticket-head__tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ticket-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.ticket-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.ticket-side { flex: 1 1 280px; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }

.notice { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; padding: 14px 18px; border-radius: var(--radius-sm); margin: 0 0 18px; font-size: 14px; }
.notice p { margin-top: 4px; max-width: 75ch; }
p.notice { display: block; }
.notice--warn { background: #FBEFC9; border: 1px solid #EBD58F; }
.notice--info { background: #E8F0F7; border: 1px solid #C9DAEA; color: #1F3F5E; }

.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.msg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
.msg--operator { background: #FFFBF4; border-color: #EBD9BF; }
.msg--internal-note { background: #FFF8DF; border-color: #EBD58F; }
.msg--auto { opacity: .8; }
.msg__head { display: flex; gap: 10px; align-items: center; }
.msg__who { flex: 1; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; min-width: 0; }
.msg__who .muted { font-size: 13px; overflow-wrap: anywhere; }
.msg__head time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.msg__rcpt { font-size: 12px; margin: 6px 0 0 38px; overflow-wrap: anywhere; }
.msg__body { margin: 12px 0 0 38px; }
.msg__full { margin: 10px 0 0 38px; font-size: 13px; }
.msg__full summary { cursor: pointer; color: var(--accent-ink); }
.msg__full .prose { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.prose { overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.6; }
.prose p { margin: 0 0 .8em; }
.prose p:last-child { margin-bottom: 0; }
.prose img { max-width: 100%; height: auto; }
.prose blockquote { margin: .5em 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.prose table { border-collapse: collapse; max-width: 100%; }
.prose td, .prose th { padding: 2px 6px; }
.prose pre { white-space: pre-wrap; }
.files { list-style: none; margin: 12px 0 0 38px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.file { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: #FFFDF9; font-size: 13px; text-decoration: none; color: var(--ink); }
.file:hover { border-color: var(--accent); color: var(--ink); }
.file--gone { color: var(--muted); text-decoration: line-through; }
.files__item { display: inline-flex; align-items: center; gap: 4px; }
.files__delete { display: inline; margin: 0; }
.files__deleted { font-size: 12px; }
.event { display: flex; gap: 8px; align-items: flex-start; padding: 2px 20px; font-size: 13px; color: var(--muted); }
.event svg { flex: none; margin-top: 3px; }
.event > div { flex: 1; }
.event p { margin: 0; }
.event p + p { margin-top: 6px; }
.event a { word-break: break-all; }
.event__action { margin-top: 8px; }
/* Automatic chase-up sent: stands out from other system notes */
.event--chase { margin: 4px 20px; padding: 10px 14px; background: var(--accent-tint); border: 1px solid var(--accent); border-left-width: 4px; border-radius: var(--radius-sm); color: var(--ink); font-size: 14px; font-weight: 500; align-items: center; }
.event--chase svg { color: var(--accent-ink); margin-top: 0; }
.event--chase > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.event--chase .pill { flex: none; }
.event--chase p { flex: 1 1 200px; }
.event time { white-space: nowrap; font-size: 12px; }

.composer { padding: 0; overflow: hidden; scroll-margin-top: 16px; }
.composer__tabs { display: flex; border-bottom: 1px solid var(--border); background: #FBF8F3; }
.composer__tab { font: inherit; font-weight: 600; font-size: 14px; background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 18px; color: var(--muted); cursor: pointer; }
.composer__tab.is-active { color: var(--ink); border-bottom-color: var(--accent); background: var(--surface); }
.composer__tab[data-tab=note].is-active { border-bottom-color: #B8A04A; }
.composer__tab[disabled] { opacity: .5; cursor: not-allowed; }
.composer__pane { display: flex; flex-direction: column; gap: 10px; padding: 16px 20px 18px; }
html.js .composer__pane:not(.is-active) { display: none; }
.composer__pane--note { background: #FFFCF0; }
.composer__to { font-size: 13px; }
.composer__text { width: 100%; resize: vertical; min-height: 140px; line-height: 1.5; }
.composer__foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filepick { position: relative; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--accent-ink); cursor: pointer; padding: 6px 10px; border: 1px dashed #D9CBB6; border-radius: 8px; }
.filepick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.filepick:focus-within { outline: 2px solid var(--accent); }
.filepick__list { font-size: 12.5px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

.side-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.side-card h2 { font-size: 15px; }
.side-sub { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 8px 0 0; font-family: var(--font-body); }
.inline-h { display: inline; }
.side-card details > summary { cursor: pointer; list-style: none; }
.side-card details > summary::-webkit-details-marker { display: none; }
.side-card details > summary::after { content: " ▾"; color: var(--muted); }
/* Merge dialog */
.merge-open { align-self: flex-start; font-size: 13px; font-weight: 500; padding-left: 0; }
.merge-choices { max-height: 260px; overflow-y: auto; }
.merge-choice { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; }
.merge-choice:hover { border-color: var(--accent); }
.merge-choice input { margin-top: 3px; accent-color: var(--accent-btn); }
.merge-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.merge-choices--tall { max-height: min(52vh, 420px); display: flex; flex-direction: column; gap: 6px; }
.merge-choice__text { min-width: 0; overflow-wrap: anywhere; }
.merge-choice__excerpt { font-size: 12.5px; }
.merge-choice[hidden] { display: none; }
.merge-links { display: flex; flex-direction: column; align-items: flex-start; }
.modal--wide { width: min(720px, calc(100vw - 32px)); }
.snooze-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.snooze-picks .chip { padding: 4px 10px; }
.snooze-box { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; margin-bottom: 10px; border: 1px solid #CFC6E8; background: #F4F1FB; border-radius: var(--radius-sm); font-size: 13.5px; }
.queue-snooze { font-size: 12px; white-space: nowrap; }
.team-card__disable { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 10px 0 4px; }

/* Block / Ignore sender (ticket Requester card, Admin → Senders) */
.sender-rule { border-top: 1px solid var(--border-soft); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.sender-rule .hint { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sender-rule__buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.choice legend { margin-bottom: 4px; }
.choice .switch { font-weight: 500; }
.switch input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent-btn); }
.rules-add { display: grid; grid-template-columns: minmax(200px, 2fr) 140px minmax(160px, 2fr) auto; gap: 10px; align-items: end; padding: 16px 18px; }
.rules-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.rules-card { padding: 0; overflow: hidden; }
.rules-card__head { padding: 14px 18px 10px; }
.rules-card__head h2 { font-size: 16px; margin: 0 0 4px; }
.rules-card__head p { margin: 0; font-size: 13px; }
.rules-list { list-style: none; margin: 0; padding: 0; }
.rules-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 18px; border-top: 1px solid var(--border-soft); }
.rules-list .rule-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.rules-list code { font-size: 13.5px; color: var(--ink); word-break: break-all; }
.rules-list .empty-row { display: block; padding: 18px; }
.rule-test { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; padding: 12px 18px; }
.rule-test .input { max-width: 320px; }
@media (max-width: 900px) {
    .rules-grid, .rules-add { grid-template-columns: 1fr; }
}

/* Macros page */
.macro-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.macro-row { display: flex; gap: 20px; align-items: flex-start; padding: 16px 20px; }
.macro-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.macro-row h2 { font-size: 16px; margin: 0; }
.macro-row h2 a { color: inherit; text-decoration: none; }
.macro-row h2 a:hover { color: var(--accent-ink); text-decoration: underline; }
.macro-row__preview { margin: 0; font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.macro-row__tags { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; }
.macro-row__actions { display: flex; align-items: center; gap: 8px; flex: none; }
.macro-form { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.macro-form__main { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.macro-form__buttons { display: flex; gap: 8px; margin-top: 6px; }
.placeholders { display: flex; flex-direction: column; gap: 8px; }
.placeholders .hint { margin: 0; }
.placeholders__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 10px 4px 6px; font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip code { background: #F4ECDF; color: var(--ink); border-radius: 999px; padding: 1px 7px; font-size: 12px; }
@media (max-width: 900px) {
    .macro-form { grid-template-columns: 1fr; }
    .macro-row { flex-direction: column; gap: 10px; }
}

/* Folded sidebar cards: the whole header toggles; a short "peek" sits on the right. */
.side-card--fold { padding: 0; gap: 0; }
.side-fold > summary { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: inherit; }
.side-fold > summary:hover { background: #FFFBF4; }
.side-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.side-fold > summary h2 { margin: 0; }
.side-card .side-fold > summary::after { content: ""; flex: none; width: 7px; height: 7px; margin: -3px 2px 0 0; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s; }
.side-card .side-fold[open] > summary::after { transform: rotate(-135deg); margin-top: 3px; }
.side-fold__peek { margin-left: auto; min-width: 0; font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-fold__body { display: flex; flex-direction: column; gap: 10px; padding: 2px 18px 16px; }
.close-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.close-actions--quiet { display: flex; justify-content: space-between; margin-top: -4px; }
.close-actions--quiet .btn--link { font-size: 13px; font-weight: 500; }
.row-form { display: flex; gap: 8px; }
.row-form select { flex: 1; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-sm .btn { align-self: flex-start; }
.mini summary { cursor: pointer; font-size: 13px; color: var(--accent-ink); }
.mini textarea { width: 100%; margin-top: 6px; }
.facts { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.mini-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.mini-list__row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mini-list .muted { overflow-wrap: anywhere; }
.activity { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; max-height: 360px; overflow-y: auto; }
.activity li span:first-child { font-weight: 600; }
.activity time { display: block; font-size: 11.5px; }

/* ---- Team ---- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 18px; }
.team-card { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.team-card__head { display: flex; align-items: center; gap: 12px; }
.team-card__head > div { flex: 1; min-width: 0; }
.team-card__head p { font-size: 13px; overflow-wrap: anywhere; }

/* ---- Admin ---- */
.health { display: flex; flex-wrap: wrap; gap: 8px; }
.health__item { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); text-decoration: none; color: var(--muted); font-size: 13px; }
.health__item strong { color: var(--ink); font-size: 15px; margin-right: 4px; }
.health__item.is-bad { background: #F6DCDC; border-color: #E9B9B9; color: #6E1C1C; }
.health__item.is-bad strong { color: #6E1C1C; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs__item { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs__item:hover { color: var(--ink); }
.tabs__item.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.settings-group { padding: 6px 0; margin-bottom: 16px; }
.graph-card { scroll-margin-top: 16px; }
.graph-card form { margin: 0; }
.graph-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border-soft); padding-top: 12px; }
.graph-step { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; font-size: 14px; }
.graph-step .tag { justify-self: start; }
.graph-step__detail { margin: 2px 0 4px; color: var(--muted); overflow-wrap: anywhere; }
.settings-group > h2 { padding: 12px 20px 6px; }
.setting { border-top: 1px solid var(--border-soft); scroll-margin-top: 16px; }
.setting > summary { display: grid; grid-template-columns: minmax(180px, 320px) 1fr auto; gap: 12px; align-items: center; padding: 12px 20px; cursor: pointer; list-style: none; }
.setting > summary::-webkit-details-marker { display: none; }
.setting > summary:hover { background: #FFFBF4; }
.setting[open] > summary { background: #FBF8F3; }
.setting__label { font-weight: 600; font-size: 14px; }
.setting__value { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setting__form { display: flex; flex-direction: column; gap: 10px; padding: 4px 20px 12px; max-width: 760px; }
.setting__foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 13px; }
.setting__reset { padding: 0 20px 14px; }
.switch { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; font-size: 14px; }
.switch input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent-btn); }
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.week__day { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.log-count { font-size: 13px; margin: 12px 0 8px; }
.log { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 860px; }
.log th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.log td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; overflow-wrap: anywhere; }
.log tr.is-bad td { background: #FDF3F3; }
.log__detail { color: var(--muted); max-width: 360px; }
.empty-row { text-align: center; color: var(--muted); padding: 28px; }
.logtag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #F1EEE9; color: #5B5148; text-transform: capitalize; white-space: nowrap; }
.logtag--failed, .logtag--error, .logtag--rate_limited { background: #F6DCDC; color: #8A2323; }
.logtag--warning, .logtag--queued, .logtag--sending, .logtag--pending_verification { background: #FBEFC9; color: #6B5A1E; }
.logtag--sent, .logtag--ticket_created, .logtag--message_added { background: #DDEEDF; color: #245C2E; }
.logtag--deleted { background: #ECE7E1; color: #6E5E4C; text-decoration: line-through; }
.log__actions { white-space: nowrap; }
.outbox-actions { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.outbox-actions form { margin: 0; }
.outbox-actions--compact { margin-left: 6px; }
.outbox-actions--compact .btn--link { font-size: 13px; font-weight: 500; padding: 2px 4px; }
.btn--link.btn--danger-link { color: #8A2323; }
.btn--link.btn--danger-link:hover { color: #5E1515; }
.detail-card__actions .outbox-actions { gap: 12px; }
.detail-card { padding: 20px 22px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px; }
.email-frame { width: 100%; height: 640px; min-height: 240px; border: 1px solid var(--border); border-radius: 8px; background: #FFFFFF; resize: vertical; }
.detail-card__head { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.detail { display: grid; grid-template-columns: 120px 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; overflow-wrap: anywhere; }
.detail--stacked { grid-template-columns: 1fr; gap: 2px; }
.detail--stacked dd { margin-bottom: 8px; }

/* ---- Users ---- */
.queue--users { min-width: 720px; }
.queue--users .queue__row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 80px 110px 150px; }
.queue--user-tickets { min-width: 640px; }
.queue--user-tickets .queue__row { grid-template-columns: 110px minmax(0, 1fr) 170px 70px 120px; }
.queue--with-requester { min-width: 860px; }
.queue--with-requester .queue__row { grid-template-columns: 110px minmax(0, 1fr) 210px 170px 70px 120px; }
.user-page { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.user-page .tabs { margin-bottom: 0; }
@media (max-width: 900px) {
    .user-page { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .ticket-side { max-width: none; }
    .msg__body, .msg__rcpt, .msg__full, .files { margin-left: 0; }
    .setting > summary { grid-template-columns: 1fr auto; }
    .setting__value { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) {
    .msg { padding: 14px; }
    .detail { grid-template-columns: 1fr; }
    .close-actions--quiet { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   Phase 4 — customer pages: ticket page, webform
   ============================================================ */
body.customer { display: flex; flex-direction: column; }
.cust-head { background: var(--surface); border-bottom: 1px solid var(--border); }
.cust-head__inner { max-width: 1200px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cust-head__link { font-weight: 600; font-size: 14px; text-decoration: none; }
.cust-main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 20px 40px; display: flex; flex-direction: column; gap: 18px; }
.cust-foot { text-align: center; font-size: 13px; color: var(--muted); padding: 20px; border-top: 1px solid var(--border-soft); }
.cust-flash { margin: 0; }
.cust-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.cust-card--narrow { max-width: 560px; margin: 24px auto 0; display: flex; flex-direction: column; gap: 12px; }
.cust-card h1 { font-size: 24px; }
.cust-card h2 { font-size: 17px; margin-bottom: 10px; }
.cust-ticket-head { display: flex; flex-direction: column; gap: 8px; }
.cust-ticket-head h1 { overflow-wrap: anywhere; }
.cust-ticket-head__meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 13px; }
.cust-callout { margin-top: 6px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-tint); font-size: 14px; }
.cust-callout--ok { background: #E6F2E8; color: #1F4A28; }
.cust-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.cust-msg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; scroll-margin-top: 16px; }
.cust-msg--team { background: #FFFBF4; border-color: #EBD9BF; }
.cust-msg__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cust-msg__head time { margin-left: auto; font-size: 12px; color: var(--muted); }
.files--flush { margin-left: 0; }
.cust-text { width: 100%; resize: vertical; min-height: 140px; line-height: 1.5; }
.cust-form-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cust-resolve { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.cust-resolve h2 { margin-bottom: 2px; }
.cust-note { font-size: 12.5px; color: var(--muted); text-align: center; }
.cust-intro { display: flex; flex-direction: column; gap: 6px; }
.cust-intro h1 { font-size: 30px; }
.cust-form { display: flex; flex-direction: column; gap: 16px; scroll-margin-top: 16px; }
.cust-form .input { width: 100%; }
.cust-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; }
.cust-form-submit { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding-top: 6px; border-top: 1px solid var(--border-soft); }
.cust-thanks { align-items: center; text-align: center; }
.cust-thanks svg { color: #2F6B3A; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 640px) {
    .cust-main { padding: 18px 16px 32px; }
    .cust-card { padding: 18px; }
    .cust-head__inner { padding: 12px 16px; }
    .cust-intro h1 { font-size: 24px; }
}

/* ---- Phase 4b — customer sign-in and "My requests" ---- */
.cust-head__nav { display: flex; align-items: center; gap: 16px; }
.cust-head__nav form { margin: 0; }
.cust-head__out { font-size: 14px; padding: 0; }
.cust-signin { gap: 16px; }
.cust-signin__option { display: flex; flex-direction: column; gap: 8px; }
.cust-signin__option h2 { margin-bottom: 0; font-size: 16px; }
.cust-signin__opts { display: flex; flex-direction: column; gap: 8px; }
.cust-signin__opts .switch { font-weight: 400; }
.cust-signin__or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.cust-signin__or::before, .cust-signin__or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.cust-code { font-family: var(--font-head); font-size: 26px; letter-spacing: 6px; text-align: center; }
.cust-intro--row { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.cust-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.cust-list li + li { border-top: 1px solid var(--border-soft); }
.cust-list__item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 4px; text-decoration: none; color: var(--ink); }
.cust-list__item:hover { background: #FFFBF4; color: var(--ink); }
.cust-list__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cust-list__main strong { font-weight: 600; overflow-wrap: anywhere; }
.cust-list__main .muted { font-size: 13px; }
.input--locked { background: #F4EFE6; color: var(--muted); cursor: default; }
.input--locked:focus { outline: none; border-color: #D9CBB6; }
.new-ticket { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; max-width: 980px; }
.new-ticket .input:not(.input--sm) { width: 100%; }
.new-ticket__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 14px; }
.new-ticket__foot { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; padding-top: 12px; border-top: 1px solid var(--border-soft); }

/* ---- Rich-text editor (Quill, snow theme) ---- */
.editor { font: inherit; }
.ql-toolbar.ql-snow { border: 1px solid #D9CBB6; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: #FBF8F3; font-family: var(--font-body); padding: 6px 8px; }
.ql-container.ql-snow { border: 1px solid #D9CBB6; border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: #FFFDF9; font-family: var(--font-body); font-size: 15px; }
.ql-container.ql-snow:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ql-editor { min-height: 150px; line-height: 1.55; color: var(--ink); }
.editor--simple .ql-editor { min-height: 140px; }
.ql-editor.ql-blank::before { color: #A39583; font-style: normal; }
.ql-snow .ql-stroke { stroke: #6E5E4C; }
.ql-snow .ql-fill { fill: #6E5E4C; }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent-btn); }
.ql-snow.ql-toolbar button:hover .ql-fill, .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent-btn); }
.ql-snow.ql-toolbar button.ql-active, .ql-snow .ql-picker-label.ql-active { color: var(--accent-btn); }
.ql-snow .ql-tooltip { border-color: var(--border); box-shadow: var(--shadow); border-radius: 8px; color: var(--ink); z-index: 5; }
.ql-snow .ql-tooltip input[type=text] { border-color: #D9CBB6; border-radius: 6px; }
.composer__pane--note .ql-container.ql-snow { background: #FFFEF6; }
/* Formatted messages in the thread */
.prose h2, .prose h3 { font-family: var(--font-head); margin: .8em 0 .4em; }
.prose h2 { font-size: 18px; } .prose h3 { font-size: 16px; }
.prose ul, .prose ol { margin: 0 0 .8em; padding-left: 1.4em; }
.prose pre { background: #FBF8F3; border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.prose code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: #FBF8F3; padding: 1px 4px; border-radius: 4px; }
.prose pre code { background: none; padding: 0; }

/* ---- Phase 5: macros menu and automation list ---- */
.composer__bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.macro-picker { max-width: 260px; }
.automation { border-top: 1px solid var(--border-soft); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.automation time { white-space: nowrap; font-size: 12px; }

/* ---- Phase 6: context panel ---- */
.ctx-down { margin: 0; font-size: 13px; }
.ctx-name { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ctx-facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 13px; }
.ctx-facts dt { color: var(--muted); }
.ctx-facts dd { margin: 0; overflow-wrap: anywhere; }
.ctx-org { font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.ctx-link { margin-top: 6px; }
.ctx-link select { min-width: 0; }
.ctx-devices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ctx-device { padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); }
.ctx-device:last-child { border-bottom: 0; padding-bottom: 0; }
.ctx-device__head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.ctx-device__meta { font-size: 12.5px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ctx-dot { width: 8px; height: 8px; border-radius: 50%; background: #C9BFB1; flex: none; }
.ctx-dot.is-on { background: #2F8A43; }
.ctx-tacc { margin-top: 6px; gap: 8px; }
.ctx-tacc__btn { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }

/* ---- Device details window (console.js, tickets/_device.twig) ---- */
.ctx-device__name { font: inherit; font-weight: 700; color: var(--accent-ink); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.ctx-device__name:hover, .ctx-device__name:focus-visible { text-decoration-color: currentColor; }
.modal.device { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 48px); position: relative; }
.device__body { padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }
.device__close { position: absolute; top: 12px; right: 12px; min-height: 32px; padding: 2px 10px; font-size: 18px; line-height: 1; }
.device__hero { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; background: var(--navbar); color: #fff; border-radius: var(--radius-sm); padding: 16px 18px; margin-right: 44px; }
.device__hero h2 { color: #fff; font-size: 20px; margin: 0 0 4px; overflow-wrap: anywhere; }
.device__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; font-size: 13px; opacity: .88; }
.device__status { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.14); padding: 5px 12px; border-radius: 999px; font-size: 13px; }
.device__status .ctx-dot:not(.is-on) { background: #D9534F; }
.device__stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.device__stat { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.device__stat strong { font-family: var(--font-head); font-size: 20px; }
.device__stat strong small { font-size: 12px; color: var(--muted); }
.device__stat > span { font-size: 12px; color: var(--muted); }
.device__ok { color: #245C2E; }
.device__cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.device__card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.device__card h3 { font-size: 14px; margin: 0 0 8px; }
.device__card .ctx-facts { grid-template-columns: minmax(110px, auto) 1fr; }
.device__notes { white-space: pre-line; }
.device__foot { margin: 0; font-size: 13px; }
@media (max-width: 700px) {
    .device__stats { grid-template-columns: repeat(2, 1fr); }
    .device__cards { grid-template-columns: 1fr; }
    .device__body { padding: 16px; }
}

/* ---- Dialogs (change requester) ---- */
.requester-actions { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.requester-actions form { margin: 0; }
.modal { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(51,41,31,.25); color: var(--ink); background: var(--surface); }
.modal::backdrop { background: rgba(51,41,31,.45); }
.modal__body { display: flex; flex-direction: column; gap: 14px; padding: 22px 24px; }
.modal__body h2 { font-size: 19px; }
.modal__body .input { width: 100%; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.modal__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal__body select[multiple] { padding: 4px; }
.modal__body textarea.input { resize: vertical; }

/* ---- Attachment preview (file-preview.js) ---- */
.modal.preview { width: min(1100px, calc(100vw - 32px)); height: calc(100vh - 48px); max-height: none; display: none; flex-direction: column; overflow: hidden; }
.modal.preview[open] { display: flex; }
.preview__head { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--border); flex: none; }
.preview__title { flex: 1; min-width: 0; font-size: 15px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview__actions { display: flex; gap: 6px; flex: none; }
.preview__actions .btn { padding: 6px 10px; }
.preview__stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: #2A231C; }
.preview__stage[data-kind="pdf"] { padding: 0; background: var(--surface); }
.preview__media { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }
video.preview__media { background: #000; }
.preview__audio { width: min(520px, 100%); }
.preview__frame { width: 100%; height: 100%; border: 0; }
.preview__fail { color: #E7DCCB; text-align: center; max-width: 36ch; }
.file[data-preview] { cursor: zoom-in; }
@media (max-width: 600px) {
    .modal.preview { width: 100vw; height: 100vh; max-width: 100vw; border-radius: 0; }
    .preview__nav { display: none; }
    .preview__actions .btn--primary { font-size: 0; gap: 0; }
}

/* ---- Live ticket page (ticket-live.js) ---- */
.presence { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.presence__item { display: inline-flex; align-items: center; gap: 6px; }
.presence__item .avatar { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #7FB08A; }
.presence__item.is-away .avatar { box-shadow: none; opacity: .55; }
.presence__item.is-typing { color: var(--ink); font-weight: 600; }
.presence__item.is-typing .avatar { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.composer__live { padding: 8px 20px; font-size: 13px; font-weight: 600; background: var(--accent-tint); color: var(--accent-ink); border-bottom: 1px solid var(--border); }
.presence__item.is-typing .avatar, .composer__live.is-typing { animation: live-pulse 1.4s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .6; } }
.live-notice { justify-content: flex-start; }
.thread > .is-new { animation: live-new 2.5s ease-out; }
.thread > .msg.is-new { box-shadow: 0 0 0 2px var(--accent); }
@keyframes live-new { from { background-color: var(--accent-tint); } }
.live-toast {
    position: fixed; z-index: 50; left: 50%; bottom: 20px; transform: translateX(-50%);
    display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
    padding: 10px 10px 10px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 600;
    background: var(--ink); color: #FAF6EF; box-shadow: 0 12px 32px rgba(51,41,31,.3);
}
.live-toast__close { background: none; border: 0; color: #E7DCCB; font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; min-height: 36px; }
.live-toast__close:hover { color: #fff; }
@media (prefers-reduced-motion: reduce) {
    .thread > .is-new { animation: none; }
    .presence__item.is-typing .avatar, .composer__live.is-typing { animation: none; }
}
.queue__row.is-new { background: var(--accent-tint); box-shadow: inset 4px 0 0 var(--accent); }

/* ---- Diagnostics (tickets/diagnostics.twig, sidebar card, request note) ---- */
.event pre.cmd { position: relative; margin: 6px 0 8px; padding: 9px 12px; padding-right: 72px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.event pre.cmd code { font-size: 12.5px; }
.cmd__copy { position: absolute; top: 5px; right: 5px; min-height: 28px; padding: 3px 10px; font-size: 12px; }
.dx-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.dx-list a { font-weight: 600; }
.dx-list__meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; color: var(--muted); }

.dx-actions .btn { margin-left: 4px; }
.dx-others { font-size: 13px; }
.dx-count { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.dx-count--bad, .dx-dot--bad { background: #F6DCDC; color: #8A2323; }
.dx-count--warn, .dx-dot--warn { background: #FBEFC9; color: #6B5A1E; }
.dx-count--ok { background: #DDEEDF; color: #245C2E; }
.dx-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--border); }
.dx-tab {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; margin-bottom: -1px;
    background: none; border: 1px solid transparent; border-radius: 10px 10px 0 0;
    font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.dx-tab:hover { color: var(--ink); }
.dx-tab.is-active { background: var(--surface); border-color: var(--border); border-bottom-color: var(--surface); color: var(--ink); }
.dx-dot { min-width: 20px; padding: 1px 6px; border-radius: 999px; font-size: 11.5px; text-align: center; }
.dx-panel { padding: 20px 22px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 16px; }
.dx-js .dx-panel:not(.is-active) { display: none; }
.dx-js .dx-panel__title { display: none; }
.dx-flags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dx-flag { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.dx-flag--bad { background: #FDF3F3; border-left: 4px solid #9B2C2C; }
.dx-flag--warn { background: #FFF8E6; border-left: 4px solid #C9A227; }
.dx-flag--ok { background: #F1F8F2; border-left: 4px solid #2F6B3A; }
.dx-flag__level { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.dx-flag--bad .dx-flag__level { color: #8A2323; }
.dx-flag--warn .dx-flag__level { color: #6B5A1E; }
.dx-flag__go { margin-left: auto; font-size: 13px; }
.dx-skipped { margin: 0; }
.dx-skipped ul { margin: 6px 0 0; padding-left: 18px; }
.dx-facts { display: grid; grid-template-columns: minmax(150px, max-content) 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
.dx-facts dt { color: var(--muted); }
.dx-facts dd { margin: 0; overflow-wrap: anywhere; }
.dx-table h3 { font-size: 15px; margin-bottom: 6px; }
.dx-table h3 .muted { font-family: var(--font-body); font-size: 12px; font-weight: 600; margin-left: 4px; }
.dx-table .hint { margin-bottom: 6px; }
.dx-grid { min-width: 0; }
.dx-grid td { max-width: 520px; overflow-wrap: break-word; }
.dx-cell--bad { color: #8A2323; font-weight: 600; background: #FDF3F3; }
.dx-cell--warn { color: #6B5A1E; font-weight: 600; background: #FFF8E6; }
.dx-empty { font-size: 13px; }
.dx-foot { margin-top: 4px; }
.dx-print-head { display: none; }
@media (max-width: 640px) {
    .dx-facts { grid-template-columns: 1fr; gap: 0; }
    .dx-facts dd { margin-bottom: 8px; }
    .dx-panel { padding: 16px; }
}

@media print {
    @page { margin: 14mm 12mm; }
    body { background: #fff; font-size: 11px; }
    .topbar, .flash, .back-link, .dx-actions .btn, .dx-tabs, .dx-others, .dx-flag__go { display: none !important; }
    .console-body { padding: 0; max-width: none; }
    .dx-head { margin-bottom: 8px; }
    .dx-head h1 { font-size: 20px; }
    .dx-print-head { display: flex; gap: 10px; align-items: center; padding-bottom: 8px; margin-bottom: 10px; border-bottom: 2px solid var(--accent); }
    .dx-print-head div { display: flex; flex-direction: column; font-size: 10px; color: var(--muted); }
    .dx-print-head strong { font-size: 13px; color: var(--ink); }
    .dx-js .dx-panel:not(.is-active), .dx-panel { display: flex !important; }
    .dx-panel__title, .dx-js .dx-panel__title { display: block !important; font-size: 16px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
    .dx-panel { border: 0; padding: 0; margin: 0 0 14px; gap: 10px; break-before: page; }
    #dx-summary { break-before: avoid; }
    .dx-facts { font-size: 11px; gap: 2px 14px; }
    .dx-grid { font-size: 9.5px; }
    .dx-grid th, .dx-grid td { padding: 3px 6px; }
    .dx-grid td { max-width: none; }
    .dx-grid tr, .dx-flag { break-inside: avoid; }
    .table-wrap { overflow: visible; }
    .dx-flag, .dx-cell--bad, .dx-cell--warn, .dx-count { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
