:root {
  --bg: #f5f4f0; --card: #ffffff; --ink: #1f1f1d; --muted: #6b6a64; --line: #e3e1da;
  --brand: #1f4f43; --brand-2: #2d6b5b; --ok-bg: #e5f2ec; --ok: #11603f;
  --warn-bg: #fbf0df; --warn: #7a4a06; --danger-bg: #fbe8e6; --danger: #9b2c22;
  --radius: 10px; --font: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151614; --card: #1e201d; --ink: #ecebe6; --muted: #a3a19a; --line: #34362f;
    --brand: #5fb49a; --brand-2: #7cc8b0; --ok-bg: #173226; --ok: #8fd6b5; --warn-bg: #3a2b12; --warn: #f2c27a; --danger-bg: #3d1a17; --danger: #f29c92; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
h1 { font-size: 22px; margin: 6px 0 14px; font-weight: 600; }
h2 { font-size: 18px; margin: 0; font-weight: 600; }
h3 { font-size: 15px; margin: 18px 0 8px; font-weight: 600; }
a { color: var(--brand); }
.muted { color: var(--muted); } .tiny { font-size: 12.5px; } .center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .5px; }
.nowrap { white-space: nowrap; } .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

label { display: block; font-size: 13.5px; color: var(--muted); margin: 10px 0 4px; }
label.inl { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); margin: 14px 0; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; }
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }
button, .btn { font: inherit; cursor: pointer; border-radius: 8px; padding: 9px 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:disabled { opacity: .6; cursor: default; }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.ghost { border-color: transparent; background: transparent; }
.small { padding: 6px 10px; font-size: 13.5px; }
.wide { width: 100%; justify-content: center; margin-top: 16px; }
.link { border: 0; background: none; color: var(--brand); padding: 0 4px; text-decoration: underline; }
.icon-btn { border: 0; background: transparent; padding: 6px 8px; position: relative; }
.row { display: flex; align-items: center; flex-wrap: wrap; } .gap { gap: 8px; } .end { justify-content: flex-end; margin-top: 14px; } .wrapr { flex-wrap: wrap; }

.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.boot { min-height: 60vh; display: grid; place-items: center; color: var(--muted); }

.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); display: inline-block; position: relative; }
.logo::after { content: ""; position: absolute; inset: 6px 5px 5px; border: 2px solid #fff; border-top-width: 3px; border-radius: 2px; }
.lock-ic { width: 10px; height: 8px; border: 2px solid currentColor; border-radius: 2px; display: inline-block; position: relative; margin-inline-end: 6px; top: 1px; }
.lock-ic::before { content: ""; position: absolute; width: 6px; height: 6px; border: 2px solid currentColor; border-bottom: 0; border-radius: 4px 4px 0 0; left: 0; top: -7px; }
.bell { width: 16px; height: 16px; display: inline-block; border: 2px solid var(--ink); border-radius: 8px 8px 3px 3px; border-bottom-width: 3px; }
.count { position: absolute; top: 0; inset-inline-end: 0; background: var(--danger); color: #fff; font-size: 11px; border-radius: 9px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 430px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.auth-head { display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lockline { margin-top: 18px; display: flex; align-items: center; }
.rk { background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; font-size: 19px; word-break: break-all; margin: 12px 0; }
.small-rk { font-size: 13px; text-align: start; }

.note { border-radius: 8px; padding: 10px 12px; margin: 8px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note.ok { background: var(--ok-bg); color: var(--ok); } .note.warn { background: var(--warn-bg); color: var(--warn); } .note.danger { background: var(--danger-bg); color: var(--danger); }
.badge { font-size: 12px; font-weight: 500; padding: 3px 8px; border-radius: 999px; display: inline-flex; align-items: center; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.danger { background: var(--danger-bg); color: var(--danger); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; margin-inline-end: 6px; }

.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; flex-wrap: wrap; }
.top-actions { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 14px 16px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 12px 0; }
.card h3 { margin-top: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 10px 0; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kl { font-size: 13px; color: var(--muted); } .kv { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 140px; gap: 10px; align-items: center; margin: 6px 0; font-size: 14px; }
.bar { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand-2); border-radius: 5px; }
.bv { text-align: end; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.toolbar input[type=search] { flex: 1 1 200px; width: auto; }
.toolbar select { width: auto; } .toolbar input[type=date] { width: auto; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: start; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; } .tbl tbody tr:hover { background: var(--bg); }
.tbl tr.cancelled td { color: var(--muted); text-decoration: line-through; }
.tbl tr.cancelled td:last-child { text-decoration: none; }
.empty { text-align: center; padding: 30px 10px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 20; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 520px; border: 1px solid var(--line); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 14px 18px 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; } .span2 { grid-column: 1 / -1; }
.rates { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin-top: 12px; font-size: 13.5px; }
.rates-edit { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; } .rates-edit input { width: 110px; }
.calc { margin-top: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.att-list { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.chip button { border: 0; background: none; padding: 0 6px; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.kvr { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kvr span { color: var(--muted); } .kvr b { font-weight: 500; text-align: end; word-break: break-word; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { border-inline-start: 3px solid var(--line); padding: 6px 12px 10px; margin-bottom: 8px; }
.history li.unread { border-color: var(--danger); }
.hline { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 14px; }
.reason { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.diff { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.diff th, .diff td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.diff th { color: var(--muted); font-weight: 500; }
.diff .old { color: var(--danger); text-decoration: line-through; } .diff .new { color: var(--ok); font-weight: 500; }
.preview { max-width: 100%; border-radius: 8px; margin-top: 10px; border: 1px solid var(--line); }
.notifs { list-style: none; margin: 0; padding: 0; }
.notif { width: 100%; text-align: start; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-bottom: 8px; }
.user-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); inset-inline-start: 50%; transform: translateX(50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 90vw; font-size: 14px; }
[dir=ltr] .toast { transform: translateX(-50%); }
.toast.error { background: var(--danger); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }

@media (max-width: 760px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kv { font-size: 18px; }
  .bar-row { grid-template-columns: 110px 1fr; } .bv { grid-column: 1 / -1; text-align: start; margin-top: -4px; font-size: 13px; color: var(--muted); }
  .grid2, .kv-grid { grid-template-columns: 1fr; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px 10px; }
  .tbl td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 10px; }
  .tbl td::before { content: attr(data-l); color: var(--muted); font-size: 13px; }
  .toolbar label.inl input { width: 140px; }
}
