/* نادي الروّاد — Dashboard shared component vocabulary («المكتبة»).
   Every page uses these classes; page files only add what is unique to them. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-page);
  color: var(--text-strong);
  font-family: var(--font-sans);
  direction: rtl;
  font-size: var(--fs-base);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; } /* component display rules must never override the attribute */
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 800; margin: 0; line-height: 1.35; text-wrap: balance; }
[dir="ltr"], .mono { font-family: var(--font-mono); direction: ltr; unicode-bidi: embed; }
.icon { flex-shrink: 0; vertical-align: middle; }
img { color: transparent; }
::selection { background: var(--gold-300); color: var(--ink-950); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent-fill) 70%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--surface-side);
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0; /* RTL: start = right edge */
  display: flex;
  flex-direction: column;
  border-inline-end: 1px solid var(--surface-line);
  z-index: 40;
  transition: transform .35s var(--ease);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-line) transparent;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 22px; min-height: var(--topnav-height);
  border-bottom: 1px solid var(--surface-line);
}
.sidebar-brand .logo {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; object-fit: cover;
  box-shadow: 0 0 0 3px var(--surface-side), 0 0 0 4px var(--gold-300);
  transition: transform .5s var(--ease-spring);
}
.sidebar-brand:hover .logo { transform: rotate(-8deg) scale(1.06); }
.sidebar-brand .name { font-weight: 800; font-size: 19px; line-height: 1.25; }
.sidebar-brand .sub { font-size: var(--fs-xs); color: var(--text-muted); }

.sidebar-nav { padding: 12px 14px 24px; flex: 1; }
.nav-section {
  padding: 18px 12px 6px; font-size: 12.5px; font-weight: 700;
  color: var(--text-soft); letter-spacing: .2px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 2px; color: var(--text-strong);
  border-radius: var(--radius-sm); transition: var(--transition);
  font-size: 15.5px; font-weight: 600; position: relative;
}
.nav-item .ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; color: var(--text-muted); transition: var(--transition); }
.nav-item:hover { background: var(--surface-sunken); }
.nav-item:hover .ic { color: var(--accent-text); transform: translateX(-2px); }
.nav-item.active { background: var(--surface-chip); color: var(--text-strong); font-weight: 700; }
.nav-item.active .ic { background: var(--primary); color: var(--on-primary); }
.nav-item.active::after {
  content: ''; position: absolute; inset-inline-end: 12px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-fill); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-fill) 22%, transparent);
}
.nav-item .badge-count {
  margin-inline-start: auto; background: var(--accent-fill); color: var(--ink-950);
  font-size: 12.5px; font-weight: 800; border-radius: 20px; padding: 0 9px; min-width: 24px; text-align: center; line-height: 22px;
}
.nav-item.active .badge-count + * { display: none; }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--surface-line); }
.sidebar-foot .help { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--radius); background: var(--surface-highlight); font-size: var(--fs-xs); color: var(--text-muted); }
.sidebar-foot .help b { display: block; color: var(--text-strong); font-size: var(--fs-sm); }
.sidebar-scrim { display: none; }

/* ---------- Main ---------- */
.main { flex: 1; margin-inline-start: var(--sidebar-width); display: flex; flex-direction: column; min-width: 0; }

.topnav {
  height: var(--topnav-height);
  background: color-mix(in srgb, var(--surface-page) 82%, transparent);
  backdrop-filter: saturate(1.5) blur(14px);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid var(--surface-line);
  display: flex; align-items: center; gap: 12px;
  padding: 0 32px; position: sticky; top: 0; z-index: 30;
}
.topnav .menu-toggle { display: none; }
.topnav-search {
  flex: 0 1 460px; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--surface-line); background: var(--surface-raised); color: var(--text-muted);
  transition: var(--transition);
}
.topnav-search:focus-within { border-color: var(--accent-fill); box-shadow: var(--glow); }
.topnav-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; color: var(--text-strong); }
.topnav-search kbd { font-family: var(--font-mono); font-size: 12px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--surface-line); color: var(--text-soft); }
.topnav .spacer { flex: 1; }
.icon-btn {
  position: relative; width: 46px; height: 46px; border-radius: var(--radius-sm); border: 1px solid var(--surface-line);
  background: var(--surface-raised); color: var(--text-strong); cursor: pointer;
  display: grid; place-items: center; transition: var(--transition); padding: 0;
}
.icon-btn:hover { border-color: var(--accent-fill); color: var(--accent-text); transform: translateY(-1px); }
.icon-btn .dot { position: absolute; top: 9px; inset-inline-end: 10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #c2410c; color: #ffffff; font-size: 11px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--surface-raised); }
#themeToggle .i-sun { display: none; }
:root[data-theme="dark"] #themeToggle .i-sun { display: block; }
:root[data-theme="dark"] #themeToggle .i-moon { display: none; }
#themeToggle svg { transition: transform .5s var(--ease-spring); }
#themeToggle:hover svg { transform: rotate(-25deg); }

.admin-menu { position: relative; }
.admin-chip {
  display: flex; align-items: center; gap: 10px; font: inherit; font-size: var(--fs-sm); font-weight: 700; cursor: pointer;
  padding: 4px 4px 4px 14px; border: 1px solid var(--surface-line); border-radius: 30px; background: var(--surface-raised); color: var(--text-strong);
  transition: var(--transition);
}
.admin-chip:hover { border-color: var(--accent-fill); }
.admin-chip .avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--accent-fill); color: var(--ink-950);
  display: grid; place-items: center; font-weight: 800;
}
.admin-pop {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 220px; padding: 8px;
  background: var(--surface-raised); border: 1px solid var(--surface-line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 50; transform-origin: top left; animation: popIn .22s var(--ease) both;
}
.admin-pop a, .admin-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-strong); font: inherit; font-weight: 600; cursor: pointer; text-align: start;
}
.admin-pop a:hover, .admin-pop button:hover { background: var(--surface-sunken); }
.admin-pop .danger { color: var(--danger); }
.admin-pop hr { border: 0; border-top: 1px solid var(--surface-line); margin: 6px 0; }

.content { padding: 30px 36px 56px; flex: 1; width: 100%; max-width: var(--content-max); margin-inline: auto; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-header h1 { font-size: var(--fs-xl); color: var(--text-strong); }
.page-header .subtitle { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 2px; }
.page-header > div:last-child:not(:first-child) { display: flex; gap: 10px; flex-wrap: wrap; }
.breadcrumb { display: flex; gap: 8px; font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.breadcrumb a:hover { color: var(--accent-text); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface-raised);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s var(--ease), border-color .25s var(--ease), transform .25s var(--ease);
}
.card-header { padding: 18px 22px; border-bottom: 1px solid var(--surface-line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-header h3 { font-size: var(--fs-md); font-weight: 800; }
.card-body { padding: 22px; }
.card-pad { padding: 22px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- KPI (used outside the home page too) ---------- */
.kpi-card {
  background: var(--surface-raised); border: 1px solid var(--surface-line);
  border-radius: var(--radius); padding: 20px 22px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--gold-300); }
.kpi-card .kpi-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--surface-chip); color: var(--accent-text); display: grid; place-items: center; margin-bottom: 10px; }
.kpi-card .kpi-value { font-weight: 800; font-size: 36px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-card .kpi-label { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }
.kpi-card .kpi-delta { font-size: var(--fs-xs); font-weight: 700; margin-top: 8px; display: inline-flex; gap: 4px; align-items: center; }
.kpi-card .kpi-delta.up { color: var(--success); }
.kpi-card .kpi-delta.down { color: var(--danger); }
.kpi-card.accent { background: var(--surface-highlight); border-color: var(--accent-fill); }

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface-raised); }
.data-table th, .data-table td { padding: 14px 18px; text-align: start; border-bottom: 1px solid var(--surface-line); font-size: 15px; vertical-align: middle; }
.data-table th { background: var(--surface-sunken); color: var(--text-muted); font-weight: 700; font-size: var(--fs-xs); white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background-color .18s ease; }
.data-table tbody tr:hover { background: var(--surface-highlight); }
.data-table td.mono, .data-table td .mono { white-space: nowrap; }
.data-table .thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; background: var(--surface-sunken); }
.data-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }

/* ---------- List-page vocabulary (lessons, teachers, members, …) ---------- */
.page-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.page-stats a, .page-stats span {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 20px; font-size: 13.5px; font-weight: 700;
  background: var(--surface-raised); border: 1px solid var(--surface-line); color: var(--text-muted); transition: var(--transition);
}
.page-stats a:hover { border-color: var(--accent-fill); color: var(--accent-text); }
.page-stats b { color: var(--text-strong); font-variant-numeric: tabular-nums; }
.page-stats .warn b { color: var(--danger); }
.page-stats i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-fill); }
.page-stats i.d-good { background: var(--success); } .page-stats i.d-soft { background: var(--text-soft); }
.page-stats i.d-bad { background: var(--danger); } .page-stats i.d-info { background: var(--info); }

.chip { display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px; border-radius: 20px; font-size: 13.5px; font-weight: 700; white-space: nowrap; background: color-mix(in srgb, var(--chip, var(--gold-500)) 13%, transparent); color: var(--text-strong); }
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--chip, var(--gold-500)); }

.cell-title { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.cell-title .thumb { flex: none; }
.cell-title b { display: block; font-weight: 700; line-height: 1.45; }
.cell-title small { display: block; color: var(--text-muted); font-size: 12.5px; font-family: var(--font-mono); direction: ltr; text-align: end; }
.cell-sub { display: block; color: var(--text-muted); font-size: 13px; }

.flags { display: inline-flex; gap: 6px; }
.flag { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-soft); }
.flag.on { background: var(--surface-chip); color: var(--accent-text); }
.flag.yt { background: color-mix(in srgb, #e0352b 12%, transparent); color: #c4281f; }

.acts { display: flex; gap: 4px; justify-content: flex-end; }
.acts form { margin: 0; }
.act {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-muted);
  display: grid; place-items: center; cursor: pointer; transition: var(--transition); position: relative;
}
.act:hover { background: var(--surface-sunken); border-color: var(--surface-line); color: var(--text-strong); }
.act.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.act[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translate(-50%, 4px);
  padding: 4px 10px; border-radius: 8px; background: var(--ink-950); color: #ffffff; font-size: 12px; font-weight: 700; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease; z-index: 5;
}
.act[data-tip]:hover::after, .act[data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

/* publish / hide as a switch (a real button inside the toggle form) */
.switch { position: relative; width: 46px; height: 26px; border-radius: 20px; border: 0; padding: 0; cursor: pointer; background: var(--surface-line); transition: background .25s var(--ease); flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #ffffff; box-shadow: 0 2px 6px rgb(0 0 0 / .2); transition: transform .3s var(--ease-spring); }
.switch[aria-checked="true"] { background: var(--success); }
.switch[aria-checked="true"]::after { transform: translateX(-20px); }
.switch-cell { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 700; color: var(--text-muted); }
.switch-cell form { margin: 0; }

.list-card { overflow: hidden; }
.list-card .card-header { background: var(--surface-sunken); }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--surface-line); font-size: 14px; color: var(--text-muted); }
.list-toolbar b { color: var(--text-strong); }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--surface-raised); border: 1px solid var(--surface-line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.filter-bar .search-input { flex: 1 1 260px; width: auto; }
.filter-bar .form-control, .filter-bar .form-select { flex: 0 1 180px; width: auto; min-width: 150px; }
.filter-bar .form-select.is-set { border-color: var(--accent-fill); background-color: var(--surface-highlight); font-weight: 700; }
.filter-bar .clear { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--danger); padding: 0 6px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: var(--fs-sm); color: var(--text-strong); margin-bottom: 7px; font-weight: 700; }
.form-control, .form-select, .search-input {
  width: 100%; min-height: var(--control-height); padding: 10px 14px; border: 1px solid var(--surface-line); border-radius: var(--radius-sm);
  background: var(--surface-input); color: var(--text-strong); font-family: inherit; font-size: 15px; transition: var(--transition);
}
.form-control::placeholder, .search-input::placeholder { color: var(--text-soft); }
.form-control:hover, .form-select:hover, .search-input:hover { border-color: color-mix(in srgb, var(--accent-fill) 55%, var(--surface-line)); }
.form-control:focus, .form-select:focus, .search-input:focus { outline: none; border-color: var(--accent-fill); box-shadow: var(--glow); }
.form-select {
  appearance: none; -webkit-appearance: none; padding-inline-end: 38px; cursor: pointer;
  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='%238a8580' 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: left 13px center; background-size: 16px;
}
.search-input {
  padding-inline-start: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238a8580' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 18px;
}
textarea.form-control { resize: vertical; min-height: 110px; line-height: 1.75; }
input[type="file"].form-control { padding: 7px; cursor: pointer; color: var(--text-muted); }
input[type="file"]::file-selector-button {
  font-family: inherit; font-size: var(--fs-sm); font-weight: 700; margin-inline-end: 12px;
  padding: 7px 16px; border-radius: 9px; border: 1px solid var(--surface-line); cursor: pointer;
  background: var(--surface-chip); color: var(--accent-text); transition: var(--transition);
}
input[type="file"]::file-selector-button:hover { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
input[type="color"].form-control { padding: 4px; cursor: pointer; }
input[type="date"].form-control { font-family: var(--font-sans); }
.localized-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 6px; overflow-wrap: anywhere; }
.field-error { color: var(--danger); font-size: var(--fs-xs); margin-top: 6px; }
.field-error ul { margin: 0 0 12px; padding-inline-start: 18px; }
.validation-summary-errors {
  font-size: var(--fs-sm); font-weight: 700; padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 10%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  animation: shake .4s var(--ease) both;
}
.validation-summary-errors ul { margin: 0; }
.form-check { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.form-check input { width: 20px; height: 20px; accent-color: var(--gold-600); cursor: pointer; }
.form-check label { cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  min-height: 46px; padding: 9px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer; transition: var(--transition);
  position: relative; overflow: hidden; white-space: nowrap; line-height: 1.4;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 18px rgb(37 37 39 / .18); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 10px 24px rgb(37 37 39 / .22); }
.btn-gold { background: var(--accent-fill); color: var(--ink-950); }
.btn-gold:hover { background: var(--gold-400); }
.btn-outline { background: var(--surface-raised); border-color: var(--surface-line); color: var(--text-strong); }
.btn-outline:hover { border-color: var(--accent-fill); color: var(--accent-text); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #ffffff; }
.btn-sm { min-height: 36px; padding: 6px 13px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 20px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: color-mix(in srgb, var(--success) 13%, transparent); color: var(--success); }
.badge-warning { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.badge-danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.badge-muted { background: var(--surface-sunken); color: var(--text-muted); }

/* ---------- Status tabs ---------- */
.status-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; padding: 5px; border-radius: 16px; background: var(--surface-raised); border: 1px solid var(--surface-line); width: fit-content; max-width: 100%; }
.status-tab {
  padding: 8px 16px; border-radius: 11px; color: var(--text-muted); font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 8px; transition: var(--transition);
}
.status-tab:hover { color: var(--text-strong); background: var(--surface-sunken); }
.status-tab.active { background: var(--primary); color: var(--on-primary); }
.status-tab .count { background: color-mix(in srgb, currentColor 16%, transparent); border-radius: 12px; padding: 0 8px; font-size: 12.5px; }

/* ---------- Tabs that swap panels on the same page (taxonomy, gallery, settings) ---------- */
.tax-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; padding: 5px; border-radius: 16px; background: var(--surface-raised); border: 1px solid var(--surface-line); width: fit-content; max-width: 100%; }
.tax-tab {
  position: relative; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 11px; border: 0; cursor: pointer;
  background: transparent; color: var(--text-muted); font: inherit; font-size: 15px; font-weight: 700; transition: var(--transition);
}
.tax-tab:hover { background: var(--surface-sunken); color: var(--text-strong); }
.tax-tab.active { background: var(--primary); color: var(--on-primary); }
.tax-tab .count { background: color-mix(in srgb, currentColor 16%, transparent); border-radius: 12px; padding: 0 8px; font-size: 12.5px; }
.tax-panel { display: none; }
.tax-panel.active { display: block; animation: fadeInUp .35s var(--ease) both; }
@media (max-width: 560px) {
  .tax-tabs { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tax-tab { flex: none; }
}

/* ---------- Editable rows that open in place (FAQ, features, banners, gallery) ---------- */
.row-card { border-radius: var(--radius); background: var(--surface-raised); border: 1px solid var(--surface-line); box-shadow: var(--shadow-sm); transition: var(--transition); }
.row-card:hover { border-color: color-mix(in srgb, var(--accent-fill) 40%, var(--surface-line)); }
.row-card[open] { box-shadow: var(--shadow); border-color: var(--accent-fill); }
.row-card.is-hidden:not([open]) { opacity: .7; }
.row-card > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: inherit; }
.row-card > summary::-webkit-details-marker { display: none; }
.row-card > summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent-fill) 60%, transparent); outline-offset: 2px; }
.row-card .rc-main { flex: 1; min-width: 0; }
.row-card .rc-main b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
.row-card .rc-main small { display: block; font-size: 14px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-card .rc-open { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--text-muted); background: var(--surface-sunken); transition: transform .3s var(--ease), background .2s; }
.row-card[open] .rc-open { transform: rotate(180deg); background: var(--primary); color: var(--on-primary); }
.row-card .rc-body { padding: 4px 16px 16px; border-top: 1px dashed var(--surface-line); animation: fadeInUp .3s var(--ease) both; }
.row-card .rc-body > form:first-child { padding-top: 14px; }
.rc-num { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--surface-chip); color: var(--accent-text); font-variant-numeric: tabular-nums; }
.row-actions { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--surface-line); }
.row-actions .toggle { flex: 1; min-width: 190px; padding: 9px 12px; }
.row-actions .form-group { margin: 0; width: 96px; }
.row-actions .btn-delete { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--surface-line)); }
.row-actions .btn-delete:hover { background: var(--danger); color: #ffffff; border-color: var(--danger); }
.row-list { display: grid; gap: 10px; }
.add-card { margin-bottom: 20px; border: 1.5px dashed var(--accent-fill); }
.add-card .card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- Full-page messages (no permission, errors) ---------- */
.state-page { min-height: 60vh; display: grid; place-items: center; text-align: center; padding: 40px 16px; }
.state-page .sp-art { position: relative; width: 132px; height: 132px; margin: 0 auto 22px; display: grid; place-items: center; border-radius: 50%; color: var(--accent-text); background: var(--surface-chip); }
.state-page .sp-art::before, .state-page .sp-art::after { content: ''; position: absolute; inset: -12px; border-radius: 50%; border: 2px dashed color-mix(in srgb, var(--accent-fill) 45%, transparent); animation: spin 18s linear infinite; }
.state-page .sp-art::after { inset: -26px; border-style: dotted; opacity: .5; animation-direction: reverse; animation-duration: 26s; }
.state-page .sp-code { font-size: 64px; font-weight: 900; line-height: 1; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.state-page h1 { font-size: 26px; margin: 0 0 8px; }
.state-page p { max-width: 460px; margin: 0 auto; color: var(--text-muted); line-height: 1.9; }
.state-page .sp-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; padding: 64px 20px; color: var(--text-muted); font-size: var(--fs-md);
  background: var(--surface-raised); border: 1px dashed var(--surface-line); border-radius: var(--radius);
}
.empty-state .ic { font-size: 44px; margin-bottom: 12px; opacity: .5; }
.empty-state p { margin: 0; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; padding: 20px 0 4px; }
.pagination a, .pagination span {
  min-width: 42px; height: 42px; padding: 0 12px; border-radius: var(--radius-sm); background: var(--surface-raised);
  border: 1px solid var(--surface-line); display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--text-strong); transition: var(--transition);
}
.pagination a:hover { border-color: var(--accent-fill); color: var(--accent-text); transform: translateY(-1px); }
.pagination .current { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.pagination .disabled { opacity: .4; pointer-events: none; }
.pagination-meta { text-align: center; color: var(--text-muted); font-size: var(--fs-sm); margin-top: 8px; }

/* ---------- Toast ---------- */
.toast-container { position: fixed; inset-block-start: 22px; inset-inline-start: 50%; transform: translateX(50%); z-index: 100; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: 14px; color: #ffffff; box-shadow: var(--shadow-lg);
  font-size: 15.5px; font-weight: 700; min-width: 300px; animation: toastIn .45s var(--ease-spring) both; pointer-events: auto;
}
.toast::before { content: ''; flex: none; width: 10px; height: 10px; border-radius: 50%; background: #ffffff; box-shadow: 0 0 0 4px rgb(255 255 255 / .25); }
.toast-success { background: #2d6a4f; }
.toast-error { background: #a03030; }
.toast.leaving { animation: toastOut .3s var(--ease) both; }

/* ---------- Modal (custom confirm) ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--surface-overlay); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 90; animation: fadeIn .2s ease both; padding: 16px; }
.modal { background: var(--surface-raised); border-radius: var(--radius-lg); width: min(440px, 100%); box-shadow: var(--shadow-lg); overflow: hidden; animation: popIn .3s var(--ease-spring) both; }
.modal-body { padding: 26px 26px 18px; font-size: var(--fs-md); display: grid; gap: 10px; justify-items: center; text-align: center; }
.modal-body .modal-ic { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.modal-body h3 { font-size: var(--fs-lg); }
.modal-body p { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); }
.modal-footer { padding: 16px 22px 22px; display: flex; gap: 10px; justify-content: center; }
.modal-footer .btn { flex: 1; }

/* ---------- Utilities ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.text-muted { color: var(--text-muted); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 20px; } .mb-3 { margin-bottom: 20px; } .mb-0 { margin-bottom: 0; }
.cover-preview { position: relative; aspect-ratio: 16 / 10; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-sunken); border: 1px solid var(--surface-line); }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; display: block; animation: scaleIn .35s var(--ease) both; }
.cover-preview .cover-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-soft); }
.cover-preview:not(.empty) .cover-empty { display: none; }
.form-note { margin-inline-start: auto; align-self: center; font-size: 13.5px; color: var(--text-muted); }
.image-preview { width: 100%; max-width: 100%; aspect-ratio: 16 / 10; border-radius: var(--radius-sm); border: 1px solid var(--surface-line); object-fit: cover; background: var(--surface-sunken); display: block; }

/* ---------- Video editor (Shared/_VideoField) ---------- */
.video-source { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.video-source-opt {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer;
  border: 1.5px solid var(--surface-line); border-radius: var(--radius-sm); background: var(--surface-input);
  transition: var(--transition); position: relative;
}
.video-source-opt:hover { border-color: var(--accent-fill); }
.video-source-opt input { position: absolute; opacity: 0; pointer-events: none; }
.video-source-opt .vs-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-sunken); color: var(--text-muted); transition: var(--transition); }
.video-source-opt b { display: block; font-size: 15.5px; }
.video-source-opt small { display: block; font-size: var(--fs-xs); color: var(--text-muted); }
.video-source-opt:has(input:checked) { border-color: var(--accent-fill); background: var(--surface-highlight); box-shadow: var(--glow); }
.video-source-opt:has(input:checked) .vs-ic { background: var(--primary); color: var(--on-primary); }
.video-source-opt:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent-fill) 60%, transparent); outline-offset: 2px; }
.video-field:has(input[value="upload"]:checked) [data-panel="youtube"],
.video-field:has(input[value="youtube"]:checked) [data-panel="upload"] { display: none; }
.video-panel { animation: fadeInUp .3s var(--ease) both; }
.video-preview { display: block; width: 100%; max-width: 420px; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); background: #000; border: 1px solid var(--surface-line); margin-bottom: 14px; }
.yt-preview { position: relative; overflow: hidden; animation: scaleIn .35s var(--ease) both; }
.yt-preview[hidden] { display: none; }
.yt-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-preview .play { position: absolute; inset: 0; margin: auto; width: 64px; height: 44px; border-radius: 12px; background: #ff0033; color: #fff; display: grid; place-items: center; font-size: 18px; }
.video-current .field-hint { margin: -6px 0 14px; }
.video-poster { margin-top: 4px; padding-top: 16px; border-top: 1px dashed var(--surface-line); }
.req { color: var(--danger); }

/* Upload progress overlay (forms with data-upload-progress) */
.upload-overlay { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: var(--surface-overlay); backdrop-filter: blur(4px); animation: fadeIn .2s ease both; }
.upload-box { width: min(420px, 90vw); background: var(--surface-raised); border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow-lg); text-align: center; animation: popIn .3s var(--ease-spring) both; }
.upload-box h4 { font-size: var(--fs-md); margin-bottom: 14px; }
.upload-bar { height: 10px; border-radius: 10px; background: var(--surface-sunken); overflow: hidden; }
.upload-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-400), var(--gold-600)); transition: width .2s ease; }
.upload-pct { margin-top: 10px; font-weight: 800; font-size: var(--fs-md); color: var(--accent-text); }

/* ---------- Form vocabulary ---------- */
.form-section > .card-header { justify-content: flex-start; gap: 14px; }
.form-section > .card-header .sec-ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none; background: var(--surface-chip); color: var(--accent-text); }
.form-section > .card-header h3 { font-size: 17.5px; }
.form-section > .card-header p { margin: 0; font-size: 13.5px; color: var(--text-muted); font-weight: 500; }
.form-section > .card-header .sec-num { margin-inline-start: auto; font-size: 13px; font-weight: 800; color: var(--text-soft); }

.w-xs { max-width: 140px; } .w-sm { max-width: 200px; }
.counter { float: inline-end; font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.counter.over { color: var(--danger); }

/* drag-and-drop file picker (a label around a real file input) */
.dropzone {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 16px; cursor: pointer;
  border: 1.5px dashed color-mix(in srgb, var(--accent-fill) 50%, var(--surface-line)); border-radius: var(--radius);
  background: var(--surface-sunken); transition: var(--transition);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent-fill); background: var(--surface-highlight); }
.dropzone.drag { transform: scale(1.01); box-shadow: var(--glow); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone .dz-ic { width: 48px; height: 48px; border-radius: 14px; flex: none; display: grid; place-items: center; background: var(--surface-raised); color: var(--accent-text); box-shadow: var(--shadow-sm); transition: transform .35s var(--ease-spring); }
.dropzone:hover .dz-ic { transform: translateY(-3px); }
.dropzone b { display: block; font-size: 15px; }
.dropzone small { display: block; font-size: 13px; color: var(--text-muted); }
.dropzone.compact { padding: 10px 12px; min-height: var(--control-height); }
.dropzone.compact .dz-ic { width: 38px; height: 38px; border-radius: 11px; }
.dropzone.has-file { border-style: solid; border-color: var(--success); background: color-mix(in srgb, var(--success) 7%, var(--surface-raised)); }
.dropzone.has-file .dz-ic { background: var(--success); color: #ffffff; }
.current-file { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px; border-radius: var(--radius-sm); background: var(--surface-sunken); font-size: 14px; }
.current-file a { color: var(--accent-text); font-weight: 700; }
.current-file .meta { margin-inline-start: auto; color: var(--text-muted); font-size: 13px; white-space: nowrap; }

/* a checkbox drawn as a switch */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-sunken); cursor: pointer; }
.toggle b { display: block; font-size: 15px; }
.toggle small { display: block; font-size: 13px; color: var(--text-muted); }
.toggle input { appearance: none; -webkit-appearance: none; position: relative; width: 46px; height: 26px; border-radius: 20px; background: var(--surface-line); cursor: pointer; flex: none; margin: 0; transition: background .25s var(--ease); }
.toggle input::after { content: ''; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #ffffff; box-shadow: 0 2px 6px rgb(0 0 0 / .2); transition: transform .3s var(--ease-spring); }
.toggle input:checked { background: var(--success); }
.toggle input:checked::after { transform: translateX(-20px); }
.toggle input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent-fill) 60%, transparent); outline-offset: 2px; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 20px; font-size: 13px; font-weight: 800; }
.status-pill.on { background: color-mix(in srgb, var(--success) 13%, transparent); color: var(--success); }
.status-pill.off { background: var(--surface-sunken); color: var(--text-muted); }

/* password with show / hide and a strength meter */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-left: 52px; }
.pw-reveal { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; display: grid; place-items: center; }
.pw-reveal:hover, .pw-reveal[aria-pressed="true"] { background: var(--surface-sunken); color: var(--accent-text); }
.pw-reveal .when-on, .pw-reveal[aria-pressed="true"] .when-off { display: none; }
.pw-reveal[aria-pressed="true"] .when-on { display: inline-flex; }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; }
.pw-meter span { height: 5px; border-radius: 4px; background: var(--surface-line); transition: background .3s ease; }
.pw-meter[data-score="1"] span:nth-child(-n+1) { background: var(--danger); }
.pw-meter[data-score="2"] span:nth-child(-n+2) { background: var(--warning); }
.pw-meter[data-score="3"] span:nth-child(-n+3) { background: var(--gold-500); }
.pw-meter[data-score="4"] span { background: var(--success); }

/* ---------- Two-column form layout (shared) ---------- */
.form-cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.form-side { position: sticky; top: calc(var(--topnav-height) + 20px); }
.form-actions {
  display: flex; gap: 10px; margin-top: 20px; padding: 14px 18px;
  background: color-mix(in srgb, var(--surface-raised) 92%, transparent); backdrop-filter: blur(10px);
  border: 1px solid var(--surface-line); border-radius: var(--radius);
  box-shadow: var(--shadow); position: sticky; bottom: 16px; z-index: 5;
}
.form-actions .btn-primary { min-width: 150px; }

/* ---------- Mobile tab bar (phones only) ---------- */
.mobile-tabbar { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .form-cols { grid-template-columns: minmax(0, 1fr); } /* plain 1fr grows to fit long paths */
  .form-side { position: static; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(105%); box-shadow: none; } /* off the right edge (RTL) */
  .sidebar.open { transform: translateX(0); box-shadow: -18px 0 50px rgb(0 0 0 / .3); }
  .sidebar.open ~ .sidebar-scrim { display: block; position: fixed; inset: 0; background: var(--surface-overlay); z-index: 35; animation: fadeIn .2s ease both; }
  .main { margin-inline-start: 0; padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
  .topnav { padding: 0 16px; height: 64px; }
  .topnav .menu-toggle { display: grid; }
  .topnav-search, .admin-chip .admin-name { display: none; }
  .admin-chip { padding: 3px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .localized-pair { grid-template-columns: 1fr; gap: 0; }
  .content { padding: 20px 16px 32px; }
  .page-header h1 { font-size: 26px; }
  .filter-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
  .filter-bar > * { width: 100%; min-width: 0 !important; }
  .filter-bar .search-input, .filter-bar .btn { grid-column: 1 / -1; }
  .form-actions { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  /* Tables become cards: each cell shows its column name from data-label */
  .data-table.stack thead { display: none; }
  .data-table.stack, .data-table.stack tbody { display: block; background: transparent; }
  .data-table.stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px; margin: 10px; border: 1px solid var(--surface-line); border-radius: var(--radius); background: var(--surface-raised); }
  .data-table.stack td { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; border: 0; grid-column: 1 / -1; font-size: 14.5px; }
  .data-table.stack td[data-label]::before { content: attr(data-label); color: var(--text-muted); font-size: 13px; font-weight: 700; }
  .data-table.stack td.primary { grid-column: 1 / -1; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--surface-line); }
  .data-table.stack td.primary::before { display: none; }
  .data-table.stack td.acts-cell { padding-top: 8px; margin-top: 4px; border-top: 1px dashed var(--surface-line); }
  .data-table.stack td.acts-cell::before { display: none; }
  .data-table.stack .acts { width: 100%; justify-content: space-between; }
  .data-table.stack .act { width: 44px; height: 44px; }
  .data-table.stack .cell-title { min-width: 0; }
  .list-card { background: transparent; border: 0; box-shadow: none; }
  .list-card .table-responsive { overflow: visible; }
  .mobile-tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
    position: fixed; inset-inline: 0; bottom: 0; z-index: 45; height: calc(74px + env(safe-area-inset-bottom, 0px));
    padding: 0 6px env(safe-area-inset-bottom, 0px); background: color-mix(in srgb, var(--surface-raised) 94%, transparent);
    backdrop-filter: blur(14px); border-top: 1px solid var(--surface-line);
  }
  .mobile-tabbar a, .mobile-tabbar button {
    display: grid; justify-items: center; gap: 2px; font: inherit; font-size: 12px; font-weight: 700; color: var(--text-muted);
    background: none; border: 0; padding: 6px 0; min-height: 52px; align-content: center; cursor: pointer;
  }
  .mobile-tabbar .active { color: var(--accent-text); }
  .mobile-tabbar .fab {
    justify-self: center; width: 58px; height: 58px; min-height: 0; border-radius: 50%; margin-bottom: 26px; padding: 0;
    background: var(--primary); color: var(--on-primary); box-shadow: 0 10px 24px rgb(0 0 0 / .22); display: grid; place-items: center;
  }
  .toast { min-width: 0; width: calc(100vw - 32px); }
}
@media (max-width: 560px) {
  .video-source { grid-template-columns: 1fr; }
  .status-tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
}
