/* Mobile-first base styles. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --border: #d9dee5;
  --primary: #1f4e79;
  --primary-text: #ffffff;
  --danger: #b42318;
  --warn-bg: #fff6d6;
  --ok-bg: #e7f6ec;
  --internal-bg: #fff8c5;
  --internal-border: #e3b341;
  --topbar-bg: #1f4e79;
  --topbar-text: #ffffff;
  /* Chart palette (validated: dataviz validate_palette.js, light on #ffffff). */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --series-other: #a9a89f;
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;
  --radius: 10px;
  color-scheme: light;
}
/* Night mode: the user's choice (data-theme on <html>, see theme.js) wins over the system setting. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c;
    --surface: #1b2129;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --border: #2f3743;
    --primary: #5b9bd5;
    --primary-text: #0b1520;
    --danger: #f97066;
    --warn-bg: #3a3214;
    --ok-bg: #16301f;
    --internal-bg: #3a3214;
    --internal-border: #d29922;
    --topbar-bg: #0e1a27;
    --topbar-text: #e6e9ee;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --series-other: #6b6a64;
    --chart-grid: #2c3440;
    --chart-axis: #3a4350;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c;
  --surface: #1b2129;
  --text: #e6e9ee;
  --muted: #98a2b3;
  --border: #2f3743;
  --primary: #5b9bd5;
  --primary-text: #0b1520;
  --danger: #f97066;
  --warn-bg: #3a3214;
  --ok-bg: #16301f;
  --internal-bg: #3a3214;
  --internal-border: #d29922;
  --topbar-bg: #0e1a27;
  --topbar-text: #e6e9ee;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --series-other: #6b6a64;
  --chart-grid: #2c3440;
  --chart-axis: #3a4350;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }

/* Top bar: brand + three main sections (icon + label) on the left, icon tools on the right. */
.topbar {
  display: flex; align-items: center; gap: .5rem 1.25rem;
  padding: calc(.4rem + env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) .4rem max(1rem, env(safe-area-inset-left, 0px));
  min-height: 56px; background: var(--topbar-bg); color: var(--topbar-text);
  position: sticky; top: 0; z-index: 20;
}
.topbar a { color: inherit; text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; }
.brand img { border-radius: 7px; display: block; }
.nav-main { display: flex; gap: .25rem; }
.nav-main a {
  display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .75rem; border-radius: 8px;
  opacity: .85; font-weight: 500;
}
.nav-main a:hover { opacity: 1; background: rgba(255, 255, 255, .1); }
.nav-main a[aria-current="page"] { opacity: 1; background: rgba(255, 255, 255, .16); font-weight: 600; }
.nav-icon { flex: 0 0 auto; display: block; }
.nav-tools { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.tool, .nav-tools .bell {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-width: 40px; height: 40px; padding: 0 .5rem; border-radius: 999px;
}
.tool:hover, .nav-tools .bell:hover { background: rgba(255, 255, 255, .12); }
.timer-pill { background: rgba(229, 72, 77, .22); font-weight: 700; font-variant-numeric: tabular-nums; }
.pulse { width: .55rem; height: .55rem; border-radius: 50%; background: #ff6b6f; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* User menu (avatar with initials). */
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-left: .25rem;
  border-radius: 50%; background: rgba(255, 255, 255, .2); font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}
.menu[open] .avatar, .avatar:hover { background: rgba(255, 255, 255, .32); }
.menu-items {
  position: absolute; right: 0; top: calc(100% + .5rem); width: min(18rem, calc(100vw - 2rem));
  display: flex; flex-direction: column; padding: .35rem 0;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.menu-head { display: flex; flex-direction: column; padding: .6rem 1rem .7rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.menu-head .muted { font-size: .85rem; }
.menu-group { display: flex; flex-direction: column; padding: .3rem 0; }
.menu-group + .menu-group { border-top: 1px solid var(--border); }
.menu-items a, .menu-items .link {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  color: var(--text); padding: .55rem 1rem; text-align: left; width: 100%; font: inherit;
}
.menu-items a:hover, .menu-items .link:hover { background: var(--bg); }
.menu-count { min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: var(--warn-bg); text-align: center; font-size: .8rem; font-weight: 700; }

/* Phone: main sections move to a bottom tab bar; the top bar keeps brand + tools. */
.tabbar { display: none; }
@media (max-width: 700px) {
  .nav-main, .brand span { display: none; }
  .topbar { min-height: 52px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
  }
  .tabbar a {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: .15rem;
    padding: .45rem 0 .4rem; min-height: 56px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 500;
  }
  .tabbar a[aria-current="page"] { color: var(--primary); font-weight: 700; }
  .tabbar a[aria-current="page"]::before {
    content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary);
  }
  .tab-badge {
    position: absolute; top: .3rem; left: calc(50% + .4rem); min-width: 1.1rem; height: 1.1rem; padding: 0 .25rem;
    border-radius: 999px; background: #e5484d; color: #fff; font-size: .65rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
  }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
}

.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.card.narrow { max-width: 30rem; margin: 2rem auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.grid-2 { display: grid; gap: 1rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 1rem; }
@media (min-width: 800px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; display: flex; flex-direction: column; }
.stat-value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-warn { background: var(--warn-bg); }

.list { list-style: none; margin: 0 0 1rem; padding: 0; }
.list li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: .85rem; }

.btn {
  display: inline-block; border: 0; border-radius: 8px; padding: .6rem 1rem; min-height: 44px;
  background: var(--primary); color: var(--primary-text); font: inherit; cursor: pointer; text-decoration: none;
}
.btn.secondary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.small { padding: .35rem .75rem; min-height: 36px; font-size: .9rem; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.danger { color: var(--danger); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }

/* Users (accounts/) */
.user-form fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin: 0 0 1rem; }
.user-form legend { font-weight: 600; padding: 0 .25rem; }
.user-form .help, .card .help { color: var(--muted); font-size: .85rem; margin: .25rem 0 .5rem; }
.user-form fieldset label { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; margin: .35rem 0; }
.user-form fieldset > div > div, .company-checks > div > div { margin: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.company-checks > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0 1rem; margin-top: .5rem; }
.user-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.user-status-active { background: var(--ok-bg); }
.user-status-invited, .user-status-no-2fa { background: var(--warn-bg); }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

input, select, textarea {
  width: 100%; font: inherit; padding: .6rem; min-height: 44px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.form > div { margin-bottom: 1rem; }
.form label { display: block; font-weight: 600; margin-bottom: .25rem; }
.form .helptext { color: var(--muted); font-size: .85rem; }
.actions { display: flex; gap: 1rem; align-items: center; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; }
.inline-form input { flex: 1 1 12rem; width: auto; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1 1 16rem; width: auto; }
.check { display: flex; gap: .4rem; align-items: center; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; border: 1px solid var(--border); }
.status-pending { background: var(--warn-bg); }
.status-open { background: var(--ok-bg); }
.muted { color: var(--muted); }
.error, .errorlist { color: var(--danger); }
.notes { white-space: normal; }

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

/* Ticket list */
.ticket-list { list-style: none; margin: 0; padding: 0; }
.ticket-list > li { margin-bottom: .5rem; }
.ticket-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem;
  padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: inherit; text-decoration: none;
}
.ticket-row:hover { border-color: var(--primary); }
.ticket-main { min-width: 0; overflow-wrap: anywhere; }
.ticket-meta { display: block; font-size: .85rem; }
.empty { padding: 1rem 0; }
.filters select { width: auto; flex: 0 1 auto; }

/* Ticket detail */
.ticket-layout { display: grid; gap: 1rem; }
@media (min-width: 900px) { .ticket-layout { grid-template-columns: minmax(0, 1fr) 20rem; align-items: start; } }
.message {
  background: var(--surface); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .75rem;
}
/* Keep a linked message (#message-123) visible below the sticky top bar. */
.message { scroll-margin-top: 5rem; }
.message:target { box-shadow: 0 0 0 2px var(--primary); }
.message-inbound { border-left-color: var(--muted); }
.message-outbound { border-left-color: var(--primary); }
.message-internal { background: var(--internal-bg); border-left-color: var(--internal-border); }
.message-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; margin-bottom: .5rem; }
.message-body { overflow-wrap: anywhere; }
.message-body blockquote { margin: .5rem 0; padding-left: .75rem; border-left: 3px solid var(--border); color: var(--muted); }
.badge-internal { background: var(--internal-border); color: #3b2f00; border-color: transparent; font-weight: 600; }
.attachments { margin: .5rem 0 0; padding-left: 1.25rem; }
.composer textarea { margin: .5rem 0; }
.composer-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.tab { padding: .5rem .9rem; border-radius: 999px; border: 1px solid var(--border); font-size: .9rem; cursor: pointer; }
.mode-radio { position: absolute; opacity: 0; pointer-events: none; }
.composer-reply, .composer-note { display: none; }
#mode-reply:checked ~ .composer-reply, #mode-note:checked ~ .composer-note { display: block; }
#mode-reply:checked ~ .composer-tabs .tab-reply { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
#mode-note:checked ~ .composer-tabs .tab-internal { background: var(--internal-bg); border-color: var(--internal-border); font-weight: 600; }
#mode-note:checked ~ .composer-note textarea { background: var(--internal-bg); }
.mode-radio:focus-visible ~ .composer-tabs .tab { outline: 2px solid var(--primary); outline-offset: 2px; }
.composer-meta { margin: 0; font-size: .85rem; }
.composer-options { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; margin-bottom: .75rem; }
.composer-options .inline-select { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.composer-options select { width: auto; }
.badge-failed { border-color: var(--danger); color: var(--danger); }
/* Time tracker */
.subnav { display: flex; gap: .25rem; flex-wrap: wrap; margin: 0 0 1rem; border-bottom: 1px solid var(--border); }
.subnav a { padding: .5rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.subnav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.timer-bar > input[type=text] { margin-bottom: .5rem; font-size: 1.05rem; }
.timer-bar-fields { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.timer-bar-fields select, .timer-bar-fields input { flex: 1 1 9rem; width: auto; }
.timer-bar-fields input[name$=ticket] { flex: 0 1 7rem; }
.timer-bar-fields label { display: flex; flex-direction: column; flex: 1 1 12rem; font-size: .85rem; color: var(--muted); }
.manual-entry summary { cursor: pointer; font-weight: 600; }
.manual-form { margin-top: .75rem; }
.manual-form > * { margin-bottom: .5rem; }
.entry-row { display: grid; grid-template-columns: 1fr auto auto; gap: .25rem .75rem; align-items: center; }
.entry-main { min-width: 0; overflow-wrap: anywhere; }
.entry-meta { display: block; font-size: .85rem; }
.entry-actions { grid-column: 1 / -1; display: flex; gap: 1rem; font-size: .85rem; }
@media (min-width: 700px) {
  .entry-row { grid-template-columns: 1fr auto auto auto; }
  .entry-actions { grid-column: auto; }
}
.entry-duration, .timer-clock { font-variant-numeric: tabular-nums; }
.timer-clock { font-size: 1.15rem; font-weight: 700; }
.btn-stop { background: var(--danger); color: #fff; }
.running-row { grid-template-columns: 1fr auto; }
@media (min-width: 700px) { .running-row { grid-template-columns: 1fr auto auto; } }
.inline-edit { min-width: 0; }
.inline-edit input[name=note] {
  font-weight: 600; border-color: transparent; background: transparent; padding: .35rem .5rem; min-height: 38px;
}
.inline-edit input[name=note]:hover, .inline-edit input[name=note]:focus { border-color: var(--border); background: var(--surface); }
.inline-edit-row { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center; margin-top: .25rem; }
.inline-edit-row select { width: auto; max-width: 100%; min-height: 34px; padding: .25rem .5rem; font-size: .9rem; }
.inline-edit-row .entry-meta { display: inline; }
.inline-status { font-size: .8rem; }
.inline-status.saved { color: var(--muted); }
.inline-status.error { color: var(--danger); }
.running-actions { display: flex; gap: .75rem; align-items: center; }
.running-list { border-color: var(--internal-border); }
.day-head { display: flex; justify-content: space-between; margin-bottom: .25rem; }
.week-head { align-items: center; margin: 1rem 0 .5rem; }
.running-dot { display: inline-flex; min-width: 1.2rem; height: 1.2rem; padding: 0 .3rem; border-radius: 999px; background: #e5484d; color: #fff; font-size: .72rem; font-weight: 700; align-items: center; justify-content: center; }
.danger-zone { margin-top: 1rem; }
.steps { padding-left: 1.25rem; }
.steps li { margin-bottom: .6rem; }
.steps form, form.inline { display: inline; }
/* Management overview. Status colors are reserved for status (never series) and always come
   with an icon and a word. */
:root { --status-good: #0ca30c; --status-warning: #fab219; --status-serious: #ec835a; --status-critical: #d03b3b; }
.status-icon { flex: 0 0 auto; }
.status-icon.status-good { color: var(--status-good); }
.status-icon.status-warning { color: var(--status-warning); }
.status-icon.status-serious { color: var(--status-serious); }
.status-icon.status-critical { color: var(--status-critical); }
.summary {
  display: flex; gap: .9rem; align-items: center; padding: 1rem 1.25rem; margin-bottom: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--status-good); border-radius: var(--radius);
}
.summary .status-icon { width: 34px; height: 34px; }
.summary-warning { border-left-color: var(--status-warning); }
.summary-serious { border-left-color: var(--status-serious); }
.summary-critical { border-left-color: var(--status-critical); }
.summary-headline { display: block; font-size: 1.35rem; }
.health-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); margin-bottom: 1.5rem; }
.health { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; }
.health-head { display: flex; gap: .5rem; align-items: center; }
.health-label { margin-left: auto; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.health p { margin: .5rem 0 0; font-size: .92rem; color: var(--muted); }
.health-serious, .health-critical { border-color: var(--status-serious); }
.health-critical { border-color: var(--status-critical); }
.section-title { margin: 0 0 .75rem; }
.figures .stat { gap: .1rem; }
.delta { font-size: .8rem; color: var(--muted); }
.delta-good { color: #006300; }
.delta-bad { color: var(--danger); }
:root[data-theme="dark"] .delta-good { color: #0ca30c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .delta-good { color: #0ca30c; } }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { background: var(--surface); color: var(--text); border: 0; padding: .45rem .8rem; font: inherit; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); font-weight: 600; }
.chart-card figcaption p { margin: -.25rem 0 .5rem; font-size: .85rem; }
.status-cell { white-space: nowrap; }
.status-cell .status-icon { width: 16px; height: 16px; vertical-align: -3px; }

.report-filters select, .report-filters input { width: auto; flex: 0 1 auto; }
.report-scope { margin: -.5rem 0 1rem; font-size: .9rem; }
.chart-grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
@media (min-width: 900px) { .chart-grid { grid-template-columns: 1fr 1fr; } .chart-wide { grid-column: 1 / -1; } }
.chart-card { margin: 0; }
.chart-card figcaption h2 { margin-bottom: .5rem; }
.chart-box { position: relative; height: 16rem; }
.chart-box-square { height: 18rem; }
.chart-box-rows { height: calc(var(--rows, 3) * 2.4rem + 2.5rem); max-height: 26rem; }
.chart-table { margin-top: .75rem; font-size: .9rem; }
.chart-table summary { cursor: pointer; color: var(--muted); }

.time-form { margin-bottom: .75rem; }
.time-form > * { margin-bottom: .5rem; }
.quick-times { display: flex; flex-wrap: wrap; gap: .4rem; }
.time-row { display: flex; gap: .5rem; align-items: center; }
.time-row input, .time-row select { flex: 1 1 0; min-width: 0; }
.running-here { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; padding: .5rem; border-radius: 8px; background: var(--warn-bg); }
.timer-button.running { background: var(--warn-bg); border-color: var(--internal-border); color: var(--text); font-variant-numeric: tabular-nums; }
.composer-options input[type=number] { width: 5.5rem; min-height: 36px; }
.composer-options .inline-select select { min-height: 36px; }
.composer-meta-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; }
.template-picker { width: auto; min-height: 36px; padding: .3rem .5rem; font-size: .9rem; }
.attach-field { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .5rem 1rem; margin-bottom: .75rem; }
.attach-field .btn { cursor: pointer; }
.attach-list { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.footer-preview { margin: 0 0 .75rem; font-size: .85rem; color: var(--muted); }
.footer-preview summary { cursor: pointer; }
.footer-preview pre { font: inherit; white-space: pre-wrap; margin: .5rem 0; padding: .5rem .75rem; border-left: 3px solid var(--border); }
.full-message pre { font: inherit; white-space: pre-wrap; }
.resolution-snippet { margin: .25rem 0 0; font-size: .85rem; }
.ai-result { margin: 0 0 .75rem; font-size: .9rem; }
.ai-result dt { font-weight: 600; margin-top: .5rem; }
.ai-result dd { margin: 0; }
.ai-panel pre, .ai-draft pre { font: inherit; font-size: .85rem; white-space: pre-wrap; max-height: 20rem; overflow: auto; padding: .5rem; border-left: 3px solid var(--border); }
.ai-panel details { margin-bottom: .75rem; font-size: .9rem; }
.ai-panel summary { cursor: pointer; }
.ai-note, .ai-meta { font-size: .8rem; margin: .5rem 0 0; }
.plain { list-style: none; margin: 0; padding: 0; }
.confidence-low { border-color: var(--danger); }
.confidence-high { background: var(--ok-bg); }
.badge-waiting { background: var(--warn-bg); border-color: var(--internal-border); font-variant-numeric: tabular-nums; }
.undo-bar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  margin: 0 0 .5rem; padding: .5rem .75rem; border-radius: 8px; background: var(--warn-bg); font-size: .9rem;
}
.btn-undo { background: var(--text); color: var(--surface); font-weight: 700; min-width: 5.5rem; }
.composer { scroll-margin-top: 5rem; }
.badge-sent { background: var(--ok-bg); border-color: transparent; }
.send-error { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; font-size: .9rem; }
.btn-internal { background: var(--internal-border); color: #3b2f00; }
.custom-fields.has-fields { border-top: 1px solid var(--border); padding-top: 1rem; margin-bottom: 1rem; }
.custom-fields > div { margin-bottom: 1rem; }
.check-field .check { font-weight: 600; }
.ticket-sidebar .card h2 { display: flex; justify-content: space-between; }
.list.compact li { padding: .4rem 0; font-size: .9rem; }
.unknown-item .inline-form select { flex: 1 1 12rem; width: auto; }
.unknown-item p { margin: .25rem 0 .75rem; }

.theme-toggle { background: none; border: 0; color: inherit; cursor: pointer; }
/* Moon in light mode (click: dark), sun in dark mode (click: light). Pure CSS, so the right
   icon shows even before theme.js runs, including when following the system setting. */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.bell { position: relative; display: inline-flex; align-items: center; }
.bell-count {
  position: absolute; top: .15rem; right: .05rem; min-width: 1.1rem; height: 1.1rem; padding: 0 .28rem;
  border-radius: 999px; background: #e5484d; color: #fff; font-size: .72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ticket-row.unread { border-left: 4px solid var(--primary); font-weight: 600; }
.ticket-row.unread .ticket-meta { font-weight: 400; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: .5rem; background: var(--surface); border: 1px solid var(--border); }
.msg-success { background: var(--ok-bg); }
.msg-warning { background: var(--warn-bg); }
.msg-error { border-color: var(--danger); }
