/* العناصر المشتركة لكل الصفحات: الأساس، الأزرار، البطاقات، الشارات، الحقول، النوافذ، الجداول.
   تقرأ القيم من assets/tokens.css فقط. */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
a {
  color: inherit;
  text-decoration: none;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
}
h1 {
  font-size: var(--fs-2xl);
  line-height: var(--lh-tight);
}
h2 {
  font-size: var(--fs-xl);
  line-height: var(--lh-tight);
}
h3 {
  font-size: var(--fs-lg);
  line-height: var(--lh-tight);
}
small {
  font-size: var(--fs-xs);
}
.muted {
  color: var(--muted);
}
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.hidden,
[hidden] {
  display: none !important;
}

/* التخطيط */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.stack {
  display: grid;
  gap: 18px;
}
.two-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.three-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.page-title {
  margin-bottom: 24px;
}
.page-title.between {
  flex-wrap: wrap;
}
.page-title.between > div:first-child {
  flex: 1 1 280px;
}
.page-title p {
  margin-top: 4px;
  font-size: 15px;
  color: var(--muted);
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

/* الأزرار: زر رئيسي واحد في كل شاشة، والباقي بإطار. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--brand);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn:hover {
  background: var(--brand-tint);
}
.btn.primary,
.btn.secondary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}
.btn.primary:hover,
.btn.secondary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover {
  background: var(--surface-2);
}
.btn.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.btn.danger {
  color: var(--danger);
}
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand);
  font-weight: 700;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* البطاقات والشارات */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  padding: 2px 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.badge.gold {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.badge.green {
  background: var(--success-soft);
  color: var(--success);
}
.badge.red {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge.blue {
  background: var(--info-soft);
  color: var(--info);
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
}

/* التبويبات والفلاتر */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-btn {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
}
.filter-btn:hover {
  background: var(--surface-2);
}
.filter-btn.active {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand);
  font-weight: 700;
}

/* الرسائل */
.notice {
  padding: 12px 16px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 14px;
}
.notice.info {
  border-color: var(--brand-line);
  background: var(--info-soft);
  color: var(--info);
}
.notice.error,
.form-error:not(:empty) {
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
}
.form-error:not(:empty) {
  margin-top: 12px;
  padding: 10px 14px;
  font-size: 14px;
}
.empty {
  padding: 40px 20px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
}
.empty h3 {
  color: var(--text);
  margin: 10px 0 4px;
}
.empty p {
  font-size: 14px;
  margin: 0 auto 18px;
  max-width: 420px;
}
.empty-icon {
  font-size: 26px;
  color: var(--accent);
}

/* الحقول */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}
.field label,
.field legend {
  font-size: 14px;
  font-weight: 700;
}
.field input,
.field select,
.field textarea,
.search-input {
  width: 100%;
  min-height: var(--touch);
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.search-input:focus {
  border-color: var(--brand);
  outline: 3px solid var(--brand-soft);
  outline-offset: 0;
}
.field textarea {
  resize: vertical;
  min-height: 150px;
  line-height: 1.8;
}
.field small {
  color: var(--muted);
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--brand);
}

/* النوافذ والتنبيه العائم */
.dialog {
  width: min(640px, calc(100% - 32px));
  max-height: calc(100dvh - 40px);
  overflow: auto;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}
.dialog::backdrop {
  background: var(--overlay);
}
.dialog h2 {
  margin-bottom: 8px;
}
.dialog .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.dialog p {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 18px;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 300;
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--surface);
  font-size: 14px;
  box-shadow: var(--shadow-pop);
}

/* الجداول */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: middle;
}
th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
tr:last-child td {
  border-bottom: 0;
}

/* الشعار */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 22px;
  color: var(--text);
}
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 20px;
  font-weight: 800;
}

@media (max-width: 720px) {
  .two-cols,
  .three-cols {
    grid-template-columns: 1fr;
  }
  .card {
    padding: 18px;
  }
  .dialog {
    padding: 20px;
  }
  .toast {
    left: 16px;
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* بطاقات الأرقام */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.summary {
  padding: 18px 20px;
}
.summary-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
}
.summary-label svg {
  width: 18px;
  height: 18px;
}
.summary strong {
  display: block;
  margin: 6px 0 2px;
  font-size: 30px;
  line-height: 1.4;
}
.summary small {
  color: var(--muted);
}
@media (max-width: 720px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .summary {
    padding: 14px;
  }
  .summary strong {
    font-size: 24px;
  }
  .summary-label svg {
    display: none;
  }
}

/* شريط التجربة المجانية: أيام التجربة الباقية، أو انتهاؤها */
.trial-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
}
