/* كزدورة — base design tokens & shared components */
:root {
  --bg: #f4efe6;
  --surface: #ffffff;
  --surface-2: #faf6ef;
  --ink: #1f1b16;
  --ink-2: #5b5248;
  --muted: #8b8176;
  --line: #e6dccb;
  --brand: #7a3e2a;      /* espresso */
  --brand-2: #a4573b;
  --accent: #e8b45a;     /* caramel gold */
  --accent-ink: #3d2b0c;
  --ok: #2e8b57;
  --ok-bg: #e5f5eb;
  --warn: #d98e04;
  --warn-bg: #fff3d6;
  --danger: #c0392b;
  --danger-bg: #fbe4e1;
  --info: #2f6f9f;
  --info-bg: #e4f0f8;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(31, 27, 22, 0.08);
  --shadow-lg: 0 12px 40px rgba(31, 27, 22, 0.18);
  --tap: 52px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.bold { font-weight: 700; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }
.center { text-align: center; }

.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 16px; color: var(--ink-2); }
.boot i { font-size: 48px; color: var(--brand); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  font-weight: 700; font-size: 16px; transition: transform 0.08s, background 0.15s, opacity 0.15s;
  user-select: none; -webkit-user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.success { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.outline-danger { color: var(--danger); border-color: var(--danger); background: #fff; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.lg { min-height: 60px; font-size: 18px; padding: 0 24px; }
.btn.block { width: 100%; }
.btn.icon { width: var(--tap); padding: 0; }
.btn.icon.sm { width: 40px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: 14px; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(164, 87, 59, 0.15); }
textarea.input { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.brand { background: var(--brand); color: #fff; border-color: transparent; }

/* Toasts */
.toast-root { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: min(520px, 94vw); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(-10px); transition: all 0.25s; font-weight: 700; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--ok); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warn); color: #241a00; }
.toast i { font-size: 20px; }

/* Modal */
#modal-root { display: none; }
#modal-root.open { display: block; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(31, 27, 22, 0.55); z-index: 900; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; width: min(560px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop 0.18s ease-out; }
.modal.lg { width: min(860px, 100%); }
.modal.xl { width: min(1100px, 100%); }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 20px; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { background: var(--surface-2); font-weight: 700; color: var(--ink-2); font-size: 13px; position: sticky; top: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.empty i { font-size: 40px; display: block; margin-bottom: 10px; opacity: 0.5; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-body { padding: 18px; }
