/* ===== متغيرات الألوان: استبدلها بهويتك من هنا فقط ===== */
/* ===== متغيرات الألوان: هوية murtada.net (داكن افتراضيًا) ===== */
:root {
  --bg: #05070f;
  --surface: #0b1128;
  --surface-2: #121a38;
  --text: #e9efff;
  --muted: #9aa8c7;
  --border: #222c55;
  --accent: #63ddff;
  --accent-text: #031018;
  --accent-soft: #0e2a44;
  --ok: #5be39a;
  --ok-soft: #0a2a1f;
  --warn: #f2c14e;
  --warn-soft: #2a2010;
  --danger: #ff8f8f;
  --danger-soft: #2d1218;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f7fc;
  --surface: #ffffff;
  --surface-2: #e8eef9;
  --text: #0e1730;
  --muted: #4a5878;
  --border: #cdd7ea;
  --accent: #2457d6;
  --accent-text: #ffffff;
  --accent-soft: #dde8ff;
  --ok: #1b7443;
  --ok-soft: #dbf0e4;
  --warn: #7f5200;
  --warn-soft: #faedcb;
  --danger: #a82820;
  --danger-soft: #f7dedb;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.1);
  color-scheme: light;
}

/* ===== الأساس ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}

[hidden] {
  display: none !important;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 1.2rem 0 0.6rem;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 0.6rem;
}

h3 {
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
}

p {
  margin: 0 0 0.8rem;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.offscreen {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
}

.skip {
  position: absolute;
  inset-inline-start: 8px;
  top: -60px;
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 50;
}

.skip:focus {
  top: 8px;
}

/* ===== هيكل التطبيق (شاشة كمبيوتر بلا تمرير) ===== */
body.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.3;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.back:hover {
  filter: brightness(1.08);
}

.stage-area {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 14px 16px;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.split {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 16px;
}

.split-main,
.split-side {
  min-height: 0;
  min-width: 0;
  overflow: auto;
}

.split-main {
  display: flex;
  flex-direction: column;
}

.split-main > .screen {
  flex: 1 1 auto;
}

.stage-area > .screen {
  flex: 1 1 auto;
  min-height: 0;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen > .display {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.btn-wide {
  width: 100%;
  margin: 0 0 10px;
}

/* ===== المكوّنات ===== */
.lead {
  color: var(--muted);
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 12px;
  margin: 0 0 14px;
}

.card-link {
  display: block;
  text-decoration: none;
  color: var(--text);
}

.card-link h2 {
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.card-link p {
  margin: 0;
  color: var(--muted);
}

.card-link:hover {
  border-color: var(--accent);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin: 0 0 10px;
}

.row.tight {
  gap: 6px;
  margin: 0;
}

.row-between {
  justify-content: space-between;
  align-items: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field.grow {
  flex: 1 1 160px;
}

.field.narrow {
  flex: 0 0 96px;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

textarea {
  resize: vertical;
  min-height: 110px;
}

input[type="range"] {
  width: 100%;
  min-height: 32px;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.6rem;
}

.btn {
  min-height: 44px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-small {
  min-height: 36px;
  min-width: 36px;
  padding: 4px 10px;
  font-size: 0.9rem;
}

.btn.toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.chip-btn {
  min-height: 40px;
  padding: 4px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.chip-btn.selected,
.chip-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  min-height: 36px;
}

.check input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px 12px;
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plain-list li {
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}

.plain-list li:last-child {
  border-bottom: 0;
}

ol.plain-list {
  list-style: decimal;
  padding-inline-start: 1.4rem;
}

.notice {
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0 0 14px;
  font-size: 0.95rem;
}

.notice-info {
  background: var(--accent-soft);
  color: var(--text);
}

.notice-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.toast {
  position: fixed;
  inset-inline: 16px;
  bottom: 16px;
  max-width: 420px;
  margin-inline: auto;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 60;
}

.toast.show {
  opacity: 1;
}

/* ===== طلبات المشروع ===== */
.orders-toolbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 5;
  background: var(--bg);
  padding-bottom: 8px;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.chips-row .count {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  margin-inline-start: 2px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  text-align: center;
}

.chip-btn[aria-pressed="true"] .count {
  background: var(--accent-text);
  color: var(--accent);
}

.orders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.orders > li {
  border-bottom: 0;
  padding: 0;
}

.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.order-card.late {
  border-color: var(--danger);
}

.order-head h3 {
  margin: 0;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.order-head {
  margin: 0 0 4px;
}

.order-when,
.order-money,
.order-notes {
  margin: 0 0 6px;
}

.late-text {
  color: var(--danger);
}

.order-items {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
}

.order-items li {
  padding: 1px 0;
}

.order-notes {
  white-space: pre-line;
  color: var(--muted);
  font-size: 0.92rem;
}

.due {
  color: var(--danger);
}

.paid {
  color: var(--ok);
}

.muted {
  color: var(--muted);
}

.order-actions {
  margin: 8px 0 0;
}

.badge {
  display: inline-block;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text);
}

.badge.st-new,
.badge.st-confirmed {
  background: var(--accent-soft);
}

.badge.st-making {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.st-ready {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.st-canceled {
  background: var(--danger-soft);
  color: var(--danger);
}

.order-more {
  margin: 8px 0 0;
}

.order-more > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 6px;
}

.item-head {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.btn-danger {
  color: var(--danger);
}

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px 96px 40px;
  gap: 6px;
  margin: 0 0 6px;
}

.item-row .btn {
  min-width: 0;
  padding: 4px;
}

.mode-set {
  border: 0;
  padding: 0;
  margin: 0;
}

.mode-set legend {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0;
  margin-bottom: 4px;
}

.stats li {
  padding: 6px 0;
}

.qty {
  font-variant-numeric: tabular-nums;
}

details.panel > summary {
  cursor: pointer;
  font-weight: 700;
  margin: -2px 0 6px;
}

details.panel[open] > summary {
  margin-bottom: 10px;
}

@media (max-width: 1100px) {
  .tiles > li {
    flex-basis: calc((100% - 3 * 14px) / 4);
  }
}

@media (max-width: 899px) {
  .tiles > li {
    flex-basis: calc((100% - 12px) / 2);
  }

  .orders-toolbar {
    position: static;
  }

  .item-row {
    grid-template-columns: minmax(0, 1fr) 70px 80px 40px;
  }
}

/* ===== الجوال: عمود واحد وتمرير عادي ===== */
@media (max-width: 899px) {
  /* أثناء نموذج الطلب: لا يظهر الملخص ولا «طلب جديد» تحته، وأزرار الحفظ ثابتة أسفل الشاشة */
  .split.is-form .split-side {
    display: none;
  }

  .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 12px -14px -14px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
  }

  body.app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .stage-area {
    overflow: visible;
  }

  .split {
    display: block;
  }

  .split-main,
  .split-side {
    overflow: visible;
  }

  .topbar {
    flex-wrap: wrap;
  }
}


/* ===== الطباعة ===== */
@media print {
  body {
    background: Canvas;
    color: CanvasText;
  }

  body.app {
    height: auto;
    overflow: visible;
    display: block;
  }

  .stage-area,
  .split-main,
  .split-side {
    overflow: visible;
    display: block;
  }

  .split {
    display: block;
  }

  body.print-prep .split-main {
    display: none !important;
  }

  body.print-prep .split-side {
    display: block !important;
  }

  body.print-prep .split-side > :not(.prep-panel) {
    display: none !important;
  }

  body.print-prep .prep-panel .field,
  body.print-prep .prep-panel .row {
    display: none !important;
  }

  .no-print,
  .topbar,
  .toast,
  .controls {
    display: none !important;
  }

  .panel,
  .card,
  .group-card {
    box-shadow: none;
    break-inside: avoid;
  }

  .seat.selected {
    background: transparent;
    border-color: CanvasText;
  }
}

/* ===== تقليل الحركة ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ===== أقسام وتقارير وأيام ===== */
.tabs { display: flex; gap: 6px; margin: 0 0 10px; }
.tab { flex: 1; min-height: 44px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 0 0 10px; }
.day-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; padding: 4px 2px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; font: inherit; font-size: 0.8rem; cursor: pointer; }
.day-btn.selected { background: var(--accent-soft); border-color: var(--accent); }
.day-btn.full { border-color: var(--danger); }
.day-count { font-weight: 700; font-size: 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 0 0 12px; }
.stat-card { display: flex; flex-direction: column; gap: 4px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.1rem; }
.stat-value.due { color: var(--danger); }
.top-item { margin: 0 0 8px; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 3px; }
.bar { display: block; height: 100%; background: var(--accent); }
.receipt { display: none; }
@media (max-width: 480px) { .days { gap: 2px; } .day-btn { font-size: 0.7rem; } }
@media print {
  body.print-receipt .topbar, body.print-receipt .stage-area, body.print-receipt .skip { display: none !important; }
  body.print-receipt .receipt { display: block !important; max-width: 560px; margin: 0 auto; padding: 16px; color: CanvasText; background: Canvas; }
  .receipt-table, .receipt-sums { width: 100%; border-collapse: collapse; margin: 10px 0; }
  .receipt-table th, .receipt-table td, .receipt-sums th, .receipt-sums td { border-bottom: 1px solid GrayText; padding: 4px; text-align: right; }
  .receipt .num { text-align: left; }
  .receipt tr.strong th, .receipt tr.strong td { font-weight: 700; }
  .receipt-disclaimer, .receipt-sub { font-size: 0.85rem; color: GrayText; }
  body.print-report .split-side, body.print-report #tabs, body.print-report #btn-rp-copy, body.print-report #btn-rp-print { display: none !important; }
  body.print-report #view-reports { display: block !important; }
}


/* ===== هوية الموقع: ترويسة وخلفية وتذييل ===== */
:root:not([data-theme="light"]) body.app {
  background:
    radial-gradient(900px 480px at 88% -80px, rgba(132, 85, 255, .18), transparent 70%),
    radial-gradient(760px 420px at 4% 60px, rgba(99, 221, 255, .11), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
:root:not([data-theme="light"]) .topbar {
  background: linear-gradient(120deg, #0b1736 0%, #171446 58%, #0b2038 100%);
  border-bottom-color: transparent;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  position: relative;
}
:root:not([data-theme="light"]) .topbar::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, #63ddff, #4d8cff, #8455ff, transparent);
}
.rights { flex: none; padding: 14px 16px 18px; text-align: center; font-size: .78rem; color: var(--muted); }
.mn-link { color: inherit; text-decoration: none; display: inline-flex; }
