/* ==========================================================================
   SPL Walaa — Components
   ========================================================================== */

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--navy-800); --btn-bd: var(--border-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px;
  border-radius: var(--r); border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; font-size: var(--fs-sm); line-height: 1; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s, box-shadow .15s, transform .05s;
  text-decoration: none !important; user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { --btn-bg: var(--indigo-600); --btn-fg: #fff; --btn-bd: var(--indigo-600); }
.btn-primary:hover { background: var(--indigo-700); border-color: var(--indigo-700); }
.btn-navy { --btn-bg: var(--navy-800); --btn-fg: #fff; --btn-bd: var(--navy-800); }
.btn-navy:hover { background: var(--navy-900); }
.btn-gold { --btn-bg: var(--gold-500); --btn-fg: var(--navy-900); --btn-bd: var(--gold-500); }
.btn-gold:hover { background: #CB9A40; }
.btn-danger { --btn-bg: var(--error); --btn-fg: #fff; --btn-bd: var(--error); }
.btn-danger:hover { background: #AE3838; }
.btn-success { --btn-bg: var(--success); --btn-fg: #fff; --btn-bd: var(--success); }
.btn-success:hover { background: #1A7049; }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--navy-800); }
.btn-soft { --btn-bg: var(--indigo-50); --btn-bd: var(--indigo-100); --btn-fg: var(--indigo-700); }
.btn-soft:hover { background: var(--indigo-100); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: var(--fs-xs); border-radius: var(--r-sm); gap: 6px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: var(--fs-base); border-radius: var(--r-lg); }
.btn-xl { min-height: 58px; padding: 0 26px; font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }
.req::after { content: " *"; color: var(--error); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-inline-end: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23697586' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
html[dir="rtl"] .select { background-position: left 12px center; }
.input:hover, .select:hover, .textarea:hover { border-color: #B9C2D0; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--indigo-600); box-shadow: var(--focus); outline: none; }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input-lg { min-height: 52px; font-size: var(--fs-md); border-radius: var(--r-lg); padding: 10px 16px; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--error); }
.field.has-error .input:focus { box-shadow: 0 0 0 3px rgba(200,70,70,.25); }
.field-error { display: none; align-items: center; gap: 6px; color: var(--error); font-size: var(--fs-xs); font-weight: 500; }
.field.has-error .field-error { display: flex; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .ico { position: absolute; inset-inline-start: 12px; color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-inline-start: 38px; }
.input-group > .input-addon { position: absolute; inset-inline-end: 6px; }
.form-grid { display: grid; gap: var(--s4) var(--s5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: var(--s3); justify-content: flex-end; flex-wrap: wrap; padding-top: var(--s4); border-top: 1px solid var(--border); margin-top: var(--s5); }
.form-section { padding: var(--s6) 0; border-top: 1px solid var(--border); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section > header { margin-bottom: var(--s4); }
.form-section > header p { color: var(--text-3); font-size: var(--fs-sm); margin-top: 2px; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-sm); }
.check input { width: 18px; height: 18px; accent-color: var(--indigo-600); margin: 0; }
.check-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); cursor: pointer; }
.check-card:has(input:checked) { border-color: var(--indigo-500); background: var(--indigo-50); }
.check-card input { margin-top: 2px; width: 18px; height: 18px; accent-color: var(--indigo-600); }

/* Toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: #C7CED9; position: relative; transition: background .2s; flex: 0 0 auto; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(18px); }
html[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-18px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.switch .switch-state { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); min-width: 26px; }
.switch input:checked ~ .switch-state { color: var(--success); }
.switch-lg .track { width: 56px; height: 32px; }
.switch-lg .track::after { width: 26px; height: 26px; }
.switch-lg input:checked + .track::after { transform: translateX(24px); }
html[dir="rtl"] .switch-lg input:checked + .track::after { transform: translateX(-24px); }

/* Segmented control */
.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: var(--r); gap: 2px; }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.segmented button[aria-pressed="true"], .segmented button.active { background: var(--surface); color: var(--navy-800); box-shadow: var(--shadow-xs); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card-pad { padding: var(--s5); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); min-height: 58px; }
.card-header h2, .card-header h3 { font-size: var(--fs-md); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-header .sub { font-size: var(--fs-xs); color: var(--text-3); font-weight: 400; }
.card-body { padding: var(--s5); }
.card-footer { padding: var(--s3) var(--s5); border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: var(--s3); font-size: var(--fs-sm); }
.card-flush .card-body { padding: 0; }
.card.is-highlight { border-color: var(--gold-200); box-shadow: 0 0 0 3px var(--gold-100), var(--shadow-xs); }
.section-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
html[lang="ar"] .section-title { letter-spacing: 0; text-transform: none; font-size: var(--fs-sm); }

/* KPI */
.kpi { padding: var(--s5); display: flex; flex-direction: column; gap: 6px; position: relative; }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; }
.kpi .kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--indigo-50); color: var(--indigo-600); }
.kpi .kpi-icon.gold { background: var(--gold-100); color: var(--gold-700); }
.kpi .kpi-icon.green { background: var(--success-bg); color: var(--success); }
.kpi .kpi-icon.navy { background: var(--surface-3); color: var(--navy-800); }
.kpi .kpi-value { font-family: var(--font-display); font-size: 2rem; font-weight: 600; color: var(--navy-800); letter-spacing: -0.02em; line-height: 1.1; }
html[lang="ar"] .kpi .kpi-value { font-family: var(--font-sans); }
.kpi .kpi-foot { font-size: var(--fs-xs); color: var(--text-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.delta.up { color: var(--success); }
.delta.down { color: var(--error); }

/* ---------- Badges / pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.4; white-space: nowrap;
  background: var(--neutral-bg); color: var(--text-2); border: 1px solid transparent;
}
.pill .ico { width: 13px; height: 13px; }
.pill-success { background: var(--success-bg); color: var(--success); border-color: var(--success-bd); }
.pill-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-bd); }
.pill-error { background: var(--error-bg); color: var(--error); border-color: var(--error-bd); }
.pill-info { background: var(--info-bg); color: var(--info); border-color: var(--info-bd); }
.pill-gold { background: var(--gold-100); color: var(--gold-700); border-color: var(--gold-200); }
.pill-navy { background: var(--navy-800); color: #fff; }
.pill-outline { background: transparent; border-color: var(--border-2); color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; flex: 0 0 auto; }

.tier-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; color: #fff; background: var(--tier-color, var(--tier-reader)); letter-spacing: .02em; }
html[dir="rtl"] .tier-badge { padding: 4px 6px 4px 10px; }
.tier-badge .ico { width: 14px; height: 14px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r-pill); border: 1px solid var(--border-2); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
button.chip:hover { border-color: var(--indigo-500); color: var(--indigo-700); }
.chip[aria-pressed="true"], .chip.active { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Avatar ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: var(--navy-600); flex: 0 0 auto; letter-spacing: .02em; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.avatar-xl { width: 76px; height: 76px; font-size: 24px; }
.avatar.guest { background: #8A6A3C; }
.avatar.child { background: #2E7D74; }
.avatar.researcher { background: #47727D; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; font-size: var(--fs-sm); }
.table thead th { text-align: start; font-weight: 600; color: var(--text-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
html[lang="ar"] .table thead th { text-transform: none; letter-spacing: 0; font-size: var(--fs-sm); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FCFAFD; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-new td { animation: rowflash 2.4s var(--ease); }
@keyframes rowflash { 0% { background: var(--gold-100); } 100% { background: transparent; } }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }
.table .actions { text-align: end; white-space: nowrap; }
.table-compact td { padding: 8px 14px; }
.cell-main { font-weight: 600; color: var(--navy-800); }
.cell-sub { font-size: var(--fs-xs); color: var(--text-3); }
.pos { color: var(--success); font-weight: 600; }
.neg { color: var(--error); font-weight: 600; }
.zero { color: var(--text-3); font-weight: 600; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; padding: var(--s3) var(--s5); border-bottom: 1px solid var(--border); }
.toolbar .input-group { flex: 1 1 260px; max-width: 420px; }
.toolbar .select { width: auto; min-width: 150px; }
.result-count { font-size: var(--fs-xs); color: var(--text-3); margin-inline-start: auto; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 12px 14px; font-weight: 600; font-size: var(--fs-sm); color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tab:hover { color: var(--navy-800); }
.tab[aria-selected="true"] { color: var(--indigo-700); border-bottom-color: var(--indigo-600); }
.tab .count { background: var(--surface-3); color: var(--text-2); border-radius: 99px; padding: 0 7px; font-size: 11px; line-height: 18px; }
.tab[aria-selected="true"] .count { background: var(--indigo-100); color: var(--indigo-700); }
.tab-panel[hidden] { display: none; }

/* ---------- Alerts / callouts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--info-bd); background: var(--info-bg); color: var(--navy-800); font-size: var(--fs-sm); }
.alert > .ico { margin-top: 2px; color: var(--info); }
.alert strong { display: block; margin-bottom: 2px; }
.alert-success { background: var(--success-bg); border-color: var(--success-bd); }
.alert-success > .ico { color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-bd); }
.alert-warning > .ico { color: var(--warning-ico); }
.alert-error { background: var(--error-bg); border-color: var(--error-bd); }
.alert-error > .ico { color: var(--error); }
.alert-gold { background: var(--gold-100); border-color: var(--gold-200); }
.alert-gold > .ico { color: var(--gold-700); }
.alert .grow > * + * { margin-top: 4px; }

.demo-flag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gold-700); background: var(--gold-100); border: 1px dashed var(--gold-500); padding: 2px 8px; border-radius: 99px; }
html[lang="ar"] .demo-flag { letter-spacing: 0; }

/* ---------- Progress ---------- */
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--indigo-600); border-radius: 99px; transition: width .6s var(--ease); }
.progress.gold > span { background: linear-gradient(90deg, var(--gold-500), #E9C27A); }
.progress.green > span { background: var(--success); }
.progress-lg { height: 12px; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px var(--s5); border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item .li-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--navy-700); flex: 0 0 auto; }
.list-item .li-icon.gold { background: var(--gold-100); color: var(--gold-700); }
.list-item .li-icon.green { background: var(--success-bg); color: var(--success); }
.list-item .li-icon.red { background: var(--error-bg); color: var(--error); }
.list-item .li-icon.blue { background: var(--indigo-50); color: var(--indigo-600); }
.list-item .li-title { font-weight: 600; font-size: var(--fs-sm); color: var(--navy-800); }
.list-item .li-sub { font-size: var(--fs-xs); color: var(--text-3); }
a.list-item { color: inherit; text-decoration: none; }
a.list-item:hover { background: var(--surface-2); }

/* Definition list */
.dl { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 10px 16px; font-size: var(--fs-sm); }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; font-weight: 500; color: var(--text); min-width: 0; overflow-wrap: anywhere; }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: var(--s8) var(--s5); color: var(--text-3); }
.empty .empty-icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); margin-bottom: 4px; }
.empty .empty-icon .ico { width: 28px; height: 28px; }
.empty h3 { font-size: var(--fs-md); color: var(--navy-800); }
.empty p { max-width: 380px; font-size: var(--fs-sm); }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(90deg, #EEF1F5 0%, #F7F8FA 50%, #EEF1F5 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.boot-skeleton { padding: 32px; display: grid; gap: 16px; max-width: 1100px; margin: 0 auto; }
.boot-skeleton .skeleton { height: 18px; }
.boot-skeleton .sk-title { height: 34px; width: 40%; }
.boot-skeleton .sk-card { height: 140px; }

.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(53, 9, 63, .55); backdrop-filter: blur(2px); z-index: 900; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .18s var(--ease); }
.modal { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop .22s var(--ease); }
.modal.modal-lg { max-width: 760px; }
.modal.modal-sm { max-width: 420px; }
.modal-header { display: flex; gap: 12px; align-items: flex-start; padding: 20px 22px 10px; }
.modal-header h2 { font-size: var(--fs-lg); flex: 1; }
.modal-header .modal-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--indigo-50); color: var(--indigo-600); flex: 0 0 auto; }
.modal-header .modal-icon.danger { background: var(--error-bg); color: var(--error); }
.modal-header .modal-icon.success { background: var(--success-bg); color: var(--success); }
.modal-header .modal-icon.warning { background: var(--warning-bg); color: var(--warning-ico); }
.modal-header .modal-icon.gold { background: var(--gold-100); color: var(--gold-700); }
.modal-body { padding: 8px 22px 18px; overflow-y: auto; color: var(--text-2); font-size: var(--fs-sm); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(53, 9, 63, .4); z-index: 880; animation: fade .18s; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(480px, 100vw); background: var(--surface); z-index: 890; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slidein .25s var(--ease); }
html[dir="rtl"] .drawer { animation-name: slidein-rtl; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slidein-rtl { from { transform: translateX(-30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-header { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-header h2 { font-size: var(--fs-lg); flex: 1; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* Toasts */
.toast-region { position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: var(--r-lg); background: var(--navy-800); color: #fff; box-shadow: var(--shadow-lg); font-size: var(--fs-sm); animation: pop .25s var(--ease); }
.toast .ico { margin-top: 1px; }
.toast.success .ico { color: #6FD3A5; }
.toast.error .ico { color: #FF9C9C; }
.toast.warning .ico { color: #F2C66D; }
.toast.info .ico { color: #D9A8E6; }
.toast .toast-title { font-weight: 600; }
.toast .toast-msg { opacity: .85; margin-top: 2px; }
.toast button { background: none; border: 0; color: #fff; opacity: .7; padding: 0; margin-inline-start: auto; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all .2s; }

/* Dropdown menu */
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px; z-index: 700; animation: pop .15s var(--ease); }
.menu[hidden] { display: none; }
.menu .menu-label { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: 8px; font-size: var(--fs-sm); color: var(--text); text-align: start; text-decoration: none !important; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item[aria-checked="true"] { color: var(--indigo-700); font-weight: 600; }
.menu-item .menu-desc { font-size: var(--fs-xs); color: var(--text-3); font-weight: 400; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* Breadcrumbs */
.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-3); flex-wrap: wrap; }
.breadcrumbs a { color: var(--text-3); }
.breadcrumbs a:hover { color: var(--indigo-600); }
.breadcrumbs .ico { width: 13px; height: 13px; }
.breadcrumbs [aria-current] { color: var(--text-2); font-weight: 500; }

/* Tooltip (CSS-only, via data-tip) */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--navy-900); color: #fff; font-size: 12px; font-weight: 500; line-height: 1.4; padding: 6px 10px; border-radius: 6px;
  width: max-content; max-width: 260px; white-space: normal; z-index: 50; pointer-events: none; text-transform: none; letter-spacing: 0;
}
.info-tip { display: inline-grid; place-items: center; color: var(--text-4); cursor: help; vertical-align: middle; }
.info-tip .ico { width: 15px; height: 15px; }

/* ---------- Book cover (generated, typographic) ---------- */
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 4px 8px 8px 4px; overflow: hidden; color: #fff; background: linear-gradient(160deg, var(--c1, #6A2080), var(--c2, #4E1162)); box-shadow: 0 1px 1px rgba(0,0,0,.08), 0 6px 14px rgba(16,30,54,.18); display: flex; flex-direction: column; justify-content: space-between; padding: 12% 10% 10% 16%; isolation: isolate; flex: 0 0 auto; }
.cover::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 7%; background: rgba(0,0,0,.18); z-index: -1; }
.cover::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 85% 15%, rgba(255,255,255,.18), transparent 45%); z-index: -1; }
.cover .cover-subject { font-size: 8px; text-transform: uppercase; letter-spacing: .12em; opacity: .75; font-weight: 600; }
.cover .cover-title { font-family: var(--font-display); font-weight: 600; font-size: 13px; line-height: 1.12; letter-spacing: -.01em; overflow-wrap: anywhere; }
.cover[lang="ar"] .cover-title { font-family: var(--font-ar); font-weight: 700; }
.cover .cover-author { font-size: 8.5px; opacity: .85; font-weight: 500; }
.cover .cover-rule { width: 30%; height: 2px; background: var(--gold-500); margin: 6px 0; }
.cover.cover-sm { width: 46px; padding: 8% 8% 8% 14%; }
.cover.cover-sm .cover-title { font-size: 6.5px; }
.cover.cover-sm .cover-subject, .cover.cover-sm .cover-author, .cover.cover-sm .cover-rule { display: none; }
.cover.cover-md { width: 120px; }
.cover.cover-lg { width: 200px; }
.cover.cover-lg .cover-title { font-size: 21px; }
.cover.cover-lg .cover-subject { font-size: 10px; }
.cover.cover-lg .cover-author { font-size: 12px; }
.cover .cover-new { position: absolute; top: 8px; inset-inline-end: 0; background: var(--gold-500); color: var(--navy-900); font-size: 8px; font-weight: 800; padding: 2px 6px 2px 6px; border-radius: 4px 0 0 4px; letter-spacing: .06em; }
html[dir="rtl"] .cover .cover-new { border-radius: 0 4px 4px 0; }

/* ---------- QR ---------- */
.qr { background: #fff; padding: 10px; border-radius: 12px; display: inline-block; line-height: 0; }
.qr svg { width: 100%; height: auto; }

/* ---------- Timeline / processing log ---------- */
.timeline { position: relative; display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; padding: 10px 0; position: relative; align-items: start; }
.tl-item::before { content: ""; position: absolute; top: 34px; bottom: -6px; inset-inline-start: 13px; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); position: relative; z-index: 1; }
.tl-dot .ico { width: 15px; height: 15px; }
.tl-item.success .tl-dot { background: var(--success-bg); color: var(--success); }
.tl-item.warning .tl-dot { background: var(--warning-bg); color: var(--warning-ico); }
.tl-item.failure .tl-dot { background: var(--error-bg); color: var(--error); }
.tl-item.pending .tl-dot { background: var(--indigo-50); color: var(--indigo-600); }
.tl-item.skipped { opacity: .55; }
.tl-title { font-weight: 600; font-size: var(--fs-sm); color: var(--navy-800); }
.tl-detail { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.tl-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-4); white-space: nowrap; direction: ltr; }

/* ---------- Stepper ---------- */
.steps { display: flex; gap: 8px; counter-reset: step; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-3); font-weight: 500; }
.step .step-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-weight: 700; font-size: 12px; }
.step.done .step-n { background: var(--success); color: #fff; }
.step.active { color: var(--navy-800); font-weight: 600; }
.step.active .step-n { background: var(--indigo-600); color: #fff; }
.step-sep { width: 28px; height: 2px; background: var(--border); align-self: center; }

/* ---------- Charts ---------- */
.chart { width: 100%; }
.chart text { font-family: var(--font-sans); fill: var(--text-3); font-size: 11px; }
.chart .axis line, .chart .grid line { stroke: var(--border); }
.chart .bar-label { fill: var(--navy-800); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: var(--fs-xs); color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 140px) 1fr 52px; gap: 12px; align-items: center; font-size: var(--fs-sm); }
.hbar .hbar-track { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.hbar .hbar-fill { height: 100%; border-radius: 99px; background: var(--indigo-600); }
.hbar .hbar-val { text-align: end; font-weight: 600; color: var(--navy-800); font-variant-numeric: tabular-nums; }
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; font-size: var(--fs-sm); min-width: 140px; }
.donut-legend .dl-row { display: flex; align-items: center; gap: 8px; }
.donut-legend .dl-row b { margin-inline-start: auto; color: var(--navy-800); font-variant-numeric: tabular-nums; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- Voucher ticket ---------- */
.ticket { display: grid; grid-template-columns: 1fr auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; position: relative; }
.ticket .ticket-main { padding: 16px 18px; min-width: 0; }
.ticket .ticket-side { padding: 16px; border-inline-start: 2px dashed var(--border-2); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; min-width: 130px; background: var(--surface-2); }
.ticket .code { font-family: var(--font-mono); font-weight: 700; font-size: 15px; letter-spacing: .06em; color: var(--navy-800); direction: ltr; }
.ticket.is-expired, .ticket.is-redeemed { opacity: .75; }
.ticket.is-expired .code, .ticket.is-redeemed .code { text-decoration: line-through; color: var(--text-3); }

/* Kbd */
kbd { font-family: var(--font-mono); font-size: 11px; background: var(--surface-3); border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-3); padding: 1px 6px; border-radius: 4px; direction: ltr; unicode-bidi: isolate; }
