:root {
  --paper: #F4F0EA; --stone: #E9E1D3; --lavender: #C8C4D5; --deep-lavender: #71659A; --plum: #4B4366;
  --sage: #ADBBAE; --deep-sage: #68836A; --charcoal: #343633; --line: rgba(52, 54, 51, 0.18);
  --danger: #8A2E2E; --ok: #3E6B45;
  --sans: 'Manrope', system-ui, sans-serif; --display: 'Instrument Serif', Georgia, serif;
}
:lang(ar) { --sans: 'IBM Plex Sans Arabic', system-ui, sans-serif; --display: 'Noto Naskh Arabic', serif; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--charcoal); font-family: var(--sans); font-size: 1rem; line-height: 1.55; }
a { color: var(--plum); }
h1, h2, h3, p { margin: 0; }
.app-top { border-bottom: 1px solid var(--line); background: var(--paper); }
.app-top .in { max-width: 1180px; margin: 0 auto; padding: 0.9rem 1.5rem; display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: var(--charcoal); }
.brand img { width: 42px; height: 37px; display: block; }
.brand b { font-family: 'Manrope', sans-serif; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.2em; display: block; }
.brand small { font-family: 'Noto Naskh Arabic', serif; font-size: 0.9rem; display: block; }
.top-actions { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; font-size: 0.9rem; }
.top-actions a, .top-actions button.link { color: var(--charcoal); text-decoration: none; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.narrow { max-width: 560px; }
.h1 { font-family: var(--display); font-weight: 400; font-size: clamp(2.2rem, 4vw, 3.2rem); line-height: 1.1; margin-bottom: 0.5rem; }
:lang(ar) .h1 { font-weight: 500; line-height: 1.35; }
.h2 { font-family: var(--display); font-weight: 400; font-size: 1.7rem; line-height: 1.2; }
:lang(ar) .h2 { font-weight: 500; line-height: 1.4; }
.lede { color: #4a4c48; max-width: 40rem; }
.muted { color: #5d5f5a; font-size: 0.9rem; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem 1.4rem; }
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.between { justify-content: space-between; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.2rem; }
.stat .k { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--plum); }
:lang(ar) .stat .k { letter-spacing: 0; text-transform: none; font-size: 0.9rem; }
.stat .v { font-family: var(--display); font-size: 2.1rem; line-height: 1.1; margin-top: 0.2rem; }
.stat.owed .v { color: var(--danger); }
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }
input, select, textarea { width: 100%; font: inherit; font-size: 0.95rem; padding: 0.65rem 0.75rem; border: 1px solid rgba(52,54,51,0.3); border-radius: 10px; background: #fff; color: var(--charcoal); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--deep-lavender); outline-offset: 2px; }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 0.9rem; }
.fields { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 44px; padding: 0.6rem 1.2rem; border-radius: 999px; border: 1px solid transparent; font: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer; text-decoration: none; background: var(--charcoal); color: var(--paper); }
.btn.plum { background: var(--plum); }
.btn.ghost { background: transparent; color: var(--charcoal); border-color: rgba(52,54,51,0.35); }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(138,46,46,0.4); }
.btn.sm { min-height: 36px; padding: 0.35rem 0.85rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--plum); cursor: pointer; text-decoration: underline; }
.msg { padding: 0.75rem 1rem; border-radius: 10px; margin: 0.75rem 0; font-size: 0.92rem; }
.msg.err { background: #F6E3E3; color: var(--danger); }
.msg.ok { background: #E3EEE4; color: var(--ok); }
.msg.info { background: var(--stone); }
.hidden { display: none !important; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: start; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--plum); padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
:lang(ar) th { letter-spacing: 0; text-transform: none; font-size: 0.85rem; }
td { padding: 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--stone); white-space: nowrap; }
.tag.ok { background: #DDEBDF; color: var(--ok); }
.tag.warn { background: #F3E6C8; color: #6B4E12; }
.tag.bad { background: #F3DCDC; color: var(--danger); }
.tag.lav { background: var(--lavender); }
.tag.void { text-decoration: line-through; }
.slots { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.slot { position: relative; }
.slot input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slot span { display: block; text-align: center; padding: 0.6rem 0.4rem; border: 1px solid rgba(52,54,51,0.3); border-radius: 10px; background: #fff; cursor: pointer; font-size: 0.88rem; min-height: 44px; }
.slot input:checked + span { background: var(--plum); color: var(--paper); border-color: var(--plum); }
.slot input:focus-visible + span { outline: 2px solid var(--deep-lavender); outline-offset: 2px; }
.day-label { font-weight: 700; font-size: 0.85rem; margin: 1rem 0 0.4rem; color: var(--plum); }
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.picker { margin-top: 0.6rem; }
.dayrow { display: grid; grid-template-columns: minmax(9rem, 12rem) 1fr; gap: 0.4rem 0.8rem; align-items: center; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.dayrow .d { font-weight: 700; font-size: 0.85rem; color: var(--plum); }
.dayrow .t { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.dayrow .slot span { min-width: 4.6rem; padding: 0.5rem 0.6rem; }
.picker details summary { cursor: pointer; font-weight: 700; color: var(--plum); padding: 0.8rem 0; min-height: 44px; }
@media (max-width: 520px) { .dayrow { grid-template-columns: 1fr; } }
.tabs { display: flex; flex-wrap: wrap; gap: 0.3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 0.7rem 1rem; font: inherit; font-weight: 600; color: #5d5f5a; cursor: pointer; min-height: 44px; }
.tabs button[aria-selected="true"] { color: var(--charcoal); border-bottom-color: var(--plum); }
.badge { display: inline-block; min-width: 1.4rem; padding: 0 0.4rem; border-radius: 999px; background: var(--plum); color: #fff; font-size: 0.72rem; text-align: center; margin-inline-start: 0.3rem; }
.list-item { padding: 0.9rem 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
dialog::backdrop { background: rgba(52,54,51,0.45); }
dialog .dlg { padding: 1.4rem 1.5rem; }
dialog h3 { font-family: var(--display); font-weight: 400; font-size: 1.6rem; margin-bottom: 1rem; }
.copybox { display: flex; gap: 0.5rem; }
.copybox input { font-size: 0.8rem; }
@media (max-width: 640px) { .wrap { padding: 1.25rem 1rem 3rem; } .card { padding: 1rem; } }
@media print { .no-print { display: none !important; } body { background: #fff; } }
.tzline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.7rem; margin: 0.5rem 0 0.2rem; }
.tzline label { margin: 0; font-weight: 600; font-size: 0.85rem; }
.tzline select { width: auto; max-width: 100%; padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.alt { color: #5d5f5a; font-weight: 400; font-size: 0.85em; }
