/* ---------- Billit admin design system ---------- */
/* Light, airy palette: white sidebar, soft borders, indigo accent. */
:root {
  --bg: #fbfcfe;
  --surface: #ffffff;
  --ink: #1e293b;
  --ink-2: #52627a;
  --ink-3: #97a3b6;
  --line: #e8ecf3;
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --brand-soft: #eef2ff;
  --ok: #16a34a;   --ok-bg: #e7f8ee;
  --warn: #d97706; --warn-bg: #fdf3dd;
  --bad: #dc2626;  --bad-bg: #fdeaea;
  --info: #0284c7; --info-bg: #e6f4fc;
  --neutral: #64748b; --neutral-bg: #f3f6fa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 41, 59, .05), 0 6px 20px rgba(30, 41, 59, .04);
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef2ff, #fbfcfe 60%, #f0fdf4);
}
.login-card {
  background: var(--surface); padding: 40px; border-radius: 16px; width: 380px;
  border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(79, 70, 229, .10);
}
.login-card .brand { color: var(--ink); padding: 0; }
.login-card h1 { font-size: 22px; margin: 12px 0 4px; }
.login-card p { margin-bottom: 20px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 14px 0 4px; }
.login-card input { width: 100%; }
.login-card .btn { margin-top: 22px; }
.error-text { color: var(--bad); font-size: 13px; margin-top: 12px; min-height: 18px; }
.login-card .lang-toggle { margin-top: 10px; width: 100%; justify-content: center; color: var(--ink-3); }
.login-card .help-line { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.login-card .link-box { margin: 2px 0 6px; }

/* ---------- Shell layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--surface); color: var(--ink-2);
  border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 12px; position: sticky; top: 0; height: 100vh;
  transition: width .18s ease;
}
.brand-row { display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 19px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; padding: 0 10px; }
.brand-mark { color: var(--brand); }
.collapse-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-3); cursor: pointer;
  border-radius: 8px; width: 26px; height: 26px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.collapse-btn:hover { background: var(--neutral-bg); color: var(--ink-2); }
.collapse-btn svg { width: 15px; height: 15px; transition: transform .18s ease; }
.collapse-btn svg.flip { transform: scaleX(-1); }

/* Line icons: consistent stroke weight/size across the sidebar, matching a Stripe/ChatGPT-style menu. */
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.profile-chevron { width: 15px; height: 15px; flex-shrink: 0; color: var(--ink-3); }
[dir="rtl"] .profile-chevron { transform: scaleX(-1); }

/* Collapsed sidebar: icons only, labels move into tooltips. */
.shell.collapsed .sidebar { width: 64px; padding-inline: 8px; }
.shell.collapsed .brand-row { flex-direction: column; gap: 10px; }
.shell.collapsed .brand { padding: 0; }
.shell.collapsed .brand-name,
.shell.collapsed #nav a span,
.shell.collapsed .nav-section,
.shell.collapsed #user-info { display: none; }
.shell.collapsed #nav a { justify-content: center; padding: 9px 4px; }
.shell.collapsed .sidebar-footer .btn { padding: 5px 4px; font-size: 15px; overflow: hidden; white-space: nowrap; }
.sidebar nav { margin-top: 24px; flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar nav a {
  color: var(--ink-2); padding: 9px 10px; border-radius: 8px; font-weight: 500; text-decoration: none;
  display: flex; align-items: center; gap: 10px;
}
.sidebar nav a:hover { background: var(--neutral-bg); text-decoration: none; }
.sidebar nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 16px 10px 4px; }
.sidebar-footer { border-top: 1px solid var(--line); padding: 10px 4px 0; display: flex; flex-direction: column; gap: 8px; }
.sidebar-footer .muted { color: var(--ink-3); }

/* Profile card: avatar + identity, opens Settings. */
.profile-card {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px;
  color: var(--ink); text-decoration: none;
}
.profile-card:hover { background: var(--neutral-bg); text-decoration: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), #8b5cf6); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.profile-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.profile-info b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-info span { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-chevron { margin-inline-start: auto; }
.footer-actions { display: flex; gap: 6px; }
.footer-actions .btn { flex: 1; justify-content: center; padding: 6px 4px; }
.shell.collapsed .profile-info, .shell.collapsed .profile-chevron, .shell.collapsed .footer-actions { display: none; }
.shell.collapsed .profile-card { justify-content: center; padding: 6px 0; }
.main { flex: 1; padding: 28px 32px; max-width: 1280px; }

/* ---------- Typography / page chrome ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--ink-2); margin-top: 2px; }
.breadcrumb { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.breadcrumb a { color: var(--ink-3); }

/* ---------- Cards, grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.card .card-head h2 { font-size: 15px; }
.card .card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .grid.cols-3 { grid-template-columns: 1fr; } }

.stat { padding: 18px; }
.stat .label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .value.ok { color: var(--ok); } .stat .value.bad { color: var(--bad); } .stat .value.warn { color: var(--warn); }
.stat .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: start; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: #f8fafc; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
/* Amounts and identifiers are always LTR runs, even inside RTL text. */
.amount-pos, .amount-neg, .mono { unicode-bidi: isolate; }
.amount-pos { color: var(--ok); font-weight: 600; }
.amount-neg { color: var(--bad); font-weight: 600; }
.empty { padding: 32px; text-align: center; color: var(--ink-3); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 3px 10px; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.brand { background: #eef2ff; color: var(--brand-dark); }

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 13.5px; font-weight: 600; border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { background: var(--neutral-bg); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  font: inherit; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--brand); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters input, .filters select { min-width: 140px; }

/* ---------- Forms in modals ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; }
.field .help { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex;
  align-items: flex-start; justify-content: center; padding: 60px 20px; z-index: 100; overflow-y: auto;
}
.modal { background: var(--surface); border-radius: 14px; width: 560px; max-width: 100%; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.modal.wide { width: 720px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.modal .close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-3); }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 20px; inset-inline-end: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: 380px; animation: slide-in .18s ease-out;
}
.toast.error { background: var(--bad); }
.toast.success { background: var(--ok); }
@keyframes slide-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Misc ---------- */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.section-title { font-size: 15px; font-weight: 700; margin: 4px 0 10px; }
.link-box {
  background: var(--neutral-bg); padding: 10px 12px; border-radius: 8px; font-family: ui-monospace, monospace;
  font-size: 12.5px; word-break: break-all; border: 1px dashed var(--line);
}
/* ---------- Guided tour ---------- */
.tour-root { position: fixed; inset: 0; z-index: 300; }
.tour-spotlight {
  position: fixed; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, .55), 0 0 0 3px var(--brand);
  transition: all .25s ease;
}
.tour-card {
  position: fixed; width: 430px; max-width: calc(100vw - 32px);
  background: var(--surface); border-radius: 14px; padding: 20px 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35); transition: top .25s ease, left .25s ease;
}
.tour-progress { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); }
.tour-card h3 { font-size: 17px; margin: 6px 0 8px; color: var(--ink); }
.tour-card p { color: var(--ink-2); font-size: 13.5px; }
.tour-card code { background: var(--neutral-bg); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.tour-dots { display: flex; gap: 5px; margin: 14px 0 4px; }
.tour-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tour-dots span.past { background: #c7d2fe; }
.tour-dots span.on { background: var(--brand); }
.tour-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

.plan-card { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.plan-card .price { font-size: 24px; font-weight: 700; }
.plan-card .price span { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.plan-card ul { padding-inline-start: 18px; color: var(--ink-2); }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tree-indent { color: var(--ink-3); }
