/* حسابات المرشد — ألوان الهوية: كريمي، أسود، عسلي، بني */
:root {
  --bg: #fbf7ec; --panel: #ffffff; --fg: #1e1a16; --muted: #6f6253; --line: #e7dcc6;
  --honey: #e39410; --honey-2: #f2a93a; --brown: #3b230c; --ink: #17130f;
  --good: #1f7a3d; --bad: #b3261e; --radius: 14px; --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14110d; --panel: #1e1913; --fg: #f6efe0; --muted: #b5a68f; --line: #3a3026; --good: #5cc27f; --bad: #ff8a80; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--fg); font-size: 16px; line-height: 1.6; padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
a { color: inherit; }
h1 { font-size: 1.5rem; margin: 0 0 12px; font-weight: 800; text-wrap: balance; }
h2 { font-size: 1.1rem; margin: 18px 0 10px; font-weight: 800; }
.muted { color: var(--muted); font-size: .9rem; }
.good { color: var(--good); } .bad { color: var(--bad); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }

.top { position: sticky; top: 0; z-index: 10; background: var(--ink); color: #fff8e8; display: flex; align-items: center; gap: 16px; padding: calc(8px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; text-decoration: none; color: var(--honey-2); }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; font-weight: 600; color: #e9dcc4; }
.nav a.on, .nav a:hover { background: #2c241b; color: #fff; }
.who { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: #cbbba0; margin: 0; }
@media (max-width: 760px) { .nav { display: none; } .top { justify-content: space-between; } }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; gap: 8px; background: var(--panel); border-top: 1px solid var(--line); padding: 8px max(12px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
.tabbar a { flex: 1; text-align: center; text-decoration: none; padding: 10px 4px; border-radius: 12px; font-weight: 700; background: var(--bg); border: 1px solid var(--line); }
.tabbar a.primary { background: var(--honey); border-color: var(--honey); color: var(--ink); }
@media (min-width: 761px) { .tabbar { display: none; } body { padding-bottom: 0; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 16px; min-width: 0; }
.card.narrow { max-width: 440px; margin: 40px auto; }
.login { text-align: center; } .login .form { text-align: start; }
.flash { padding: 12px 14px; border-radius: 12px; margin: 0 0 14px; font-weight: 600; background: #e8f5ec; color: #12512a; }
.flash.bad { background: #fdecea; color: #8c1d18; }
@media (prefers-color-scheme: dark) { .flash { background: #173322; color: #bdf0cd; } .flash.bad { background: #3b1715; color: #ffd2cd; } }
.token { display: block; word-break: break-all; margin-top: 6px; font-size: .85rem; }

.form { display: grid; gap: 12px; }
.form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
label { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; color: var(--muted); min-width: 0; }
input, select { font: inherit; font-size: 1rem; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
input[type=checkbox] { width: 22px; height: 22px; }
input:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible { outline: 3px solid var(--honey-2); outline-offset: 2px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.btn { font: inherit; font-weight: 700; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); padding: 11px 18px; cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
.btn.primary { background: var(--honey); border-color: var(--honey); color: var(--ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-style: dashed; }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.link { background: none; border: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
.link.danger { color: var(--bad); }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
details.more summary { cursor: pointer; color: var(--muted); font-weight: 600; }
details.more[open] { display: grid; gap: 10px; }
fieldset.items { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
fieldset.items legend { font-weight: 800; margin-bottom: 6px; }
.item-row { display: grid; grid-template-columns: 1fr 80px 110px; gap: 8px; align-items: end; }
@media (max-width: 480px) { .item-row { grid-template-columns: 1fr 70px 90px; } }
.total-line { font-size: 1.2rem; padding: 10px 14px; background: var(--bg); border-radius: 12px; }
.total-line b { color: var(--honey); font-size: 1.5rem; font-variant-numeric: tabular-nums; }

.hello { margin-bottom: 8px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.action { display: flex; align-items: center; gap: 12px; padding: 18px; border-radius: 18px; text-decoration: none; background: var(--panel); border: 1px solid var(--line); font-weight: 800; font-size: 1.1rem; }
.action b { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.6rem; background: var(--bg); }
.action.primary { background: var(--ink); color: #fff8e8; border-color: var(--ink); }
.action.primary b { background: var(--honey); color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.tiles.small .val { font-size: 1.2rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.tile .lbl { color: var(--muted); font-size: .85rem; font-weight: 600; }
.tile .val { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--muted); font-size: .8rem; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list a { display: flex; justify-content: space-between; gap: 8px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; }
.list .off a, tr.off, .jentry.off { opacity: .5; text-decoration: line-through; }
.empty { color: var(--muted); text-align: center; padding: 16px; }
.pill { display: inline-block; font-size: .75rem; padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); vertical-align: middle; }
.pill.bad { background: var(--bad); color: #fff; border-color: var(--bad); }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .85rem; color: var(--muted); font-weight: 700; }
.num { text-align: end; }
tfoot th { color: var(--fg); }
.statement table td, .statement table th { white-space: normal; }
.statement .head th { background: var(--bg); color: var(--brown); font-size: .95rem; }
@media (prefers-color-scheme: dark) { .statement .head th { color: var(--honey-2); } }
.statement .sum th, .statement .sum td { font-weight: 800; }
.statement .total th, .statement .total td { font-weight: 800; font-size: 1.15rem; border-top: 2px solid var(--fg); border-bottom: 3px double var(--fg); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.subnav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; font-size: .9rem; }
.subnav a.on { background: var(--ink); color: #fff8e8; border-color: var(--ink); }
.range { display: grid; gap: 10px; margin: 0 0 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { text-decoration: none; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: .85rem; font-weight: 600; background: var(--panel); }
.chip.on { background: var(--honey); border-color: var(--honey); color: var(--ink); }
.dates { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.dates label { flex: 1; min-width: 140px; } .range .grow { min-width: 220px; }
.jentry { padding: 12px; } .jentry table td { padding: 6px 8px; }
.jhead { margin-bottom: 6px; }

.erows { display: grid; gap: 6px; overflow-x: auto; }
.ehead, .erow { display: grid; gap: 6px; align-items: center; min-width: 760px; }
.ehead { font-size: .8rem; color: var(--muted); font-weight: 700; }
.prod .ehead, .prod .erow { grid-template-columns: 2.4fr 1fr 1fr .7fr 1fr .7fr .5fr auto; }
.usr .ehead, .usr .erow { grid-template-columns: 1.5fr 1.2fr 1.2fr 1.5fr .5fr auto; }
.erow input, .erow select { padding: 8px; }

@media print {
  .top, .tabbar, .subnav, .range, .btn, form.inline { display: none !important; }
  body { background: #fff; color: #000; } .card, .table-wrap { border: 0; }
}
@media (prefers-reduced-motion: no-preference) { .btn, .action, .chip { transition: transform .1s ease; } .btn:active, .action:active { transform: scale(.98); } }
