/* Wallfort Care — portal styles
   Brand colours are set in assets/js/config.js and applied to the variables below. */

:root {
  --primary: #1F4D45;
  --primary-dark: #163A34;
  --primary-tint: #E4EDEA;
  --accent: #B0873A;
  --accent-tint: #F6EDDA;

  --ink: #1B2422;
  --ink-2: #44514E;
  --ink-3: #6B7774;
  --mist: #F1F4F3;
  --paper: #FFFFFF;
  --line: #DAE1DE;
  --line-strong: #BFCAC6;
  --focus: #2F6FED;

  --danger: #A9392A;
  --danger-tint: #F9E7E3;
  --ok: #2B7150;
  --ok-tint: #E2F1E8;

  --s-new: #36559A;       --s-new-bg: #E7ECF7;
  --s-progress: #8A5E0E;  --s-progress-bg: #FAEFD8;
  --s-hold: #56625F;      --s-hold-bg: #E9EDEC;
  --s-resolved: #2B7150;  --s-resolved-bg: #E2F1E8;
  --s-closed: #44514E;    --s-closed-bg: #E4E8E7;
  --s-reopened: #A9392A;  --s-reopened-bg: #F9E7E3;

  --r-sm: 9px;
  --r-md: 14px;
  --r-lg: 20px;
  --shadow: 0 1px 2px rgba(27, 36, 34, .06), 0 6px 20px rgba(27, 36, 34, .05);

  --font: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topbar__in {
  max-width: var(--page, 760px); margin: 0 auto; padding: 0 16px;
  height: 62px; display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand__logo { height: 34px; width: auto; }
.brand__word { font-weight: 800; font-size: 1.25rem; letter-spacing: .02em; color: var(--primary); }
.brand__divider { width: 1px; height: 24px; background: var(--line-strong); }
.brand__name { font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar__who { text-align: right; line-height: 1.25; min-width: 0; }
.topbar__who strong { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__who span { font-size: .8rem; color: var(--ink-3); }
@media (max-width: 520px) {
  .brand__divider, .brand__name { display: none; }
  .topbar__who span { display: none; }
}

/* ---------- banners ---------- */
.banner {
  background: var(--accent-tint); color: #5B4415; font-size: .875rem;
  border-bottom: 1px solid #E8D6AE;
}
.banner__in { max-width: var(--page, 760px); margin: 0 auto; padding: 8px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner--warn { background: var(--danger-tint); color: #7C2A1E; border-color: #EDC4BB; }
.banner button { background: none; border: 1px solid currentColor; border-radius: 999px; padding: 3px 12px; cursor: pointer; font-size: .82rem; }
@media (max-width: 520px) { .banner__in { padding: 8px 16px 10px; font-size: .82rem; } .banner__actions { margin-left: 0; gap: 6px; } }

/* ---------- layout ---------- */
.page { max-width: var(--page, 760px); margin: 0 auto; padding: 24px 16px 64px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.tiny { font-size: .8rem; }
.lead { font-size: 1.05rem; color: var(--ink-2); }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px;
}
.panel__title { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }
.panel--flush { padding: 0; overflow: hidden; }

.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .92rem; margin-bottom: 14px; }
.back:hover { color: var(--primary); }
.back svg { width: 16px; height: 16px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  font-weight: 650; font-size: 1rem; text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--ghost { background: var(--paper); border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn--danger { background: var(--paper); border-color: #E2B3A9; color: var(--danger); }
.btn--danger:hover { background: var(--danger-tint); }
.btn--small { min-height: 36px; padding: 0 14px; font-size: .9rem; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; }
.btn[aria-busy="true"]::after {
  content: ''; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.linkbtn { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: block; }
.field + .field { margin-top: 16px; }
.label { display: block; font-weight: 650; font-size: .95rem; margin-bottom: 6px; }
.label .opt { font-weight: 400; color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2344514E' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 15px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: .85rem; margin-top: 6px; }
.field__hint { color: var(--ink-3); font-size: .85rem; margin-top: 6px; }

.phone { display: flex; align-items: stretch; }
.phone__cc {
  display: flex; align-items: center; padding: 0 12px; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--line-strong); border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); background: var(--mist);
}
.phone .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; letter-spacing: .04em; }

.otp {
  font-size: 1.6rem; letter-spacing: .5em; text-align: center; font-weight: 700;
  padding-left: calc(14px + .5em);
}

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--paper); font-weight: 600; font-size: .95rem; line-height: 1.25;
}
.choice input:checked + span { border-color: var(--primary); background: var(--primary-tint); color: var(--primary-dark); box-shadow: inset 0 0 0 1px var(--primary); }
.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.choices--compact { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.choices--list { grid-template-columns: 1fr; }
.choices--list .choice span { justify-content: flex-start; text-align: left; }
@media (min-width: 560px) { .choices--list { grid-template-columns: 1fr 1fr; } }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }

.form-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.form-actions .btn--primary { flex: 1 1 auto; }
.form-error { background: var(--danger-tint); color: #7C2A1E; border-radius: var(--r-sm); padding: 10px 14px; font-size: .92rem; margin-top: 14px; }
.form-error .btn { margin-top: 10px; }

/* ---------- auth screens ---------- */
.auth { display: grid; min-height: calc(100vh - 62px); }
.auth__panel { display: none; }
.auth__main { padding: 32px 16px 48px; max-width: 460px; width: 100%; margin: 0 auto; }
.auth__main h1 { margin-bottom: 8px; }
.auth__main .lead { margin-bottom: 26px; }
.auth__alt { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); font-size: .95rem; }
.auth__help { margin-top: 14px; font-size: .88rem; color: var(--ink-3); }
.test-otp { margin-top: 12px; background: var(--accent-tint); color: #5B4415; padding: 8px 12px; border-radius: var(--r-sm); font-size: .9rem; }
.test-otp strong { letter-spacing: .14em; }
.demo-list { margin-top: 18px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); padding: 12px 14px; font-size: .88rem; }
.demo-list button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 0; cursor: pointer; color: var(--ink-2); }
.demo-list button:hover strong { color: var(--primary); text-decoration: underline; }
@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(340px, 5fr) 7fr; }
  .auth__panel {
    display: flex; flex-direction: column; justify-content: space-between;
    background: var(--primary); color: #E4EDEA; padding: 48px 44px;
  }
  .auth__panel h2 { color: #fff; font-size: 2rem; line-height: 1.15; max-width: 14ch; font-weight: 700; }
  .auth__panel p { margin-top: 14px; max-width: 36ch; color: #C5D6D1; }
  .auth__projects { list-style: none; padding: 0; margin: 28px 0 0; columns: 2; column-gap: 24px; font-size: .9rem; color: #C5D6D1; }
  .auth__projects li { padding: 3px 0; break-inside: avoid; }
  .auth__foot { font-size: .85rem; color: #A9C0BA; margin-top: 28px; }
  .auth__main { align-self: center; padding: 48px 32px; }
}

/* ---------- steps (registration) ---------- */
.steps { list-style: none; padding: 0; margin: 0 0 24px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; counter-reset: step; }
.steps li { font-size: .78rem; color: var(--ink-3); font-weight: 600; counter-increment: step; }
.steps li::before {
  content: counter(step); display: flex; align-items: center; justify-content: center;
  height: 6px; border-radius: 3px; background: var(--line); color: transparent; margin-bottom: 6px; overflow: hidden;
}
.steps li.is-done::before { background: var(--primary); }
.steps li.is-current { color: var(--ink); }
.steps li.is-current::before { background: var(--accent); }
.step-title { margin-bottom: 4px; }
.step-sub { color: var(--ink-3); margin-bottom: 20px; }

.summary { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; font-size: .92rem; background: var(--mist); }
.summary dt { color: var(--ink-3); font-size: .8rem; }
.summary dd { margin: 0 0 8px; font-weight: 600; }
.summary dd:last-child { margin-bottom: 0; }

/* ---------- pills & chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 11px; border-radius: 999px; font-size: .82rem; font-weight: 700;
  background: var(--s-new-bg); color: var(--s-new);
}
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill--progress { background: var(--s-progress-bg); color: var(--s-progress); }
.pill--hold { background: var(--s-hold-bg); color: var(--s-hold); }
.pill--resolved { background: var(--s-resolved-bg); color: var(--s-resolved); }
.pill--closed { background: var(--s-closed-bg); color: var(--s-closed); }
.pill--reopened { background: var(--s-reopened-bg); color: var(--s-reopened); }

.sev { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: .8rem; font-weight: 700; border: 1px solid; white-space: nowrap; }
.sev--critical { color: #fff; background: var(--danger); border-color: var(--danger); }
.sev--high { color: #8A4A0E; background: #FCEBD5; border-color: #F0CDA0; }
.sev--medium { color: #36559A; background: #EEF2FA; border-color: #CBD6EE; }
.sev--low { color: var(--ink-2); background: var(--mist); border-color: var(--line-strong); }

.due { font-size: .85rem; font-weight: 650; white-space: nowrap; color: var(--ink-2); }
.due--over { color: var(--danger); }
.due--soon { color: #8A5E0E; }
.due--paused { color: var(--ink-3); font-weight: 500; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.tab {
  background: none; border: 0; padding: 10px 14px 12px; font-weight: 650; color: var(--ink-3); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--primary); }
.tab .count { color: var(--ink-3); font-weight: 500; margin-left: 4px; }

/* ---------- customer: home ---------- */
.hello { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.hello p { color: var(--ink-2); margin-top: 4px; }
.tickets { list-style: none; margin: 0; padding: 0; }
.ticket-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px;
  padding: 16px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
}
.ticket-row:hover .ticket-row__title { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.ticket-row__title { font-weight: 700; font-size: 1.02rem; }
.ticket-row__meta { color: var(--ink-3); font-size: .86rem; grid-column: 1 / -1; display: flex; gap: 6px 14px; flex-wrap: wrap; }
.ticket-row__who { color: var(--ink-2); }
.empty { text-align: left; padding: 28px 4px; color: var(--ink-2); }
.empty h3 { margin-bottom: 6px; color: var(--ink); }
.empty .btn { margin-top: 14px; }

/* ---------- ticket page ---------- */
.ticket-head { margin-bottom: 20px; }
.ticket-head__id { font-weight: 700; color: var(--ink-3); font-size: .92rem; letter-spacing: .02em; }
.ticket-head h1 { margin: 6px 0 8px; font-size: 1.6rem; }
.ticket-head__meta { color: var(--ink-2); font-size: .95rem; }
.ticket-head__chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

.callout {
  border-radius: var(--r-md); padding: 18px 20px; background: var(--ok-tint); border: 1px solid #BFDFCB; color: #1F4F38;
}
.callout h3 { color: #1F4F38; margin-bottom: 4px; }
.callout .row { margin-top: 14px; }

/* The handling ladder — three floors, current one lit */
.ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.ladder li {
  display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 0 12px;
  padding: 12px 14px; color: var(--ink-3); background: var(--paper);
}
.ladder li + li { border-bottom: 1px solid var(--line); }
.ladder__num {
  width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; background: var(--mist); color: var(--ink-3); grid-row: span 2;
}
.ladder__role { font-weight: 650; font-size: .95rem; }
.ladder__name { font-size: .88rem; }
.ladder li.is-current { background: var(--accent-tint); color: var(--ink); box-shadow: inset 4px 0 0 var(--accent); }
.ladder li.is-current .ladder__num { background: var(--accent); color: #fff; }
.ladder li.is-current .ladder__name { color: var(--ink); font-weight: 600; }
.ladder-note { font-size: .86rem; color: var(--ink-3); margin-top: 10px; }

.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 20px; margin-top: 16px; font-size: .92rem; }
.facts dt { color: var(--ink-3); font-size: .8rem; }
.facts dd { margin: 2px 0 0; font-weight: 600; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 14px; }
.gallery a {
  position: relative; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; background: var(--mist);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; text-decoration: none;
  color: var(--ink-2); font-size: .78rem; font-weight: 600; text-align: center; padding: 6px;
}
.gallery img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gallery .tag { position: absolute; left: 6px; bottom: 6px; background: rgba(27,36,34,.75); color: #fff; padding: 1px 7px; border-radius: 6px; font-size: .7rem; }
.gallery .hidden-tag { position: absolute; right: 6px; top: 6px; background: var(--ink); color: #fff; padding: 1px 7px; border-radius: 6px; font-size: .68rem; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.tl { position: relative; padding: 0 0 20px 30px; }
.tl:last-child { padding-bottom: 4px; }
.tl::before {
  content: ''; position: absolute; left: 1px; top: 5px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--paper); border: 3px solid var(--line-strong);
}
.tl--customer::before { border-color: var(--accent); }
.tl--staff::before { border-color: var(--primary); }
.tl--system::before { border-color: var(--line-strong); background: var(--line-strong); }
.tl__head { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.tl__action { font-weight: 700; }
.tl__by { font-size: .86rem; color: var(--ink-3); }
.tl__time { font-size: .82rem; color: var(--ink-3); margin-left: auto; white-space: nowrap; }
.tl__note { margin-top: 6px; background: var(--mist); border-radius: var(--r-sm); padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.tl--internal .tl__note { background: #FFF; border: 1px dashed var(--line-strong); }
.tl__flag { font-size: .75rem; font-weight: 700; color: var(--ink-2); background: var(--line); border-radius: 5px; padding: 1px 6px; }
.tl .gallery { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); max-width: 420px; }

.reply { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }

/* file picker */
.picker__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-bottom: 10px; }
.picker__grid:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; background: var(--mist); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 600; color: var(--ink-2); text-align: center; padding: 6px; overflow-wrap: anywhere; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb button {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0;
  background: rgba(27,36,34,.8); color: #fff; cursor: pointer; font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.thumb .busy { position: absolute; inset: 0; background: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; }
.picker__add {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 10px 14px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-sm); cursor: pointer; font-weight: 650; color: var(--ink-2); background: var(--paper);
}
.picker__add:hover { border-color: var(--primary); color: var(--primary); }
.picker__add svg { width: 20px; height: 20px; }

.progress { margin-top: 14px; font-size: .92rem; color: var(--ink-2); }
.progress__bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.progress__bar span { display: block; height: 100%; background: var(--primary); width: 0; transition: width .3s; }

/* success */
.done { text-align: left; }
.done__id { font-size: 2rem; font-weight: 800; letter-spacing: .02em; color: var(--primary); margin: 6px 0 14px; }
.done .ladder { margin: 18px 0 6px; }

/* rating */
.rating { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rating .choice span { flex-direction: column; min-height: 64px; gap: 2px; font-size: .78rem; font-weight: 500; }
.rating .choice span b { font-size: 1.2rem; }

/* ---------- dialog ---------- */
dialog.modal {
  border: 0; border-radius: var(--r-lg); padding: 0; width: min(520px, calc(100vw - 24px));
  box-shadow: 0 20px 60px rgba(27,36,34,.25); color: var(--ink);
}
dialog.modal::backdrop { background: rgba(27,36,34,.45); }
.modal__body { padding: 24px; }
.modal__body h2 { margin-bottom: 6px; }
.modal__body > p { color: var(--ink-2); margin-bottom: 18px; }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
@media (min-width: 900px) { .toasts { left: auto; right: 20px; transform: none; } }
.toast {
  background: var(--ink); color: #fff; border-radius: var(--r-sm); padding: 12px 16px; font-size: .92rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); pointer-events: auto; animation: toast-in .2s ease-out;
}
.toast--error { background: var(--danger); }
.toast--ok { background: var(--primary-dark); }
.toast--wa { background: #fff; color: var(--ink); border: 1px solid var(--line); border-left: 4px solid #25A35A; }
.toast--wa b { display: block; font-size: .8rem; color: #1E7C46; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- loading ---------- */
.loading { padding: 60px 16px; text-align: center; color: var(--ink-3); }
.loading::before {
  content: ''; display: block; width: 28px; height: 28px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite;
}

/* ---------- team portal ---------- */
body.team { --page: 1240px; }
.team-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.team-head p { color: var(--ink-2); margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 16px; cursor: pointer; transition: border-color .15s;
}
.stat:hover { border-color: var(--line-strong); }
.stat[aria-pressed="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.stat__n { font-size: 1.9rem; font-weight: 750; line-height: 1.1; display: block; font-variant-numeric: tabular-nums; }
.stat__l { font-size: .88rem; color: var(--ink-2); font-weight: 600; }
.stat--alert .stat__n { color: var(--danger); }

.filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
@media (min-width: 760px) { .filters { grid-template-columns: 2fr repeat(4, 1fr) auto; } }
.filters .input, .filters .select { min-height: 42px; font-size: .95rem; }

.table-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
table.list th { text-align: left; font-size: .8rem; color: var(--ink-3); font-weight: 650; padding: 10px 14px; background: var(--mist); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: #F8FAF9; }
table.list tr.is-over td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.cell-main { font-weight: 650; }
.cell-sub { color: var(--ink-3); font-size: .84rem; }
.cell-id a { font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.list-foot { padding: 10px 14px; font-size: .85rem; color: var(--ink-3); border-top: 1px solid var(--line); background: var(--mist); }
@media (max-width: 860px) {
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
  table.list td { padding: 0; border: 0; }
  table.list td[data-k="sev"], table.list td[data-k="status"], table.list td[data-k="due"] { justify-self: end; text-align: right; }
  table.list td[data-k="id"] { grid-column: 1; }
  table.list td[data-k="status"] { grid-column: 2; grid-row: 1; }
  table.list td[data-k="cust"], table.list td[data-k="prob"], table.list td[data-k="who"] { grid-column: 1; }
  table.list td[data-k="sev"] { grid-column: 2; grid-row: 2; }
  table.list td[data-k="due"] { grid-column: 2; grid-row: 3; }
  table.list tr.is-over td:first-child { box-shadow: none; }
  table.list tr.is-over { box-shadow: inset 4px 0 0 var(--danger); }
}

.ticket-grid { display: grid; gap: 16px; }
@media (min-width: 980px) { .ticket-grid { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } .ticket-side { position: sticky; top: 78px; } }
.ticket-side > * + * { margin-top: 16px; }
/* On phones: the complaint first, then who is handling it (and the customer's contact for staff), then updates */
@media (max-width: 979px) {
  .ticket-grid > .stack { display: contents; }
  .ticket-grid > .stack > * { order: 3; margin-top: 0; }
  .ticket-grid > .stack > :first-child { order: 1; }
  .ticket-grid > .ticket-side { order: 2; }
}
.contact-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.clock { border-radius: var(--r-sm); padding: 10px 12px; font-size: .9rem; background: var(--mist); margin-top: 12px; }
.clock--over { background: var(--danger-tint); color: #7C2A1E; font-weight: 600; }

.demo-bar { position: fixed; right: 16px; bottom: 16px; z-index: 50; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 10px 12px; font-size: .82rem; max-width: 300px; }
.demo-bar strong { display: block; margin-bottom: 6px; }
.demo-bar .row { gap: 6px; }

.site-foot { max-width: var(--page, 760px); margin: 0 auto; padding: 0 16px 32px; font-size: .82rem; color: var(--ink-3); }

/* ---------- page widths ---------- */
.page--narrow { max-width: 640px; }
.page--wide { max-width: 1080px; }
body.customer .topbar__in, body.customer .banner__in { max-width: 1080px; }

/* ---------- customer extras ---------- */
.home-pick { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--mist); }
.home-pick .label { margin-bottom: 2px; font-size: .85rem; color: var(--ink-3); font-weight: 600; }
.home-pick p { font-weight: 650; }
.ticket-row__ask { color: #8A5E0E; font-weight: 650; }
.closed-note { padding: 14px 18px; }
.demo-list p { margin-bottom: 4px; }
.ticket-row .pill { align-self: start; }

/* ---------- demo banner + WhatsApp log ---------- */
.banner__actions { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.banner__actions a { color: inherit; font-weight: 650; font-size: .82rem; border: 1px solid currentColor; border-radius: 999px; padding: 3px 12px; text-decoration: none; }
.banner__actions a:hover, .banner button:hover { background: rgba(255,255,255,.55); }
.wa-log { list-style: none; margin: 4px 0 0; padding: 0; max-height: 62vh; overflow: auto; }
.wa-log li { padding: 14px 0; border-top: 1px solid var(--line); }
.wa-log__to { font-size: .9rem; margin-bottom: 6px; }
.wa-log__to span { color: var(--ink-3); }
.wa-bubble {
  background: #E7F6DC; border-radius: 4px 12px 12px 12px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: .9rem; line-height: 1.45; max-width: 46ch; color: #17231B;
}
.wa-bubble mark { background: rgba(37, 163, 90, .16); color: inherit; border-radius: 3px; padding: 0 2px; }
.wa-bubble small { display: block; color: #5E6B62; margin-top: 6px; font-size: .78rem; }
.wa-log__meta { display: flex; gap: 12px; font-size: .78rem; color: var(--ink-3); margin-top: 6px; }
.wa-log__meta code { font-family: inherit; font-weight: 650; color: var(--ink-2); }
dialog.modal:has(.wa-log) { width: min(640px, calc(100vw - 24px)); }

/* ---------- team extras ---------- */
.team-tabs { margin: -4px 0 18px; overflow-x: auto; scrollbar-width: none; }
.team-tabs .tab { white-space: nowrap; }
.banner__clock { display: inline-flex; gap: 6px; align-items: center; font-weight: 650; font-size: .82rem; padding-right: 8px; margin-right: 2px; border-right: 1px solid #E0C994; }
td[data-k="who"] .cell-main { white-space: nowrap; }
@media (max-width: 759px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters [type="search"] { grid-column: 1 / -1; }
  .filters > span:empty { display: none; }
}
.team-tabs .tab { text-decoration: none; display: inline-block; }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--primary); }
.auth__levels { list-style: none; padding: 0; margin: 28px 0 0; counter-reset: lvl; display: grid; gap: 14px; max-width: 40ch; }
.auth__levels li { counter-increment: lvl; display: grid; grid-template-columns: 34px 1fr; gap: 0 12px; font-size: .92rem; color: #C5D6D1; }
.auth__levels li::before { content: 'L' counter(lvl); grid-row: span 2; width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,.12); color: #fff; font-weight: 700; font-size: .85rem; display: flex; align-items: center; justify-content: center; }
.auth__levels li:last-child::before { background: var(--accent); }
.auth__levels b { color: #fff; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; max-width: 34ch; }
table.list td.num { font-variant-numeric: tabular-nums; }
table.list--plain tbody tr { cursor: pointer; }
@media (max-width: 860px) {
  table.list--plain thead { display: table-header-group; }
  table.list--plain, table.list--plain tbody { display: table; width: 100%; }
  table.list--plain tr { display: table-row; padding: 0; box-shadow: none; }
  table.list--plain td { display: table-cell; padding: 10px 10px; border-bottom: 1px solid var(--line); width: auto; }
  .table-wrap:has(.list--plain) { overflow-x: auto; }
}
.choices--status { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.choices--status .choice span { min-height: 42px; font-size: .9rem; }
.check.is-disabled { opacity: .5; }
.disclose summary { cursor: pointer; font-weight: 650; color: var(--primary); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.disclose summary::-webkit-details-marker { display: none; }
.disclose summary::before { content: '+'; display: inline-flex; width: 20px; height: 20px; border-radius: 5px; border: 1px solid currentColor; align-items: center; justify-content: center; font-size: .9rem; line-height: 1; }
.disclose[open] summary::before { content: '−'; }
.disclose form { margin-top: 14px; }
.ticket-side .form-actions { margin-top: 14px; }
.ticket-side .panel .small .sev { margin-right: 6px; }
.ticket-head__chips .due { margin-left: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
