/* =============================================================================
   app.css — تصميم أداة «كشف حساب» ورموز الهوية المشتركة. هاتف أولًا، RTL، نهاري/ليلي عبر رموز CSS.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f1f4f7;
  --line: rgba(15, 23, 42, 0.09);
  --line-strong: rgba(15, 23, 42, 0.16);
  --ink: #111827;
  --ink-2: #4b5563;
  --muted: #8a93a3;
  --brand: #0e7c66;
  --brand-ink: #0b5f4f;
  --brand-soft: rgba(14, 124, 102, 0.1);
  --brand-soft-2: rgba(14, 124, 102, 0.18);
  --credit: #0b7a52;
  --credit-soft: rgba(11, 122, 82, 0.1);
  --debit: #c62b2b;
  --debit-soft: rgba(198, 43, 43, 0.09);
  --mark-credit: #199e70;
  --mark-debit: #e66767;
  --hero-a: #0b2545;
  --hero-b: #0e7c66;
  --hero-c: #2ecc9e;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.18);
  --radius: 18px;
  --radius-sm: 12px;
  --nav-h: 64px;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --ink: #f2f4f8;
    --ink-2: #b4bac6;
    --muted: #7f8696;
    --brand: #22b389;
    --brand-ink: #7fe3c3;
    --brand-soft: rgba(34, 179, 137, 0.14);
    --brand-soft-2: rgba(34, 179, 137, 0.24);
    --credit: #3ecf8e;
    --credit-soft: rgba(62, 207, 142, 0.12);
    --debit: #ff7b7b;
    --debit-soft: rgba(255, 123, 123, 0.12);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --ink: #f2f4f8;
  --ink-2: #b4bac6;
  --muted: #7f8696;
  --brand: #22b389;
  --brand-ink: #7fe3c3;
  --brand-soft: rgba(34, 179, 137, 0.14);
  --brand-soft-2: rgba(34, 179, 137, 0.24);
  --credit: #3ecf8e;
  --credit-soft: rgba(62, 207, 142, 0.12);
  --debit: #ff7b7b;
  --debit-soft: rgba(255, 123, 123, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* ---------- الأساس ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  min-height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
input, select, textarea { background: var(--surface); }
a { color: var(--brand-ink); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 40px; text-align: center; }

.app { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
.container { max-width: 860px; margin: 0 auto; padding: 0 16px; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar .container { display: flex; align-items: center; gap: 10px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.account-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 46vw;
  padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-weight: 600; font-size: 13px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.account-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chip svg { flex: none; opacity: .6; }
.spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center;
  color: var(--ink-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.active { background: var(--brand-soft); color: var(--brand-ink); }
.icon-btn svg { width: 22px; height: 22px; }
.page-title { font-size: 20px; font-weight: 700; }

/* ---------- بطاقة الرصيد ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff;
  margin-top: 16px; padding: 22px 22px 18px; border-radius: 24px;
  background: linear-gradient(135deg, var(--hero-a) 0%, var(--hero-b) 70%, var(--hero-c) 140%);
  box-shadow: 0 18px 44px rgba(11, 37, 69, 0.28);
}
.hero::before, .hero::after {
  content: ''; position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(255,255,255,.08);
}
.hero::before { width: 260px; height: 260px; top: -140px; left: -80px; }
.hero::after { width: 180px; height: 180px; bottom: -110px; right: -40px; background: rgba(46,204,158,.18); }
.hero-label { font-size: 13px; opacity: .85; font-weight: 500; }
.hero-value { font-size: clamp(34px, 9vw, 46px); font-weight: 700; line-height: 1.15; margin-top: 2px; letter-spacing: -.3px; }
.hero-value small { font-size: .42em; font-weight: 500; opacity: .85; margin-inline-start: 6px; }
.hero-value.negative { color: #ffd0d0; }
.hero-meta { font-size: 12px; opacity: .75; margin-top: 4px; }
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; position: relative; }
.hero-stat {
  padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.12); backdrop-filter: blur(6px);
}
.hero-stat .k { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 6px; }
.hero-stat .v { font-weight: 600; font-size: 17px; margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.credit { background: #6ff0bf; }
.dot.debit { background: #ffb3b3; }

/* ---------- أدوات الترشيح ---------- */
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.month-nav {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px;
}
.month-nav .icon-btn { width: 36px; height: 36px; }
.month-nav .label { flex: 1; text-align: center; font-weight: 600; }
.month-nav .all-btn {
  padding: 6px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.month-nav .all-btn.active, .month-nav .all-btn:hover { background: var(--brand-soft); color: var(--brand-ink); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--ink-2); transition: background .15s, color .15s; }
.seg button.active { background: var(--brand); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.seg.type button.active[data-value='debit'] { background: var(--debit); }
.seg.type button.active[data-value='credit'] { background: var(--credit); }
.select {
  appearance: none; -webkit-appearance: none;
  padding: 8px 34px 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--ink-2); max-width: 200px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 10px center;
}
.search { position: relative; flex: 1; min-width: 160px; }
.search input {
  width: 100%; padding: 9px 38px 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 14px;
}
.search svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }

/* ---------- كشف الحساب ---------- */
.statement { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.statement-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  font-size: 13px; color: var(--ink-2);
}
.statement-head b { color: var(--ink); }
.period-balances { display: flex; gap: 14px; flex-wrap: wrap; }
.period-balances span { white-space: nowrap; }
.day-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px 6px; font-size: 12.5px; color: var(--muted); font-weight: 600;
  background: var(--surface); border-top: 1px solid var(--line);
}
.day-head:first-of-type { border-top: 0; }
.day-head .net { font-weight: 500; }
.row {
  display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 16px; width: 100%; text-align: start; transition: background .12s;
  border-top: 1px solid var(--line);
}
.row:hover { background: var(--surface-2); }
.row .icon {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 21px;
  background: var(--surface-2);
}
.row.credit .icon { background: var(--credit-soft); }
.row.debit .icon { background: var(--debit-soft); }
.row .main { min-width: 0; }
.row .cat { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.row .note { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { text-align: end; }
.row .amt .a { font-weight: 700; font-size: 15.5px; white-space: nowrap; }
.row.credit .amt .a { color: var(--credit); }
.row.debit .amt .a { color: var(--debit); }
.row .amt .b { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.row.opening { color: var(--ink-2); }
.row.opening .icon { background: var(--brand-soft); }
.row.opening .amt .a { color: var(--ink); font-weight: 600; }
.row .date-cell { display: none; }

/* عرض جدولي على الشاشات العريضة */
@media (min-width: 760px) {
  .statement .day-head { display: none; }
  .statement-cols {
    display: grid; grid-template-columns: 110px 42px 1fr 130px 130px 140px; gap: 12px;
    padding: 8px 16px; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line);
  }
  .statement-cols span:nth-child(n+4) { text-align: end; }
  .row { grid-template-columns: 110px 42px 1fr 130px 130px 140px; padding: 9px 16px; }
  .row .date-cell { display: block; font-size: 13px; color: var(--ink-2); }
  .row .amt { display: contents; }
  .row .amt .a, .row .amt .b { text-align: end; }
  .row .amt .debit-col, .row .amt .credit-col { text-align: end; font-weight: 700; font-size: 15px; }
  .row .amt .b { font-size: 13.5px; color: var(--ink-2); }
}
@media (max-width: 759px) { .statement-cols { display: none; } .amt .debit-col, .amt .credit-col { display: none; } }
@media (min-width: 760px) { .amt .a { display: none; } }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty .art { font-size: 54px; line-height: 1; margin-bottom: 12px; filter: saturate(.8); }
.empty h3 { font-size: 17px; color: var(--ink); margin-bottom: 4px; }
.empty p { font-size: 14px; }

/* ---------- الزر العائم والتنقّل ---------- */
.fab {
  position: fixed; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); inset-inline-end: 18px; z-index: 25;
  display: inline-flex; align-items: center; gap: 8px; padding: 0 20px 0 16px; height: 54px; border-radius: 999px;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 12px 28px rgba(14, 124, 102, 0.4); transition: transform .15s, box-shadow .15s;
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(14, 124, 102, 0.45); }
.fab:active { transform: translateY(0) scale(.98); }
.fab svg { width: 22px; height: 22px; }
.nav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 24; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav .container { display: grid; grid-template-columns: repeat(3, 1fr); height: var(--nav-h); }
.nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--muted); transition: color .15s; }
.nav button svg { width: 24px; height: 24px; }
.nav button.active { color: var(--brand-ink); }
.nav button.active svg { color: var(--brand); }

/* ---------- البطاقات العامة ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-top: 16px; }
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 .sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.stat.credit .v { color: var(--credit); }
.stat.debit .v { color: var(--debit); }

/* ---------- أعمدة التصنيفات ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; }
.bar-row .ic { font-size: 20px; text-align: center; }
.bar-row .name { font-size: 13.5px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.bar-row .name .share { color: var(--muted); font-weight: 500; font-size: 12px; }
.bar-row .track { height: 10px; border-radius: 6px; background: var(--surface-2); margin-top: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 0 6px 6px 0; background: var(--brand); min-width: 3px; transition: width .35s ease; }
.bar-row.income .fill { background: var(--mark-credit); }
.bar-row .val { font-weight: 700; font-size: 14px; white-space: nowrap; }

/* ---------- رسم الأشهر ---------- */
.chart { position: relative; height: 190px; margin-top: 8px; }
.chart .grid { position: absolute; inset: 0 0 26px 0; display: flex; flex-direction: column; justify-content: space-between; }
.chart .grid div { border-top: 1px solid var(--line); position: relative; font-size: 10.5px; color: var(--muted); }
.chart .grid div span { position: absolute; right: 0; top: -14px; }
.chart .cols { position: absolute; inset: 0 0 26px 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 6px; padding-inline-start: 44px; }
.chart .col { display: flex; align-items: end; justify-content: center; gap: 2px; height: 100%; position: relative; }
.chart .col .bar { width: 16px; max-width: 40%; border-radius: 4px 4px 0 0; transition: height .35s ease; position: relative; }
.chart .col .bar.credit { background: var(--mark-credit); }
.chart .col .bar.debit { background: var(--mark-debit); }
.chart .col .bar .lbl { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 10.5px; color: var(--ink-2); white-space: nowrap; padding-bottom: 2px; }
.chart .col:hover .bar { filter: brightness(1.08); }
.chart .col .tip {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: 11.5px; padding: 6px 9px; border-radius: 8px; white-space: nowrap; z-index: 2;
}
.chart .col:hover .tip, .chart .col:focus-within .tip { display: block; }
.chart .xaxis { position: absolute; bottom: 0; inset-inline: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding-inline-start: 44px; gap: 6px; }
.chart .xaxis span { text-align: center; font-size: 11.5px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.credit { background: var(--mark-credit); }
.legend i.debit { background: var(--mark-debit); }
@media (forced-colors: active), print {
  .chart .col .bar.debit, .legend i.debit, .bar-row .fill { background-image: repeating-linear-gradient(45deg, transparent 0 3px, rgba(0,0,0,.35) 3px 5px); }
}

/* ---------- النماذج ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 15px;
}
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12.5px; color: var(--debit); font-weight: 600; }
.amount-wrap { position: relative; }
.amount-wrap input { font-size: 30px; font-weight: 700; padding: 12px 14px; padding-inline-end: 66px; text-align: start; direction: ltr; letter-spacing: .3px; }
.amount-wrap .cur { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); font-weight: 600; color: var(--muted); pointer-events: none; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.chip.active, .chip:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.type-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.type-seg button { padding: 10px; border-radius: 11px; font-weight: 700; font-size: 15px; color: var(--ink-2); transition: background .15s, color .15s; }
.type-seg button.active[data-value='debit'] { background: var(--debit); color: #fff; }
.type-seg button.active[data-value='credit'] { background: var(--credit); color: #fff; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface); font-size: 12px; font-weight: 600; color: var(--ink-2); line-height: 1.25; text-align: center;
  transition: border-color .15s, background .15s, transform .1s;
}
.cat-btn .ic { font-size: 24px; }
.cat-btn:hover { border-color: var(--line-strong); }
.cat-btn.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.cat-btn.add { border-style: dashed; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 13px;
  font-weight: 700; font-size: 15px; border: 1px solid transparent; transition: transform .1s, filter .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 8px 20px rgba(14,124,102,.28); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.secondary { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--debit-soft); color: var(--debit); }
.btn.ghost { color: var(--ink-2); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.actions .btn { flex: 1; }

/* ---------- الأوراق السفلية والحوارات ---------- */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(6, 10, 20, 0.5); backdrop-filter: blur(3px); animation: fade .18s ease; }
.sheet {
  position: fixed; z-index: 41; inset-inline: 0; bottom: 0; max-height: 92vh; max-height: 92dvh; overflow: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lg); animation: rise .22s cubic-bezier(.2,.8,.2,1);
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
}
.sheet::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.sheet-head h2 { font-size: 18px; font-weight: 700; }
@media (min-width: 640px) {
  .sheet { inset-inline: auto; left: 50%; transform: translateX(-50%); width: 560px; bottom: 24px; border-radius: 24px; animation: pop .2s cubic-bezier(.2,.8,.2,1); }
  .sheet::before { display: none; }
}
.dialog {
  position: fixed; z-index: 42; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 420px);
  background: var(--surface); border-radius: 20px; padding: 22px; box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
.dialog h3 { font-size: 17px; margin-bottom: 6px; }
.dialog p { color: var(--ink-2); font-size: 14px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.96); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@media (min-width: 640px) { @keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } } .sheet { animation: sheetpop .2s ease; } }
@keyframes sheetpop { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- القوائم (الإعدادات/التصنيفات/الحسابات) ---------- */
.list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--line); width: 100%; text-align: start;
}
.item:first-child { border-top: 0; }
.item .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); font-size: 20px; flex: none; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-size: 14.5px; }
.item .t small { color: var(--muted); font-size: 12.5px; }
.item .act { display: flex; gap: 4px; }
.item .act .icon-btn { width: 34px; height: 34px; }
.item.active .ic { background: var(--brand-soft); }
.item .chev { color: var(--muted); }
.section-title { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin: 22px 4px 6px; }
.seg.block { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.note-box { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.emoji-input { width: 64px !important; text-align: center; font-size: 22px !important; }
.inline-form { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; margin-top: 8px; }
.inline-form input { padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-strong); }

/* ---------- التنبيهات ---------- */
.toast-root { position: fixed; bottom: calc(var(--nav-h) + 76px + env(safe-area-inset-bottom)); inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 12px; padding: 11px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: rise .2s ease;
}
.toast button { color: var(--hero-c); font-weight: 700; }
:root[data-theme='dark'] .toast button, :root:not([data-theme='light']) .toast button { color: #0e7c66; }
@media (prefers-color-scheme: light) { :root:not([data-theme='dark']) .toast button { color: #6ff0bf; } }
:root[data-theme='light'] .toast button { color: #6ff0bf; }

/* ---------- الترحيب ---------- */
.onboard { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.onboard .card { width: min(100%, 460px); padding: 26px 22px; }
.onboard .logo { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; margin-bottom: 8px; }
.onboard .logo img { width: 84px; height: 84px; border-radius: 24px; box-shadow: 0 14px 30px rgba(11,37,69,.28); }
.onboard h1 { font-size: 26px; }
.onboard p { color: var(--ink-2); font-size: 14px; }
.features { display: grid; gap: 6px; margin: 14px 0 4px; font-size: 13px; color: var(--ink-2); }
.features span { display: flex; gap: 8px; align-items: center; }

/* ---------- الطباعة ---------- */
.print-area { display: none; }
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .app, #sheet-root, .toast-root, .fab, .nav { display: none !important; }
  .print-area { display: block; padding: 8mm; }
  .print-area h1 { font-size: 20px; margin-bottom: 2px; }
  .print-area .meta { color: #444; margin-bottom: 10px; display: flex; gap: 16px; flex-wrap: wrap; }
  .print-area table { width: 100%; border-collapse: collapse; }
  .print-area th, .print-area td { border-bottom: 1px solid #ddd; padding: 6px 8px; text-align: start; }
  .print-area th { background: #f0f0f0; font-size: 11.5px; }
  .print-area td.n { text-align: end; font-variant-numeric: tabular-nums; direction: ltr; }
  .print-area tfoot td { font-weight: 700; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
