:root {
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --fs-base: 16px;
  --color-text: #e2e8f0;
  --color-heading: #f8fafc;
  --color-muted: #94a3b8;
  --bg: #0f172a;
  --card: #1e293b;
  --border: #334155;
  --input: #0b1220;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --info: #38bdf8;
}

* { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.45;
  background: var(--bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}
.wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 16px;
}
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
h1 {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--color-heading);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--color-heading);
  margin: 0 0 10px;
}
.muted { color: var(--color-muted); font-size: 13px; }
.hidden { display: none !important; }

input, button, select, textarea {
  font-family: inherit;
  font-size: var(--fs-base);
  width: 100%;
  margin: 6px 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
input, select, textarea {
  background: var(--input);
  color: var(--color-text);
}
textarea {
  resize: vertical;
  min-height: 100px;
}
input[type="date"] {
  width: auto;
  max-width: 11rem;
  padding: 10px;
}
button {
  background: var(--ok);
  color: #001b0a;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
button.alt { background: var(--info); color: #042135; }
button.ghost {
  background: #2563eb;
  color: #fff;
  border: 1px solid #1d4ed8;
}
button.danger { background: var(--err); color: #fff; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row > * { flex: 1 1 auto; min-width: 0; }
.presets { display: flex; gap: 8px; margin: 6px 0; }
.presets button {
  flex: 1;
  padding: 10px 8px;
  background: #334155;
  color: #e2e8f0;
  font-weight: 600;
}
.presets button.active {
  background: #22c55e;
  color: #001b0a;
}

.tabs {
  display: none;
}

.burger {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 10px;
  margin: 0;
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  background: #334155;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.burger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #f8fafc;
  border-radius: 1px;
}
.burger.open {
  background: #22c55e;
}
.burger.open span {
  background: #001b0a;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.topbar-mid {
  flex: 1 1 auto;
  min-width: 0;
}
.topbar .section-title {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}
.topbar .who {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 2px;
}
.topbar #logoutBtn {
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
  background: #475569;
  color: #fff;
  margin: 0;
  flex: 0 0 auto;
}

.menu-drawer {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 12px;
}
.menu-drawer button {
  width: 100%;
  margin: 4px 0;
  background: #334155;
  color: #e2e8f0;
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
}
.menu-drawer button.active {
  background: #22c55e;
  color: #001b0a;
}

.log {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0b1220;
  border-radius: 10px;
  padding: 10px;
  min-height: 120px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0;
}
.stat {
  background: #0b1220;
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
  border: 1px solid var(--border);
}
.stat .num {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-heading);
  line-height: 1.2;
}
.stat .lbl {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 4px;
}
.stat-sm {
  padding: 8px 10px;
}
.stat-sm .num {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
}
.stat-sm .lbl {
  font-size: 11px;
}

.list-item {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 6px 0;
  cursor: pointer;
}
.list-item:active, .list-item.selected {
  border-color: #22c55e;
}
.list-item .title { font-weight: 700; color: var(--color-heading); }
.list-item .meta { font-size: 12px; color: var(--color-muted); margin-top: 2px; }

.staff-row {
  display: block;
  cursor: default;
}
.staff-row .staff-line {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 10px 14px;
  color: #ffffff;
  width: 100%;
}
.staff-row .staff-who {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.staff-row .staff-big {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.staff-row .staff-big + .staff-big {
  margin-left: 0;
}

.err-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--err);
  color: #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  font-weight: 600;
}
.ok-banner {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid var(--ok);
  color: #bbf7d0;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
}

label.chk {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 14px;
}
label.chk input { width: auto; margin: 0; }

.form-grid label {
  display: block;
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 8px;
}

.daily-box {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--color-muted);
}
.daily-box strong {
  color: #ffffff;
  font-weight: 400;
}

.done-toolbar {
  margin: 6px 0 0;
}
.done-toolbar button {
  margin: 0;
  flex: 0 0 auto;
  width: auto;
  min-width: 140px;
}
.done-pager {
  margin: 6px 0;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.done-pager .done-page-btn {
  flex: 1 1 0;
  margin: 0;
  max-width: 42%;
}
.done-pager .done-page-info {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--color-muted);
  white-space: nowrap;
}
.done-bal {
  color: #22c55e;
  font-weight: 600;
  margin-left: 6px;
  font-size: 14px;
}

.lottery-toolbar {
  margin: 8px 0 12px;
}
.lottery-toolbar button {
  margin: 0;
}
.winner-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}
.winner-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}
.winner-actions button {
  flex: 1;
  margin: 0;
  padding: 10px 8px;
  font-size: 13px;
}
.winner-actions button.btn-add {
  background: var(--ok);
  color: #001b0a;
}
.winner-actions button:disabled {
  opacity: 0.55;
}
.winner-status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.status-reg {
  color: #22c55e;
  font-weight: 800;
}
.status-not {
  color: #ef4444;
  font-weight: 800;
}
.status-unknown {
  color: #f59e0b;
  font-weight: 700;
}
.winner-bal {
  color: var(--color-muted);
}
.winner-bal strong {
  color: #ffffff;
  font-weight: 800;
}
.winner-payout-line {
  width: 100%;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 800;
}
.payout-done {
  color: #22c55e;
}
.payout-error {
  color: #ef4444;
}
.lottery-toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.hidden {
  display: none !important;
}
.modal-card {
  width: 100%;
  max-width: 360px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 18px 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 10px;
}
.modal-body {
  font-size: 15px;
  color: #e2e8f0;
  line-height: 1.45;
  margin-bottom: 14px;
  white-space: pre-wrap;
}
.modal-card button {
  margin: 0;
}
.modal-actions {
  display: flex;
  gap: 8px;
}
.modal-actions button {
  flex: 1;
}
.confirm-warn {
  color: #ef4444;
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.4;
}
.confirm-bal {
  color: #22c55e;
  font-weight: 700;
  margin: 0;
  font-size: 1.05rem;
}

/* Cashier chat embed (admin) */
.chat-panel.card {
  padding: 0;
  overflow: hidden;
}
.chat-embed {
  display: flex;
  flex-direction: column;
  min-height: min(72vh, 720px);
  height: calc(100vh - 120px);
  max-height: 820px;
}
.chat-topbar {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: #111827;
  flex: 0 0 auto;
}
.chat-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
}
.chat-brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
  flex: 0 0 auto;
}
.chat-status {
  flex: 1;
  min-width: 0;
  color: var(--color-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-status.ok {
  color: #22c55e;
}
.chat-status.err {
  color: #ef4444;
}
.chat-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}
.chat-actions button {
  width: 36px;
  height: 36px;
  min-width: 36px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid var(--border);
  font-size: 15px;
}
.chat-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #0b1220;
}
#chatFrame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  display: block;
}
.chat-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.72);
  z-index: 2;
}
.chat-overlay.hidden {
  display: none;
}
.chat-card {
  width: min(360px, calc(100% - 28px));
  padding: 22px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #1e293b;
  text-align: center;
}
.chat-card p {
  margin: 14px 0 0;
  color: var(--color-muted);
  line-height: 1.4;
  font-size: 13px;
}
.chat-spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #22d3ee;
  animation: chat-spin 0.8s linear infinite;
}
@keyframes chat-spin {
  to {
    transform: rotate(360deg);
  }
}
