:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242d;
  --line: #2a2f3a;
  --text: #eef0f4;
  --muted: #8b93a3;
  --green: #2fbf71;
  --red: #ef5b5b;
  --accent: #4f8cff;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, "SF Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--red); }

#app { padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 110px); max-width: 640px; margin: 0 auto; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.hello { font-size: 22px; font-weight: 700; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn.block { width: 100%; margin-top: 4px; }
.pending-card { flex-direction: column; align-items: stretch !important; border-color: #b8860b !important; gap: 10px !important; }
.pc-head { display: flex; justify-content: space-between; align-items: center; }
.pc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pc-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.pc-grid input, .pc-grid select { padding: 9px; font-size: 14px; color: var(--text); }
.badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.badge.on { color: var(--green); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.wide { grid-column: 1 / -1; }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 4px; direction: ltr; text-align: right; }
.card.in .value { color: var(--green); }
.card.out .value { color: var(--red); }
.card .split { display: flex; gap: 16px; margin-top: 6px; }

.section-title { display: flex; justify-content: space-between; align-items: center; margin: 18px 2px 8px; font-weight: 700; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.list .empty { color: var(--muted); justify-content: center; background: transparent; border-style: dashed; }
.tx-main { flex: 1; min-width: 0; }
.tx-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { color: var(--muted); font-size: 12px; }
.tx-amt { font-weight: 700; direction: ltr; white-space: nowrap; }
.tx-amt.in { color: var(--green); }
.tx-amt.out { color: var(--red); }
.del { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); margin-inline-start: 4px; }

.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); background: none; flex: none; cursor: pointer; }
.check.done { background: var(--green); border-color: var(--green); }
li.done .tx-title { text-decoration: line-through; color: var(--muted); }
li.overdue .tx-sub { color: var(--red); }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bars li { background: var(--panel); border-radius: 12px; padding: 10px 12px; position: relative; overflow: hidden; }
.bars .fill { position: absolute; inset-block: 0; inset-inline-start: 0; background: rgba(239, 91, 91, .15); }
.bars .row-c { position: relative; display: flex; justify-content: space-between; }

.chips { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 14px; cursor: pointer; white-space: nowrap; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.inline-form { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 14px; }

input, select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 12px 16px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }

/* bottom nav */
.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; display: flex; justify-content: space-around; align-items: center;
  background: rgba(15, 17, 21, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 8px 6px calc(var(--safe-b) + 8px);
}
.nav { background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; font-size: 11px; gap: 2px; cursor: pointer; min-width: 56px; }
.nav span { font-size: 20px; }
.nav.active { color: var(--text); }
.mic {
  width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 28px;
  margin-top: -30px; box-shadow: 0 6px 24px rgba(79, 140, 255, .45); cursor: pointer;
}
.mic.rec { background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px rgba(239, 91, 91, .15); } }

/* sheets */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; z-index: 20; }
.sheet-inner {
  width: 100%; max-width: 640px; margin: 0 auto; background: var(--panel); border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(var(--safe-b) + 18px); display: flex; flex-direction: column; gap: 10px;
  max-height: 92dvh; overflow-y: auto;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet-head select { width: auto; padding: 6px 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }

.listening { display: flex; align-items: center; gap: 8px; color: var(--red); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.reply {
  position: fixed; inset-inline: 12px; bottom: calc(var(--safe-b) + 96px); max-width: 616px; margin: 0 auto;
  background: var(--panel-2); border: 1px solid var(--accent); border-radius: 16px; padding: 14px; z-index: 10;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); white-space: pre-wrap;
}
.reply .link { margin-top: 6px; }

.toast {
  position: fixed; top: calc(var(--safe-t) + 14px); inset-inline: 0; margin: 0 auto; width: max-content; max-width: 90vw;
  background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; z-index: 30;
}

.screen-full { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.logo { font-size: 48px; font-weight: 800; color: var(--accent); }
