/* Wared on a computer: the app's palette (ui/theme/Color.kt). Teal structure, gold accents, red
   for errors only. No gradients, no side-stripe cards. */
:root {
  --teal: #0F766E;
  --teal-strong: #0B5953;
  --on-teal: #FFFFFF;
  --gold: #D4A017;
  --gold-text: #7A5C00;
  --bg: #F5F8F7;
  --surface: #FFFFFF;
  --surface-2: #EFF4F3;
  --surface-3: #E3ECEA;
  --ink: #101B1A;
  --muted: #475856;
  --line: #D3DFDC;
  --hairline: #E3ECEA;
  --teal-soft: #CCF3EE;
  --on-teal-soft: #042F2C;
  --selected: #E6F6F3;
  --gold-soft: #FBEFC4;
  --on-gold-soft: #3D2E00;
  --error: #B42318;
  --error-soft: #FDE7E5;
  --on-error-soft: #5A0D07;
  --radius: 16px;
  --radius-s: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --teal: #2DD4BF; --teal-strong: #5EEAD4; --on-teal: #00201D; --gold: #F2C94C; --gold-text: #F2C94C;
    --bg: #0A1312; --surface: #111D1C; --surface-2: #162423; --surface-3: #1D2E2C; --ink: #E6F0EE;
    --muted: #A3B6B3; --line: #2A3D3B; --hairline: #1D2E2C; --teal-soft: #0D4F4A; --on-teal-soft: #CCF3EE;
    --selected: #12332F; --gold-soft: #4D3A00; --on-gold-soft: #FBEFC4; --error: #FF8A80;
    --error-soft: #5A0D07; --on-error-soft: #FDE7E5; color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --teal: #2DD4BF; --teal-strong: #5EEAD4; --on-teal: #00201D; --gold: #F2C94C; --gold-text: #F2C94C;
  --bg: #0A1312; --surface: #111D1C; --surface-2: #162423; --surface-3: #1D2E2C; --ink: #E6F0EE;
  --muted: #A3B6B3; --line: #2A3D3B; --hairline: #1D2E2C; --teal-soft: #0D4F4A; --on-teal-soft: #CCF3EE;
  --selected: #12332F; --gold-soft: #4D3A00; --on-gold-soft: #FBEFC4; --error: #FF8A80;
  --error-soft: #5A0D07; --on-error-soft: #FDE7E5; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
h1, h2 { margin: 0; line-height: 1.3; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--teal); }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.strong { font-weight: 600; }
.center { text-align: center; align-self: center; }
.grow { flex: 1 1 auto; }
.nowrap { white-space: nowrap; }
.gold-text { color: var(--gold-text); font-weight: 600; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.pad { padding: 16px 20px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
bdi { unicode-bidi: isolate; }

.skip { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { inset-inline-start: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--teal) 55%, transparent); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  max-width: 1360px; margin: 0 auto; padding: 0 24px; min-height: 64px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
}
#header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
#header:empty { display: none; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand > div { display: flex; flex-direction: column; line-height: 1.3; }
.brand strong { font-size: 1rem; }
.brand span { font-size: 0.85rem; color: var(--muted); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--teal-soft); display: grid; place-items: center; }
.tabs { display: flex; gap: 4px; align-self: stretch; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; min-height: 64px;
  border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); cursor: pointer; font-size: 0.95rem;
}
.tab:hover { color: var(--ink); background: var(--bg); }
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--teal); }
.count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--gold-soft); color: var(--on-gold-soft); font-size: 0.75rem; font-weight: 600; display: inline-grid; place-items: center; }
.live { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 16px; background: var(--teal-soft); color: var(--on-teal-soft); font-size: 0.82rem; font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--teal); flex: none; }
.dot.off { background: var(--gold); }
.account { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 15px; background: var(--gold-soft); color: var(--on-gold-soft); display: grid; place-items: center; font-size: 0.85rem; font-weight: 600; }
.account-name { font-size: 0.9rem; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; display: grid; place-items: center; cursor: pointer; }
.icon-button:hover { background: var(--surface-2); }
.icon-button.framed { border: 1px solid var(--line); background: var(--surface); }
.offline { background: var(--gold-soft); color: var(--on-gold-soft); text-align: center; padding: 8px 16px; font-size: 0.9rem; }

/* ---------- Layout ---------- */
.main { max-width: 1360px; margin: 0 auto; padding: 24px; display: block; outline: none; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.page-head h1 { font-size: 1.6rem; }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; margin-top: 16px; }
.stack .split { margin-top: 0; }
.split-main { flex: 999 1 560px; min-width: 0; }
.split-side { flex: 1 1 340px; min-width: 0; max-width: 100%; position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; }
.columns { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.grow-2 { flex: 999 1 560px; min-width: 0; }
.grow-1 { flex: 1 1 320px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--hairline); }

/* ---------- Controls ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 0.92rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.button.primary { background: var(--teal); color: var(--on-teal); }
.button.primary:hover { background: var(--teal-strong); }
.button.secondary { background: var(--surface); color: var(--teal); border-color: var(--teal); }
.button.secondary:hover { background: var(--teal-soft); }
.button.block { width: 100%; }
.button.large { min-height: 50px; font-size: 1rem; border-radius: 12px; }
.button:disabled { opacity: 0.5; cursor: default; }
.link-button { border: 0; background: none; color: var(--teal); font-weight: 600; cursor: pointer; padding: 8px 2px; font-size: 0.9rem; }
.link-button:hover { text-decoration: underline; }
.link-button.start { align-self: flex-start; }
kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--surface);
  font-family: "IBM Plex Mono", monospace; font-size: 0.75rem; color: var(--muted);
}
kbd.on-primary { background: var(--teal-strong); border-color: transparent; color: var(--on-teal); }
.segments { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 12px; }
.segment { height: 36px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.segment.active { background: var(--surface); color: var(--ink); }
.search-box { flex: 0 1 320px; min-width: 200px; height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.search { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 0.92rem; }
.select { height: 40px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 0.9rem; color: var(--muted); }
.select select { border: 0; background: transparent; color: var(--ink); outline: none; }
.chips { display: flex; gap: 8px; align-items: center; }
.chips.scroll { overflow-x: auto; max-width: 100%; }
.chips.wrap { flex-wrap: wrap; }
.filter-chip { height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface); font-size: 0.9rem; white-space: nowrap; cursor: pointer; }
.filter-chip.active { border-color: var(--teal); background: var(--teal-soft); color: var(--on-teal-soft); font-weight: 600; }
.filter-chip.gold { border-color: var(--gold); background: var(--gold-soft); color: var(--on-gold-soft); }
.filter-chip.gold.active { font-weight: 700; }
.ref-chip {
  height: 34px; display: inline-flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 17px; background: var(--surface); cursor: pointer; font-family: "IBM Plex Mono", monospace; font-size: 0.82rem; white-space: nowrap;
}
.ref-chip:hover { background: var(--teal-soft); }
.ref-chip.large { height: 44px; border-radius: 22px; padding: 0 14px; font-size: 1rem; }
.pill { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 13px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.pill-new { background: var(--teal-soft); color: var(--on-teal-soft); }
.pill-gold { background: var(--gold-soft); color: var(--on-gold-soft); }
.pill-used { background: var(--surface-3); color: var(--muted); }

/* ---------- Payments (branch) ---------- */
.pay-list { display: flex; flex-direction: column; }
.pay-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 80px 130px; gap: 16px; align-items: center;
  min-height: 72px; padding: 10px 20px; border-bottom: 1px solid var(--hairline);
}
.pay-row:last-child { border-bottom: 0; }
.pay-row.selected { background: var(--selected); }
.pay-main { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; padding: 4px 0; border: 0; background: none; text-align: start; cursor: pointer; }
.pay-sender { font-weight: 600; }
.pay-body { color: var(--muted); font-size: 0.85rem; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; }
.pay-time { font-size: 0.85rem; color: var(--muted); }
.pay-time.fresh { color: var(--gold-text); font-weight: 700; }
.pay-row > .button, .pay-row > .end { justify-self: end; }
.shortcuts { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 12px; font-size: 0.85rem; color: var(--muted); }
.shortcuts span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Detail panel ---------- */
.split-side { display: flex; flex-direction: column; gap: 18px; }
.detail-head { display: flex; flex-direction: column; gap: 4px; }
.detail-sender { font-size: 1.35rem; font-weight: 700; }
.detail-block { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px solid var(--hairline); }
.detail-block:first-of-type { border-top: 0; padding-top: 0; }
.label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.message-text { padding: 14px 16px; background: var(--bg); border-radius: 12px; font-size: 0.92rem; line-height: 1.8; white-space: pre-wrap; user-select: text; overflow-wrap: anywhere; }
.message-text.raw { background: var(--gold-soft); color: var(--on-gold-soft); }
.use-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.85rem; font-weight: 500; }
.field input, .field select, .use-form select {
  height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 0.95rem; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 20%, transparent); }
.field input[aria-invalid="true"] { border-color: var(--error); }
.field-hint { font-size: 0.8rem; color: var(--muted); }
.field-error { font-size: 0.8rem; color: var(--error); }
.field-error:empty { display: none; }
.used-box { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--surface-3); border-radius: 12px; font-size: 0.9rem; }
.history { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.history li { display: flex; justify-content: space-between; gap: 12px; font-size: 0.88rem; }

/* ---------- Admin ---------- */
.receivers { display: flex; flex-direction: column; gap: 8px; }
.status-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 0.92rem; }
.status-row.warn { background: var(--gold-soft); border-color: transparent; color: var(--on-gold-soft); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 18px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: start; font: inherit; color: inherit; }
.stat span { font-size: 0.9rem; color: var(--muted); }
.stat strong { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat.primary { background: var(--teal); border-color: var(--teal); color: var(--on-teal); }
.stat.primary span { color: var(--teal-soft); }
.stat.gold { background: var(--gold-soft); border-color: transparent; color: var(--on-gold-soft); cursor: pointer; }
.stat.gold span { color: var(--on-gold-soft); }
.stat.gold.calm { background: var(--surface); border-color: var(--line); color: var(--ink); }
.stat .stat-action { color: var(--teal); font-weight: 600; }
.mini-list { display: flex; flex-direction: column; }
.mini-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: center; padding: 12px 20px; border: 0; border-bottom: 1px solid var(--hairline); background: none; text-align: start; cursor: pointer; }
.mini-row:hover { background: var(--bg); }
.mini-main { display: flex; flex-direction: column; min-width: 0; }
.branch-row { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--hairline); font-size: 0.92rem; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: start; font-weight: 500; color: var(--muted); font-size: 0.82rem; padding: 12px; border-bottom: 1px solid var(--hairline); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-inline-start: 20px; }
.table tr.selected { background: var(--selected); }
.cell-button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 360px; border: 0; background: none; padding: 4px 0; text-align: start; cursor: pointer; }
.table-foot { padding: 12px 20px; }

/* ---------- States ---------- */
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 64px 16px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--teal-soft); border-top-color: var(--teal); animation: spin 0.9s linear infinite; flex: none; }
.spinner.small { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 16px; text-align: center; color: var(--muted); }
.empty strong { color: var(--ink); font-size: 1.05rem; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 0.9rem; }
.notice-info { background: var(--surface-2); }
.notice-success { background: var(--teal-soft); color: var(--on-teal-soft); }
.notice-warning { background: var(--gold-soft); color: var(--on-gold-soft); }
.notice-error { background: var(--error-soft); color: var(--on-error-soft); }
.gate { max-width: 520px; margin: 48px auto; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 40px 32px; }
.gate p { color: var(--muted); }
.toasts { position: fixed; inset-inline: 0; bottom: 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 20; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 560px; padding: 12px 16px; border-radius: 12px; background: #253331; color: #EAF2F0; font-size: 0.92rem; animation: rise 0.2s ease-out; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: 0.25s; }
.toast-error { background: var(--error-soft); color: var(--on-error-soft); }
.toast-action { margin-inline-start: 8px; border: 0; background: none; color: #5EEAD4; font-weight: 700; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.toast-action:hover { background: rgba(255, 255, 255, 0.08); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.dialog { border: 0; border-radius: 16px; padding: 0; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
.dialog::backdrop { background: rgba(16, 27, 26, 0.45); }
.dialog header, .dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 20px; }
.dialog-body { padding: 0 20px 8px; }

/* ---------- Signed out ---------- */
.auth-page { min-height: calc(100vh - 48px); display: grid; place-items: center; padding: 24px 0; }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 36px 32px; display: flex; flex-direction: column; gap: 20px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 1.5rem; }
.auth-brand .brand-mark { width: 48px; height: 48px; border-radius: 14px; }
.auth-head { display: flex; flex-direction: column; gap: 8px; }
.auth-head p { color: var(--muted); line-height: 1.8; }
.badge-icon { width: 64px; height: 64px; border-radius: 18px; background: var(--teal-soft); display: grid; place-items: center; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.input-with-button { position: relative; }
.input-with-button input { padding-inline-end: 48px; }
.reveal { position: absolute; inset-inline-end: 2px; top: 2px; width: 42px; height: 42px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; border-radius: 8px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 0.9rem; line-height: 1.7; }
.check input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--teal); }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.85rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }
.switch { text-align: center; font-size: 0.92rem; }
.legal { font-size: 0.8rem; color: var(--muted); text-align: center; }
.back { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px 0; }
.waiting { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-size: 0.9rem; }
.general:empty { display: none; }
.general { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Narrow screens ---------- */
@media (max-width: 720px) {
  .topbar { padding: 8px 16px; }
  .main { padding: 16px; }
  .live, .account-name { display: none; }
  .pay-row { grid-template-columns: minmax(0, 1fr) auto; }
  .pay-row .chips { grid-column: 1 / -1; }
  .shortcuts { display: none; }
  .split-side { position: static; max-height: none; }
  .search-box { flex: 1 1 100%; }
  .auth-card { padding: 28px 20px; }
}
