:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel2: #f1f5f9;
  --line: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #475569;
  --accent2: #1e293b;
  --ok: #16a34a;
  --warn: #b45309;
  --bad: #dc2626;
  --radius: 12px;
}
* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.6 "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1, h2, h3, h4 { font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; margin: 0 0 12px; font-weight: 700; line-height: 1.25; }
h2 { font-size: 17px; }
button { font: inherit; cursor: pointer; }
input, select {
  width: 100%; padding: 9px 11px; margin-top: 4px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label b { color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }

/* buttons */
.btn {
  display: inline-block; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel2); color: var(--text); padding: 8px 14px;
  transition: background .15s, transform .05s;
}
.btn:hover { background: #e2e8f0; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.big { width: 100%; padding: 12px; font-size: 15px; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn.tiny.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.next { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.next.me { background: var(--ok); border-color: var(--ok); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: rgba(231,76,60,.12); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

/* login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(100, 116, 139, .10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 116, 139, .10) 1px, transparent 1px);
  background-size: 44px 44px;
}
.login-card { width: 420px; max-width: 100%; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.brand h1 { margin: 0; }
.brand p { margin: 2px 0 0; color: var(--muted); }
.brand-mark {
  width: 46px; height: 46px; border-radius: 12px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
}
.brand.small { margin: 0; }
.brand.small .brand-mark { width: 32px; height: 32px; font-size: 16px; border-radius: 9px; }

.login-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.login-tabs button {
  flex: 1; padding: 9px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--muted); border-radius: 9px;
}
.login-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.form { display: block; }
.modal-inline { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel2); }
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,.45); backdrop-filter: blur(3px);
}
.modal-card {
  width: min(92vw, 420px); padding: 22px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.modal-actions { display: flex; gap: 10px; align-items: center; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: auto; margin: 0; }

/* topbar (content centered to match main on large screens) */
.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 24px;
}
.tabs { display: flex; gap: 6px; flex: 1; }
.tabs button {
  padding: 8px 16px; border: none; background: transparent;
  color: var(--muted); border-radius: 8px; font-weight: 550;
}
.tabs button.active { background: var(--panel2); color: var(--text); }
.userbox { display: flex; align-items: center; gap: 10px; }
.pill { background: var(--panel2); border: 1px solid var(--line); padding: 5px 12px; border-radius: 999px; font-size: 13px; }
.pill.plan { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.transfer { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel2); }
.transfer .stats-table td { border-bottom: none; padding: 4px 8px; vertical-align: top; }

/* Landing hero background: the brand grid (44px graph-paper squares). */
.app {
  min-height: 100vh;
  background-color: #f8fafc;
  background-image:
    linear-gradient(rgba(100,116,139,.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100,116,139,.1) 1px, transparent 1px);
  background-size: 44px 44px;
}
main { padding: 20px; max-width: 1200px; margin: 0 auto; }

/* inlet */
.inlet-grid { display: grid; grid-template-columns: minmax(320px, 460px) 1fr; gap: 20px; }
.ticket-card { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ticket-big {
  font-size: 88px; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  padding: 10px 0;
}

/* queue board */
.board-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; flex: 1; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 16px;
}
.stat b { font-size: 24px; font-family: "Plus Jakarta Sans", system-ui, sans-serif; display: block; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }

/* stats: table + notifications side by side on wide screens */
.stats-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .stats-grid { grid-template-columns: 1fr; } }

.board { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 20px; align-items: start; }
.queue-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; }
.queue-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  cursor: grab;
}
.queue-item.dragging { opacity: .4; }
.num {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 18px;
}
.num.big { width: 56px; height: 56px; font-size: 26px; }
.qi-info { flex: 1; display: flex; flex-direction: column; }
.qi-info b { font-size: 14px; }
.qi-info span { font-size: 12px; }

.providers { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.provider-col { min-height: 150px; }
.provider-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.provider-head b { font-size: 15px; }
.current { border-radius: 10px; padding: 14px; min-height: 110px; border: 1px dashed var(--line); }
.current.idle { display: flex; align-items: center; justify-content: center; text-align: center; }
.current.busy { border-style: solid; border-color: var(--ok); background: rgba(46,204,113,.07); }
.cur-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.cur-actions { display: flex; gap: 8px; margin-top: 6px; }

/* stats */
.stats-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range input { width: 150px; margin: 0; }
.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.stats-table th { color: var(--muted); font-weight: 550; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stats-table tfoot td { font-weight: 650; border-top: 2px solid var(--line); }
.stats-table.small td { font-size: 13px; }

/* presentation display (big screen) */
.display {
  min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(1200px 800px at 50% -10%, var(--panel2), var(--bg));
}
.disp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 26px 44px; border-bottom: 1px solid var(--line);
}
.disp-head h1 { font-size: 30px; margin: 0; }
.disp-counts { display: flex; gap: 18px; font-size: 20px; color: var(--muted); }
.disp-counts b { color: var(--text); }
.disp-body {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 40px; padding: 40px; text-align: center;
}
.disp-label {
  margin: 0 0 16px; color: var(--muted); font-size: 20px;
  text-transform: uppercase; letter-spacing: .18em;
}
.disp-numbers { display: flex; gap: 32px; justify-content: center; flex-wrap: wrap; }
.disp-number {
  padding: 28px 60px; border-radius: 24px;
  background: var(--panel); border: 2px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.disp-number.multi { padding: 22px 44px; }
.disp-ticket {
  font-size: 150px; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.disp-number.multi .disp-ticket { font-size: 110px; }
.disp-ticket.muted { color: var(--muted); background: none; -webkit-background-clip: initial; background-clip: initial; }
.disp-name { font-size: 26px; }
.disp-next .disp-nextnum {
  font-size: 88px; font-weight: 700; line-height: 1;
  color: var(--ok);
}
.disp-nextname { font-size: 22px; color: var(--muted); margin: 8px 0 0; }

.disp-soundgate {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,.45); backdrop-filter: blur(3px);
  cursor: pointer;
}
.disp-soundgate-box { text-align: center; padding: 24px; }

/* language switcher + RTL */
.lang-row { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.lang-select {
  width: auto; margin: 0; padding: 6px 10px; font-size: 13px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
html[dir="rtl"] .lang-row { justify-content: flex-start; }
html[dir="rtl"] body { text-align: right; }
html[dir="rtl"] .stats-table th, html[dir="rtl"] .stats-table td { text-align: right; }

/* staff management */
.stats-table input.inline, .stats-table select {
  width: 100%; max-width: 150px; margin: 0; padding: 6px 8px;
}
.staff-actions { white-space: nowrap; }
.pw {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; color: var(--warn); letter-spacing: .06em;
}
.staff-actions input.inline { max-width: 120px; }
.staff-add {
  display: grid; gap: 0 16px; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.staff-add label { margin-bottom: 0; }
.staff-add .btn { grid-column: 1 / -1; justify-self: start; margin-top: 12px; }

/* employee roster (reuse a known person so stats stay continuous) */
.roster { margin: 20px 0 4px; }
.roster-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 8px; }
.roster-item {
  display: flex; align-items: center; gap: 8px; text-align: left; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel2); color: var(--text); cursor: pointer;
}
.roster-item:hover { border-color: var(--accent); background: var(--panel); }
.roster-item .reuse { margin-left: auto; font-size: 12px; color: var(--accent); }
.roster-item .badge { color: var(--ok); font-weight: 700; }
.disp-provider { font-size: 18px; color: var(--muted); }

@media (max-width: 860px) {
  .board, .inlet-grid { grid-template-columns: 1fr; }
  .disp-ticket { font-size: 90px; }
  .disp-number.multi .disp-ticket { font-size: 70px; }
  .disp-head { padding: 18px 20px; }
  .disp-head h1 { font-size: 20px; }
  .disp-counts { font-size: 15px; }
}
