:root {
  --bg: #0f0d0c;
  --panel: #181513;
  --panel-2: #211d1a;
  --line: #2e2824;
  --text: #f1ebe3;
  --muted: #a39789;
  --accent: #c9965a;
  --accent-ink: #1a1410;
  --ok: #5fb87a;
  --warn: #e0a84a;
  --bad: #e06a5a;
  --info: #6fa8dc;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: 'Inter', 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
[dir='rtl'] { --font: 'Cairo', 'Inter', system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; letter-spacing: 0.2px; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Layout */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-inline-end: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 18px; letter-spacing: 0.5px; }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); opacity: 0.8; }
.nav a:hover { background: var(--panel-2); text-decoration: none; opacity: 1; }
.nav a.active { background: var(--panel-2); color: var(--accent); opacity: 1; }
.nav .ico { width: 20px; text-align: center; }
.side .foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.main { padding: 26px 30px 90px; max-width: 1200px; width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row; padding: 6px; z-index: 20; border-top: 1px solid var(--line); border-inline-end: 0; overflow-x: auto; }
  .brand, .side .foot { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { flex-direction: column; gap: 0; font-size: 11px; padding: 6px 10px; white-space: nowrap; }
  .main { padding: 18px 14px 100px; }
  .mobile-only { display: inline-flex !important; }
}
.mobile-only { display: none !important; }
.mobile-bar { display: none; }
@media (max-width: 860px) {
  .mobile-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .g4 { grid-template-columns: 1fr 1fr !important; }
  .stat .value { font-size: 20px; }
  .card { padding: 14px; }
  .table td, .table th { padding: 8px 6px; }
}

/* Cards & grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* Buttons & forms */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button:disabled { opacity: 0.5; cursor: wait; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
.danger { color: var(--bad); }
.ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form { grid-template-columns: 1fr; } }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }
.end, .table th.end, .table td.end { text-align: end; }

/* Status pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.st-draft { color: var(--muted); }
.st-sent { color: var(--warn); }
.st-confirmed { color: var(--ok); }
.st-completed { color: var(--info); }
.st-cancelled { color: var(--bad); }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal .dow { background: var(--panel-2); padding: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.cal .day { min-height: 110px; padding: 6px; border-top: 1px solid var(--line); border-inline-start: 1px solid var(--line); background: var(--panel); }
.cal .day:nth-child(7n + 1) { border-inline-start: 0; }
.cal .day.other { opacity: 0.4; }
.cal .day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal .d { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chip { display: block; font-size: 12px; padding: 3px 6px; border-radius: 6px; margin-bottom: 3px; background: var(--panel-2); border-inline-start: 3px solid currentColor; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.chip.st-confirmed { border-color: var(--ok); } .chip.st-sent { border-color: var(--warn); } .chip.st-draft { border-color: var(--muted); } .chip.st-completed { border-color: var(--info); } .chip.st-cancelled { border-color: var(--bad); text-decoration: line-through; opacity: 0.6; }
@media (max-width: 640px) { .cal .day { min-height: 64px; } .chip { font-size: 10px; } }

/* Bars */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 160px; }
.bars .b { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 2px; }
.bars .in { background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .out { background: var(--bad); opacity: 0.7; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .m { text-align: center; font-size: 11px; color: var(--muted); }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; overflow-y: auto; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); width: 100%; max-width: 640px; padding: 22px; box-shadow: var(--shadow); }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; bottom: 24px; inset-inline-end: 24px; background: var(--panel-2); border: 1px solid var(--line); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60; max-width: 360px; }
.toast.err { border-color: var(--bad); }
@media (max-width: 860px) { .toast { bottom: 90px; inset-inline: 14px; } }
.loading { position: fixed; top: 0; inset-inline: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 200% 100%; animation: load 1s linear infinite; z-index: 70; }
@keyframes load { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Center screens (login, setup, client) */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.center .card { max-width: 460px; width: 100%; padding: 30px; }
.logo-mark { font-size: 13px; letter-spacing: 4px; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 14px; }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step::before { counter-increment: s; content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 13px; }
.step.done::before { content: '✓'; background: var(--ok); color: #fff; border-color: var(--ok); }
.lang-toggle { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.copy { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--bg); padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line); word-break: break-all; }
.pin { font-size: 28px; letter-spacing: 8px; font-weight: 700; color: var(--accent); }

/* Client portal */
.portal { max-width: 720px; margin: 0 auto; padding: 30px 18px 60px; }
.portal header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.portal .hero { background: linear-gradient(135deg, #221b15, #14110f); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; }
.portal .hero .date { font-size: 22px; font-weight: 700; }
.pin-input { font-size: 28px; letter-spacing: 12px; text-align: center; max-width: 220px; margin: 0 auto; }
.totals td { padding: 6px 0; } .totals td:last-child { text-align: end; font-variant-numeric: tabular-nums; }
.totals tr.strong td { font-weight: 700; border-top: 1px solid var(--line); padding-top: 10px; }
.terms { white-space: pre-line; color: var(--muted); font-size: 14px; }
