/* Mizaniyati Web Dashboard. Colors = the brand tokens of the website (website/src/styles/tokens.css), VALUES UNCHANGED; fonts = the
   same Alexandria (display) + Readex Pro (body), self-hosted (no third-party request). Layout only differs by width: one set of
   components, stacked on phones, a real grid on laptops / desktops. */
@font-face { font-family: 'Alexandria'; font-weight: 500 800; font-display: swap; src: url(/assets/fonts/alexandria-arabic.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-089F, U+08A0-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Alexandria'; font-weight: 500 800; font-display: swap; src: url(/assets/fonts/alexandria-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, 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: 400 600; font-display: swap; src: url(/assets/fonts/readex-arabic.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-089F, U+08A0-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Readex Pro'; font-weight: 400 600; font-display: swap; src: url(/assets/fonts/readex-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  /* brand tokens — identical values to the website */
  --c-paper: #ffffff; --c-bg: #f6f7f3; --c-cream: #fdefd2; --c-pale: #ddefe6; --c-line: #e3eae5; --c-ink: #12201a; --c-muted: #56675e;
  --c-green: #0b5d48; --c-green-ink: #08463a; --c-deep: #0b2a21; --c-mint: #4cc79c; --c-saffron: #f0a21a; --c-saffron-ink: #8f5500; --c-coral: #e5654b;
  --font-display: 'Alexandria', 'Segoe UI', system-ui, sans-serif; --font-body: 'Readex Pro', 'Segoe UI', system-ui, sans-serif;
  --radius-sm: 10px; --radius: 18px; --shadow: 0 1px 2px rgba(11, 42, 33, 0.06), 0 8px 24px rgba(11, 42, 33, 0.06);
  --focus: 0 0 0 3px var(--c-paper), 0 0 0 5px var(--c-green);
  --container: 76rem; --gutter: clamp(1rem, 3vw, 2rem);
  color-scheme: light;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--c-bg); color: var(--c-ink); font: 400 1rem/1.6 var(--font-body); -webkit-font-smoothing: antialiased; overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(11, 93, 72, 0.12); }
h1, h2, h3 { font-family: var(--font-display); color: var(--c-deep); margin: 0; line-height: 1.25; }
a { color: var(--c-green); }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.muted { color: var(--c-muted); }
.wrap { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }

/* every interactive element: visible focus, pressed state, comfortable touch target */
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
.press { transition: background-color .15s, border-color .15s, transform .08s; }
.press:active { transform: scale(0.985); }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--c-paper); border-bottom: 1px solid var(--c-line); }
.top .wrap { display: flex; align-items: center; gap: .75rem; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--c-deep); font: 800 1.2rem/1 var(--font-display); padding: .35rem .25rem; border-radius: var(--radius-sm); }
.brand img { width: 34px; height: 34px; display: block; }
.nav { display: flex; gap: .25rem; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .95rem; border-radius: 999px; text-decoration: none; color: var(--c-muted); font: 600 .95rem/1 var(--font-body); white-space: nowrap; }
.nav a:hover { background: var(--c-bg); color: var(--c-deep); }
.nav a[aria-current="page"] { background: var(--c-pale); color: var(--c-green-ink); }
.acct { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; flex: none; min-height: 44px; padding: 0 .9rem; border: 1px solid var(--c-line); border-radius: 999px; background: var(--c-paper); color: var(--c-deep); font: 600 .95rem/1 var(--font-body); cursor: pointer; }
.acct:hover { border-color: var(--c-green); }
.menu { position: fixed; top: 64px; inset-inline-end: var(--gutter); z-index: 30; background: var(--c-paper); border: 1px solid var(--c-line); border-radius: var(--radius);
  padding: .75rem; display: flex; flex-direction: column; gap: .5rem; min-width: 240px; box-shadow: var(--shadow); }
.menu .who { font: 700 1rem/1.3 var(--font-display); color: var(--c-deep); padding: .25rem .25rem .5rem; border-bottom: 1px solid var(--c-line); }

/* ---------- filter bar ---------- */
.acctline { background: var(--c-deep); color: #e6f2ec; font: 600 .82rem/1 var(--font-body); }
.acctline .wrap { padding-block: .5rem; }
.filters { background: var(--c-paper); border-bottom: 1px solid var(--c-line); }
.filters .wrap { display: flex; flex-direction: column; gap: .6rem; padding-block: .75rem; }
.filters .wrap > * { min-width: 0; max-width: 100%; }   /* a flex item never grows wider than the screen (the period row scrolls instead) */
.seg { display: flex; flex-wrap: wrap; gap: .35rem; }
.seg a { flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 .9rem; border-radius: 999px; border: 1px solid var(--c-line);
  text-decoration: none; color: var(--c-ink); font: 500 .92rem/1 var(--font-body); background: var(--c-paper); }
.seg a:hover { border-color: var(--c-green); }
.seg a[aria-current="true"] { background: var(--c-green); border-color: var(--c-green); color: #fff; font-weight: 600; }
.custom { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.custom input { min-height: 40px; padding: 0 .6rem; border: 1px solid var(--c-line); border-radius: var(--radius-sm); font: inherit; color: var(--c-ink); background: var(--c-paper); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; padding: 0 .4rem 0 .8rem; border-radius: 999px; background: var(--c-pale); color: var(--c-green-ink);
  font: 600 .88rem/1 var(--font-body); text-decoration: none; }
.chip .x { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(11, 93, 72, .14); font-size: .95rem; }
.chip:hover .x { background: rgba(11, 93, 72, .28); }
.clear { font: 600 .88rem/1 var(--font-body); color: var(--c-coral); text-decoration: none; padding: .5rem .4rem; }
.search { display: flex; gap: .5rem; }
.search input { flex: 1; min-width: 0; min-height: 44px; padding: 0 .9rem; border: 1px solid var(--c-line); border-radius: 999px; font: inherit; background: var(--c-bg); color: var(--c-ink); }
.search input:focus { background: var(--c-paper); border-color: var(--c-green); outline: none; }

/* ---------- page + cards ---------- */
main.wrap { padding-block: 1rem 2.5rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.card { background: var(--c-paper); border: 1px solid var(--c-line); border-radius: var(--radius); padding: 1.1rem 1.15rem; box-shadow: var(--shadow); min-width: 0; }
.card > h2, .card-h h2 { font-size: 1.05rem; font-weight: 700; }
.card-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem .75rem; margin-bottom: .75rem; }
.card-h .more { font: 600 .88rem/1 var(--font-body); text-decoration: none; white-space: nowrap; padding: .35rem 0; }
.empty { color: var(--c-muted); padding: .75rem 0; }
.note { font-size: .9rem; color: var(--c-muted); }

/* summary */
.summary { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { border-radius: var(--radius); padding: 1rem 1.1rem; background: var(--c-paper); border: 1px solid var(--c-line); box-shadow: var(--shadow); min-width: 0; }
.kpi .k { display: flex; align-items: center; gap: .45rem; font: 600 .9rem/1.2 var(--font-body); color: var(--c-muted); }
.kpi .ic { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--c-pale); font-size: 15px; }
.kpi .v { margin-top: .5rem; font: 800 clamp(1.45rem, 1.1rem + 1.4vw, 2rem)/1.1 var(--font-display); color: var(--c-deep); }
.kpi .s { margin-top: .35rem; font-size: .85rem; color: var(--c-muted); }
.kpi.main { grid-column: 1 / -1; background: var(--c-deep); border-color: var(--c-deep); }
.kpi.main .k { color: var(--c-mint); } .kpi.main .ic { background: rgba(76, 199, 156, .16); }
.kpi.main .v { color: #fff; } .kpi.main .s { color: #c9dcd3; }
.delta { display: inline-flex; align-items: center; gap: .3rem; font: 700 .85rem/1 var(--font-display); padding: .3rem .55rem; border-radius: 999px; }
.delta.up { background: rgba(229, 101, 75, .14); color: #a33a24; } .kpi.main .delta.up { background: rgba(229, 101, 75, .22); color: #ffd2c7; }
.delta.down { background: var(--c-pale); color: var(--c-green-ink); } .kpi.main .delta.down { background: rgba(76, 199, 156, .18); color: var(--c-mint); }
.delta.same { background: var(--c-bg); color: var(--c-muted); }

/* quick actions */
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.quick a { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .7rem .25rem; min-height: 72px; border-radius: var(--radius-sm); background: var(--c-paper);
  border: 1px solid var(--c-line); text-decoration: none; color: var(--c-deep); font: 600 .82rem/1.2 var(--font-body); text-align: center; }
.quick a:hover { border-color: var(--c-green); background: var(--c-bg); }
.quick .ic { font-size: 20px; }

/* lists (category / merchant / family / operations) — each row is ONE link */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: .75rem; padding: .7rem .5rem; margin: 0 -.5rem; border-radius: var(--radius-sm); text-decoration: none; color: inherit; min-height: 52px; }
a.row:hover { background: var(--c-bg); }
.row + .row { border-top: 1px solid var(--c-line); }
.row .ic { flex: none; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--c-pale); font-size: 18px; }
.row .ic.in { background: var(--c-cream); }
.row .main { flex: 1; min-width: 0; display: block; }
.row .t, .row .s, .row .pct, .row .bar, .row .end > * { display: block; }
.row .t { font: 600 .98rem/1.35 var(--font-body); color: var(--c-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-size: .84rem; color: var(--c-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { flex: none; text-align: end; }
.row .amt { font: 700 1rem/1.2 var(--font-display); color: var(--c-deep); }
.row .amt.in { color: var(--c-green); }
.row .pct { font-size: .8rem; color: var(--c-muted); }
.row .chev { flex: none; color: var(--c-muted); font-size: 1.1rem; }
.bar { height: 7px; background: var(--c-bg); border-radius: 99px; overflow: hidden; margin-top: .4rem; }
.bar > i { display: block; height: 100%; background: var(--c-mint); border-radius: 99px; }
.bar.near > i { background: var(--c-saffron); }
.bar.over > i { background: var(--c-coral); }
.tag { display: inline-flex; align-items: center; gap: .25rem; font-size: .76rem; font-weight: 600; color: var(--c-saffron-ink); background: var(--c-cream); border-radius: 999px; padding: .1rem .45rem; margin-inline-start: .35rem; }

/* budget */
.budget .big { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.budget .big .v { font: 800 1.6rem/1.1 var(--font-display); color: var(--c-deep); }
.budget .bar { height: 12px; margin: .7rem 0 .6rem; }
.budget dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: 0; }
.budget dt { font-size: .82rem; color: var(--c-muted); } .budget dd { margin: .15rem 0 0; font: 700 1rem/1.2 var(--font-display); color: var(--c-deep); }
.warn { margin-top: .7rem; padding: .55rem .75rem; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600; }
.warn.near { background: var(--c-cream); color: var(--c-saffron-ink); } .warn.over { background: rgba(229, 101, 75, .12); color: #a33a24; }
.cta { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 1.1rem; border-radius: 999px; background: var(--c-green); color: #fff; font-weight: 600; text-decoration: none; border: 0; cursor: pointer; font-family: var(--font-body); font-size: .95rem; }
.cta:hover { background: var(--c-green-ink); }
.ghost { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 1rem; border-radius: 999px; background: var(--c-paper); color: var(--c-deep);
  border: 1px solid var(--c-line); font: 600 .95rem/1 var(--font-body); cursor: pointer; text-decoration: none; }
.ghost:hover { border-color: var(--c-green); } .ghost.danger { color: #a33a24; }

/* trend */
.trend .tabs { display: flex; gap: .3rem; }
.trend .tabs a { font: 600 .8rem/1 var(--font-body); padding: .45rem .7rem; border-radius: 999px; text-decoration: none; color: var(--c-muted); border: 1px solid var(--c-line); }
.trend .tabs a[aria-current="true"] { background: var(--c-pale); color: var(--c-green-ink); border-color: var(--c-pale); }
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; height: 230px; }   /* equal columns; follows the page direction */
.bars .col { display: grid; grid-template-rows: minmax(0, 1fr) 1.2rem; min-width: 0; text-decoration: none; border-radius: 6px; }
.bars .area { position: relative; display: flex; align-items: flex-end; min-height: 0; }
.bars .col i { display: block; width: 100%; min-height: 3px; background: var(--c-mint); border-radius: 6px 6px 2px 2px; }
.bars .val { position: absolute; left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; padding: 3px 0; }
.bars .val .num { writing-mode: vertical-rl; transform: rotate(180deg); font: 700 .66rem/1 var(--font-display); color: var(--c-deep); white-space: nowrap; }
.bars .lab { font-size: .7rem; color: var(--c-muted); text-align: center; white-space: nowrap; line-height: 1.2rem; overflow: visible; }
.bars .col:hover i, .bars .col:focus-visible i { background: var(--c-green); }
.bars .zero i { background: var(--c-line); }
.bars.dense { gap: 1px; } .bars.dense .val .num { font-size: .5rem; letter-spacing: -.01em; }
@media (max-width: 520px) { .trend.card { padding-inline: .7rem; } }

/* insights */
.insights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.ins { display: block; padding: .75rem .8rem; border-radius: var(--radius-sm); background: var(--c-bg); text-decoration: none; color: inherit; min-width: 0; }
a.ins:hover { background: var(--c-pale); }
.ins .k { font-size: .8rem; color: var(--c-muted); }
.ins .v { font: 700 1rem/1.3 var(--font-display); color: var(--c-deep); margin-top: .2rem; overflow-wrap: anywhere; }
.ins .s { font-size: .82rem; color: var(--c-muted); margin-top: .1rem; }

/* details + receipt viewer */
.details dl { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1rem; margin: 0; }
.details dt { color: var(--c-muted); font-size: .9rem; } .details dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.details .amount { font: 800 2rem/1.1 var(--font-display); color: var(--c-deep); margin: .25rem 0 1rem; }
.receipt h2 { font-size: 1.05rem; margin-bottom: .6rem; }
.receipt img { display: block; max-width: 100%; max-height: 70vh; border-radius: var(--radius-sm); border: 1px solid var(--c-line); background: var(--c-bg); }
.back { display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; text-decoration: none; font-weight: 600; margin-bottom: .5rem; }

.center { text-align: center; } .pin { max-width: 360px; margin: 2rem auto; display: flex; flex-direction: column; gap: .75rem; }
.pin input { min-height: 52px; font: 700 1.6rem/1 var(--font-display); letter-spacing: .5rem; text-align: center; direction: ltr; border: 1px solid var(--c-line); border-radius: var(--radius-sm); }
.err { color: #a33a24; font-weight: 600; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--c-paper), var(--c-bg), var(--c-paper)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- tablet ---------- */
@media (min-width: 640px) {
  .summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi.main { grid-column: auto; }
  .insights { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters .wrap { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
}
/* ---------- laptop / desktop: a real grid ---------- */
@media (min-width: 1024px) {
  main.wrap { padding-block: 1.5rem 3rem; }
  .grid.dash { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1.25rem; align-items: stretch; }
  .dash > .a-summary, .dash > .a-quick, .dash > .a-recent { grid-column: 1 / -1; }
  .dash > .a-trend { grid-column: span 7; } .dash > .a-cats { grid-column: span 5; }
  .dash > .a-family, .dash > .a-merchants, .dash > .a-budget, .dash > .a-insights { grid-column: span 6; }
  .dash > .a-merchants.solo, .dash > .a-insights.solo { grid-column: 1 / -1; }
  .bars { height: 240px; }
  .grid.two { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.25rem; align-items: start; }
}
@media (min-width: 1280px) { .quick { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
@media (max-width: 520px) {
  .acct .lbl { display: none; } .acct { width: 44px; padding: 0; }
  .nav a { padding: 0 .75rem; font-size: .9rem; }
  .seg a { min-height: 38px; padding: 0 .75rem; font-size: .88rem; }
}
@media (max-width: 380px) { .brand span { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
