/* ميجا عهدة — أنماط عائلة MEGA. الكحلي #23237A أساسي، الأصفر #FFC21A للتمييز، Readex Pro للعناوين والأرقام، IBM Plex Sans Arabic للنصوص.
   كل الاتجاهات بخصائص منطقية (inline-start/end) فتنقلب تلقائيًا بين RTL و LTR. الجوال أولًا: شريط سفلي على الجوال، شريط جانبي على الكمبيوتر. */
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Readex Pro'; font-weight: 500; font-display: swap; src: url(fonts/readex-pro-arabic-500-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Readex Pro'; font-weight: 600; font-display: swap; src: url(fonts/readex-pro-arabic-600-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Readex Pro'; font-weight: 700; font-display: swap; src: url(fonts/readex-pro-arabic-700-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Readex Pro'; font-weight: 500; font-display: swap; src: url(fonts/readex-pro-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Readex Pro'; font-weight: 600; font-display: swap; src: url(fonts/readex-pro-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Readex Pro'; font-weight: 700; font-display: swap; src: url(fonts/readex-pro-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sora'; font-weight: 700; font-display: swap; src: url(fonts/sora-latin-700-normal.woff2) format('woff2'); }

:root {
  --navy: #23237A; --navy-2: #3434A8; --sun: #FFC21A; --sun-d: #EBAE00; --gold: #B98A00; --deep: #0B0B14;
  --bg: #F5F5FC; --card: #FFFFFF; --ink: #12122E; --body: #34345A; --mute: #5B5B7A; --line: #E2E2EE; --line-2: #D3D3E3; --soft: #EEEEF8; --sun-soft: #FFF6DA;
  --ok: #15803D; --ok-bg: #E7F5EC; --warn: #8A5A00; --warn-bg: #FFF4D6; --bad: #B42318; --bad-bg: #FDECEA; --info: #1D4ED8; --info-bg: #EAF0FF;
  --accent: var(--navy); --on-accent: #fff;
  --f-body: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, Arial, system-ui, sans-serif;
  --f-head: 'Readex Pro', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --f-mark: 'Sora', 'Readex Pro', 'Segoe UI', sans-serif;
  --r: 18px; --r-c: 14px; --r-s: 10px;
  --sh: 0 1px 2px rgba(18, 18, 46, .05), 0 14px 34px -20px rgba(18, 18, 46, .22);
  --side-w: 260px; --bar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0D0D22; --card: #16163A; --ink: #ECECF8; --body: #C9C9E0; --mute: #A3A3C2; --line: #2A2A50; --line-2: #36366A; --soft: #1E1E48; --sun-soft: #2E2711;
  --ok: #4ADE80; --ok-bg: #0F2A1B; --warn: #FFD15A; --warn-bg: #2E2711; --bad: #FF8A80; --bad-bg: #3A1513; --info: #93B4FF; --info-bg: #17204A;
  --accent: #FFC21A; --on-accent: #0B0B14; --navy-2: #A9A9FF;
  --sh: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font: 400 15.5px/1.6 var(--f-body); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3 { font-family: var(--f-head); font-weight: 700; line-height: 1.3; margin: 0; color: var(--ink); }
h1 { font-size: clamp(21px, 2.4vw, 27px); } h2 { font-size: 17px; font-weight: 600; } h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
a { color: var(--navy-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.num, .money { font-family: var(--f-head); font-feature-settings: 'tnum' 1; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.muted { color: var(--mute); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.wordmark { font-family: var(--f-mark); font-weight: 700; letter-spacing: .02em; direction: ltr; unicode-bidi: isolate; }
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------------- layout ---------------- */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid transparent; }
.top.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 10px; flex: none; }
.brand b { font: 700 16px/1.15 var(--f-head); display: block; white-space: nowrap; }
.brand span { white-space: nowrap; display: block; font: 700 11px/1.2 var(--f-mark); color: var(--mute); letter-spacing: .04em; }
.top .sp { flex: 1; }
@media (max-width: 520px) { .top:has(.chip-trial) .brand div { display: none; } }
.hero::after { opacity: .6; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; font: 600 13px var(--f-head); }
.iconbtn:hover { border-color: var(--line-2); }
.chip-trial { font: 600 12px var(--f-head); background: var(--sun-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--sun) 50%, transparent); border-radius: 999px; padding: 6px 10px; cursor: pointer; white-space: nowrap; }
main#view { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 8px 16px calc(var(--bar-h) + 32px + var(--safe-b)); }
.side { display: none; }
.bottom { position: fixed; inset-inline: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); box-shadow: 0 -10px 30px -24px rgba(0,0,0,.35); }
.bottom a, .bottom button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; justify-content: center; text-decoration: none; color: var(--mute); font: 600 11.5px var(--f-head); border: 0; background: none; cursor: pointer; border-radius: 12px; }
.bottom a[aria-current="page"] { color: var(--accent); }
.bottom a[aria-current="page"] .ic { stroke-width: 2.4; }
.bottom .fab { position: relative; top: -14px; }
.bottom .fab i { width: 58px; height: 58px; border-radius: 18px; background: var(--sun); color: var(--deep); display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 24px -10px rgba(235, 174, 0, .9); }
.bottom .fab i .ic { width: 28px; height: 28px; stroke-width: 2.6; }
.bottom .fab span { margin-top: 2px; color: var(--ink); }

@media (min-width: 900px) {
  .shell { flex-direction: row; }
  .side { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; width: var(--side-w); flex: none; background: #12123A; color: #E8E8F6; padding: 18px 14px; overflow-y: auto; }
  :root[data-theme="dark"] .side { background: #0A0A1C; border-inline-end: 1px solid var(--line); }
  .side .brand { color: #fff; padding: 4px 6px 16px; } .side .brand span { color: #A9A9D0; }
  .side nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: #D6D6EE; text-decoration: none; font: 600 14.5px var(--f-head); }
  .side nav a:hover { background: rgba(255,255,255,.06); }
  .side nav a[aria-current="page"] { background: rgba(255, 194, 26, .14); color: var(--sun); }
  .side .addbtn { margin: 6px 0 14px; }
  .side .sect { font: 600 11.5px var(--f-head); color: #8F8FB8; text-transform: uppercase; letter-spacing: .06em; padding: 14px 12px 6px; }
  .side .mini { display: block; padding: 8px 12px; border-radius: 10px; color: #D6D6EE; text-decoration: none; font-size: 13.5px; }
  .side .mini:hover { background: rgba(255,255,255,.06); }
  .side .mini small { display: block; color: #A9A9D0; font-family: var(--f-head); }
  .side .foot { margin-top: auto; padding: 14px 8px 0; font-size: 12px; color: #8F8FB8; }
  .side .chip-trial { display: inline-block; margin-bottom: 8px; }
  .content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .bottom { display: none; }
  main#view { padding: 12px 32px 48px; }
  .top .brand { display: none; }
}

/* ---------------- buttons & forms ---------------- */
.btn { --b: var(--navy); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; font: 600 15px/1.2 var(--f-head); padding: 10px 18px; border-radius: var(--r-c); border: 1.5px solid var(--b); background: var(--b); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
:root[data-theme="dark"] .btn:not(.ghost):not(.primary):not(.danger):not(.ok) { --b: #3A3A9A; }
.btn:active { transform: translateY(1px); }
.btn.primary { --b: var(--sun); color: var(--deep); } .btn.primary:hover { --b: var(--sun-d); }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line-2); } .btn.ghost:hover { border-color: var(--navy-2); }
.btn.danger { --b: var(--bad); color: #fff; } :root[data-theme="dark"] .btn.danger { color: #200; }
.btn.ghost.danger { background: var(--card); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.ok { --b: #1E8E4E; }
.btn.small { min-height: 38px; padding: 7px 12px; font-size: 13.5px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn .ic { width: 20px; height: 20px; }
.linkbtn { background: none; border: 0; color: var(--navy-2); font: 600 14px var(--f-head); cursor: pointer; padding: 8px 4px; text-decoration: underline; text-underline-offset: 3px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.field { display: grid; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .lbl { font: 600 14px var(--f-head); color: var(--ink); }
.field .hint { font-size: 12.5px; color: var(--mute); }
.field .err { font-size: 13px; color: var(--bad); font-weight: 600; }
.in { width: 100%; min-height: 50px; border: 1.5px solid var(--line-2); border-radius: var(--r-c); background: var(--card); padding: 10px 14px; font-size: 16px; color: var(--ink); }
.in:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sun) 55%, transparent); }
.in.bad { border-color: var(--bad); }
textarea.in { min-height: 84px; resize: vertical; line-height: 1.5; }
select.in { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--mute) 50%), linear-gradient(135deg, var(--mute) 50%, transparent 50%); background-position: calc(100% - 22px) 22px, calc(100% - 16px) 22px; background-size: 6px 6px; background-repeat: no-repeat; padding-inline-end: 40px; }
[dir="rtl"] select.in { background-position: 16px 22px, 22px 22px; }
.in.amount { font: 700 26px/1.2 var(--f-head); min-height: 62px; direction: ltr; text-align: center; letter-spacing: .5px; }
input[type="date"].in { direction: ltr; text-align: start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 420px) { .grid2.s1 { grid-template-columns: 1fr; } }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button, .chipsel { min-height: 42px; border-radius: 999px; border: 1.5px solid var(--line-2); background: var(--card); padding: 7px 14px; cursor: pointer; font: 600 13.5px var(--f-head); color: var(--body); display: inline-flex; align-items: center; gap: 6px; }
.seg button[aria-pressed="true"], .chipsel[aria-pressed="true"] { border-color: var(--navy); background: var(--navy); color: #fff; }
:root[data-theme="dark"] .seg button[aria-pressed="true"], :root[data-theme="dark"] .chipsel[aria-pressed="true"] { background: var(--sun); border-color: var(--sun); color: var(--deep); }
.chipsel .dot { width: 10px; height: 10px; border-radius: 50%; }
.switch { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.switch input { width: 46px; height: 28px; appearance: none; -webkit-appearance: none; background: var(--line-2); border-radius: 999px; position: relative; flex: none; cursor: pointer; transition: background .15s; }
.switch input::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--ok); } .switch input:checked::after { inset-inline-start: 21px; }

/* ---------------- cards & blocks ---------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); padding: 16px; }
.card + .card { margin-top: 12px; }
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 16px; }
.pagehead .grow p { color: var(--mute); font-size: 14px; margin-top: 2px; }
.section-t { display: flex; align-items: center; gap: 8px; margin: 22px 2px 10px; font: 600 14px var(--f-head); color: var(--mute); }
.section-t .grow { flex: 1; }
.empty { text-align: center; padding: 36px 16px; }
.empty img { width: 84px; height: 84px; border-radius: 22px; margin-bottom: 14px; }
.empty h2 { margin-bottom: 8px; } .empty p { color: var(--mute); max-width: 460px; margin: 0 auto 18px; }

.hero { background: linear-gradient(135deg, #23237A, #2E2E99 60%, #3A2F8F); color: #fff; border-radius: 22px; padding: 18px; position: relative; overflow: hidden; box-shadow: 0 20px 40px -26px rgba(35, 35, 122, .9); }
.hero::after { content: ''; position: absolute; inset-inline-end: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; border: 18px solid rgba(255, 194, 26, .16); }
.hero .lbl { color: #C9C9F0; font-size: 13px; font-weight: 600; }
.hero .big { font: 700 34px/1.15 var(--f-head); margin: 4px 0 2px; }
.hero .big small { font-size: 16px; font-weight: 600; opacity: .85; }
.hero .row { position: relative; z-index: 1; }

.ccard { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); padding: 16px; transition: border-color .15s, transform .1s; }
.ccard:hover { border-color: var(--line-2); } .ccard:active { transform: scale(.995); }
.ccard + .ccard { margin-top: 12px; }
.ccard .t { display: flex; align-items: flex-start; gap: 10px; }
.ccard h3 { font-size: 16.5px; }
.ccard .sub { color: var(--mute); font-size: 13px; }
.ccard .rem { text-align: end; }
.ccard .rem b { font: 700 21px var(--f-head); display: block; }
.ccard .rem span { font-size: 12px; color: var(--mute); }
.ccard .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; color: var(--mute); }
.cards { display: grid; gap: 12px; }
.cards .ccard + .ccard { margin-top: 0; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(2, 1fr); } }

.bar { height: 10px; border-radius: 999px; background: var(--soft); overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width .4s; }
.bar.warn > i { background: var(--sun-d); } .bar.danger > i { background: var(--bad); }
.hero .bar { background: rgba(255,255,255,.18); } .hero .bar > i { background: var(--sun); } .hero .bar.danger > i { background: #FF8A80; }

.badge { display: inline-flex; align-items: center; gap: 4px; font: 600 12px var(--f-head); padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--body); white-space: nowrap; }
.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); }

.alert { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--r-c); padding: 12px 14px; margin: 10px 0; border: 1px solid; font-size: 14px; }
.alert .ic { margin-top: 1px; }
.alert.danger { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--sun) 45%, transparent); }
.alert.info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert b { font-family: var(--f-head); }
.alert .grow { flex: 1; }
.alert .btn { flex: none; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-c); padding: 12px; min-width: 0; }
.kpi span { display: block; font-size: 12.5px; color: var(--mute); font-weight: 600; }
.kpi b { display: block; font: 700 clamp(15px, 4.2vw, 22px)/1.25 var(--f-head); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.hero .kpis .kpi { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); }
.hero .kpis .kpi span { color: #C9C9F0; } .hero .kpis .kpi b { color: #fff; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 4px; }
.actions .act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 76px; padding: 8px 4px; border-radius: var(--r-c); border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 12.5px/1.25 var(--f-head); cursor: pointer; text-align: center; text-decoration: none; }
.actions .act:hover { border-color: var(--line-2); }
.actions .act.main { background: var(--sun); border-color: var(--sun); color: var(--deep); }
.actions .act .ic { width: 24px; height: 24px; }
@media (min-width: 700px) { .actions { grid-template-columns: repeat(7, 1fr); } }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 18px 0 12px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 12px 12px; font: 600 14px var(--f-head); color: var(--mute); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; min-height: 46px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--sun); }

/* expense rows */
.xlist { display: grid; gap: 8px; }
.xday { font: 600 12.5px var(--f-head); color: var(--mute); margin: 12px 4px 2px; }
.xrow { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-c); cursor: pointer; text-align: start; width: 100%; min-height: 70px; }
.xrow:hover { border-color: var(--line-2); }
.xrow .th { width: 50px; height: 50px; border-radius: 10px; flex: none; background: var(--soft) center/cover no-repeat; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.xrow .th.missing { background: var(--warn-bg); color: var(--warn); border: 1.5px dashed color-mix(in srgb, var(--sun-d) 70%, transparent); }
.xrow .th em { position: absolute; bottom: 2px; inset-inline-end: 2px; font: 700 10px var(--f-head); background: rgba(11,11,20,.7); color: #fff; border-radius: 6px; padding: 0 4px; font-style: normal; }
.xrow .mid { flex: 1; min-width: 0; }
.xrow .mid b { display: block; font: 600 15px/1.3 var(--f-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xrow .mid span { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--mute); flex-wrap: wrap; }
.xrow .amt { text-align: end; flex: none; }
.xrow .amt b { font: 700 16px var(--f-head); display: block; }
.xrow .amt small { font-size: 11.5px; color: var(--mute); }
.cdot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* timeline */
.tl { display: grid; gap: 0; }
.tl .it { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px dashed var(--line); }
.tl .it:last-child { border-bottom: 0; }
.tl .ico { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--soft); }
.tl .ico.in { background: var(--ok-bg); color: var(--ok); } .tl .ico.out { background: var(--bad-bg); color: var(--bad); }
.tl .ico .ic { width: 18px; height: 18px; }
.tl .d b { font: 600 14px var(--f-head); display: block; } .tl .d span { font-size: 12px; color: var(--mute); }
.tl .v { text-align: end; } .tl .v b { font: 700 14.5px var(--f-head); display: block; } .tl .v span { font-size: 11.5px; color: var(--mute); }
.tl .pos { color: var(--ok); } .tl .neg { color: var(--ink); } .tl .bneg { color: var(--bad); }

/* category chart */
.catwrap { display: grid; gap: 18px; align-items: center; }
@media (min-width: 640px) { .catwrap { grid-template-columns: 220px 1fr; } }
.donut { width: 200px; height: 200px; margin: 0 auto; display: block; }
.donut text { font-family: var(--f-head); fill: var(--ink); }
.catlist { display: grid; gap: 10px; }
.catrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.catrow .nm { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.catrow .vv { font: 700 14px var(--f-head); }
.catrow .bar { grid-column: 1 / -1; margin-top: 0; height: 8px; }

/* filters */
.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.filters .full { grid-column: 1 / -1; }
.filters .field { margin: 0; min-width: 0; }
.filters > * { min-width: 0; }
input[type="date"].in { min-width: 0; -webkit-appearance: none; appearance: none; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(6, 1fr); } .filters .full { grid-column: span 2; } }
.totline { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--sun-soft); border-radius: var(--r-c); font: 600 14px var(--f-head); color: var(--warn); margin-bottom: 10px; }

/* sheet (modal) */
.sheet-bg { position: fixed; inset: 0; z-index: 100; background: rgba(11, 11, 20, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 94vh; max-height: 94dvh; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; box-shadow: 0 -20px 50px -20px rgba(0,0,0,.5); animation: up .2s ease-out; }
.sheet-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-h h2 { flex: 1; font-size: 18px; }
.sheet-b { padding: 16px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-f { padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 10px; background: var(--card); border-radius: 0; }
.sheet-f .btn { flex: 1; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 0; }
@media (min-width: 700px) { .sheet-bg { align-items: center; padding: 24px; } .sheet { border-radius: 22px; max-height: 88vh; } .sheet .grab { display: none; } .sheet-f { border-radius: 0 0 22px 22px; } }
@keyframes up { from { transform: translateY(30px); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photos .ph { width: 92px; height: 92px; border-radius: 12px; background: var(--soft) center/cover no-repeat; position: relative; border: 1px solid var(--line); cursor: zoom-in; padding: 0; }
.photos .ph .rm { position: absolute; top: -8px; inset-inline-end: -8px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--card); background: var(--bad); color: #fff; font: 700 15px/1 var(--f-head); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.photos .add { width: 92px; height: 92px; border-radius: 12px; border: 2px dashed var(--line-2); background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--navy-2); font: 600 11.5px/1.2 var(--f-head); cursor: pointer; text-align: center; padding: 6px; }
.photos .add.cam { border-color: var(--sun-d); background: var(--sun-soft); color: var(--warn); }
.photos .busy { width: 92px; height: 92px; border-radius: 12px; background: var(--soft); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--mute); text-align: center; padding: 6px; }
.vatrow { display: flex; gap: 8px; align-items: stretch; }
.vatrow .in { flex: 1; min-width: 0; }

/* toasts */
.toasts { position: fixed; z-index: 300; inset-inline: 0; bottom: calc(var(--bar-h) + 22px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; width: max-content; background: #16163A; color: #fff; border-radius: 14px; padding: 12px 14px; font-size: 14.5px; box-shadow: 0 16px 40px -16px rgba(0,0,0,.6); animation: up .2s; }
.toast.bad { background: #8F1C13; } .toast.warn { background: #6B4600; }
.toast button { background: var(--sun); color: var(--deep); border: 0; border-radius: 10px; padding: 7px 12px; font: 700 13px var(--f-head); cursor: pointer; min-height: 36px; }

/* viewer */
.viewer { position: fixed; inset: 0; z-index: 400; background: rgba(5, 5, 12, .96); display: flex; flex-direction: column; touch-action: none; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 10px; color: #fff; }
.viewer-bar .sp { flex: 1; } .viewer-n { font: 600 14px var(--f-head); }
.vbtn { min-width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; font: 600 18px var(--f-head); cursor: pointer; padding: 0 10px; }
.vbtn.danger { font-size: 13px; color: #FFB4AB; }
.viewer-stage { flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: none; }
.viewer-stage img { max-width: 100%; max-height: 100%; transform-origin: center center; user-select: none; -webkit-user-drag: none; }
.vnav { position: absolute; top: 50%; width: 46px; height: 64px; border: 0; border-radius: 12px; background: rgba(255,255,255,.1); color: #fff; font-size: 30px; cursor: pointer; }
.vnav.prev { inset-inline-start: 8px; } .vnav.next { inset-inline-end: 8px; }

/* pin */
.pin { position: fixed; inset: 0; z-index: 500; background: linear-gradient(160deg, #12123A, #23237A); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; }
.pin img { width: 64px; height: 64px; border-radius: 18px; }
.pin h2 { color: #fff; }
.pin .dots { display: flex; gap: 14px; direction: ltr; } .pin .dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); } .pin .dots i.f { background: var(--sun); border-color: var(--sun); }
.pin .pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; direction: ltr; }
.pin .pad button { height: 76px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; font: 600 26px var(--f-head); cursor: pointer; }
.pin .pad button:active { background: rgba(255,255,255,.25); }
.pin .msg { min-height: 22px; color: #FFB4AB; font-weight: 600; }
.pin .linkbtn { color: #C9C9F0; }

/* settings */
.set-sec { margin-bottom: 14px; }
.set-sec h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.set-row:first-of-type { border-top: 0; }
.set-row .grow b { display: block; font: 600 14.5px var(--f-head); }
.set-row .grow span { display: block; font-size: 13px; color: var(--mute); }
.logo-prev { width: 64px; height: 64px; border-radius: 12px; border: 1px solid var(--line); background: #fff center/contain no-repeat; flex: none; }
.cat-ed { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.cat-ed input[type="color"] { width: 44px; height: 44px; border: 1px solid var(--line-2); border-radius: 10px; padding: 2px; background: var(--card); }
.cat-ed .in { min-height: 44px; font-size: 14.5px; }
@media (max-width: 480px) { .cat-ed { grid-template-columns: auto 1fr auto; } .cat-ed .en { grid-column: 2; } }
.code { direction: ltr; font: 700 17px var(--f-head); letter-spacing: 1px; color: var(--navy-2); }

/* reports list */
.rlist { display: grid; gap: 10px; }
.ritem { display: flex; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-c); background: var(--card); cursor: pointer; text-align: start; width: 100%; }
.ritem:hover { border-color: var(--line-2); }
.ritem .ri { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--soft); color: var(--navy-2); }
.ritem .ri.pdf { background: var(--bad-bg); color: var(--bad); } .ritem .ri.xl { background: var(--ok-bg); color: var(--ok); } .ritem .ri.mc { background: var(--sun-soft); color: var(--warn); }
.ritem b { display: block; font: 600 15px var(--f-head); } .ritem span { display: block; font-size: 13px; color: var(--mute); }

.banner-upd { position: fixed; top: calc(10px + var(--safe-t)); inset-inline: 12px; z-index: 250; margin: 0 auto; max-width: 520px; }

/* ---------------- print: settlement report (A4) ---------------- */
#print-root { display: none; }
body.printing .shell, body.printing .toasts, body.printing .bottom { display: none !important; }
body.printing #print-root { display: block; }
.rp-bar { position: sticky; top: 0; z-index: 10; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: calc(10px + var(--safe-t)) 12px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
.rp-bar .grow { flex: 1; }
.rp-paper-wrap { padding: 16px 8px 40px; overflow-x: auto; }
.rp { --p-ink: #12122E; width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; color: var(--p-ink); padding: 14mm 12mm; box-shadow: 0 20px 50px -30px rgba(0,0,0,.4); font: 10.5pt/1.45 var(--f-body); }
@media (max-width: 820px) { .rp { zoom: .46; } }
@media (max-width: 520px) { .rp { zoom: .44; } }
.rp h1 { font-size: 17pt; color: #23237A; } .rp h2 { font-size: 11.5pt; color: #23237A; margin: 12px 0 6px; }
.rp .en { font-family: var(--f-head); color: #5B5B7A; font-size: 9pt; font-weight: 500; }
.rp-head { display: flex; align-items: center; gap: 14px; border-bottom: 3px solid #23237A; padding-bottom: 10px; margin-bottom: 10px; }
.rp-head .logo { width: 22mm; height: 22mm; object-fit: contain; }
.rp-head .co { flex: 1; } .rp-head .co b { font: 700 13pt var(--f-head); display: block; }
.rp-head .ttl { text-align: end; } .rp-head .ttl .no { font: 600 9pt var(--f-head); color: #5B5B7A; margin-top: 2px; }
.rp-info { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 12px; background: #F5F5FC; border-radius: 6px; padding: 8px 10px; }
.rp-info div span { display: block; font-size: 8pt; color: #5B5B7A; } .rp-info div b { font: 600 10pt var(--f-head); }
.rp-sum { width: 100%; border-collapse: collapse; margin-top: 8px; }
.rp-sum td { border: 1px solid #D3D3E3; padding: 5px 8px; } .rp-sum td:nth-child(even) { text-align: end; font: 700 10.5pt var(--f-head); width: 22%; }
.rp-sum tr.tot td { background: #FFF6DA; font-weight: 700; }
.rp-t { width: 100%; border-collapse: collapse; font-size: 9pt; }
.rp-t th { background: #23237A; color: #fff; font: 600 8.5pt/1.25 var(--f-head); padding: 5px 4px; text-align: start; }
.rp-t th .en { color: #C9C9F0; font-size: 7pt; display: block; }
.rp-t td { border-bottom: 1px solid #E2E2EE; padding: 4px; vertical-align: middle; }
.rp-t tr:nth-child(even) td { background: #FAFAFE; }
.rp-t td.n { text-align: end; font-family: var(--f-head); white-space: nowrap; direction: ltr; }
.rp-t tfoot td { background: #FFF6DA !important; font-weight: 700; border-top: 2px solid #23237A; }
.rp-t img { width: 12mm; height: 12mm; object-fit: cover; border-radius: 2px; display: block; }
.rp-t .miss { color: #B42318; font-size: 7.5pt; font-weight: 600; }
.rp-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.rp-cats div { display: flex; justify-content: space-between; border-bottom: 1px dotted #D3D3E3; padding: 2px 0; }
.rp-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; page-break-inside: avoid; }
.rp-sign div { border: 1px solid #D3D3E3; border-radius: 6px; padding: 8px; min-height: 28mm; display: flex; flex-direction: column; }
.rp-sign div b { font: 600 9.5pt var(--f-head); } .rp-sign div .ln { margin-top: auto; border-top: 1px solid #12122E; padding-top: 2px; font-size: 8pt; color: #5B5B7A; }
.rp-foot { margin-top: 12px; font-size: 7.5pt; color: #5B5B7A; display: flex; justify-content: space-between; border-top: 1px solid #E2E2EE; padding-top: 6px; }
.rp-app { page-break-before: always; }
.rp-app .pics { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; }
.rp-app figure { margin: 0; page-break-inside: avoid; border: 1px solid #E2E2EE; border-radius: 4px; padding: 3mm; }
.rp-app figure img { width: 100%; max-height: 110mm; object-fit: contain; display: block; }
.rp-app figcaption { font-size: 8pt; margin-top: 2mm; color: #34345A; }
.rp .diffbad { color: #B42318; } .rp .diffok { color: #15803D; }
@media print {
  @page { size: A4; margin: 11mm 10mm 12mm; }
  html, body { background: #fff !important; }
  .rp-bar { display: none !important; }
  .rp-paper-wrap { padding: 0; overflow: visible; }
  .rp { box-shadow: none; margin: 0; zoom: 1 !important; width: auto; min-height: 0; padding: 0; }
  .rp-t tr { page-break-inside: avoid; }
  .rp-t thead { display: table-header-group; }
}
