:root {
    --ink: #4d3533;
    --ink-2: rgba(77, 53, 51, 0.7);
    --ink-3: rgba(77, 53, 51, 0.5);
    --hairline: rgba(77, 53, 51, 0.1);
    --page: #fdfcfb;
    --raised: #f6f2ef;
    --teal: #73a89a;
    --teal-wash: rgba(115, 168, 154, 0.1);
    --red: #ed313e;
    --red-wash: rgba(237, 49, 62, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Arabic", "Noto Kufi Arabic", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 720px;
    margin: 0 auto;
    padding: 28px 20px 44px;
}

/* ------------------------------ الترويسة ------------------------------ */

.hd h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.3;
}
.hd-fact {
    margin: 6px 0 0;
    color: var(--teal);
    font-size: 13px;
    font-weight: 600;
}
.hd-intro {
    margin: 12px 0 0;
    color: var(--ink-2);
    font-size: 14px;
    line-height: 1.8;
}

/* ------------------------------ التابات ------------------------------ */

.nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-top: 22px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--hairline);
    overflow-x: auto;
    scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 999px;
    color: var(--ink-2);
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}
.nav a[aria-current="page"] {
    background: var(--teal-wash);
    color: var(--ink);
    font-weight: 600;
}

/* ------------------------------ الأقسام ------------------------------ */

.grp { margin-top: 30px; }
.grp-h {
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.hero { padding: 6px 0 14px; }
.hero-label { color: var(--ink-2); font-size: 13px; }
.hero-value {
    margin: 4px 0 6px;
    font-size: 38px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
}
.hero-quiet .hero-value { font-size: 30px; }
.unit {
    margin-inline-start: 6px;
    color: var(--ink-2);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0;
}
.hero-note { color: var(--ink-3); font-size: 12px; line-height: 1.7; }

.stats { border-top: 1px solid var(--hairline); }
.stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--hairline);
}
.stat-label { color: var(--ink-2); font-size: 14px; }
.stat-value { font-size: 17px; font-weight: 600; }
.stat.is-strong { border-bottom: none; padding-top: 14px; }
.stat.is-strong .stat-label { color: var(--ink); font-weight: 600; }
.stat.is-strong .stat-value { font-size: 21px; }

.total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0 14px;
    border-bottom: 1px solid var(--hairline);
}

/* ------------------------------ الصفوف ------------------------------ */

.list { border-top: 1px solid var(--hairline); }
.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 13px 0;
    border-bottom: 1px solid var(--hairline);
    color: inherit;
    text-decoration: none;
}
.row-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row-name { font-size: 15px; font-weight: 600; }
.row-sub { color: var(--ink-2); font-size: 12px; line-height: 1.5; }
.row-value { font-size: 16px; font-weight: 600; white-space: nowrap; }
.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--red-wash);
    color: var(--red);
    font-size: 11px;
    line-height: 1.7;
}

/* ------------------------------ الأزرار ------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}
.btn-primary {
    border-color: transparent;
    background: var(--ink);
    color: var(--page);
    font-weight: 600;
}
.btn-ghost {
    border-color: transparent;
    background: none;
    color: var(--ink-2);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.btn-sm { width: auto; margin-top: 12px; }

.actions { display: grid; gap: 8px; margin: 12px 0; }
.actions.is-row { grid-template-columns: 1fr 1fr; }
@media (min-width: 380px) {
    .actions.is-row { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
}
@media (min-width: 768px) {
    .actions { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.chip {
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
}
.chip.is-on {
    border-color: var(--teal);
    background: var(--teal-wash);
    font-weight: 600;
}

.linkbtn {
    display: block;
    min-height: 44px;
    padding: 8px 0;
    border: none;
    background: none;
    color: var(--ink-2);
    font-family: inherit;
    font-size: 13px;
    text-align: start;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

/* ------------------------------ الحقول ------------------------------ */

.field { display: block; margin: 0 0 12px; }
.label { display: block; margin-bottom: 5px; color: var(--ink-2); font-size: 12px; }
.input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
}
.amount {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font-family: inherit;
    font-size: 30px;
    font-weight: 600;
    text-align: right;
}
.amount-box { margin: 12px 0; }
.input:focus-visible, .amount:focus-visible, .chip:focus-visible, .btn:focus-visible, .linkbtn:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
}

/* ------------------------------ لوحة الإدخال ------------------------------ */

.panel {
    margin: 16px 0;
    padding: 14px 16px 16px;
    border-radius: var(--radius);
    background: var(--raised);
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.panel-title { font-size: 15px; font-weight: 600; }
.close {
    width: 44px;
    height: 44px;
    margin-inline-end: -10px;
    border: none;
    background: none;
    color: var(--ink-2);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.pick {
    max-height: 210px;
    margin-bottom: 12px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
    background: #fff;
    overflow-y: auto;
}
.pick-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid var(--hairline);
    background: none;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    text-align: start;
    cursor: pointer;
}
.pick-row:last-child { border-bottom: none; }
.pick-row.is-on { background: var(--teal-wash); font-weight: 600; }
.pick-value { color: var(--ink-2); font-size: 13px; }
.picked {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--teal);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 14px;
    font-weight: 600;
}
.picked .linkbtn { min-height: auto; padding: 0; font-weight: 400; }

.error { margin: 6px 0 10px; color: var(--red); font-size: 13px; }
.ok { margin: 4px 0 12px; font-size: 15px; line-height: 1.8; }

/* ------------------------------ صفحة الحساب ------------------------------ */

.back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--ink-2);
    font-size: 13px;
    text-decoration: none;
}
.name {
    margin: 2px 0 0;
    font-size: 24px;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.4;
}

.limit { padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.limit-head { display: flex; justify-content: space-between; gap: 10px; color: var(--ink-2); font-size: 12px; }
.bar {
    height: 6px;
    margin: 8px 0 6px;
    border-radius: 999px;
    background: rgba(77, 53, 51, 0.05);
    overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 999px; background: var(--teal); }
.callout {
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--raised);
    font-size: 13px;
}
.callout strong { display: block; margin-bottom: 4px; font-size: 13px; }
.callout p { margin: 0; color: var(--ink-2); line-height: 1.8; }

.remind-text {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 14px;
    line-height: 1.9;
    white-space: pre-line;
}

/* ------------------------------ الحركات ------------------------------ */

.hist { border-top: 1px solid var(--hairline); }
.hist-row { padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.hist-main { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hist-kind { font-size: 14px; }
.hist-amt { font-size: 15px; font-weight: 600; }
.hist-amt.is-plus { color: var(--ink); }
.hist-amt.is-minus { color: var(--teal); }
.hist-sub {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 3px;
    color: var(--ink-2);
    font-size: 12px;
}
.del {
    margin-top: 8px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    background: none;
    color: var(--ink-2);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}
.del.is-confirm { border-color: var(--red); color: var(--red); }

/* ------------------------------ نص ------------------------------ */

.para { margin: 12px 0; color: var(--ink-2); line-height: 1.9; }
.caption { margin: 8px 0; color: var(--ink-3); font-size: 12px; line-height: 1.8; }
.notice {
    margin: 20px 0 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--teal-wash);
    color: var(--ink);
    font-size: 13px;
}
.closing {
    margin: 34px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--hairline);
    color: var(--ink-3);
    font-size: 12px;
    line-height: 1.8;
}

@media (min-width: 768px) {
    #app { padding: 40px 36px 56px; }
    .hd h1 { font-size: 34px; }
    .hero-value { font-size: 42px; }
    .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
    .stat.is-strong { grid-column: 1 / -1; }
}
