:root {
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #181c25;
  --surface-3: #1f2430;
  --border: #242a36;
  --border-strong: #323949;
  --text: #e7eaf0;
  --text-2: #b4bccb;
  --muted: #7f889b;
  --accent: #6d8dff;
  --accent-soft: rgba(109, 141, 255, .14);
  --good: #3ecf8e;
  --good-soft: rgba(62, 207, 142, .13);
  --bad: #f2707a;
  --bad-soft: rgba(242, 112, 122, .13);
  --warn: #f5b841;
  --warn-soft: rgba(245, 184, 65, .14);
  --recharge: #3ecf8e;
  --redeem: #f59f4a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --topbar-h: 56px;
  --bottomnav-h: 64px;
  --sidenav-w: 220px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* ---------- App shell ---------- */
.app { display: grid; height: 100dvh; grid-template-rows: var(--topbar-h) 1fr calc(var(--bottomnav-h) + var(--safe-b)); grid-template-columns: 1fr; }
.sidenav { display: none; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  border-bottom: 1px solid var(--border); background: rgba(11, 13, 18, .92);
  backdrop-filter: blur(10px); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .2px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #9b6dff); color: #fff; font-size: 14px; font-weight: 800;
}
.topbar-title { font-weight: 650; font-size: 16px; }
.topbar .spacer { flex: 1; }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 11px; border: 1px solid transparent;
  background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.badge-dot {
  position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--bg);
}
.user-chip { font-size: 13px; color: var(--muted); padding: 0 4px; }
@media (max-width: 420px) { .user-chip { display: none; } }

.views { position: relative; overflow: hidden; min-height: 0; }
.view { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 14px 28px; }
.view:not(.active) { display: none; }
/* The games view is never display:none - its platform frames must stay live
   (and keep their real size) while another view is on screen. */
.view.view-games { padding: 0; overflow: hidden; display: flex !important; flex-direction: column; }
.view-games:not(.active) { visibility: hidden; pointer-events: none; z-index: -1; }
.view-inner { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

.bottomnav {
  display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--border);
  background: rgba(11, 13, 18, .96); backdrop-filter: blur(10px); padding-bottom: var(--safe-b); z-index: 20;
}
.nav-btn {
  background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; cursor: pointer; position: relative;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--text); }
.nav-btn.active::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 2px; background: var(--accent);
}
.nav-count {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; display: grid; place-items: center;
}

@media (min-width: 900px) {
  .app { grid-template-columns: var(--sidenav-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; }
  .sidenav {
    display: flex; flex-direction: column; gap: 4px; grid-row: 1 / 3; padding: 14px 12px;
    border-right: 1px solid var(--border); background: var(--surface);
  }
  .sidenav .brand { padding: 6px 8px 18px; }
  .sidenav .nav-btn {
    flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  }
  .sidenav .nav-btn:hover { background: var(--surface-2); color: var(--text); }
  .sidenav .nav-btn.active { background: var(--accent-soft); color: var(--text); }
  .sidenav .nav-btn.active::before { display: none; }
  .sidenav .nav-count { position: static; margin-left: auto; }
  .sidenav .nav-spacer { flex: 1; }
  .topbar .brand { display: none; }
  .bottomnav { display: none; }
  .view { padding: 22px 26px 40px; }
}

/* ---------- Cards / generic ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-size: 14px; font-weight: 650; color: var(--text-2); letter-spacing: .2px; margin: 0; }
.card-sub { font-size: 12.5px; color: var(--muted); margin: -8px 0 12px; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
.empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 18px 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #7f9bff; }
.btn-danger { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

input[type=text], input[type=number], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text); outline: none; font-size: 15px;
}
textarea { height: 76px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 600;
  font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.segmented button.active { background: var(--surface-3); color: var(--text); }
.pill-count { background: var(--border-strong); color: var(--text); border-radius: 8px; padding: 0 6px; font-size: 11px; }

.date-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.date-nav button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); cursor: pointer; font-size: 18px; }
.date-nav button:hover { background: var(--surface-2); }
.date-nav input { border: 0; background: transparent; height: 34px; width: 138px; padding: 0 4px; text-align: center; font-weight: 600; }
.date-nav input:focus { box-shadow: none; }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 7px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px; }
.tag-recharge { background: var(--good-soft); color: var(--recharge); }
.tag-redeem { background: var(--warn-soft); color: var(--redeem); }
.tag-muted { background: var(--surface-3); color: var(--text-2); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Home ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; letter-spacing: -.2px; }
.hero {
  background: radial-gradient(120% 140% at 0% 0%, rgba(109, 141, 255, .22), transparent 55%), var(--surface);
  border: 1px solid var(--border); border-radius: 18px; padding: 18px;
}
.hero-label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.hero-label em { font-style: normal; color: var(--muted); font-weight: 500; }
.hero-value { font-size: 38px; font-weight: 800; letter-spacing: -1px; margin: 4px 0 2px; }
.hero-meta { font-size: 13px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: rgba(255, 255, 255, .03); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-sub { font-size: 11px; color: var(--muted); opacity: .8; }
.kpi-value { font-size: 19px; font-weight: 750; margin-top: 3px; }
.opcost { margin-top: 12px; }
.opcost-bar { position: relative; height: 10px; border-radius: 6px; background: var(--surface-3); overflow: visible; margin: 8px 0 6px; }
.opcost-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--good); }
.opcost-fill.over { background: var(--bad); }
.opcost-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); border-radius: 2px; }

.attention-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border); cursor: pointer;
}
.attention-item + .attention-item { margin-top: 8px; }
.attention-item:hover { border-color: var(--border-strong); }
.att-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; font-weight: 800; }
.att-icon.recharge { background: var(--good-soft); color: var(--recharge); }
.att-icon.redeem { background: var(--warn-soft); color: var(--redeem); }
.att-main { flex: 1; min-width: 0; }
.att-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-sub { font-size: 12.5px; color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.bar-track { height: 8px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.bar-val { font-weight: 650; min-width: 64px; text-align: right; }

/* ---------- Transactions list ---------- */
.tx-list { display: flex; flex-direction: column; }
.tx {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px 4px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.tx:last-child { border-bottom: 0; }
.tx:hover { background: rgba(255, 255, 255, .02); }
.tx-dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; font-weight: 800; }
.tx-dot.recharge { background: var(--good-soft); color: var(--recharge); }
.tx-dot.redeem { background: var(--warn-soft); color: var(--redeem); }
.tx-main { min-width: 0; }
.tx-who { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt { text-align: right; }
.tx-cash { font-weight: 700; }
.tx-pts { font-size: 12px; color: var(--muted); }
.tx-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tx-summary .chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; font-size: 12.5px; }

.pending {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
.pending + .pending { margin-top: 10px; }
.pending-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pending-grid input { height: 38px; }

/* ---------- Games (platform tabs) ---------- */
.tabstrip {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex: none; min-width: 0;
}
.tab-scroll { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tab-scroll::-webkit-scrollbar { display: none; }
.gtab {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); cursor: pointer; flex: none;
  font-weight: 600; font-size: 13.5px; max-width: 190px;
}
.gtab.active { background: var(--accent-soft); border-color: rgba(109, 141, 255, .45); color: var(--text); }
.gtab-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gtab-x { width: 24px; height: 24px; border-radius: 7px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
.gtab-x:hover { background: var(--surface-3); color: var(--text); }
.gtab-spin { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.tab-add { width: 36px; height: 36px; flex: none; border-radius: 10px; border: 1px dashed var(--border-strong); background: transparent; color: var(--text-2); cursor: pointer; font-size: 20px; }
.tab-add:hover { color: var(--text); border-color: var(--accent); }
.tab-tools { display: flex; gap: 4px; flex: none; }
.frames { position: relative; flex: 1; min-height: 0; background: #fff; }
.frames iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.frames iframe:not(.active) { visibility: hidden; pointer-events: none; }
.games-empty { position: absolute; inset: 0; overflow-y: auto; background: var(--bg); padding: 22px 14px; }
.games-empty h2 { margin: 0 0 4px; font-size: 20px; }
.platform-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
@media (min-width: 700px) { .platform-grid { grid-template-columns: repeat(4, 1fr); } }
.ptile {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; padding: 14px;
  cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 6px; min-height: 86px;
}
.ptile:hover:not(:disabled) { border-color: var(--accent); }
.ptile:disabled { opacity: .45; cursor: default; }
.ptile-abbr { font-size: 12px; font-weight: 800; color: var(--accent); letter-spacing: .5px; }
.ptile-name { font-weight: 650; }
.ptile-foot { margin-top: auto; font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.det-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.det-dot.on { background: var(--good); }

/* ---------- Customers ---------- */
.search { position: relative; }
.search input { padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 11px; width: 18px; height: 18px; color: var(--muted); }
.cust {
  display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.cust:last-child { border-bottom: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 750;
  background: var(--surface-3); color: var(--text-2); font-size: 14px;
}
.cust-main { flex: 1; min-width: 0; }
.cust-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-meta { font-size: 12.5px; color: var(--muted); }
.acct-chip { display: inline-flex; gap: 6px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; font-size: 12.5px; margin: 0 6px 6px 0; }
.acct-chip b { color: var(--accent); font-size: 11px; }

/* ---------- Reports ---------- */
.compare { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .compare { grid-template-columns: repeat(4, 1fr); } }
.compare .kpi-value { font-size: 20px; }
.delta { font-size: 12px; font-weight: 700; }
.trend { display: flex; gap: 3px; align-items: end; height: 150px; margin-top: 8px; }
.trend-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; cursor: pointer; }
.trend-bars { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.trend-bar { width: 46%; max-width: 10px; border-radius: 3px 3px 1px 1px; min-height: 2px; }

/* Month highlights */
.hl-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .hl-tiles { grid-template-columns: repeat(4, 1fr); } }
.hl-tile { background: var(--surface-2, var(--surface-3)); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.hl-label { font-size: 12px; color: var(--muted); }
.hl-value { font-size: 20px; font-weight: 700; margin: 2px 0; }
.hl-sub { font-size: 11px; }
.pace { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: 14px; }
.hl-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hl-chips .chip { background: var(--surface-3); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; }
.hl-chips .pos-chip { background: color-mix(in srgb, var(--good) 20%, transparent); }

/* Hour-of-day activity */
.hours { display: flex; gap: 3px; align-items: end; height: 110px; margin-top: 4px; }
.hr-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.hr-bar-wrap { display: flex; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.hr-bar { width: 70%; max-width: 12px; min-height: 2px; border-radius: 3px 3px 1px 1px; background: var(--accent); opacity: .5; }
.hr-col.peak .hr-bar { opacity: 1; }
.hr-lbl { font-size: 10px; white-space: nowrap; }
.trend-bar.in { background: var(--good); }
.trend-bar.out { background: var(--redeem); }
.trend-lbl { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.pie-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.pie-legend { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.pie-legend .row { justify-content: space-between; }
.rank { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.rank-n { width: 22px; height: 22px; border-radius: 7px; background: var(--surface-3); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: var(--text-2); flex: none; }
.rank-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-weekdays span { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; }
.cal-day {
  min-height: 52px; border-radius: 9px; background: var(--surface-2); border: 1px solid transparent; padding: 5px;
  display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; font-size: 12px;
}
.cal-day:hover { border-color: var(--border-strong); }
.cal-day.empty { background: transparent; cursor: default; }
.cal-day.today { border-color: var(--accent); }
.cal-day .d { color: var(--muted); font-weight: 600; }
.cal-day .v { font-size: 10.5px; font-weight: 700; white-space: nowrap; overflow: hidden; }
.cal-day.pos-day { background: rgba(62, 207, 142, .09); }
.cal-day.neg-day { background: rgba(242, 112, 122, .09); }
.ai-content { font-size: 14px; line-height: 1.6; color: var(--text-2); }
.ai-content p, .msg p { margin: 0 0 8px; }
.ai-content p:last-child, .msg p:last-child { margin-bottom: 0; }
.ai-content ul, .msg ul { margin: 0 0 8px; padding-left: 18px; }
.ai-content h4 { margin: 10px 0 6px; font-size: 14px; color: var(--text); }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; margin-bottom: 10px; }
.msg { padding: 9px 12px; border-radius: 12px; max-width: 88%; font-size: 14px; }
.msg.user { white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); }

/* ---------- Settings ---------- */
.cred { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cred:last-child { border-bottom: 0; }
.cred-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cred-fields { display: grid; grid-template-columns: 1fr 1fr 90px; gap: 8px; }
.cred-fields input { height: 38px; font-size: 14px; }
@media (max-width: 560px) { .cred-fields { grid-template-columns: 1fr 1fr; } .cred-fields .rate { grid-column: span 2; } }
.pm-row { display: flex; gap: 8px; align-items: center; }
.pm-row + .pm-row { margin-top: 8px; }

/* ---------- Sheets (modals) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(4, 6, 10, .6); z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow); padding: 8px 18px calc(18px + var(--safe-b)); animation: rise .2s ease;
}
.sheet-grip { width: 38px; height: 4px; border-radius: 3px; background: var(--border-strong); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-head h3 { margin: 0; font-size: 18px; flex: 1; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; padding: 18px 22px 22px; }
  .sheet-grip { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: .6; } }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.notice { font-size: 13px; border-radius: 10px; padding: 10px 12px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.notice.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.notice.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.receipt-top { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.receipt-top .big { font-size: 22px; font-weight: 800; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }

.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 11px; max-height: 210px; overflow-y: auto; box-shadow: var(--shadow);
}
.combo-opt { padding: 10px 12px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.combo-opt:hover, .combo-opt.hl { background: var(--surface-3); }
.combo-opt small { color: var(--muted); }

.review-pill {
  position: fixed; right: 14px; bottom: calc(var(--bottomnav-h) + var(--safe-b) + 14px); z-index: 90; display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 16px 0 12px; border-radius: 23px; border: 0; background: var(--accent); color: #fff; font-weight: 700;
  box-shadow: var(--shadow); cursor: pointer; animation: rise .2s ease;
}
.review-pill .n { background: #fff; color: var(--accent); border-radius: 11px; min-width: 22px; height: 22px; display: grid; place-items: center; font-size: 12px; }
@media (min-width: 900px) { .review-pill { bottom: 22px; right: 22px; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottomnav-h) + var(--safe-b) + 18px); transform: translateX(-50%); z-index: 200;
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 28px); animation: rise .2s ease;
}
.toast.error { background: #3a1d22; border-color: #5c2a31; color: #ffd5d9; }
@media (min-width: 900px) { .toast { bottom: 26px; } }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Login ---------- */
.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 20px; overflow: auto;
  background: radial-gradient(80% 60% at 50% 0%, rgba(109, 141, 255, .18), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 26px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { font-size: 20px; margin-bottom: 6px; }
.login-card .brand-mark { width: 36px; height: 36px; font-size: 17px; border-radius: 10px; }
.error-text { color: var(--bad); font-size: 13px; }

/* ---------- Boost ---------- */
.boost-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .boost-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1050px) { .boost-grid { grid-template-columns: 1fr 1fr 1fr; } }
.boost-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.boost-card.pinned { border-color: rgba(109,141,255,.5); background: linear-gradient(180deg, var(--accent-soft), transparent 40%), var(--surface); }
.boost-kind { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 3px 8px; border-radius: 7px; align-self: flex-start; }
.boost-kind.promo { background: var(--accent-soft); color: var(--accent); }
.boost-kind.bonus { background: var(--good-soft); color: var(--good); }
.boost-kind.reengage { background: var(--warn-soft); color: var(--warn); }
.boost-kind.idea { background: var(--surface-3); color: var(--text-2); }
.boost-title { font-weight: 700; font-size: 15px; }
.boost-body { font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; line-height: 1.5; flex: 1; }
.boost-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.boost-actions { display: flex; gap: 4px; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; }
.boost-actions .icon-btn { width: 34px; height: 34px; }
.boost-actions .icon-btn svg { width: 17px; height: 17px; }
.boost-actions .icon-btn.on { color: var(--accent); }
.boost-empty { grid-column: 1 / -1; }

/* ---------- Broadcast ---------- */
.broadcast-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .broadcast-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1050px) { .broadcast-grid { grid-template-columns: repeat(4, 1fr); } }
.device { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; }
.device:hover { border-color: var(--border-strong); }
.device-screen { width: 100%; aspect-ratio: 9 / 19; background: #000 center/contain no-repeat; display: block; }
.device-screen.offline { display: grid; place-items: center; color: var(--muted); font-size: 12px; background: var(--surface-2); }
.device-foot { display: flex; align-items: center; gap: 8px; padding: 9px 11px; }
.device-live { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; box-shadow: 0 0 0 3px var(--good-soft); }
.device-live.off { background: var(--muted); box-shadow: none; }
.device-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-view { position: fixed; inset: 0; z-index: 150; background: #000; display: flex; flex-direction: column; }
.device-view-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px calc(10px + var(--safe-b)) 14px; background: rgba(0,0,0,.85); color: #fff; }
.device-view-bar .device-name { font-size: 15px; }
.device-view img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }

/* ---------- Boost: templates rail & playbook ---------- */
.tmpl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px; }
.tmpl-rail { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; scroll-snap-type: x proximity; }
.tmpl-rail::-webkit-scrollbar { height: 6px; }
.tmpl-rail::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.tmpl-empty { color: var(--muted); font-size: 13px; padding: 14px; }
.tmpl {
  flex: 0 0 78%; max-width: 300px; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; position: relative;
}
@media (min-width: 640px) { .tmpl { flex-basis: 46%; } }
@media (min-width: 1050px) { .tmpl { flex-basis: 31%; } }
.tmpl.pinned { border-color: rgba(109,141,255,.5); }
.tmpl.dragging { opacity: .5; }
.tmpl.dragover { border-color: var(--accent); }
.tmpl-title { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.tmpl-grip { cursor: grab; color: var(--muted); font-size: 15px; line-height: 1; touch-action: none; }
.tmpl-body { font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; line-height: 1.45; max-height: 108px; overflow: hidden; flex: 1; position: relative; }
/* let the copy TEXT be long-pressed/selected too, as a fallback to the button */
.tmpl-body, .boost-body, .boost-title { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; cursor: text; }
.tmpl-body.clip::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 26px; background: linear-gradient(transparent, var(--surface)); }
.tmpl-actions { display: flex; gap: 2px; align-items: center; }
.tmpl-actions .icon-btn { width: 32px; height: 32px; }
.tmpl-actions .icon-btn svg { width: 16px; height: 16px; }
.tmpl-actions .icon-btn.on { color: var(--accent); }
.playbook { padding: 0; }
.playbook > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.playbook > summary::-webkit-details-marker { display: none; }
.playbook[open] > summary { border-bottom: 1px solid var(--border); }
#playbook-body { padding: 6px 16px 16px; }
.pb-group { margin-top: 12px; }
.pb-group h4 { margin: 0 0 6px; font-size: 13px; color: var(--text); }
.pb-item { display: flex; gap: 9px; font-size: 13px; color: var(--text-2); padding: 4px 0; line-height: 1.4; }
.pb-item::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex: none; }

/* ---------- Broadcast: interactive viewer ---------- */
.dv-stage { flex: 1; min-height: 0; display: grid; place-items: center; background: #000; overflow: hidden; touch-action: none; }
.dv-stage .dv-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; touch-action: none; -webkit-user-select: none; user-select: none; }
.dv-keys { display: flex; align-items: center; gap: 6px; padding: 8px 10px calc(8px + var(--safe-b)); background: rgba(0,0,0,.92); }
.dv-keys .btn { flex: none; }
.dv-text { flex: 1; height: 38px; min-width: 60px; }
.device-view-bar [data-control] { margin-left: auto; }

/* ---------- Broadcast viewer: safe-area + tap feedback ---------- */
.device-view { padding-top: env(safe-area-inset-top, 0px); }
.device-view-bar { padding: 10px 12px !important; gap: 8px; position: sticky; top: 0; z-index: 2; min-height: 44px; }
.device-view-bar [data-close] { font-size: 15px; font-weight: 700; }
.dv-ripple { position: fixed; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 2px solid #6d8dff; background: rgba(109,141,255,.25); pointer-events: none; z-index: 160; animation: dvr .4s ease-out forwards; }
@keyframes dvr { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

/* ---------- Broadcast viewer: live stream ---------- */
.device-view { overscroll-behavior: contain; }
.dv-stage { position: relative; -webkit-touch-callout: none; }
/* fill the stage and letterbox, so it re-fits instantly when the keyboard opens or the phone rotates */
.dv-stage .dv-img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; }
.dv-status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1; max-width: 80%;
  padding: 10px 14px; border-radius: 10px; background: rgba(20, 20, 28, .88); color: #fff; font-size: 13px; text-align: center; }
/* 16px+ stops iOS zooming the whole page when the text box is focused */
.dv-text { font-size: 16px; flex: 1 1 0; min-width: 0; }
.dv-keys { gap: 5px; padding-left: 8px; padding-right: 8px; }
.dv-keys .btn { padding-left: 9px; padding-right: 9px; }
.dv-fps { flex: none; font-variant-numeric: tabular-nums; }

/* First-login "set your password" gate */
.pw-gate { position: fixed; inset: 0; z-index: 400; background: var(--bg); display: grid; place-items: center; padding: 20px; overflow: auto; }

/* Broadcast: device-agent setup card */
.agent-setup { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.agent-setup h3 { margin: 0 0 6px; }
.agent-setup p { margin: 0 0 12px; }
.agent-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; font-size: 14px; line-height: 1.5; }
.agent-steps code { display: inline-block; background: var(--surface-3); border-radius: 6px; padding: 2px 7px; font-size: 12.5px; margin-top: 4px; -webkit-user-select: all; user-select: all; }
.agent-setup .btn-primary { text-decoration: none; }
.agent-os-tabs { display: flex; gap: 6px; margin: 4px 0 14px; }
#agent-recheck { margin-top: 16px; }

/* Employees don't see vendor-only features (also enforced server-side) */
body[data-role="employee"] .vendor-only { display: none !important; }

/* Staff (vendor) */
.staff-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.staff-row.disabled { opacity: .6; }
.staff-row .staff-name { font-weight: 600; }
.staff-row .staff-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.staff-row .spacer { flex: 1; }
.staff-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.cmd-row { display: flex; align-items: stretch; gap: 8px; margin: 8px 0 4px; }
.cmd-row .cmd { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: var(--surface-2, #111); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text); -webkit-user-select: all; user-select: all; }
.cmd-row .btn { flex: 0 0 auto; align-self: center; }
