@font-face { font-family: 'Thmanyah Sans'; src: local('thmanyah sans Light'), url('/fonts/thmanyah-sans-Light.woff2') format('woff2'); font-weight: 300; font-display: swap; }
@font-face { font-family: 'Thmanyah Sans'; src: local('thmanyah sans'), local('thmanyah sans Regular'), url('/fonts/thmanyah-sans-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Thmanyah Sans'; src: local('thmanyah sans Medium'), url('/fonts/thmanyah-sans-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Thmanyah Sans'; src: local('thmanyah sans Bold'), url('/fonts/thmanyah-sans-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --text: #1b2233;
  --text-2: #5d6474;
  --muted: #8b909c;
  --border: #e6e2da;
  --primary: #245437;
  --primary-ink: #ffffff;
  --accent: #9c6d22;
  --gold: #b5812f;
  --accent-bg: #f6eedf;
  --danger: #b4392f;
  --danger-bg: #fbeceb;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --ok: #2f6b45;
  --ok-bg: #e8f3ec;
  --info: #2a5aa0;
  --info-bg: #e8effa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 25, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161f; --surface: #1a1f2b; --surface-2: #202634; --text: #eef0f4; --text-2: #b4b9c4; --muted: #868c99;
    --border: #2c3342; --primary: #d1a457; --primary-ink: #12161f; --accent: #d1a457; --gold: #d1a457; --accent-bg: #2b2619;
    --danger: #f08a80; --danger-bg: #3a1f1d; --warn: #f0c46a; --warn-bg: #352a14; --ok: #8fd1a6; --ok-bg: #1b3024;
    --info: #9ebcf0; --info-bg: #1c2840;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Thmanyah Sans', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

.container { max-width: 980px; margin: 0 auto; padding: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-logo { height: 40px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-weight: 700; color: var(--primary); font-size: 17px; }
.brand-text small { font-size: 11px; color: var(--gold); font-weight: 500; }
@media (prefers-color-scheme: dark) { .brand-logo { filter: brightness(1.15); } }
.topnav { display: none; gap: 4px; }
.topnav a { padding: 6px 14px; border-radius: 999px; color: var(--text-2); font-weight: 500; }
.topnav a.active { background: var(--primary); color: var(--primary-ink); }

.bottomnav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); padding: 4px 0; }
.bottomnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bottomnav a.active { color: var(--primary); font-weight: 700; }

@media (min-width: 760px) {
  body { padding-bottom: 24px; }
  .topnav { display: flex; }
  .bottomnav { display: none; }
  .container { padding: 24px; }
}

h1 { font-size: 24px; font-weight: 700; margin: 4px 0 2px; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 10px; }
.sub { color: var(--text-2); margin: 0 0 16px; font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { font-size: 13px; color: var(--text-2); }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat.danger .value { color: var(--danger); }

textarea, input[type=text], input[type=email], input[type=tel], input[type=search], select {
  width: 100%; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; outline: none;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.mt { margin-top: 10px; }

.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item .time { min-width: 64px; font-weight: 700; font-variant-numeric: tabular-nums; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 500; overflow-wrap: anywhere; }
.item .meta { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
a.item:hover .title { color: var(--accent); }

.date-group { font-size: 13px; font-weight: 700; color: var(--gold); margin: 14px 0 0; padding-bottom: 4px; border-bottom: 1px solid var(--border); }

.badge { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge.accent { background: var(--accent-bg); color: var(--accent); border-color: transparent; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--border); background: var(--surface); padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--text-2); }
.tabs button.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

.results { margin-top: 12px; display: grid; gap: 8px; }
.result { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); font-size: 14px; }
.result b { font-weight: 700; }

.empty { color: var(--muted); text-align: center; padding: 18px 8px; font-size: 14px; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.task { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task input[type=checkbox] { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--primary); flex: none; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.section-label { font-size: 13px; font-weight: 700; margin: 14px 0 0; color: var(--text-2); }
.section-label.danger { color: var(--danger); }

.timeline .item { border-bottom: 1px dashed var(--border); }
pre.raw { white-space: pre-wrap; font-family: inherit; font-size: 13px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin: 6px 0 0; color: var(--text-2); }
details summary { cursor: pointer; color: var(--text-2); font-size: 13px; }

.toast { position: fixed; bottom: calc(90px + env(safe-area-inset-bottom)); inset-inline: 16px; margin: 0 auto; max-width: 420px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; text-align: center; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; transform: none; }
@media (min-width: 760px) { .toast { bottom: 24px; } }
.error { color: var(--danger); font-size: 13px; margin-top: 6px; }

.money { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.money.in { color: var(--ok); }
.money.out { color: var(--danger); }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 72px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; background: var(--gold); border-radius: 999px; }
.del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 6px; }
.del:hover { color: var(--danger); }
