/* ===== راتبي — design tokens (Dark OLED + Trust blue / profit green) ===== */
:root {
  --bg: #070d19;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f2f6ff;
  --muted: #93a0ba;
  --primary: #1e40af;
  --primary-2: #3b82f6;
  --primary-grad: linear-gradient(135deg, #2563eb, #60a5fa);
  --accent: #059669;
  --accent-2: #34d399;
  --accent-grad: linear-gradient(135deg, #059669, #34d399);
  --danger: #dc2626;
  --warn: #f59e0b;
  --warn-2: #fbbf24;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  --glow: radial-gradient(ellipse at 50% 0%, rgba(37, 99, 235, 0.35), transparent 62%);
  --nav-bg: rgba(7, 13, 25, 0.86);
  --font-body: 'Noto Sans Arabic', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Noto Naskh Arabic', 'Noto Sans Arabic', ui-serif, serif;
}

[data-theme='light'] {
  --bg: #eef2f9;
  --surface: #ffffff;
  --surface-2: #f4f7fc;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.2);
  --text: #0f172a;
  --muted: #5a6780;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 44px rgba(15, 23, 42, 0.14);
  --glow: radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.18), transparent 62%);
  --nav-bg: rgba(238, 242, 249, 0.9);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}
.glow { position: fixed; inset: -30% -20% auto -20%; height: 72vh; pointer-events: none; z-index: 0; background: var(--glow); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.25; }
svg { flex-shrink: 0; }

/* ===== layout ===== */
.section { max-width: 1180px; margin: 0 auto; padding: 2.5rem 1.5rem; position: relative; z-index: 1; }
.stack { display: flex; flex-direction: column; gap: 1.25rem; }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.spacer { flex: 1; }
.mt { margin-top: 1.1rem; }

/* ===== card ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); backdrop-filter: blur(14px);
  box-shadow: var(--shadow); padding: 1.5rem;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.card.hoverable:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.card-title { font-size: 1.12rem; display: flex; align-items: center; gap: 0.5rem; }
.card-sub { color: var(--muted); font-size: 0.86rem; margin-top: 0.2rem; }
.span-all { grid-column: 1 / -1; }

/* ===== buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 44px; padding: 0.6rem 1.3rem; border-radius: 999px;
  font-family: var(--font-body); font-size: 0.92rem; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-primary { background: var(--primary-grad); color: #fff; box-shadow: 0 8px 26px rgba(37, 99, 235, 0.32); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(37, 99, 235, 0.45); }
.btn-accent { background: var(--accent-grad); color: #04140d; box-shadow: 0 8px 26px rgba(5, 150, 105, 0.28); }
.btn-accent:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(5, 150, 105, 0.4); }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); transform: translateY(-2px); }
.btn-icon {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border-radius: 50%; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); cursor: pointer;
  transition: transform 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-2px); }
.btn-icon.danger:hover { color: #f87171; border-color: var(--danger); }
.btn-sm { min-height: 38px; padding: 0.35rem 0.9rem; font-size: 0.82rem; }
.btn:focus-visible, .btn-icon:focus-visible, .tab:focus-visible, .chip:focus-visible,
input:focus-visible, select:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; }

/* ===== forms ===== */
label.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 0.6rem 0.9rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font-body); font-size: 0.95rem; outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input[type='number'], input[type='date'] { direction: ltr; text-align: right; }
input::placeholder { color: var(--muted); opacity: 0.75; }
input:focus, select:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18); }
input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14); }
.field-error { color: #f87171; font-size: 0.78rem; }
.money-input { position: relative; display: block; }
.money-input .suffix { position: absolute; right: 0.85rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.82rem; pointer-events: none; }
.money-input input { padding-right: 3rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }

/* ===== navbar ===== */
.navbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.6rem 1.5rem; min-height: 64px;
  background: var(--nav-bg);
  backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.55rem; font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  background: var(--primary-grad); color: #fff; box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}
.nav-tabs { display: flex; gap: 0.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0.25rem; }
.tab {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 1rem; min-height: 40px;
  border-radius: 999px; border: none; background: transparent; color: var(--muted);
  font-family: var(--font-body); font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--primary-grad); color: #fff; box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28); }
.nav-select { width: auto; min-height: 40px; padding: 0.35rem 0.7rem; font-size: 0.85rem; border-radius: 999px; }

/* ===== hero ===== */
.hero { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 3rem 1.5rem 0.5rem; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.85rem; border-radius: 999px;
  background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-2); font-size: 0.78rem; font-weight: 600;
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); animation: pulse 2.2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }
.hero h1 { font-size: clamp(1.85rem, 4.4vw, 3rem); margin: 1rem 0 0.75rem; }
.hero h1 .grad { background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: clamp(0.95rem, 2vw, 1.06rem); max-width: 64ch; }
.hero-bar { margin-top: 1.5rem; }
.month-label { min-width: 138px; text-align: center; font-family: var(--font-head); }
.hero-usage { margin-top: 1.1rem; }

/* ===== stat cards ===== */
.stat { display: flex; flex-direction: column; gap: 0.4rem; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.stat-chip {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  background: rgba(59, 130, 246, 0.14); color: var(--primary-2);
  font-weight: 700; font-size: 0.9rem; font-family: var(--font-head);
}
.stat-label { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.stat-value { font-size: clamp(1.2rem, 3vw, 1.65rem); font-weight: 700; font-family: var(--font-head); direction: ltr; text-align: right; }
.stat-value.green { color: var(--accent-2); }
.stat-value.red { color: #f87171; }
.stat-value.amber { color: var(--warn-2); }
.stat-foot { font-size: 0.78rem; color: var(--muted); }

/* ===== progress bars ===== */
.bar { display: block; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
.bar.sm { height: 6px; }

/* ===== chips & badges ===== */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.35rem 0.75rem; min-height: 36px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font-family: var(--font-body); font-size: 0.82rem; cursor: pointer; transition: all 0.18s ease;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.chip.active { background: rgba(59, 130, 246, 0.16); border-color: var(--primary-2); color: var(--text); }
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.74rem; font-weight: 600;
  padding: 0.18rem 0.6rem; border-radius: 999px;
  background: rgba(59, 130, 246, 0.14); color: var(--primary-2);
}
.badge.green { background: rgba(16, 185, 129, 0.14); color: var(--accent-2); }
.badge.red { background: rgba(220, 38, 38, 0.14); color: #f87171; }
.badge.amber { background: rgba(245, 158, 11, 0.16); color: var(--warn-2); }
.badge.muted { background: var(--surface-2); color: var(--muted); }

/* ===== donut & legend ===== */
.donut-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 1.75rem; justify-content: center; }
.donut { position: relative; width: min(238px, 66vw); aspect-ratio: 1; flex-shrink: 0; }
.donut svg { width: 100%; height: 100%; }
.donut circle.seg { transition: stroke-width 0.2s ease, opacity 0.2s ease; cursor: pointer; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 0.05rem; pointer-events: none; }
.donut-center .d-label { color: var(--muted); font-size: 0.76rem; }
.donut-center .d-value { font-weight: 700; font-family: var(--font-head); font-size: 1.05rem; direction: ltr; }
.legend { display: flex; flex-direction: column; gap: 0.5rem; min-width: 250px; flex: 1; }
.legend-item { display: flex; align-items: center; gap: 0.6rem; font-size: 0.86rem; padding: 0.35rem 0.5rem; border-radius: var(--radius-sm); transition: background 0.18s ease; }
.legend-item:hover { background: var(--surface-2); }
.dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.legend-item .lname { flex: 1; }
.legend-item .lpct { color: var(--muted); font-size: 0.78rem; min-width: 42px; }
.legend-item .lval { font-weight: 600; direction: ltr; }

/* ===== list rows ===== */
.list { display: flex; flex-direction: column; gap: 0.6rem; max-height: 470px; overflow-y: auto; padding-inline-end: 0.3rem; }
.list-item {
  display: flex; align-items: center; gap: 0.9rem; padding: 0.8rem 0.95rem;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
  transition: transform 0.18s ease, border-color 0.18s ease; animation: fadeUp 0.35s ease both;
}
.list-item:hover { transform: translateX(-3px); border-color: var(--border-strong); }
.li-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; background: rgba(59, 130, 246, 0.14); color: var(--primary-2); font-weight: 700; font-size: 0.85rem; }
.li-body { flex: 1; min-width: 0; }
.li-title { font-size: 0.92rem; font-weight: 600; }
.li-meta { font-size: 0.76rem; color: var(--muted); display: flex; gap: 0.45rem; flex-wrap: wrap; }
.li-amount { font-weight: 700; direction: ltr; white-space: nowrap; }
.cat-total { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.15rem; border-bottom: 1px dashed var(--border); }
.cat-total:last-child { border-bottom: none; }
.cat-total .ct-name { min-width: 130px; font-size: 0.88rem; display: flex; align-items: center; gap: 0.5rem; }
.cat-total .ct-bar { flex: 1; min-width: 70px; }
.cat-total .ct-val { font-weight: 600; font-size: 0.86rem; direction: ltr; min-width: 96px; text-align: start; }

/* ===== rules / insights ===== */
.rule-row { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.85rem 0; border-bottom: 1px dashed var(--border); }
.rule-row:last-child { border-bottom: none; }
.insight { display: flex; gap: 0.7rem; padding: 0.8rem 0.95rem; border-radius: var(--radius-sm); font-size: 0.88rem; border: 1px solid var(--border); background: var(--surface-2); }
.insight.info { border-inline-start: 3px solid var(--primary-2); }
.insight.good { border-inline-start: 3px solid var(--accent-2); }
.insight.warn { border-inline-start: 3px solid var(--warn); }
.insight.bad { border-inline-start: 3px solid var(--danger); }
.insight .mark { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0; margin-top: 0.25rem; font-size: 0.72rem; font-weight: 700; }
.insight.info .mark { background: rgba(59, 130, 246, 0.2); color: var(--primary-2); }
.insight.good .mark { background: rgba(16, 185, 129, 0.2); color: var(--accent-2); }
.insight.warn .mark { background: rgba(245, 158, 11, 0.2); color: var(--warn-2); }
.insight.bad .mark { background: rgba(220, 38, 38, 0.2); color: #f87171; }

/* ===== toast ===== */
.toast-wrap { position: fixed; bottom: 1.5rem; inset-inline-start: 1.5rem; z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1.1rem; border-radius: var(--radius-sm);
  font-size: 0.88rem; font-weight: 600; box-shadow: var(--shadow-lg); backdrop-filter: blur(12px);
  animation: fadeUp 0.28s ease both;
}
.toast.success { background: rgba(16, 185, 129, 0.16); border: 1px solid rgba(16, 185, 129, 0.4); color: var(--accent-2); }
.toast.error { background: rgba(220, 38, 38, 0.16); border: 1px solid rgba(220, 38, 38, 0.4); color: #f87171; }
.toast.info { background: rgba(59, 130, 246, 0.16); border: 1px solid rgba(59, 130, 246, 0.4); color: var(--primary-2); }

/* ===== empty ===== */
.empty { text-align: center; padding: 2.4rem 1rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 0.45rem; }
.empty-ico { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--surface-2); color: var(--primary-2); font-family: var(--font-head); font-size: 1.4rem; }

/* ===== footer ===== */
.footer { border-top: 1px solid var(--border); margin-top: 2rem; padding: 2rem 1.5rem; text-align: center; color: var(--muted); font-size: 0.84rem; position: relative; z-index: 1; }
.footer strong { color: var(--text); font-weight: 600; }

/* ===== animation ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.d1 { animation-delay: 0.06s; }
.d2 { animation-delay: 0.12s; }
.d3 { animation-delay: 0.18s; }
.d4 { animation-delay: 0.24s; }

/* ===== responsive ===== */
@media (max-width: 900px) {
  .navbar { flex-wrap: wrap; padding: 0.6rem 1rem; }
  .nav-tabs { order: 4; width: 100%; justify-content: space-between; }
  .tab { flex: 1; justify-content: center; font-size: 0.82rem; padding: 0.45rem 0.5rem; }
  .cat-total .ct-name { min-width: 100px; font-size: 0.82rem; }
  .cat-total .ct-val { min-width: 84px; }
}
@media (max-width: 640px) {
  .section { padding: 1.75rem 1rem; }
  .hero { padding: 2rem 1rem 0.5rem; }
  .card { padding: 1.15rem; }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .legend { min-width: 100%; }
  .donut-wrap { gap: 1.2rem; }
  .cat-total .ct-val { min-width: 72px; font-size: 0.76rem; }
  .cat-total .ct-name { min-width: 78px; font-size: 0.76rem; }
}
@media print {
  .navbar, .footer, .toast-wrap, .btn, .btn-icon, .chip-row { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
