:root {
  --bg: #0f1115;
  --panel: #161922;
  --panel-2: #1d2230;
  --text: #e8ebf2;
  --muted: #8a93a6;
  --accent: #6aa7ff;
  --danger: #ff6b6b;
  --border: #262b39;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { color: var(--text); font-weight: 600; }
.topbar nav { display: flex; align-items: center; gap: 14px; }
.topbar .who { color: var(--muted); }
.topbar .logout { display: inline; }
.topbar button {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; cursor: pointer;
}
.topbar button:hover { background: #232a3c; }

.container { padding: 22px; max-width: 1300px; margin: 0 auto; }

h1 { margin: 0 0 14px; font-size: 22px; }
h2 { margin: 28px 0 12px; font-size: 17px; color: #cdd5e8; }

.muted { color: var(--muted); }
.center { text-align: center; }
.badge {
  display: inline-block; padding: 2px 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; color: var(--muted); font-size: 12px;
  margin-left: 6px;
}

.error {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.5);
  color: #ffd0d0;
  padding: 10px 12px; border-radius: 6px; margin: 10px 0;
}

.login-card {
  max-width: 380px; margin: 80px auto 0;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 26px;
}
.login-card h1 { margin-top: 0; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; }
.login-card input {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font: inherit;
}
.login-card button {
  background: var(--accent); color: #0b1322;
  border: 0; border-radius: 6px;
  padding: 10px 12px; cursor: pointer; font-weight: 600;
  margin-top: 6px;
}

.search {
  display: flex; gap: 8px; align-items: center;
  margin: 8px 0 18px;
}
.search input {
  flex: 1; max-width: 460px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 12px;
}
.search button {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px; cursor: pointer;
}

table.grid {
  width: 100%; border-collapse: collapse;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
}
table.grid th, table.grid td {
  padding: 9px 10px; border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: middle;
}
table.grid th { background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr:hover td { background: rgba(255,255,255,0.02); }

.thumb-cell { width: 56px; }
.thumb {
  width: 44px; height: 44px;
  object-fit: cover; border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.thumb.placeholder { display: block; }
.thumb.big { width: 160px; height: 160px; border-radius: 10px; }

.pager {
  display: flex; gap: 14px; align-items: center;
  margin: 14px 0;
}

.profile {
  display: flex; gap: 22px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--border);
  padding: 18px; border-radius: 10px; margin-bottom: 18px;
}
.profile-photo img { width: 160px; height: 160px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }

dl.kv {
  display: grid; grid-template-columns: 200px 1fr;
  row-gap: 6px; column-gap: 14px; margin: 8px 0 0;
}
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
ul.taglist { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
ul.taglist li {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 10px; font-size: 13px;
}

.analysis-image img { max-width: 480px; max-height: 480px; border-radius: 8px; border: 1px solid var(--border); }

/* Photo gallery */
.gallery { margin-top: 14px; }
.gallery-main {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.gallery-main img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #000;
}
.gallery-meta {
  margin-top: 12px;
  display: flex; gap: 18px; flex-wrap: wrap;
  color: var(--muted);
  align-items: center;
}
.gallery-meta strong { color: var(--text); }
.gallery-nav {
  margin-top: 14px;
  display: flex; gap: 10px;
}
.gallery-btn {
  padding: 8px 16px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer;
}
.gallery-btn.disabled { opacity: 0.35; pointer-events: none; }
.gallery-strip {
  margin-top: 16px;
  display: flex; gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.strip-thumb {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 4px;
  color: var(--muted);
  text-decoration: none;
}
.strip-thumb.active { border-color: var(--accent); }
.strip-thumb img {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.strip-label { font-size: 11px; margin-top: 4px; }

/* Original vs. overlay compare */
.compare {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start;
}
.compare-item { margin: 0; flex: 1 1 320px; max-width: 480px; }
.compare-item figcaption { color: var(--muted); margin-bottom: 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.compare-item img {
  width: 100%; border-radius: 8px; border: 1px solid var(--border); background: #000;
}
.compare-empty {
  display: flex; align-items: center; justify-content: center;
  min-height: 160px; border: 1px dashed var(--border); border-radius: 8px; padding: 20px; text-align: center;
}

.legend {
  list-style: none; padding: 0; margin: 14px 0 0;
  display: flex; flex-wrap: wrap; gap: 8px 18px;
}
.legend li { display: flex; align-items: center; gap: 8px; }
.legend-swatch {
  width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(255,255,255,0.25);
  display: inline-block; flex: 0 0 auto;
}

/* Report rendering */
.report { margin-top: 6px; }
.report-block {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px; margin-bottom: 14px;
}
.report-block h3 { margin: 0 0 10px; font-size: 15px; color: #cdd5e8; }
.routine-step { padding: 10px 0; border-top: 1px solid var(--border); }
.routine-step:first-child { border-top: 0; padding-top: 0; }
.routine-step-head { display: flex; align-items: center; gap: 8px; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--accent); font-size: 12px; font-weight: 600; flex: 0 0 auto;
}
.routine-step-desc { margin: 4px 0 8px; }
.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px; margin-top: 8px;
}
.product-card {
  display: flex; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px;
}
.product-img {
  width: 56px; height: 56px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--border); background: #000; flex: 0 0 auto;
}
.product-body { min-width: 0; }
.product-name { font-weight: 600; }
.report-disclaimer { font-size: 12px; font-style: italic; }

/* CSS-only Original/Translation tabs (no JS, CSP-safe) */
.report-tabradio { position: absolute; opacity: 0; pointer-events: none; }
.report-tablabels { display: flex; gap: 8px; margin-bottom: 12px; }
.report-tablabels label {
  padding: 7px 16px; cursor: pointer;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
.report-tablabels label:hover { color: var(--text); }
#rtab-orig:checked ~ .report-tablabels label[for="rtab-orig"],
#rtab-trans:checked ~ .report-tablabels label[for="rtab-trans"] {
  background: var(--accent); color: #0b1322; border-color: var(--accent); font-weight: 600;
}
.report-panel { display: none; }
#rtab-orig:checked ~ .panel-orig,
#rtab-trans:checked ~ .panel-trans { display: block; }

/* Detected-problem cut and its healed simulation, in the analysis detail table.
   The healed panel is a side-by-side pair, so it gets twice the width. */
.cut-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 4px; display: block; }
.cut-thumb-wide { width: 146px; }

/* A concern's detected area inside a rendered report. The paired variant is a
   before|after simulation composite, so it gets roughly twice the width. */
.concern-img { width: 132px; margin-top: 6px; border-radius: 4px; display: block; }
.concern-img-pair { width: 266px; }
.simulation-note { font-size: 11px; margin-top: 8px; }

/* ── Survey area ──────────────────────────────────────────────────────────
   The dashboard is a dark theme: every colour here comes from the :root
   variables at the top of this file, never a literal light value, so these
   pages sit on --bg like the rest of the admin.

   The survey pages render right-to-left. The rules are direction-agnostic or
   use logical properties, so they serve the LTR admin pages unchanged. .ltr is
   the escape hatch for values that are never Arabic: phone numbers read wrong
   when the browser bidi-reorders them inside an RTL cell. */

.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}

.small { font-size: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 14px 0;
}

.card > h2 {
  margin: 2px 0 12px;
  font-size: 15px;
  color: #cdd5e8;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.notice-ok {
  background: rgba(106, 255, 165, 0.10);
  border: 1px solid rgba(106, 255, 165, 0.45);
  color: #bdf5d4;
  padding: 10px 12px;
  border-radius: 6px;
  margin: 10px 0;
}

a.button,
a.button:visited {
  display: inline-block;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  text-decoration: none;
  white-space: nowrap;
}

a.button:hover { background: #232a3c; text-decoration: none; }

/* One question: its text, then whatever control it takes. Kept as a block so a
   long Arabic question wraps above its choices instead of squeezing them. */
.q {
  display: block;
  margin: 0 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.q:last-of-type { border-bottom: 0; }

.q-text {
  display: block;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.55;
}

.q textarea,
.q select,
.q input[type="text"] {
  width: 100%;
  max-width: 640px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font: inherit;
}

.q textarea { resize: vertical; }

/* The native dropdown list is drawn by the OS, not by this stylesheet: without
   an explicit colour on the options, a dark-on-dark pairing leaves the open
   list unreadable on some platforms. */
.q select option { background: var(--panel-2); color: var(--text); }

.q textarea:focus,
.q select:focus,
.q input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.choice:hover { border-color: var(--accent); }
.choice input { margin: 0; accent-color: var(--accent); }
/* "no answer" stays legible but visibly recedes from the real options. */
.choice.muted { color: var(--muted); }

.card form > button[type="submit"] {
  background: var(--accent);
  color: #0f1115;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 9px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
}

.card form > button[type="submit"]:hover { filter: brightness(1.08); }

/* RTL: the grid tables and key/value lists are left-aligned by rule, which
   reads as "detached" when the content is Arabic. */
[dir="rtl"] table.grid th,
[dir="rtl"] table.grid td { text-align: right; }
[dir="rtl"] .badge { margin-left: 0; margin-right: 6px; }
[dir="rtl"] dl.kv { grid-template-columns: 160px 1fr; }

/* Routine read off the report JSON. The admin renders the same data through
   _report.html with .routine-step/.product-card; these are deliberately
   separate classes because this view is a call script -- ordered steps with a
   compact product list -- not the customer-facing report layout. */

.rx-title {
  margin: 16px 0 8px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rx-step {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.rx-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.rx-step-desc { margin: 6px 0 0; line-height: 1.55; }

.rx-products {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rx-products li {
  padding: 5px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.rx-name { color: var(--text); }

/* Product rows carry a catalogue thumbnail. The placeholder keeps the text
   column aligned when a product has no image, so a list of five products does
   not look ragged because one of them is missing a photo. */

.rx-products li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rx-thumb {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: #fff;          /* catalogue PNGs are cut out on white */
  border: 1px solid var(--border);
  border-radius: 5px;
}

.rx-thumb-empty { background: var(--panel-2); }

.rx-item { min-width: 0; }

/* Model-comparison tab in the topbar, and the comparison page itself. */
.navtab { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line);
          text-decoration: none; margin-right: 12px; }
.navtab-on { background: #222733; }

.cmp-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
           margin-bottom: 14px; }
.cmp-bar .spacer { flex: 1; }
.cmp-nav { padding: 8px 16px; font-size: 18px; line-height: 1; }
.cmp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cmp-pane { border: 1px solid var(--line); border-radius: 8px; padding: 12px;
            background: var(--panel); }
.cmp-pane h3 { margin: 0 0 4px; font-size: 15px; }
.cmp-pane img { width: 100%; border-radius: 6px; display: block; }
.cmp-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.cmp-classes { width: 100%; font-size: 13px; margin-top: 10px; border-collapse: collapse; }
.cmp-classes td { padding: 3px 6px; border-top: 1px solid var(--line); }
.cmp-classes td:last-child { text-align: right; color: var(--muted); }
.cmp-none { color: var(--muted); font-style: italic; margin-top: 10px; }
.cmp-err { color: var(--rec, #ff4f5e); }
.cmp-original a { display: block; }
@media (max-width: 1200px) {
  .cmp-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .cmp-grid { grid-template-columns: 1fr; }
}

/* Dashboard user management. */
.staff-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.staff-form { max-width: 560px; display: flex; flex-direction: column; gap: 12px; }
.staff-form label { display: flex; flex-direction: column; gap: 6px; }
.staff-form input[type="text"], .staff-form input[type="password"], .staff-form select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font: inherit;
}
.staff-form button {
  background: var(--accent); color: #0b1322;
  border: 0; border-radius: 6px;
  padding: 8px 14px; cursor: pointer; font-weight: 600;
}
.staff-form label.perm { flex-direction: row; align-items: center; gap: 8px; }
.perm-list { border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; margin: 0; }
.perm-list legend { color: var(--muted); padding: 0 6px; }
.badge-on { color: #bdf5d4; border-color: rgba(106, 255, 165, 0.45); }
.badge-off { color: #ffd0d0; border-color: rgba(255, 107, 107, 0.5); }
