/* أساس مشترك: الخط Cairo، الألوان، الأزرار، الحقول، النوافذ، التنبيهات، رمز الريال. */
@font-face {
  font-family: 'Cairo';
  src: url('/shared/fonts/Cairo.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
}
:root {
  --brand: #0f766e;
  --brand-ink: #fff;
  --brand-soft: rgba(15, 118, 110, 0.1);
  --brand-line: rgba(15, 118, 110, 0.3);
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --ink: #1c1917;
  --ink-2: #44403c;
  --muted: #78716c;
  --line: #e7e5e4;
  --line-2: #d6d3d1;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --err: #b91c1c;
  --err-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.06), 0 4px 16px rgba(28, 25, 23, 0.06);
  --shadow-lg: 0 10px 40px rgba(28, 25, 23, 0.18);
  --tap: 44px;
  color-scheme: light;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: 'Cairo', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img {
  max-width: 100%;
  display: block;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.3;
  font-weight: 800;
}
p {
  margin: 0;
}
a {
  color: var(--brand);
}
:focus-visible {
  outline: 3px solid var(--brand-line);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* رمز الريال العماني: قناع بلون النص من المسار الرسمي */
.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  unicode-bidi: isolate;
}
.rial {
  display: inline-block;
  width: 1.32em;
  height: 0.7em;
  background: currentColor;
  -webkit-mask: url('/shared/omr.svg') center / contain no-repeat;
  mask: url('/shared/omr.svg') center / contain no-repeat;
  vertical-align: -0.02em;
}

/* أزرار */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  touch-action: manipulation;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}
.btn.primary:hover {
  filter: brightness(1.06);
}
.btn.danger {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover {
  background: var(--brand-soft);
}
.btn.soft {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand);
}
.btn.sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
}
.btn.lg {
  min-height: 54px;
  font-size: 17px;
  padding: 0 24px;
}
.btn.block {
  width: 100%;
}
.icon-btn {
  width: var(--tap);
  height: var(--tap);
  padding: 0;
}
.icon-btn.sm {
  width: 34px;
  height: 34px;
  min-height: 34px;
}
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* حقول */
.field {
  display: grid;
  gap: 4px;
  align-content: start;
}
.field > span,
.label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}
.field small,
.hint {
  color: var(--muted);
  font-size: 12.5px;
}
input:not([type]),
input[type='text'],
input[type='search'],
input[type='password'],
input[type='number'],
input[type='tel'],
input[type='date'],
input[type='email'],
input[type='url'],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type='color'] {
  width: 64px;
  height: var(--tap);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 4px;
  background: var(--surface);
}
textarea {
  min-height: 84px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input[inputmode='decimal'],
input[inputmode='numeric'],
input[type='number'],
input[type='tel'],
.ltr {
  direction: ltr;
  text-align: right;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  cursor: pointer;
}
.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
  flex: none;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.stack {
  display: grid;
  gap: 12px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.strong {
  font-weight: 800;
}
.ok-text {
  color: var(--ok);
}
.err-text {
  color: var(--err);
}
.warn-text {
  color: var(--warn);
}
@media (max-width: 560px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* شارات */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: transparent;
}
.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}
.badge.err {
  background: var(--err-soft);
  color: var(--err);
  border-color: transparent;
}
.badge.info {
  background: var(--info-soft);
  color: var(--info);
  border-color: transparent;
}
.badge.brand {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: transparent;
}

/* نوافذ */
dialog.modal {
  border: 0;
  padding: 0;
  border-radius: 16px;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  color: var(--ink);
  overflow: auto;
}
dialog.modal.wide {
  width: min(920px, calc(100vw - 24px));
}
dialog.modal::backdrop {
  background: rgba(28, 25, 23, 0.45);
}
dialog.modal[open] {
  animation: pop 0.16s ease-out;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.modal-head h2 {
  font-size: 18px;
}
.modal-body {
  padding: 18px;
  display: grid;
  gap: 14px;
}
.modal-foot {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--surface);
  z-index: 2;
}
.confirm {
  padding: 22px;
  display: grid;
  gap: 18px;
}
.confirm p {
  font-size: 16px;
  font-weight: 600;
}
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* تنبيهات منبثقة */
#toasts {
  position: fixed;
  inset-inline: 0;
  bottom: 18px;
  display: grid;
  justify-items: center;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  background: #1c1917;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.err {
  background: var(--err);
}
.toast.warn {
  background: var(--warn);
}
.toast.out {
  opacity: 0;
  transform: translateY(8px);
}

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  display: grid;
  gap: 8px;
  justify-items: center;
}
.empty .icon {
  width: 40px;
  height: 40px;
  stroke-width: 1.5;
  opacity: 0.6;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 24px auto;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
