@font-face {
  font-family: "YekanBakhFaNum";
  src: url("/fonts/YekanBakhFaNum-Regular.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "YekanBakhFaNum";
  src: url("/fonts/YekanBakhFaNum-Bold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #0d1117;
  --bg-2: #010409;
  --card: #161b22;
  --card-2: #1c2128;
  --line: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --brand: #2f81f7;
  --brand-2: #1f6feb;
  --accent: #58a6ff;
  --up: #3fb950;
  --down: #f85149;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
  --gradient: linear-gradient(135deg, var(--brand-2), var(--brand));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "YekanBakhFaNum", "Segoe UI", Tahoma, system-ui, sans-serif;
  background: radial-gradient(130% 90% at 100% 0%, #10233f 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(14px + var(--safe-top)) 20px 14px;
  background: rgba(1, 4, 9, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 30px; height: 30px; border-radius: 8px; display: block;
  box-shadow: 0 4px 14px rgba(31, 111, 235, 0.35);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }

.view { flex: 1; padding: 18px 16px 96px; max-width: 640px; width: 100%; margin: 0 auto; }
.greeting { margin: 6px 2px 2px; }
.greeting .hi { font-size: 13px; color: var(--muted); }
.greeting .who { font-size: 20px; font-weight: 700; margin-top: 2px; }
.section-title { font-size: 13px; color: var(--muted); margin: 22px 4px 12px; }

.notice {
  display: flex; align-items: center; gap: 12px;
  margin-top: 16px; padding: 14px 16px; width: 100%; text-align: right;
  border: 1px solid var(--brand-2); border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(31, 111, 235, 0.12), rgba(31, 111, 235, 0.04));
  color: var(--text); font-family: inherit; font-size: 14px; cursor: pointer;
}
.notice .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; box-shadow: 0 0 8px var(--brand); }
.notice .chev { margin-inline-start: auto; color: var(--muted); }

.range { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; }
.range button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 7px 16px; border-radius: 999px; cursor: pointer; }
.range button.on { background: var(--gradient); color: #fff; font-weight: 700; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card .label { font-size: 13px; color: var(--muted); }
.card .value { font-size: 28px; font-weight: 700; margin-top: 8px; letter-spacing: 0.5px; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; margin-top: 8px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--muted); }
.card.full { grid-column: 1 / -1; }
.card.wide { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.card.query .q { font-size: 18px; font-weight: 700; }
.card.query .rank { margin-inline-start: auto; text-align: center; }
.card.query .rank b { font-size: 24px; display: block; color: var(--accent); }
.card .updated { font-size: 11px; color: var(--muted); margin-top: 4px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.item .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; color: var(--accent); background: rgba(31, 111, 235, 0.1); flex: none; }
.item .ico svg { width: 20px; height: 20px; }
.item .meta { min-width: 0; }
.item .meta .t { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item .go { margin-inline-start: auto; color: var(--accent); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }

.invoice-hero {
  background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); text-align: center;
}
.invoice-hero .amt { font-size: 32px; font-weight: 700; margin: 6px 0; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px; }
.chip.open { background: rgba(88, 166, 255, 0.15); color: var(--accent); }
.chip.overdue { background: rgba(248, 81, 73, 0.15); color: var(--down); }
.chip.locked { background: rgba(248, 81, 73, 0.2); color: var(--down); }
.chip.paid { background: rgba(63, 185, 80, 0.15); color: var(--up); }
.btn {
  display: block; width: 100%; margin-top: 16px; padding: 15px;
  border: 0; border-radius: var(--radius-sm); font: inherit; font-weight: 700; font-size: 16px;
  color: #fff; background: var(--gradient); cursor: pointer;
}
.btn:disabled { opacity: 0.5; }
.payinfo { margin-top: 14px; padding: 14px; border: 1px dashed var(--line); border-radius: var(--radius-sm); font-size: 14px; white-space: pre-wrap; text-align: right; }

.empty, .locked-note { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty .big, .locked-note .big { font-size: 40px; color: var(--accent); margin-bottom: 8px; }
.empty .big svg, .locked-note .big svg { width: 40px; height: 40px; }
.loader { display: grid; place-items: center; padding: 80px 0; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
[data-state="loading"] .tabbar, [data-state="loading"] #tabbar { display: none; }

.tabbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(1, 4, 9, 0.9); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 0; cursor: pointer; transition: color 0.2s; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--brand); }

@media (max-width: 360px) { .card .value { font-size: 24px; } }
