@font-face {
  font-family: Inter;
  src: url("InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  font: 16px/1.5 Inter, system-ui, sans-serif;
  color-scheme: light;
  color: var(--text);
  background: var(--surface);
  --surface: #f7f8fa;
  --panel: #fff;
  --soft: #f3f4f6;
  --text: #111827;
  --muted: #596273;
  --neutral: #4b5563;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --primary: #18181b;
  --primary-hover: #27272a;
  --on-primary: #fff;
  --focus: #1d4ed8;
  --green: #15803d;
  --green-hover: #166534;
  --on-green: #fff;
  --green-soft: #f0fdf4;
  --green-text: #14532d;
  --green-line: #bbf7d0;
  --amber: #854d0e;
  --amber-soft: #fefce8;
  --amber-notice: #fffbeb;
  --amber-line: #fde68a;
  --amber-border: #ca8a04;
  --amber-action: #854d0e;
  --amber-action-hover: #713f12;
  --on-amber-action: #fff;
  --new-bg: #eff6ff;
  --new-text: #1d4ed8;
  --working-text: #92400e;
  --done-bg: #ecfdf5;
  --done-text: #047857;
  --network-connecting: #b45309;
  --network-ready: #16a34a;
  --network-offline: #b91c1c;
  --unread-hot: #b91c1c;
  --control: 44px;
  --gutter: 16px;
  --mobile-width: 36rem;
  --bottom: max(12px, env(safe-area-inset-bottom));
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #111317;
  --panel: #1b1f26;
  --soft: #252b35;
  --text: #eef1f7;
  --muted: #b4bdcc;
  --neutral: #c4cdda;
  --line: #333a47;
  --line-strong: #657087;
  --primary: #e3e9f3;
  --primary-hover: #f6f8fd;
  --on-primary: #161a21;
  --focus: #9abfff;
  --green: #72d09a;
  --green-hover: #9ae3b8;
  --on-green: #0e271a;
  --green-soft: #182c23;
  --green-text: #a6e8be;
  --green-line: #407656;
  --amber: #f3cd90;
  --amber-soft: #302617;
  --amber-notice: #392b17;
  --amber-line: #73542c;
  --amber-border: #b88843;
  --amber-action: #e4b976;
  --amber-action-hover: #f6d396;
  --on-amber-action: #271a0b;
  --new-bg: #20304c;
  --new-text: #a8c7ff;
  --working-text: #f5c488;
  --done-bg: #193629;
  --done-text: #98e0b5;
  --network-connecting: #f3cd90;
  --network-ready: #72d09a;
  --network-offline: #fba9a9;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p { margin: 0; }
h1, h2 { font-weight: 680; line-height: 1.35; letter-spacing: -.025em; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control);
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  text-align: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}
button:hover:not(:disabled), .button:hover { background: var(--soft); }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--accent, var(--primary)); border-color: var(--accent, var(--primary)); color: var(--on-accent, var(--on-primary)); }
.primary:hover:not(:disabled) { background: var(--accent-hover, var(--primary-hover)); }
.wide { width: 100%; min-height: 48px; font-size: 15px; }
.icon, .sprite { display: inline-block; }
.sprite { position: absolute; overflow: hidden; pointer-events: none; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-button { min-width: var(--control); padding: 0 10px; }
.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.theme-toggle { flex: none; }
.theme-toggle .theme-sun, :root[data-theme="dark"] .theme-toggle .theme-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-sun { display: inline-block; }
.muted, time { color: var(--muted); }
.help { font-size: 13px; }
.number, time, .unread { font-variant-numeric: tabular-nums; }
.sr-only, .categories input, .mode input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
:focus-visible, .categories input:focus-visible + span, .mode input:focus-visible + span { outline: 2px solid var(--accent, var(--focus)); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
label, legend, .label { font-size: 13px; font-weight: 600; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin: 0 0 8px; padding: 0; }
label { display: block; min-width: 0; }
input:where([type="text"], [type="password"], [type="search"]), select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--control);
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
}
label > :is(input:not([type="checkbox"]), select, textarea) { margin-top: 4px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[readonly] { background: var(--soft); color: var(--muted); }
textarea { resize: vertical; }
input[type="checkbox"] { width: 19px; height: 19px; margin: 0; flex: none; accent-color: var(--primary); }
.form-stack { display: grid; gap: 16px; align-content: start; }
.check { display: flex; gap: 10px; align-items: center; min-height: var(--control); font-size: 14px; font-weight: 450; cursor: pointer; }

.gate { display: grid; min-height: 100vh; min-height: 100dvh; padding: 24px var(--gutter); place-items: center; }
.login-card { width: min(100%, 26rem); border: 1px solid var(--line); border-radius: 16px; background: var(--panel); padding: 24px; }
.login-brand { display: grid; gap: 8px; margin-bottom: 24px; }
.login-brand-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.login-brand img { display: block; object-fit: contain; }
:root[data-theme="dark"] :is(.login-brand img, .staff-logo) { background: #fff; border-radius: 8px; }
.login-brand p { margin-top: 4px; font-size: 13px; }
.pilot-note, .notice, .standalone-notice { border: 1px solid var(--amber-line); border-radius: 10px; background: var(--amber-notice); color: var(--amber); padding: 8px 12px; font-size: 13px; overflow-wrap: anywhere; }
.pilot-note, .login-card .notice { margin-bottom: 16px; }
.notice[data-kind="success"] { background: var(--green-soft); color: var(--green-text); border-color: var(--green-line); }
.login-card input:not([type="checkbox"]) { min-height: 48px; }
.password-field { position: relative; }
.password-field input { margin-top: 4px; padding-right: 48px; }
.password-field button { position: absolute; bottom: 2px; right: 2px; border-color: transparent; color: var(--muted); }
.standalone-notice { margin: 24px auto; max-width: var(--mobile-width); }

.portal { display: flex; flex-direction: column; height: 100vh; height: 100dvh; margin-inline: auto; max-width: var(--mobile-width); }
.portal.staff { max-width: none; --accent: var(--green); --accent-hover: var(--green-hover); --on-accent: var(--on-green); }
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
  padding: max(8px, env(safe-area-inset-top)) var(--gutter) 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.identity, .account-bar, .profile, .network { display: flex; align-items: center; gap: 8px; min-width: 0; }
.identity-text { min-width: 0; }
.identity strong { display: block; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.eyebrow { font-size: 12px; font-weight: 550; color: var(--muted); }
.staff-logo, .profile, .top-search:empty { display: none; }
.staff .staff-logo { display: block; object-fit: contain; flex: none; }
.staff .identity-text { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.staff .eyebrow { color: var(--text); font-weight: 680; font-size: 15px; }
.staff .identity strong, .pilot-badge {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
}
.pilot-badge { background: var(--amber-notice); border-color: var(--amber-line); color: var(--amber); }
.account-bar { flex: none; gap: 4px; }
.network { font-size: 12px; color: var(--muted); white-space: nowrap; gap: 6px; }
.network::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--network-connecting); }
.network[data-state="ready"]::before { background: var(--network-ready); }
.network[data-state="offline"]::before { background: var(--network-offline); }
.connection { background: var(--amber-notice); color: var(--amber); border-bottom: 1px solid var(--amber-line); font-size: 13px; text-align: center; padding: 4px var(--gutter); }
.portal-notice { margin: 8px var(--gutter); }
.staff .top-search { flex: 1; max-width: 27rem; min-width: 0; }
.export { min-width: var(--control); }
.export .icon { width: 18px; height: 18px; }
.avatar { display: grid; flex: none; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--green); color: var(--on-green); font-size: 12px; font-weight: 650; }
#account { max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

.workspace { display: flex; flex: 1; min-height: 0; }
.queue, .compose, .ticket, .screen-form, .workspace-empty { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; }
.queue-scroll, .compose-scroll, .conversation { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.portal:not(.staff):not([data-view="queue"]) :is(.appbar, .queue) { display: none; }
.queue-controls { display: grid; gap: 12px; padding: 16px var(--gutter) 12px; }
.states { display: flex; align-items: stretch; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.states button { flex: 1; border-color: transparent; background: transparent; color: var(--muted); }
.states button[aria-pressed="true"] { border-color: var(--line); background: var(--panel); color: var(--text); }
.staff .states { flex-wrap: wrap; gap: 6px; padding: 0; border: 0; background: transparent; }
.staff .states button { flex: none; padding-inline: 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); font-size: 13px; }
.staff .states button[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: var(--on-green); }
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { margin: 0; padding-left: 40px; font-weight: 400; }
.extra-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.extra-filters select { padding-inline: 8px; }
#queue-search:empty { display: none; }
.list { display: grid; gap: 12px; padding: 0 var(--gutter) 16px; }
.ticket-row {
  display: grid;
  justify-content: stretch;
  gap: 6px;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  font-weight: 400;
  overflow-wrap: anywhere;
}
.ticket-row:hover:not(:disabled) { border-color: var(--line-strong); background: var(--panel); }
.row-head, .row-foot, .row-details, .row-activity, .ticket-heading-title, .message-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-head, .row-foot { justify-content: space-between; }
.row-head .number { font-weight: 670; }
.row-store { font-size: 13px; font-weight: 600; }
.row-description { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.row-foot { font-size: 12px; color: var(--muted); }
.row-activity { flex: none; }
.category { color: var(--muted); font-size: 12px; font-weight: 550; }
.status, .unread { display: inline-flex; justify-content: center; align-items: center; padding: 2px 8px; border-radius: 999px; white-space: nowrap; font-size: 12px; font-weight: 600; }
.status[data-status="new"] { background: var(--new-bg); color: var(--new-text); }
.status[data-status="working"] { background: var(--amber-notice); color: var(--working-text); }
.status[data-status="waiting"] { background: var(--soft); color: var(--neutral); }
.status[data-status="done"] { background: var(--done-bg); color: var(--done-text); }
.unread { min-width: 21px; background: var(--accent, var(--primary)); color: var(--on-accent, var(--on-primary)); padding-inline: 5px; }
.unread.multiple { background: var(--unread-hot); color: #fff; }
.paging { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 var(--gutter) 16px; }
.screen-footer, .composer { flex: none; padding: 12px var(--gutter) var(--bottom); border-top: 1px solid var(--line); background: var(--panel); }
.form-footer { display: grid; gap: 8px; }
.empty-state { display: grid; justify-items: center; gap: 6px; padding: 32px 16px; text-align: center; font-size: 14px; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--muted); }
.workspace-empty { justify-content: center; }

.screen-head { display: flex; flex: none; align-items: center; flex-wrap: wrap; gap: 12px; padding: 8px var(--gutter); border-bottom: 1px solid var(--line); background: var(--panel); }
.screen-head h1 { font-size: 17px; }
.screen-head .theme-toggle { margin-inline-start: auto; }
.compose-fields { max-width: 40rem; margin-inline: auto; padding: 16px var(--gutter) 24px; }
.categories { display: flex; flex-wrap: wrap; gap: 8px; }
.categories label, .mode label { margin: 0; }
.categories label span, .mode label span { display: inline-flex; align-items: center; gap: 6px; min-height: var(--control); padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--panel); cursor: pointer; }
.categories input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
:is(.categories, .mode) input:disabled + span { opacity: .6; cursor: default; }
.label-line { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 8px; }
.draft-saved { display: inline-flex; align-items: center; gap: 4px; color: var(--green-text); font-size: 12px; font-weight: 500; }
.draft-saved .icon { width: 15px; height: 15px; }
.extra-fields { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 0 12px; }
.extra-fields summary { display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px; min-height: var(--control); font-size: 13px; font-weight: 600; cursor: pointer; list-style: none; }
.extra-fields summary::-webkit-details-marker { display: none; }
.extra-fields summary .icon { margin-left: auto; }
.extra-fields[open] summary .icon { transform: rotate(180deg); }
.extra-fields .form-stack { padding: 12px 0; border-top: 1px solid var(--line); gap: 12px; }
.attachments-picker { gap: 8px; }
.previews { display: flex; flex-wrap: wrap; gap: 8px; }
.preview { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: var(--panel); }
.preview img { display: block; width: 38px; height: 38px; object-fit: cover; border-radius: 4px; }
.preview span { max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.preview button { min-width: var(--control); padding: 0; border: 0; }

.ticket-heading-main { flex: 1; min-width: 10rem; }
.ticket-heading-title { flex-wrap: wrap; gap: 4px 8px; }
.ticket-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.ticket-meta strong { color: var(--text); }
.ticket-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.ticket-controls button { font-size: 13px; }
.conversation { scroll-padding: 8px; }
.chat-feed { max-width: 56rem; margin-inline: auto; padding: 16px var(--gutter); }
.messages { display: grid; gap: 12px; }
.initial-bubble { margin-bottom: 12px; }
.bubble { width: fit-content; max-width: min(86%, 42rem); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; background: var(--panel); font-size: 14px; overflow-wrap: anywhere; }
.body-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.own { margin-left: auto; border-color: var(--green-line); background: var(--green-soft); color: var(--green-text); }
.message-meta { justify-content: space-between; flex-wrap: wrap; font-size: 12px; font-weight: 550; gap: 1px 12px; margin-bottom: 4px; }
.bubble.public > time { display: block; margin-top: 4px; text-align: right; font-size: 12px; }
.bubble.note { width: 100%; max-width: none; border: 1px dashed var(--amber-border); background: var(--amber-soft); }
.note .message-meta, .note time { color: var(--amber); }
.note-author { display: inline-flex; gap: 8px; align-items: center; }
.message-meta .icon { width: 15px; height: 15px; vertical-align: text-bottom; }
.bubble.system { margin-inline: auto; padding: 4px 12px; border: 0; border-radius: 999px; background: var(--soft); text-align: center; color: var(--neutral); font-size: 12px; }
.ticket-context { display: grid; gap: 6px; padding: 0 0 12px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.ticket-context a { color: var(--green-text); }
.files { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.files a { display: inline-flex; align-items: center; gap: 6px; min-height: var(--control); max-width: 100%; color: var(--green-text); font-size: 13px; }
.files a:not(.picture) { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.files img { display: block; max-width: 100%; width: 14rem; max-height: 11rem; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; }
.actions { padding: 12px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); gap: 8px; }
.actions button { justify-self: start; }
.composer { padding-top: 8px; }
.composer-inner { display: grid; gap: 8px; max-width: 56rem; margin-inline: auto; }
.reply-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.reply-text { background: var(--surface); height: var(--control); resize: none; }
.reply-submit { min-width: var(--control); }
.portal:not(.staff) .reply-submit .submit-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.reply-row .choose-files span { display: none; }
.staff .reply-text { grid-area: 1 / 1 / 2 / -1; height: 64px; }
.staff .reply-row .choose-files { grid-area: 2 / 1; }
.staff #quick-reply { grid-area: 2 / 2; }
.staff .reply-submit { grid-area: 2 / 3; white-space: nowrap; }
.mode { display: flex; flex-wrap: wrap; gap: 6px; }
.mode label span { border-color: transparent; border-radius: 8px; padding-inline: 8px; color: var(--muted); }
.mode .icon { width: 16px; height: 16px; }
.mode input[value="public"]:checked + span { border-color: var(--green-line); background: var(--green-soft); color: var(--green-text); }
.mode input[value="note"]:checked + span, .composer[data-kind="note"] .reply-text { border-color: var(--amber-border); background: var(--amber-soft); color: var(--amber); }
.composer[data-kind="note"] .reply-submit { --accent: var(--amber-action); --accent-hover: var(--amber-action-hover); --on-accent: var(--on-amber-action); }
.reset { border-color: var(--amber-line); background: var(--amber-notice); color: var(--amber); font-size: 13px; }

@media (max-width: 899px) {
  .staff:not([data-view="queue"]) :is(.appbar, .queue) { display: none; }
  .workspace-empty { display: none; }
  .staff .appbar { flex-wrap: wrap; }
  .staff .top-search { order: 3; flex-basis: 100%; max-width: none; }
  .staff .export span { display: none; }
}
@media (max-width: 550px) {
  .network #network-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .staff .staff-logo { display: none; }
  .staff .reply-submit { font-size: 13px; padding-inline: 8px; }
  .staff .reply-submit .icon { display: none; }
  .staff .extra-filters { grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.75rem), 1fr)); }
}
@media (min-width: 900px) {
  .staff .profile { display: flex; padding-inline: 6px; }
  .staff .appbar { gap: 20px; }
  .staff .queue { flex: 0 0 38%; max-width: 42rem; border-right: 1px solid var(--line); background: var(--panel); }
  .staff .queue-controls { background: var(--surface); border-bottom: 1px solid var(--line); }
  .staff .list { gap: 0; padding: 0 0 12px; }
  .staff .ticket-row { border: 0; border-left: 4px solid transparent; border-bottom: 1px solid var(--line); border-radius: 0; padding: 10px 12px; }
  .staff .ticket-row:hover:not(:disabled) { border-bottom-color: var(--line); background: var(--surface); }
  .staff .ticket-row[aria-current="true"] { border-left-color: var(--green); background: var(--green-soft); }
  .staff .row-description { color: var(--muted); font-size: 13px; -webkit-line-clamp: 1; }
  .staff .screen-head { padding: 12px 24px; }
  .staff .ticket-heading h1 { font-size: 24px; }
  .staff .ticket-heading-title { gap: 8px; }
  .staff .ticket-heading [data-back] { border-color: transparent; }
  .staff .screen-head .theme-toggle { display: none; }
  .staff .chat-feed { padding-inline: 24px; }
  .staff .composer { padding-inline: 24px; }
  .staff .reply-row .choose-files span { display: inline; }
  .staff .reply-row { grid-template-columns: auto minmax(8rem, 14rem) 1fr; }
  .staff .reply-submit { justify-self: end; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
