:root {
  --canvas: #eef0ee; --panel: #ffffff; --line: #ecefec; --line2: #dfe4df; --soft: #f5f7f5;
  --ink: #141d18; --ink2: #5e6a63; --ink3: #9aa49e;
  --green: #1f4d3a; --green2: #2d6b50; --green3: #3f8a68; --mint: #9bd9b3; --mint2: #dbf1e3; --mint3: #eef7f1;
  --amber: #9a5a08; --amber2: #fff0d9; --red: #b2362f; --red2: #fde6e4; --blue: #2c5fb3; --blue2: #e6edfb; --violet: #6b4fb3; --violet2: #efe9fb;
  --r: 24px; --r2: 18px; --r3: 12px;
  --font: "Plus Jakarta Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--canvas); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--green2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; font-weight: 700; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 .8rem; }
h3 { font-size: 1rem; font-weight: 700; margin: 0 0 .6rem; }
.muted { color: var(--ink2); } .faint { color: var(--ink3); } .small { font-size: .84rem; }
.warn { color: var(--amber); } .ok { color: var(--green2); } .danger { color: var(--red); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ===== shell ===== */
#shell { display: flex; gap: 14px; padding: 14px; min-height: 100vh; }
#side { width: 236px; flex: none; background: var(--panel); border-radius: var(--r); padding: 22px 16px 16px; display: flex; flex-direction: column; position: sticky; top: 14px; height: calc(100vh - 28px); }
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 6px 6px; color: var(--ink); font-weight: 800; font-size: 1.3rem; }
.brand:hover { text-decoration: none; }
.mark { width: 36px; height: 36px; border-radius: 12px; background: var(--green); color: #fff; display: grid; place-items: center; }
.mark svg { width: 20px; height: 20px; stroke-width: 2; }
#nav { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }
.nav-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; color: var(--ink3); margin: 16px 10px 6px; }
#nav a, #nav button.navbtn { position: relative; display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: var(--r3); color: var(--ink2); font-weight: 500; font-size: .95rem; background: none; border: 0; width: 100%; text-align: start; cursor: pointer; }
#nav a:hover, #nav button.navbtn:hover { color: var(--ink); background: var(--soft); text-decoration: none; }
#nav a.active { color: var(--ink); font-weight: 700; }
#nav a.active svg { color: var(--green); }
#nav a.active::before { content: ""; position: absolute; inset-inline-start: -16px; top: 9px; bottom: 9px; width: 4px; border-radius: 4px; background: var(--green); }
#nav .badge { margin-inline-start: auto; background: var(--green); color: #fff; font-size: .7rem; font-weight: 700; padding: .05rem .45rem; border-radius: 999px; }
#side-promo { margin-top: auto; background: var(--green); color: #fff; border-radius: var(--r2); padding: 16px; position: relative; overflow: hidden; }
#side-promo::after { content: ""; position: absolute; width: 150px; height: 150px; border-radius: 50%; background: var(--green2); inset-inline-end: -70px; bottom: -80px; opacity: .8; }
#side-promo b { display: block; font-size: 1rem; margin-bottom: 2px; position: relative; z-index: 1; }
#side-promo span { font-size: .8rem; opacity: .8; display: block; position: relative; z-index: 1; }
#side-promo a { display: inline-block; margin-top: 12px; background: #fff; color: var(--green); font-weight: 700; font-size: .82rem; padding: .4rem 1rem; border-radius: 999px; position: relative; z-index: 1; }
#side-promo a:hover { text-decoration: none; background: var(--mint2); }
#content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
#topbar { background: var(--panel); border-radius: var(--r); padding: 12px 18px; display: flex; align-items: center; gap: 12px; }
.search { flex: 1; max-width: 360px; background: var(--soft); border-radius: 999px; padding: 8px 14px; display: flex; gap: 8px; align-items: center; color: var(--ink3); }
.search input { border: 0; background: none; padding: 0; flex: 1; font-size: .9rem; outline: none; }
.search kbd { font: inherit; font-size: .7rem; background: #fff; border-radius: 6px; padding: 1px 6px; color: var(--ink3); }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line2); background: #fff; display: inline-grid; place-items: center; color: var(--ink2); position: relative; padding: 0; }
.iconbtn:hover { background: var(--soft); }
.iconbtn .dot { position: absolute; top: 7px; inset-inline-end: 7px; min-width: 16px; height: 16px; border-radius: 999px; background: var(--red); color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.user { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }
.user .av { width: 40px; height: 40px; font-size: 1rem; }
.user b { display: block; font-size: .9rem; line-height: 1.2; }
.user span { font-size: .78rem; color: var(--ink3); }
main { background: var(--panel); border-radius: var(--r); padding: 26px 28px 34px; flex: 1; }
#menu-btn { display: none; }
@media (max-width: 960px) {
  #shell { padding: 10px; gap: 10px; }
  #side { position: fixed; inset-inline-start: 10px; top: 10px; z-index: 30; transform: translateX(120%); transition: transform .2s; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
  html[dir=ltr] #side { transform: translateX(-120%); }
  body.side-open #side { transform: none; }
  #menu-btn { display: inline-grid; position: fixed; top: 18px; inset-inline-start: 18px; z-index: 31; background: var(--panel); border: 1px solid var(--line2); border-radius: 50%; width: 40px; height: 40px; place-items: center; padding: 0; }
  #topbar { padding-inline-start: 58px; }
  main { padding: 20px 16px 30px; }
  .user b, .user span { display: none; }
}

/* ===== page header ===== */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.page-head .sub { color: var(--ink2); font-size: .92rem; margin-top: .15rem; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; }
.datenav { display: inline-flex; align-items: center; border: 1px solid var(--line2); border-radius: 999px; background: #fff; overflow: hidden; height: 40px; }
.datenav a { padding: 0 .6rem; color: var(--ink2); display: inline-flex; align-items: center; height: 100%; }
.datenav a:hover { background: var(--soft); text-decoration: none; }
.datenav input[type=date] { border: 0; border-inline: 1px solid var(--line); border-radius: 0; padding: .3rem .5rem; width: 10.5rem; height: 100%; }
.datenav .today { font-weight: 600; color: var(--green2); padding: 0 .9rem; }

/* ===== cards & stats ===== */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); padding: 18px 20px; margin-bottom: 14px; }
.card.tight { padding: 0; overflow: hidden; }
.card.warn { border-color: #f0d9b0; background: #fffaf1; }
.card > h2, .card > h3 { display: flex; align-items: center; gap: .5rem; }
.card > h2 .spacer, .card > h3 .spacer { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); padding: 16px 18px; min-height: 118px; display: flex; flex-direction: column; }
.stat .top { display: flex; align-items: center; justify-content: space-between; font-size: .9rem; font-weight: 600; color: var(--ink2); }
.stat .top .go { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line2); display: grid; place-items: center; color: var(--ink2); }
.stat .top .go svg { width: 14px; height: 14px; }
.stat .big { font-size: 2.1rem; font-weight: 800; line-height: 1.1; margin: 8px 0 auto; letter-spacing: -.02em; }
.stat .big small { font-size: .95rem; font-weight: 600; color: var(--ink3); margin-inline-start: 4px; }
.stat .trend { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; color: var(--green2); background: var(--mint3); padding: .15rem .55rem; border-radius: 999px; align-self: flex-start; margin-top: 10px; }
.stat .trend.amber { color: var(--amber); background: var(--amber2); }
.stat .trend.grey { color: var(--ink2); background: var(--soft); }
.stat.dark { background: var(--green); border-color: var(--green); color: #fff; }
.stat.dark .top { color: #fff; } .stat.dark .top .go { border-color: rgba(255,255,255,.35); color: #fff; }
.stat.dark .big small { color: rgba(255,255,255,.7); }
.stat.dark .trend { background: rgba(255,255,255,.14); color: var(--mint); }

/* dashboard grid */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.dash .col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dash .card { margin-bottom: 0; }
@media (max-width: 1100px) { .dash { grid-template-columns: 1fr; } }

/* problems list */
.pitem { padding: 12px 0; border-top: 1px solid var(--line); }
.pitem:first-of-type { border-top: 0; padding-top: 4px; }
.pitem .txt { font-size: .9rem; margin-bottom: 8px; }
.pitem .ctl { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pitem select, .pitem input[type=date] { font-size: .85rem; padding: .3rem .5rem; }
.allgood { display: flex; align-items: center; gap: 12px; color: var(--ink2); font-size: .9rem; }
.allgood .ic { width: 42px; height: 42px; border-radius: 50%; background: var(--mint2); color: var(--green); display: grid; place-items: center; }

/* gauge */
.gauge { display: flex; flex-direction: column; align-items: center; }
.gauge svg { width: 100%; max-width: 230px; height: auto; }
.gauge .val { font-size: 2rem; font-weight: 800; margin-top: -2.2rem; letter-spacing: -.02em; }
.gauge .lbl { font-size: .8rem; color: var(--ink3); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--ink2); margin-top: 10px; }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 6px; background: var(--c, var(--green)); vertical-align: middle; }

/* pill bars */
.bars { display: flex; justify-content: space-between; align-items: flex-end; height: 130px; gap: 8px; padding: 6px 4px 0; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar i { display: block; width: 100%; max-width: 30px; border-radius: 999px; background: var(--green3); transition: height .2s; min-height: 8px; }
.bar.today i { background: var(--green); }
.bar.empty i { height: 100% !important; background: repeating-linear-gradient(135deg, #e3e7e3 0 3px, transparent 3px 8px); border: 1px solid var(--line2); }
.bar.sel i { background: var(--mint); }
.bar b { font-size: .72rem; font-weight: 600; color: var(--ink3); margin-top: 8px; }
.bar.today b { color: var(--green); }
.bar .n { font-size: .72rem; font-weight: 700; color: var(--ink2); margin-bottom: 4px; }

/* avatars */
.av { width: 32px; height: 32px; border-radius: 50%; background: var(--mint2); color: var(--green); display: inline-grid; place-items: center; font-weight: 700; font-size: .82rem; flex: none; }
.av.c1 { background: var(--amber2); color: var(--amber); } .av.c2 { background: var(--blue2); color: var(--blue); } .av.c3 { background: var(--violet2); color: var(--violet); } .av.c4 { background: var(--red2); color: var(--red); }
.who { display: inline-flex; align-items: center; gap: 10px; }
.who .nm { font-weight: 600; line-height: 1.2; }
.who .sb { font-size: .78rem; color: var(--ink3); display: block; font-weight: 400; }

/* ===== tables ===== */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); margin-bottom: 14px; }
.card > .table-wrap, .card > table { border: 0; margin: 0; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .7rem .9rem; text-align: start; vertical-align: middle; border-bottom: 1px solid var(--line); }
thead th { font-weight: 600; color: var(--ink3); font-size: .78rem; white-space: nowrap; background: none; }
tbody tr:last-child td { border-bottom: 0; }
tr.inactive td { color: var(--ink3); }
td.num, th.num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.totals td { font-weight: 700; background: var(--soft); }
tr.driver-head td { background: var(--soft); font-weight: 700; color: var(--ink2); font-size: .8rem; padding: .4rem .9rem; }
main > table { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); margin-bottom: 14px; overflow: hidden; }
td .row { flex-wrap: nowrap; } td .row button, td .row .btn { white-space: nowrap; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .65rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--soft); color: var(--ink2); white-space: nowrap; }
.pill.green { background: var(--mint2); color: var(--green2); }
.pill.amber { background: var(--amber2); color: var(--amber); }
.pill.red { background: var(--red2); color: var(--red); }
.pill.blue { background: var(--blue2); color: var(--blue); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ===== controls ===== */
button, .btn { font: inherit; font-size: .88rem; font-weight: 600; padding: .5rem 1rem; border: 1px solid var(--line2); background: #fff; color: var(--ink); border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; line-height: 1.3; transition: background .12s, border-color .12s; }
button:hover, .btn:hover { background: var(--soft); text-decoration: none; }
button.primary, .btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
button.primary:hover { background: var(--green2); }
button.danger { color: var(--red); }
button.danger:hover { background: var(--red2); border-color: #e9b4b0; }
button.link { border: none; background: none; color: var(--green2); padding: .2rem .4rem; }
button.ghost { border-color: transparent; background: transparent; color: var(--ink2); }
button.ghost:hover { background: var(--soft); color: var(--ink); }
button.sm, .btn.sm { font-size: .78rem; padding: .28rem .7rem; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: .5rem .75rem; border: 1px solid var(--line2); border-radius: var(--r3); background: #fff; color: inherit; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--mint); outline-offset: 0; border-color: var(--green3); }
input[type=number] { width: 6.5rem; }
input[type=date] { width: 11rem; }
textarea { width: 100%; min-height: 3.5rem; }
label { display: block; margin: .75rem 0 .25rem; font-size: .84rem; font-weight: 600; color: var(--ink2); }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row label { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.checks { display: flex; gap: .35rem .5rem; flex-wrap: wrap; }
.checks label { display: inline-flex; gap: .35rem; align-items: center; margin: 0; font-size: .88rem; font-weight: 500; color: var(--ink); border: 1px solid var(--line2); border-radius: 999px; padding: .25rem .75rem .25rem .55rem; cursor: pointer; }
.checks label:has(input:checked) { background: var(--green); border-color: var(--green); color: #fff; }
.checks input { margin: 0; accent-color: var(--green); }
.box { border: 1px solid var(--line); border-radius: var(--r2); padding: .8rem 1rem; margin: .5rem 0 1rem; background: var(--panel); }
.box.warn { border-color: #f0d9b0; background: #fffaf1; }

/* ===== schedule board ===== */
.board td { padding: .5rem .7rem; }
.board .maid-cell { white-space: nowrap; }
.board td.att { width: 11.5rem; }
.board td.att select { width: 100%; border-radius: 999px; padding: .3rem .7rem; font-size: .82rem; font-weight: 600; }
.board td.att.absent select { background: var(--red2); border-color: transparent; color: var(--red); }
.board td.att.off select { background: var(--soft); border-color: transparent; color: var(--ink2); }
.board td.att.present select { background: var(--mint2); border-color: transparent; color: var(--green2); }
.board td.slot { min-width: 8.5rem; }
.board thead th.slot-h { text-align: center; }
.cell-visit { display: flex; align-items: center; gap: .4rem; padding: .35rem .75rem; background: var(--mint2); color: var(--green); border-radius: 999px; cursor: pointer; margin: 2px 0; font-weight: 600; font-size: .84rem; }
.cell-visit:hover { background: var(--mint); }
.cell-visit.unpaid { background: var(--amber2); color: var(--amber); }
.cell-visit .t { font-weight: 500; font-size: .74rem; opacity: .75; margin-inline-start: auto; }

/* ===== modal & toast ===== */
#modal-root:empty { display: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 25, 20, .45); display: flex; align-items: flex-start; justify-content: center; padding: 3rem 1rem; overflow: auto; z-index: 40; }
.modal { background: var(--panel); border-radius: 22px; padding: 1.5rem 1.7rem 1.6rem; width: 100%; max-width: 660px; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 .5rem; font-size: 1.25rem; }
.modal .actions { display: flex; gap: .5rem; margin-top: 1.4rem; }
.modal .actions .grow { flex: 1; }
#toast { position: fixed; bottom: 1.4rem; inset-inline-start: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1.1rem; border-radius: 999px; z-index: 50; max-width: 90vw; font-size: .9rem; font-weight: 500; }
html[dir=rtl] #toast { transform: translateX(50%); }
#toast.err { background: var(--red); }

/* ===== login ===== */
body.logged-out #side, body.logged-out #topbar, body.logged-out #menu-btn { display: none; }
body.logged-out main { padding: 0; background: none; }
.login-wrap { min-height: calc(100vh - 28px); display: grid; place-items: center; }
.login { width: 100%; max-width: 380px; background: var(--panel); border-radius: 24px; padding: 2.2rem; }
.login .brand { padding: 0; margin-bottom: 1.2rem; }
.login input { width: 100%; }
.login button { width: 100%; justify-content: center; margin-top: 1.2rem; padding: .7rem; }

/* ===== documents ===== */
.doc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); padding: 1.4rem 1.6rem; margin-bottom: 14px; }
.doc h2 { margin: 0 0 .9rem; display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.doc .table-wrap { margin-bottom: .6rem; }
.doc-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.doc-head h1 { margin: 0 0 .2rem; }
.doc .total-line { display: flex; justify-content: flex-end; gap: 2rem; align-items: baseline; margin-top: 1rem; font-size: 1.1rem; }
.doc .total-line b { font-size: 1.6rem; letter-spacing: -.02em; }
.print-title { display: none; }

@media print {
  .no-print, #side, #menu-btn, #topbar { display: none !important; }
  body { background: #fff; font-size: 12px; }
  #shell { padding: 0; display: block; } main { padding: 0; border-radius: 0; }
  .doc, .table-wrap, .card { border: 0; padding: 0; border-radius: 0; }
  table { font-size: 11px; } th, td { padding: .35rem .5rem; border-bottom: 1px solid #ccc; }
  tr { page-break-inside: avoid; }
  .page-break { page-break-after: always; }
  .print-title { display: block; }
}
td.row { display: table-cell; white-space: nowrap; }
td.row > button, td.row > .btn { margin: 2px 1px; vertical-align: middle; }
select.sm { font-size: .8rem; padding: .25rem .5rem; }
@media print { td .print-title { display: inline; } }
table.sched td, table.sched th { padding: .4rem .5rem; }
table.sched select, table.sched input { font-size: .85rem; padding: .3rem .4rem; }
table.sched select[multiple] { min-width: 9rem; }
.modal { max-width: 860px; }
