:root {
  --teal: #7eacb6; --grey: #575757; --lime: #cae00c; --cream: #f6f4eb;
  --ink: #575757; --heading: #3a3a3a; --muted: #6a6a6a; --line: rgba(87, 87, 87, .14);
  --card: #fff; --in: #5f97a3; --out: #d9896a; --good: #4f7f1d; --bad: #b42f2f; --warn: #a46a00;
  --shadow: 0 1px 2px rgba(87, 87, 87, .05), 0 8px 24px rgba(87, 87, 87, .07);
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 400 15px/1.55 "Plus Jakarta Sans", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
:lang(ar), [dir="auto"] { font-family: "Cairo", "Plus Jakarta Sans", sans-serif; }
h1, h2 { margin: 0; color: var(--heading); line-height: 1.2; letter-spacing: -.02em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; margin-bottom: 14px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--grey); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.tiny { font-size: .78rem; }
.nums { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.error { color: var(--bad); font-size: .9rem; margin: 0; }
.grow { flex: 1; }

/* header */
.top { background: #fff; position: sticky; top: 0; z-index: 10; box-shadow: 0 1px 0 var(--line); }
.top-inner { max-width: 1180px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--heading); }
.brand img { height: 36px; width: auto; }
.brand span { padding-left: 12px; border-left: 1px solid var(--line); font-size: 1.05rem; }
.who { display: flex; align-items: center; gap: 12px; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; color: var(--ink); }
.tabs { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tab { background: none; border: 0; padding: 10px 12px 12px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.on { color: var(--heading); border-bottom-color: var(--lime); }
.tab:hover { color: var(--heading); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 24px 64px; }
.page-title { margin-bottom: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head .page-title { margin: 0; }
.note { background: rgba(126, 172, 182, .16); border-radius: 12px; padding: 10px 14px; margin: 0 0 16px; font-size: .9rem; }

/* buttons */
.btn { border: 1px solid transparent; border-radius: 999px; padding: 9px 18px; font-weight: 600; background: #fff; line-height: 1.2; }
.btn.primary { background: var(--grey); color: #fff; }
.btn.primary:hover { background: #434343; }
.btn.ghost { border-color: var(--line); background: #fff; }
.btn.ghost:hover { border-color: var(--grey); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger-ghost { border-color: rgba(180, 47, 47, .35); color: var(--bad); }
.btn.small { padding: 5px 12px; font-size: .85rem; }
.btn:disabled { opacity: .4; cursor: default; }

/* cards & tiles */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.pad { padding: 18px 20px; margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; border-top: 4px solid var(--teal); }
.tile.good { border-top-color: var(--lime); }
.tile.bad { border-top-color: var(--bad); }
.tile.warn { border-top-color: #e3a73a; }
.tile-label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 1.75rem; font-weight: 800; color: var(--heading); margin-top: 2px; }
.tile.bad .tile-value { color: var(--bad); }
.tile-extra { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2 .card { margin-bottom: 18px; }

.month-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.month-bar h1 { min-width: 0; }
.month-bar .btn { padding: 6px 14px; font-size: 1.2rem; }

/* horizontal bars */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bar-row { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; margin-bottom: 4px; }
.bar-row span:last-child { font-weight: 700; color: var(--heading); }
.bar-track { height: 8px; background: rgba(87, 87, 87, .08); border-radius: 99px; overflow: hidden; }
.bar { height: 100%; border-radius: 99px; width: 0; }
.bar.in { background: var(--in); }
.bar.out { background: var(--out); }

/* month chart */
.legend { display: flex; align-items: center; gap: 6px; margin: -6px 0 12px; color: var(--muted); }
.key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.key:first-child { margin-left: 0; }
.key.in { background: var(--in); }
.key.out { background: var(--out); }
.chart { display: flex; align-items: stretch; gap: 6px; height: 220px; overflow-x: auto; padding-bottom: 2px; }
.col { flex: 1 0 34px; display: flex; flex-direction: column; background: none; border: 0; padding: 0; border-radius: 8px; }
.col:hover { background: rgba(126, 172, 182, .12); }
.pair { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 0 3px; }
.cbar { width: 12px; border-radius: 4px 4px 0 0; height: 0; min-height: 1px; }
.cbar.in { background: var(--in); }
.cbar.out { background: var(--out); }
.clabel { font-size: .7rem; color: var(--muted); padding-top: 6px; white-space: nowrap; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.r { text-align: right; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(126, 172, 182, .1); }

/* entries */
.filters { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.filters label { display: grid; gap: 4px; font-weight: 600; }
.filters .grow { min-width: 200px; }
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry-main { flex: 1; min-width: 0; }
.entry-desc { font-weight: 600; color: var(--heading); overflow-wrap: anywhere; unicode-bidi: plaintext; text-align: start; }
.entry-amount { font-weight: 700; color: var(--heading); white-space: nowrap; }
.chip { display: inline-block; background: rgba(126, 172, 182, .2); border-radius: 99px; padding: 0 8px; font-size: .78rem; color: var(--heading); }
.chip.soft { background: rgba(202, 224, 12, .25); }

/* forms */
input, select { border: 1px solid rgba(87, 87, 87, .25); border-radius: 10px; padding: 9px 12px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus { border-color: var(--grey); outline: none; }
label { display: grid; gap: 5px; font-size: .88rem; font-weight: 600; }
.cash-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.cash-form label { flex: 1 1 160px; }
.cash-form label.grow { flex: 2 1 220px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 28px; }
.login-logo { height: 48px; width: auto; }

/* modal & toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(43, 43, 43, .4); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); padding: 22px; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 50px rgba(43, 43, 43, .2); }
.modal form { display: grid; gap: 12px; }
.modal h2 { margin-bottom: 4px; }
.modal p { margin: 0 0 8px; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; }
#toast div { background: var(--heading); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: .9rem; box-shadow: var(--shadow); }

@media (max-width: 760px) {
  .top-inner, .wrap { padding-left: 16px; padding-right: 16px; }
  .tabs { padding: 0 8px; }
  .brand img { height: 30px; }
  .who .muted { display: none; }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 12px 14px; }
  .tile-value { font-size: 1.3rem; }
  h1 { font-size: 1.3rem; }
  .entry { flex-wrap: wrap; padding: 12px 14px; gap: 6px 12px; }
  .entry-main { flex-basis: 100%; }
  .entry-amount { flex: 1; }
}
