/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f4f1; --surface: #fcfcfb; --surface-2: #f0efec; --border: #e2e1dc;
  --text: #0b0b0b; --text-2: #52514e; --text-3: #8a8985;
  --accent: #2a78d6; --accent-soft: #e3eefb;
  --good: #008300; --good-soft: #e3f3e3; --warn: #c98500; --warn-soft: #fff3d6; --bad: #e34948; --bad-soft: #fde5e5;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-6: #8a63d2;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --font: "Inter", "IBM Plex Sans Arabic", -apple-system, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.55; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; } h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
p { margin: 0; } small, .muted { font-size: 12px; color: var(--text-2); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* ---------- Public pages (login, sign-up, setup) ---------- */
.public { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card-auth { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.card-auth.wide { width: min(640px, 100%); }
.card-auth .brand { justify-content: center; margin-bottom: 8px; font-size: 20px; }
.card-auth h1 { text-align: center; font-size: 20px; margin-bottom: 4px; }
.card-auth .sub { text-align: center; color: var(--text-2); margin-bottom: 20px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; }
.demo-box { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--border); text-align: center; }
.demo-box .row { justify-content: center; margin-top: 8px; }
.steps { display: flex; gap: 6px; justify-content: center; margin-bottom: 20px; }
.steps span { width: 36px; height: 4px; border-radius: 2px; background: var(--border); }
.steps span.on { background: var(--accent); }

/* ---------- Layout ---------- */
.topbar { display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--text); color: #fff; font-size: 15px; }
.topbar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-chip .avatar, .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; flex: none; }
.user-chip small { display: block; line-height: 1.1; }
.btn.menu-btn { display: none; }
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 56px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.sidebar a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar a.soon { color: var(--text-3); }
.sidebar a .count { margin-left: auto; font-size: 11px; background: var(--surface-2); padding: 0 7px; border-radius: 10px; color: var(--text-2); }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 14px 12px 4px; }
.side-note { margin: 18px 12px 0; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 12px; color: var(--text-3); }
.content { padding: 24px 28px 60px; min-width: 0; max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--text-2); margin-top: 2px; }

/* ---------- Building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.filters select, .filters input { width: auto; flex: 0 1 auto; }
.filters input[type=search] { flex: 1 1 220px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.stat .label { font-size: 12px; color: var(--text-2); }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 2px; }
.stat .hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 500; background: var(--surface-2); color: var(--text-2); }
.badge.green { background: var(--good-soft); color: var(--good); } .badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--bad-soft); color: var(--bad); } .badge.blue { background: var(--accent-soft); color: var(--accent); }
.tag { display: inline-block; padding: 0 7px; border-radius: 6px; font-size: 11.5px; background: var(--surface-2); color: var(--text-2); }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: #1d4f8f; font-size: 13px; }
.notice.warn { background: var(--warn-soft); color: #7a5200; } .notice.bad { background: var(--bad-soft); color: #9b2423; } .notice.good { background: var(--good-soft); color: #105c10; }
.empty { text-align: center; color: var(--text-3); padding: 28px 10px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.cat-dot { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-size: 14px; flex: none; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13px; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- Buttons + forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--text); color: #fff; border-color: var(--text); } .btn-primary:hover { background: #2b2b2b; }
.btn-danger { color: var(--bad); border-color: #f2b9b8; } .btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.form { display: grid; gap: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }
.field .help { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.field .err { font-size: 12px; color: var(--bad); margin-top: 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font: inherit; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; }
.money-input { display: flex; } .money-input input { border-radius: 8px 0 0 8px; text-align: right; font-variant-numeric: tabular-nums; }
.money-input span { padding: 9px 11px; border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font: inherit; font-weight: 500; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr[data-href] { cursor: pointer; } tr[data-href]:hover td { background: var(--surface-2); }
td.r, th.r { text-align: right; }
.day-head td { background: var(--surface-2); font-size: 12px; color: var(--text-2); font-weight: 500; padding: 6px 10px; }

/* ---------- Wallet cards ---------- */
.wallets { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.wallet { position: relative; border-radius: 12px; padding: 16px; color: #fff; min-height: 128px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; box-shadow: var(--shadow); }
.wallet:hover { filter: brightness(1.05); }
.wallet .w-type { font-size: 12px; opacity: .85; }
.wallet .w-name { font-weight: 600; font-size: 15px; }
.wallet .w-bal { font-size: 22px; font-weight: 600; }
.wallet .w-cur { position: absolute; top: 14px; right: 14px; font-size: 11px; background: rgba(255,255,255,.2); padding: 1px 8px; border-radius: 8px; }
.wallet.add { background: transparent; color: var(--text-2); border: 2px dashed var(--border); box-shadow: none; align-items: center; justify-content: center; }

/* ---------- Charts ---------- */
.donut-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.legend { display: grid; gap: 6px; font-size: 13px; flex: 1; min-width: 200px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .num { margin-left: auto; }

/* ---------- Modal + toast ---------- */
.modal-root { position: fixed; inset: 0; background: rgba(10,10,10,.35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); }
.toast button { margin-left: 12px; background: none; border: 0; color: #9cc5ff; font: inherit; cursor: pointer; }

/* ---------- Chart tooltip ---------- */
.chart-tip { position: absolute; min-width: 170px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; pointer-events: none; }
.chart-tip b { display: block; margin-bottom: 4px; color: var(--text-2); font-weight: 500; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row i { width: 10px; height: 2px; flex: none; }
.tip-row strong { font-variant-numeric: tabular-nums; color: var(--text); }
.tip-row span { color: var(--text-2); margin-left: auto; }
.bar-mark { transition: opacity .1s; outline: none; }

/* ---------- Telegram mock ---------- */
.tg { background: #e6ebee; border-radius: 12px; padding: 14px; display: grid; gap: 8px; font-size: 13px; }
.tg .msg { max-width: 80%; padding: 7px 11px; border-radius: 10px; background: #fff; }
.tg .msg.me { justify-self: end; background: #e1ffc7; }
.tg .btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tg .btns span { background: #f1f4f6; border-radius: 6px; padding: 3px 9px; font-size: 12px; color: #2a6db0; }

/* ---------- Phone width ---------- */
@media (max-width: 860px) {
  .btn.menu-btn { display: inline-flex; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 56px; left: 0; width: 250px; z-index: 30; transform: translateX(-100%); transition: transform .15s; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 18px 16px 60px; }
  .g2, .g3, .g4, .form-row { grid-template-columns: minmax(0, 1fr); }
  td { padding: 8px 6px; }
  .col-when, th:nth-child(3):not(:last-child) { display: none; }
  .ask-table tr { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 6px 0; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .ask-table td { border: 0; padding: 0 4px; width: auto !important; }
  .ask-table td:nth-child(n+3) { grid-column: 2; text-align: left; }
  .topbar { padding: 0 12px; gap: 8px; }
  .brand-name, .user-chip div, #logoutBtn { display: none; }
  .card-auth { padding: 24px 18px; }
}

/* ---------- Laravel build additions ---------- */
.field .err, div.err { font-size: 12px; color: var(--bad); margin-top: 4px; }
.modal-root[hidden] { display: none; }
.inline-form { display: inline; }
.chart-tip { position: absolute; min-width: 170px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; pointer-events: none; }
.chart-tip b { display: block; margin-bottom: 4px; color: var(--text-2); font-weight: 500; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row i { width: 10px; height: 2px; flex: none; }
.tip-row strong { font-variant-numeric: tabular-nums; color: var(--text); }
.tip-row span { color: var(--text-2); margin-left: auto; }
.bar-mark { outline: none; }
.ask-table td { vertical-align: middle; }
@media (max-width: 860px) {
  .ask-table tr { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 6px 0; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .ask-table td { border: 0; padding: 0 4px; width: auto !important; }
  .ask-table td:nth-child(n+3) { grid-column: 2; text-align: left; }
}
