:root {
  color-scheme: light;
  --canvas: #f5f6f1;
  --paper: #fff;
  --ink: #1c2822;
  --muted: #59645d;
  --line: #dce2db;
  --soft: #edf1e9;
  --green: #214f40;
  --green-dark: #193d32;
  --orange: #a54b1a;
  --orange-soft: #ffecd9;
  --red: #993d36;
  --radius: 16px;
  --width: 1112px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 3px solid #477f68; outline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { overflow-wrap: anywhere; }
p, dd, dt, td, label { overflow-wrap: anywhere; }
h1 { font-size: clamp(2rem, 5vw, 3.35rem); font-weight: 720; line-height: 1.06; letter-spacing: -.06em; }
h2 { font-size: 1.22rem; line-height: 1.25; letter-spacing: -.026em; }
h3 { font-size: 1.12rem; line-height: 1.3; letter-spacing: -.02em; }
p { line-height: 1.56; }
.skip { position: absolute; z-index: 20; left: 16px; top: -50px; border-radius: 8px; padding: 8px 14px; background: var(--paper); }
.skip:focus { top: 10px; }

.header { color: #eff8f2; background: #19372e; }
.header-inner { width: min(var(--width), calc(100% - 64px)); margin: auto; min-height: 72px; display: flex; align-items: center; gap: 42px; }
.brand { display: inline-flex; gap: 11px; align-items: center; flex: 0 0 auto; font-size: 1.15rem; font-weight: 720; letter-spacing: -.04em; }
.brand-mark { display: grid; place-content: center; gap: 3px; width: 32px; height: 32px; border-radius: 8px; background: #cfe7bc; }
.brand-mark i { width: 14px; height: 2px; border-radius: 2px; background: #214f40; }
.brand-mark i:nth-child(2) { width: 10px; }
.brand-mark i:nth-child(3) { width: 6px; }
.header nav { display: flex; align-items: center; gap: 6px; }
.header nav a, .header-right a, .header-right .quiet { display: block; color: #cadbd0; font-size: .88rem; padding: 9px 13px; white-space: nowrap; border-radius: 8px; }
.header nav [aria-current="page"], .header nav a:hover, .header-right a:hover, .header-right .quiet:hover { color: white; background: #315349; }
.header-right { margin-left: auto; }
.header :focus-visible { outline-color: #cfe7bc; }
.container { width: min(var(--width), calc(100% - 64px)); margin: 0 auto; padding: 51px 0 70px; }
main:focus { outline: none; }
.heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 32px; }
.heading p { margin-top: 12px; font-size: 1.02rem; color: var(--muted); }
.heading-actions { display: flex; align-items: center; flex-wrap: wrap; flex-shrink: 0; gap: 8px; }
.back { display: inline-block; font-size: .9rem; margin-bottom: 16px; color: var(--green); font-weight: 650; }
.back:hover, .arrow-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.description { max-width: 700px; margin: -13px 0 24px; color: var(--muted); white-space: pre-wrap; }

.btn, .quiet { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; border: 1px solid transparent; border-radius: 8px; font-size: .9rem; font-weight: 650; line-height: 1.3; text-align: center; white-space: normal; }
.btn.primary { background: var(--green); border-color: var(--green); color: white; }
.btn.primary:hover:not(:disabled) { background: var(--green-dark); }
.btn.secondary { background: var(--paper); border-color: #ccd6ce; color: #284638; }
.btn.secondary:hover { background: var(--soft); }
.btn.danger { background: var(--red); color: white; }
.btn.danger:hover { background: #7d332e; }
.quiet { color: var(--muted); background: transparent; padding-left: 8px; padding-right: 8px; }
.quiet:hover { background: var(--soft); color: var(--ink); }
.danger-text { color: var(--red); }
.arrow-link { color: var(--green); font-weight: 680; font-size: .9rem; white-space: nowrap; }
.arrow-link span { margin-left: 3px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.container > .section-bar { margin-bottom: 12px; }
.section-bar > span:not(.status) { font-size: .86rem; color: var(--muted); }
.queue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 15px; }
.queue-card { display: flex; flex-direction: column; min-height: 178px; padding: 20px; }
.queue-card h3 { margin-top: 16px; font-size: 1.33rem; }
.queue-card h3 a:hover { color: var(--green); }
.queue-card p { margin-top: 5px; font-size: .89rem; color: var(--muted); }
.queue-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; margin-top: auto; }
.queue-card-bottom > span { color: var(--muted); font-size: .9rem; }
.queue-card-bottom b { color: var(--ink); padding-left: 5px; font-variant-numeric: tabular-nums; }
.status { display: inline-flex; width: fit-content; align-items: center; justify-content: center; gap: 6px; border-radius: 6px; color: #48564e; background: #ebefeb; padding: 5px 8px; font-size: .75rem; font-weight: 700; line-height: 1.1; }
.status > span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.status.open { background: #e4efdf; color: #31573a; }
.status.warm { background: var(--orange-soft); color: #8d401b; }
.empty { border: 1px dashed #cbd6cb; border-radius: var(--radius); color: var(--muted); display: grid; justify-items: center; text-align: center; gap: 9px; padding: 36px 20px; }
.empty strong { font-size: 1rem; color: var(--ink); }
.empty .btn { margin-top: 5px; }
.loading { color: var(--muted); }

.split, .operator-grid { display: grid; grid-template-columns: minmax(0, 1.64fr) minmax(0, 1fr); align-items: start; gap: 16px; }
.stack { display: grid; gap: 16px; }
.join-card, .connect, .live, .metrics { padding: 22px; }
.join-card p, .connect p { color: var(--muted); margin: 8px 0 16px; }
.own-ticket { padding: 24px; }
.own-ticket.called { border: 2px solid #e29a60; background: #fff8f1; }
.ticket-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.label { color: var(--muted); font-weight: 630; font-size: .88rem; }
.ticket-number, .dispatch-number, .board-current > div { font-size: clamp(2.6rem, 8.5vw, 6.4rem); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.075em; font-weight: 700; overflow-wrap: anywhere; }
.ticket-number { margin: 14px 0 17px; color: var(--green); }
.called .ticket-number { color: var(--orange); }
.ticket-hint { font-weight: 650; margin-bottom: 16px; }
.ticket-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 0; border-top: 1px dashed var(--line); }
.ticket-stats span { display: block; font-size: .86rem; color: var(--muted); }
.ticket-stats strong { display: block; margin-top: 4px; font-size: 1.12rem; }
.ticket-actions, .dispatch-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.live-status { margin-top: 14px; }
.live dl, .metrics dl { margin: 14px 0 12px; }
.live dl div, .metrics dl div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.live dt, .metrics dt { color: var(--muted); font-size: .89rem; }
.live dd, .metrics dd { font-size: 1.12rem; font-weight: 700; }
.live-label { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem !important; }
.live-label::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #64955e; }
.list-section { margin: 24px 0 0; }
.list-section > h2, .list-section > .section-bar { margin-bottom: 10px; }
.list-row { display: grid; grid-template-columns: 80px minmax(0, 1fr) max-content 24px; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: #f9fbf8; }
.list-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.list-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.list-row:only-child { border-radius: var(--radius); }
.row-number, .table-number { color: var(--green); font-weight: 720; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.row-title { font-weight: 650; overflow-wrap: anywhere; }
.row-title small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }
.row-arrow { justify-self: end; color: var(--green); }
.manage-list .list-row { grid-template-columns: minmax(0, 1fr) max-content max-content 24px; }
.manage-count { color: var(--muted); font-size: .87rem; }
.manage-count b { color: var(--ink); }
.ops-status { display: flex; align-items: center; gap: 10px; margin: -13px 0 16px; }
.ops-status .btn { min-height: 33px; padding: 4px 9px; }
.dispatch { padding: 24px; }
.dispatch-number { color: var(--green); margin: 16px 0 12px; }
.dispatch p { color: var(--muted); margin-bottom: 16px; }
.operator-grid { align-items: stretch; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
th, td { padding: 11px 18px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .82rem; font-weight: 650; background: #f8faf7; }
td { font-size: .9rem; }
tbody tr:last-child td { border-bottom: none; }
td .btn { min-height: 30px; padding: 5px 9px; font-size: .8rem; }
.login { width: min(100%, 414px); margin: 21px auto 0; padding: 25px; }
.login h1 { font-size: 1.82rem; margin-bottom: 22px; }
.form-panel { width: min(100%, 600px); padding: 23px; }
.form-stack { display: grid; gap: 16px; }
.form-stack label, .share-field { display: grid; gap: 6px; font-size: .9rem; font-weight: 620; }
input:not([type="checkbox"]), textarea { width: 100%; min-width: 0; min-height: 42px; border: 1px solid #aebfb2; border-radius: 7px; background: #fff; padding: 9px 11px; color: var(--ink); font-size: 1rem; font-weight: 400; }
textarea { resize: vertical; }
input::placeholder { color: #69756e; }
label small { color: var(--muted); font-weight: 400; }
.form-stack .checkbox { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.checkbox input { margin: .15em 0; accent-color: var(--green); width: 18px; height: 18px; flex: 0 0 18px; }
fieldset { margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
legend { font-size: .89rem; font-weight: 650; }
.checks { display: grid; gap: 8px; }
.form-error { color: var(--red); font-size: .89rem; }
.team-card { padding: 22px; border-bottom: 1px solid var(--line); }
.team-card:last-child { border-bottom: none; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 23px; width: min(440px, calc(100% - 28px)); color: var(--ink); }
dialog::backdrop { background: #152820a6; }
dialog p, dialog label { margin: 12px 0; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { z-index: 10; position: fixed; right: 20px; bottom: 20px; max-width: min(390px, calc(100% - 40px)); padding: 13px 16px; border-radius: 10px; color: #fff; background: var(--green-dark); box-shadow: 0 5px 20px #0002; }
.toast-error { background: #8b3c33; }
.board-mode { background: #152b24; color: #eef4ed; }
.board-mode .container { width: min(1400px, calc(100% - 8vw)); }
.board-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 28px; }
.board-back { display: inline-block; margin-bottom: 12px; color: #b7cfc0; font-size: .88rem; }
.board-head p { margin-top: 8px; color: #b7cfc0; }
.board-state { display: grid; gap: 9px; align-self: flex-start; justify-items: end; }
.board-state .live-label { color: #b7cfc0; }
.board-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.board-grid section { border: 1px solid #436456; border-radius: 16px; padding: clamp(14px, 3.1vw, 32px); background: #213d33; }
.board-grid h2 { color: #cbe0d0; font-size: clamp(.95rem, 2.5vw, 1.4rem); }
.board-current > div { color: #ddf1d2; font-size: clamp(3rem, 19vw, 13rem); margin: 12px 0; }
.board-grid p { margin-top: 16px; color: #b7cfc0; }
.board-next h2 { display: flex; justify-content: space-between; gap: 5px; }
.board-next ol { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 15px 0 0; padding: 0; }
.board-next li { padding: 10px 6px; text-align: center; border-radius: 6px; background: #2e5144; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

@media (max-width: 820px) {
  .header-inner, .container { width: calc(100% - 36px); }
  .header-inner { gap: 17px; }
  .heading { align-items: flex-start; flex-direction: column; gap: 13px; }
  .heading-actions { max-width: 100%; }
}

@media (max-width: 590px) {
  .header-inner { min-height: 80px; position: relative; flex-wrap: wrap; align-content: center; align-items: center; gap: 3px 8px; padding: 7px 0; }
  .brand { font-size: 1rem; }
  .brand-mark { width: 28px; height: 28px; }
  .header nav { order: 3; width: 100%; gap: 5px; }
  .header nav a, .header-right a, .header-right .quiet { padding: 6px 8px; font-size: .8rem; }
  .container { padding: 29px 0 55px; }
  .heading { margin-bottom: 23px; }
  .heading p { font-size: .93rem; margin-top: 8px; }
  .split, .operator-grid, .board-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .own-ticket, .join-card, .connect, .live, .metrics, .dispatch { padding: 17px; }
  .btn { min-height: 42px; }
  .list-row, .manage-list .list-row { grid-template-columns: auto minmax(0, 1fr) max-content; gap: 7px; padding: 12px; }
  .manage-list .list-row { grid-template-columns: minmax(0, 1fr) max-content; }
  .manage-list .manage-count { display: none; }
  .row-arrow { display: none; }
  th, td { padding-left: 10px; padding-right: 10px; }
  .board-head { align-items: stretch; flex-direction: column; }
  .board-state { justify-items: start; }
}
