/* ==========================================================================
   Dashboard — Artline Production
   Same tokens as the public site: warm neutrals, one orange accent.
   ========================================================================== */

:root {
  --brand: #ef5e1d;
  --brand-strong: #c2470f;
  --brand-hover: #a93d0c;
  --brand-tint: #fff4ed;

  --ink: #1d1c1b;
  --ink-2: #44403c;
  --muted: #6d6660;
  --line: #ece7e1;
  --line-2: #ddd6cd;
  --bg: #f8f6f3;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --surface-3: #f1ede8;

  --ok: #15803d;   --ok-tint: #f0fdf4;
  --warn: #b45309; --warn-tint: #fffbeb;
  --danger: #b91c1c; --danger-tint: #fef2f2;

  --font-display: "Cairo", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font: "Cairo", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;

  --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(29, 28, 27, .04);
  --shadow-2: 0 2px 6px rgba(29, 28, 27, .04), 0 12px 32px rgba(29, 28, 27, .08);
  --focus: 0 0 0 4px rgba(194, 71, 15, .14);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --sidebar-w: 264px;
}

/* ---------------------------------- Base ---------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img, video, svg { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-family: var(--font-display); font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { background: var(--surface-3); padding: 2px 8px; border-radius: 6px; font-size: 13px; }

/* ---------------------------------- Shell --------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px 14px; background: var(--surface); border-inline-end: 1px solid var(--line); overflow-y: auto; }
.brand { display: flex; flex-direction: column; gap: 8px; padding: 6px 10px 20px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand svg { width: 172px; height: auto; flex: none; }
.brand small { font-size: 12px; font-weight: 500; color: var(--muted); }
.brand--dark { align-items: center; text-align: center; padding-bottom: 6px; }
.brand--dark svg { width: 200px; }
.sidebar__label { margin: 18px 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--muted); }
.sidebar nav a, .sidebar__foot > a { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; transition: background-color .15s var(--ease), color .15s var(--ease); }
.sidebar nav a:hover, .sidebar__foot > a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.sidebar nav a.is-active { background: var(--brand-tint); color: var(--brand-strong); font-weight: 600; }
.sidebar nav svg, .sidebar__foot svg { width: 20px; height: 20px; flex: none; }
.sidebar__foot { margin-top: auto; padding-top: 14px; display: grid; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.me__avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; font-family: var(--font-display); font-size: 13px; font-weight: 600; flex: none; }
.me__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.me__text strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me__text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: end; }
.me form { margin: 0 0 0 0; margin-inline-start: auto; }
.me__logout { width: 34px; height: 34px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.me__logout:hover { background: var(--danger-tint); color: var(--danger); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; min-height: 76px; padding: 14px 40px; background: rgba(247, 245, 242, .9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.topbar__actions { margin-inline-start: auto; display: flex; gap: 10px; }
.menu-btn { display: none; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); align-items: center; justify-content: center; cursor: pointer; flex: none; }
.menu-btn svg { width: 20px; height: 20px; }
.content { padding: 28px 40px 64px; max-width: 1360px; width: 100%; }
.backdrop { position: fixed; inset: 0; background: rgba(29, 28, 27, .45); z-index: 30; }

/* --------------------------------- Buttons -------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer; transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease); }
.btn:hover { border-color: var(--ink); text-decoration: none; }
.btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn--primary:disabled { opacity: .55; cursor: progress; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--brand-strong); }
.btn--ghost:hover { background: var(--brand-tint); border-color: transparent; }
.btn--block { width: 100%; height: 50px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--danger); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); border: 0; background: none; color: var(--ink-2); cursor: pointer; vertical-align: middle; transition: background-color .15s, color .15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn--danger:hover { color: var(--danger); background: var(--danger-tint); }

/* --------------------------------- Feedback ------------------------------- */
.alert { display: flex; align-items: center; gap: 10px; margin: 20px 40px 0; padding: 12px 16px; border-radius: var(--r); font-weight: 500; border: 1px solid; }
.alert::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.alert--success { background: var(--ok-tint); border-color: #bbf7d0; color: #14532d; }
.alert--error { background: var(--danger-tint); border-color: #fecaca; color: #991b1b; }
.auth .alert, .form .alert { margin: 0 0 16px; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { background: var(--ok-tint); color: var(--ok); }
.badge--off { background: var(--surface-3); color: var(--muted); }
.badge--warn { background: var(--warn-tint); color: var(--warn); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 64px 16px; color: var(--muted); }

/* ---------------------------------- Panels -------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; }
.panel + .panel, .panel + .grid-2, .stats + .panel { margin-top: 20px; }
.panel--flush { padding: 0; overflow: hidden; }
.panel--hint { background: var(--brand-tint); border-color: #fbd9c5; margin-bottom: 20px; }
.panel--hint h2 { font-size: 17px; margin-bottom: 8px; }
.panel--hint ol { margin: 0; padding-inline-start: 1.2em; display: grid; gap: 4px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel h2 { font-size: 16px; font-weight: 600; }

/* -------------------------------- Dashboard ------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--ink); transition: border-color .15s, box-shadow .2s var(--ease); }
a.stat:hover { text-decoration: none; border-color: var(--line-2); box-shadow: var(--shadow-2); }
.stat__icon { grid-row: span 2; width: 46px; height: 46px; border-radius: var(--r); display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-strong); }
.stat__icon svg { width: 22px; height: 22px; }
.stat > span:not(.stat__icon) { font-size: 13px; color: var(--muted); }
.stat strong { font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.quick__item { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px dashed var(--line-2); color: var(--ink); transition: border-color .15s, background-color .15s; }
.quick__item:hover { text-decoration: none; border-style: solid; border-color: var(--brand); background: var(--brand-tint); }
.quick__item strong { font-weight: 600; }
.quick__item span { font-size: 13px; color: var(--muted); }
.storage__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.storage__head span { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; }
.storage .muted { margin-top: 10px; font-size: 13px; }
.meter { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--brand-strong); border-radius: inherit; transition: width .3s var(--ease); }
.meter.is-high span { background: var(--danger); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2 .panel + .panel { margin-top: 0; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li + li { border-top: 1px solid var(--line); }
.mini-list a { display: flex; align-items: center; gap: 14px; padding: 12px 0; color: var(--ink); }
.mini-list a:hover { text-decoration: none; }
.mini-list a:hover strong { color: var(--brand-strong); }
.mini-list strong { display: block; font-weight: 600; }
.mini-list small { color: var(--muted); }

/* ---------------------------------- Lists --------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar__search { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; }
.toolbar__search input, .toolbar__search select { height: 44px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface); min-width: 0; }
.toolbar__search input { flex: 1; min-width: 200px; max-width: 380px; }
.toolbar__search input:focus, .toolbar__search select:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.cell--title { min-width: 220px; }
.cell-title { display: block; font-weight: 600; color: var(--ink); }
.cell-title:hover { color: var(--brand-strong); }
.cell--title small { display: block; font-size: 12px; }
.cell--number { font-variant-numeric: tabular-nums; }
.table__actions { white-space: nowrap; text-align: end; width: 1%; }
.table__actions form { display: inline; margin: 0; }
.thumb { display: block; width: 88px; aspect-ratio: 16 / 9; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-3); flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.avatar { display: block; width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--surface-3); }
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.icon-cell { color: var(--brand); }
.icon-cell svg { width: 30px; height: 30px; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pager a, .pager span { min-width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; padding-inline: 10px; font-variant-numeric: tabular-nums; }
.pager a:hover { border-color: var(--ink); text-decoration: none; }
.pager .is-current { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------------------------------- Forms --------------------------------- */
.form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 24px; padding: 28px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field > label, .field > .label { font-weight: 600; font-size: 14px; }
.req { color: var(--danger); font-weight: 600; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="number"], .field input[type="url"],
.field input[type="datetime-local"], .field select, .field textarea, .video-field input[type="text"] {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: #cbc2b6; }
.field input:focus, .field select:focus, .field textarea:focus, .video-field input[type="text"]:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.field textarea { resize: vertical; min-height: 110px; line-height: 1.7; }
.field input[type="file"] { font-size: 13px; }
.field input[type="file"]::file-selector-button { margin-inline-end: 12px; height: 36px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; cursor: pointer; }
.has-error input, .has-error select, .has-error textarea, .has-error .editor, .has-error .video-field { border-color: var(--danger) !important; }
.hint { color: var(--muted); font-size: 12.5px; }
.error { color: var(--danger); font-weight: 600; font-size: 13px; }
.form__actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; padding: 14px 0 18px; background: linear-gradient(to top, var(--bg) 75%, rgba(247, 245, 242, 0)); }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; padding-top: 28px; }
.switch input { position: absolute; opacity: 0; }
.switch__track { width: 44px; height: 26px; border-radius: var(--r-pill); background: var(--line-2); position: relative; transition: background-color .2s var(--ease); flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: inset-inline-start .2s var(--ease); }
.switch input:checked + .switch__track { background: var(--brand-strong); }
.switch input:checked + .switch__track::after { inset-inline-start: 21px; }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus); }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip input { position: absolute; opacity: 0; }
.check-chip span { display: inline-flex; align-items: center; height: 36px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 500; font-size: 14px; transition: all .15s; }
.check-chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.check-chip input:focus-visible + span { box-shadow: var(--focus); }
.inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 8px; }
.icon-picker input { position: absolute; opacity: 0; }
.icon-picker span { display: grid; place-items: center; height: 60px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: all .15s; }
.icon-picker span:hover { border-color: var(--line-2); }
.icon-picker svg { width: 32px; height: 32px; }
.icon-picker input:checked + span { border-color: var(--brand); background: var(--brand-tint); color: var(--brand); box-shadow: var(--focus); }
.icon-picker input:focus-visible + span { box-shadow: var(--focus); }

.image-field { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.image-field__preview { width: 120px; height: 120px; border-radius: var(--r-lg); overflow: hidden; background: var(--surface-2); border: 1px dashed var(--line-2); display: grid; place-items: center; color: var(--muted); font-size: 12px; flex: none; }
.image-field__preview--wide { width: 240px; height: 135px; }
.image-field__preview img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.image-field__controls { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.file-btn { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; transition: border-color .15s; }
.file-btn:hover { border-color: var(--ink); }
.file-btn:focus-within { box-shadow: var(--focus); border-color: var(--brand); }
.file-btn svg { width: 18px; height: 18px; color: var(--brand-strong); }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-name { font-size: 12.5px; color: var(--muted); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name.is-set { color: var(--ink); font-weight: 600; }

.editor { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.editor:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
.editor__bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.editor__bar button { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); cursor: pointer; }
.editor__bar button:hover { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.editor__bar svg { width: 18px; height: 18px; }
.editor__area { min-height: 200px; padding: 16px 18px; line-height: 1.85; outline: none; }
.editor__area:empty::before { content: "اكتب هنا…"; color: #a59d94; }
.editor__area h3 { font-family: var(--font-display); font-size: 17px; margin: .6em 0 .3em; }
.editor__area ul, .editor__area ol { padding-inline-start: 1.4em; }
.editor__area blockquote { margin: 0; padding: 8px 16px; border-inline-start: 3px solid var(--brand); background: var(--surface-2); border-radius: 6px; }

.video-field { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; margin: 0; background: var(--surface-2); }
.video-field legend { font-weight: 600; padding-inline: 6px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px; margin-bottom: 16px; border-radius: var(--r-pill); background: var(--surface-3); }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 8px 16px; border-radius: var(--r-pill); cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); transition: all .15s; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.seg input:focus-visible + span { box-shadow: var(--focus); }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 16px; border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); background: var(--surface); text-align: center; cursor: pointer; transition: border-color .15s, background-color .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-tint); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone__icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-strong); margin-bottom: 6px; }
.dropzone__icon svg { width: 26px; height: 26px; }
.dropzone small { color: var(--muted); }
.current-video { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.current-video video { width: 260px; border-radius: var(--r); background: #000; }
.upload-status { margin-top: 14px; padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.upload-status__row { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 14px; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.upload-status.is-error .upload-status__row { color: var(--danger); }
.upload-status.is-done .meter span { background: var(--ok); }
.upload-status .link-btn { margin-top: 8px; font-size: 13px; }
.capture { display: flex; gap: 16px; align-items: center; margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); flex-wrap: wrap; }
.capture img { width: 200px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-sm); background: #000; }
.capture p { margin: 2px 0 10px; font-size: 13px; }
.capture input[type="range"] { width: 240px; accent-color: var(--brand-strong); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; padding: 4px; border-radius: var(--r-pill); background: var(--surface-3); width: fit-content; max-width: 100%; }
.tab { height: 38px; padding: 0 18px; border-radius: var(--r-pill); border: 0; background: transparent; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

/* -------------------------------- Inquiries ------------------------------- */
.nav-count { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--r-pill); background: var(--brand-strong); color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.inquiries { display: grid; gap: 14px; }
.inquiry { padding: 20px 22px; }
.inquiry.is-new { border-color: #f6c7ad; box-shadow: inset 3px 0 0 var(--brand); }
[dir="rtl"] .inquiry.is-new { box-shadow: inset -3px 0 0 var(--brand); }
.inquiry__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.inquiry__head h2 { font-size: 17px; }
.inquiry__msg { margin-top: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); line-height: 1.8; white-space: normal; overflow-wrap: anywhere; }
.inquiry__foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.inquiry__contact { display: flex; flex-wrap: wrap; gap: 8px; }
.inquiry__contact .btn { height: 38px; padding: 0 14px; font-size: 13px; }
.inquiry__actions { display: flex; align-items: center; gap: 8px; margin: 0; }
.inquiry__actions select { height: 38px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); }
.tabs a.tab { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }

/* ---------------------------------- Auth ---------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; padding: 40px 32px 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-2); }
.auth-card .field input { min-height: 50px; }
.auth-card > p { text-align: center; }

/* ------------------------------- Responsive ------------------------------- */
@media (max-width: 1200px) {
  .stats, .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 280px; z-index: 40; transform: translateX(100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-2); }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar-open .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; min-height: 64px; }
  .topbar h1 { font-size: 18px; }
  .content { padding: 20px 16px 48px; }
  .alert { margin-inline: 16px; }
  .grid-2, .form__grid { grid-template-columns: 1fr; }
  .form__grid { padding: 20px; }
  .switch { padding-top: 0; }
}
@media (max-width: 640px) {
  .topbar__actions .btn { width: 44px; padding: 0; font-size: 0; gap: 0; }
  .topbar__actions .btn svg { width: 20px; height: 20px; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: 3px 0; }
  .table td[data-label]:not(.cell--title):not(.cell--thumb):not(.cell--avatar):not(.cell--icon)::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; }
  .table__actions { text-align: start; width: auto; padding-top: 8px !important; }
  .stats { gap: 10px; }
  .stat { padding: 14px; column-gap: 10px; }
  .stat__icon { width: 38px; height: 38px; }
  .stat strong { font-size: 22px; }
  .quick { grid-template-columns: 1fr; }
  .toolbar__search input { max-width: none; }
  .current-video video { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; }
}

/* ==========================================================================
   Interaction & motion layer
   ========================================================================== */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: sidebar; }
::view-transition-old(root) { animation: vt-out 160ms ease both; }
::view-transition-new(root) { animation: vt-in 260ms var(--ease) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

.ui-icon, .nav-icon { width: 20px; height: 20px; flex: none; }
.btn .ui-icon { width: 18px; height: 18px; }
.icon-btn .ui-icon { width: 18px; height: 18px; }

/* Entrance: panels, rows and cards rise in, staggered */
.enter { animation: enter 520ms var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }

/* Sidebar: active pill slides in, icons nudge on hover */
.sidebar nav a { position: relative; }
.sidebar nav a::before { content: ""; position: absolute; inset-inline-start: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); transform: scaleY(0); transition: transform 250ms var(--ease); }
[dir="rtl"] .sidebar nav a::before { border-radius: 3px 0 0 3px; }
.sidebar nav a.is-active::before { transform: scaleY(1); }
.sidebar nav a .nav-icon { transition: transform 250ms var(--ease); }
.sidebar nav a:hover .nav-icon { transform: scale(1.12); }

/* Buttons */
.btn { position: relative; transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease), box-shadow .2s var(--ease); }
.btn:active { transform: scale(.97); }
.btn--primary { box-shadow: none; }
.btn--primary:hover { box-shadow: 0 6px 16px rgba(29, 28, 27, .12); transform: translateY(-1px); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: #991b1b; border-color: #991b1b; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toasts */
.toasts { position: fixed; z-index: 90; top: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 10px; width: min(460px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 14px; background: var(--ink); color: #fff; box-shadow: 0 12px 32px rgba(29, 28, 27, .25); font-weight: 500; animation: toast-in 420ms cubic-bezier(.2, 1.3, .4, 1) both; }
.toast--error { background: #991b1b; }
.toast__icon { width: 20px; height: 20px; color: #7ee2a8; }
.toast--error .toast__icon { color: #ffc4bd; }
.toast span { flex: 1; }
.toast__close { width: 30px; height: 30px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .1); color: #fff; display: grid; place-items: center; cursor: pointer; }
.toast__close:hover { background: rgba(255, 255, 255, .2); }
.toast__close .ui-icon { width: 16px; height: 16px; }
.toast.is-leaving { animation: toast-out 240ms ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px) scale(.97); } }
.alert { display: none; }

/* Confirm dialog */
.modal { border: 0; padding: 0; border-radius: 20px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(29, 28, 27, .3); color: var(--ink); background: var(--surface); }
.modal::backdrop { background: rgba(29, 28, 27, .45); backdrop-filter: blur(3px); }
.modal[open] { animation: modal-in 320ms cubic-bezier(.2, 1.2, .4, 1) both; }
.modal[open]::backdrop { animation: fade-in 200ms ease both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes fade-in { from { opacity: 0; } }
.modal__box { margin: 0; padding: 28px 24px 22px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.modal__icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--danger-tint); color: var(--danger); margin-bottom: 4px; }
.modal__icon .ui-icon { width: 26px; height: 26px; }
.modal h2 { font-size: 18px; }
.modal__text { color: var(--ink-2); line-height: 1.7; }
.modal__actions { display: flex; gap: 10px; width: 100%; margin-top: 10px; }
.modal__actions .btn { flex: 1; }

/* Row actions menu */
.row-actions { display: inline-flex; align-items: center; gap: 2px; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--surface-3); color: var(--ink); }
.menu__list { position: absolute; z-index: 20; top: calc(100% + 6px); inset-inline-end: 0; min-width: 220px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(29, 28, 27, .14); text-align: start; animation: menu-in 180ms var(--ease) both; transform-origin: top; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu__list a, .menu__list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: none; color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.menu__list a:hover, .menu__list button:hover { background: var(--surface-2); text-decoration: none; }
.menu__list .ui-icon { width: 17px; height: 17px; color: var(--muted); }
.menu__list form { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--line); display: block; }
.menu__danger { color: var(--danger) !important; }
.menu__danger .ui-icon { color: var(--danger) !important; }
.menu__danger:hover { background: var(--danger-tint) !important; }

/* Tables: sticky header, row lift */
.table-wrap { overflow: visible; }
.panel--flush { overflow: visible; }
.table thead th { position: sticky; top: 76px; z-index: 2; }
.table thead th:first-child { border-start-start-radius: var(--r-lg); }
.table thead th:last-child { border-start-end-radius: var(--r-lg); }
.table tbody tr { transition: background-color .15s, box-shadow .15s; }
.table tbody tr:hover { background: #fffaf6; box-shadow: inset 3px 0 0 var(--brand); }
[dir="rtl"] .table tbody tr:hover { box-shadow: inset -3px 0 0 var(--brand); }
.thumb img, .avatar img { transition: transform .4s var(--ease); }
.table tbody tr:hover .thumb img { transform: scale(1.06); }

/* Stat cards & quick actions */
.stat__icon { transition: transform .3s var(--ease), background-color .3s, color .3s; }
a.stat:hover .stat__icon { transform: rotate(-6deg) scale(1.08); background: var(--brand); color: #fff; }
.quick__item { transition: border-color .2s, background-color .2s, transform .2s var(--ease); }
.quick__item:hover { transform: translateY(-2px); }

/* Inputs: focus glow animates in */
.field input, .field select, .field textarea, .editor { transition: border-color .2s var(--ease), box-shadow .25s var(--ease); }

@media (max-width: 960px) {
  .table thead th { top: 64px; }
}
@media (max-width: 640px) {
  .table-wrap { overflow-x: visible; }
  .menu__list { inset-inline-end: auto; inset-inline-start: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .enter, .toast, .modal[open], .menu__list { animation: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}
/* Keep an open row menu above the following rows */
.table tbody tr { position: relative; }
.table tbody tr:has(.menu[open]) { z-index: 30; }
.enter { animation-fill-mode: backwards; }

/* Lists: switch rows to stacked cards whenever the list panel is too narrow for the table
   (phones, tablets, and small laptops with the sidebar open). */
.panel--flush { container: list / inline-size; }
@container list (max-width: 860px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: 3px 0; }
  .table td[data-label]:not(.cell--title):not(.cell--thumb):not(.cell--avatar):not(.cell--icon)::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; }
  .table__actions { text-align: start; width: auto; padding-top: 8px !important; }
}

/* Touch-friendly native checkboxes and radios */
input[type="checkbox"]:not(.check-chip input), input[type="radio"] { width: 20px; height: 20px; accent-color: var(--brand-strong); flex: none; }
@container list (min-width: 560px) and (max-width: 860px) {
  .table tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table tbody tr:nth-child(odd) { border-inline-end: 1px solid var(--line); }
}
