:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #182030;
  --muted: #5c6678;
  --border: #d9dfe8;
  --brand: #0f3d5e;
  --brand-2: #145a86;
  --accent: #d9480f;
  --accent-soft: #fff1e8;
  --call: #1864ab;
  --wa: #2b8a3e;
  --focus: #2f7fd6;
  --badge-bg: #e6f4ea;
  --badge-text: #1e6b34;
  --link: #1864ab;
  --danger: #c92a2a;
  --notice-bg: #fff4e6;
  --notice-text: #8a3b00;
  --notice-border: #ffd8a8;
  /* Chart series (charts.dart), checked with the dataviz palette validator
     against --surface in each theme: distinct for colorblind eyes, >= 3:1
     except the light aqua (2.8:1), which the table under the charts covers. */
  --s-call: #2a78d6;
  --s-whatsapp: #1baf7a;
  --s-map: #eb6834;
  --s-seen: #7c879a;
  --grid: #e9edf2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

/* Dark: the phone's own setting, unless the visitor chose light with the
   header's button; or their choice of dark. The choice is data-theme on
   <html> (the jcp_theme cookie, see web/theme.dart). Both blocks hold the
   same values: change them together. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1219;
    --surface: #171d27;
    --surface-2: #1c2330;
    --text: #e7eaf0;
    --muted: #a0a9b8;
    --border: #2d3644;
    --brand: #0b2c44;
    --brand-2: #0f3d5e;
    --accent-soft: #3a2014;
    --badge-bg: #1d3a26;
    --badge-text: #8fd6a4;
    --link: #74b3f0;
    --danger: #ff8787;
    --notice-bg: #3a2410;
    --notice-text: #ffd8a8;
    --notice-border: #5c3a14;
    --s-call: #3987e5;
    --s-whatsapp: #199e70;
    --s-map: #d95926;
    --grid: #232b37;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1219;
  --surface: #171d27;
  --surface-2: #1c2330;
  --text: #e7eaf0;
  --muted: #a0a9b8;
  --border: #2d3644;
  --brand: #0b2c44;
  --brand-2: #0f3d5e;
  --accent-soft: #3a2014;
  --badge-bg: #1d3a26;
  --badge-text: #8fd6a4;
  --link: #74b3f0;
  --danger: #ff8787;
  --notice-bg: #3a2410;
  --notice-text: #ffd8a8;
  --notice-border: #5c3a14;
  --s-call: #3987e5;
  --s-whatsapp: #199e70;
  --s-map: #d95926;
  --grid: #232b37;
  --shadow: none;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
a, button, summary, label { touch-action: manipulation; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
}

a { color: var(--link); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.muted { color: var(--muted); font-size: .9rem; }

/* ── Header ─────────────────────────────────────────────── */

.site-header {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
/* The header row: the logo, and across from it the light / dark button. */
.header-row {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.logo {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}
.logo-mark { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.theme-form { margin: 0; flex: none; }
.theme-toggle {
  width: 42px;
  height: 42px;
  min-height: 0;
  padding: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .28);
  color: #fff;
}
@media (hover: hover) { .theme-toggle:hover { background: rgba(255, 255, 255, .22); } }
.theme-toggle .icon { width: 20px; height: 20px; }
/* The moon in light (switch to dark), the sun in dark (switch to light). */
.theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
/* The Jordanian flag after the site's name, with a light edge so its black
   stripe shows on the dark header. */
.flag { display: inline-block; width: 22px; height: 11px; border-radius: 2px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(255, 255, 255, .6); }
.logo-name .flag { margin-inline-start: 4px; position: relative; top: -1px; }
.site-footer .flag { width: 18px; height: 9px; box-shadow: 0 0 0 1px var(--border); }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-name { font-weight: 800; font-size: 1.15rem; }
.logo-sub { font-size: .78rem; opacity: .8; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

h1 { font-size: 1.4rem; margin: 14px 0 4px; line-height: 1.4; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }

.hero { padding: 14px 0 2px; }
.hero h1 { margin-top: 6px; }
.hero p { color: var(--muted); margin: 0 0 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

/* ── The search form: brand → model → category → part ──── */

/* Phones: one dropdown per line, so brand, model and part names fit.
   minmax(0, 1fr) rather than 1fr: a plain 1fr column grows to fit its widest
   content, so a long part name or the buttons would push the form out of the
   card. This way long names end in "…" instead. */
.finder {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
@media (min-width: 760px) {
  .finder { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
}
/* Wraps to two lines on very narrow phones or with large text. */
.finder .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.finder .actions button { flex: 1 1 auto; }
.finder .actions .clear-filters { flex: 0 0 auto; }
@media (min-width: 760px) {
  .finder .actions { justify-content: flex-start; }
  .finder .actions button { flex: 0 0 auto; min-width: 240px; }
}

.field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: 5px;
}
.step {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  flex: none;
}
.optional { color: var(--muted); font-weight: 400; font-size: .8rem; }

select {
  width: 100%;
  font: inherit;
  font-size: 1rem; /* 16px: iPhones zoom in on smaller form fields */
  color: var(--text);
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 46px;
  padding: 8px 12px;
  padding-left: 34px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2.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 10px center;
  background-size: 16px;
  text-overflow: ellipsis;
}
@media (hover: hover) { select:hover:not(:disabled) { border-color: var(--muted); } }
select:disabled { opacity: .55; cursor: not-allowed; }

button, .btn {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  min-height: 46px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}
button[type=submit]:not(.btn-secondary):not(.link-button):not(.theme-toggle):not(.btn-danger) { background: var(--accent); color: #fff; font-weight: 700; }
@media (hover: hover) { button[type=submit]:hover { filter: brightness(1.08); } }
button:active:not(:disabled), .btn:active { filter: brightness(.92); }

/* ── Free-text search ───────────────────────────────────── */

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  padding-inline-start: 12px;
}
.search-box:focus-within { border-color: var(--accent); }
.search-icon { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 10px 4px;
}
.search-box input:focus { outline: none; }
/* Tappable examples, and the browse links (brands, models, categories). */
.examples, .link-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; margin: 12px 0 0; }
.link-chips { margin: 0; }
.examples a, .link-chips a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
@media (hover: hover) { .examples a:hover { border-color: var(--accent); } }

.how { color: var(--muted); font-size: .95rem; margin: 8px 0 20px; }
.how h2 { color: var(--text); }
.how ol { margin: 0; padding-inline-start: 22px; }

/* ── Notices ────────────────────────────────────────────── */

.notice {
  background: var(--notice-bg);
  color: var(--notice-text);
  border: 1px solid var(--notice-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 0 16px;
}

/* ── Results ────────────────────────────────────────────── */

.summary { color: var(--muted); margin: 0 0 10px; }

table.results {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.results th, .results td {
  padding: 12px;
  text-align: start;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.results th { font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.results tbody tr:last-child td { border-bottom: 0; }

.shop-name { font-weight: 700; }
.badge {
  display: inline-block;
  font-size: .75rem;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--badge-bg);
  color: var(--badge-text);
  margin-inline-start: 6px;
}

.contact { display: flex; flex-wrap: wrap; gap: 6px; }
.btn .icon { width: 18px; height: 18px; flex: none; }
.btn-call { background: var(--call); color: #fff; }
.btn-wa { background: var(--wa); color: #fff; }
.btn-map { background: transparent; color: var(--text); border: 1px solid var(--border); }
.phone { direction: ltr; unicode-bidi: isolate; }
/* A shop's mobiles: tap to call (counted like the Call button). */
a.phone { white-space: nowrap; }

/* Phones: each shop becomes a block, labels come from data-label. */
@media (max-width: 759px) {
  .results thead { display: none; }
  .results, .results tbody, .results tr, .results td { display: block; width: 100%; }
  .results tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
  .results tbody tr:last-child { border-bottom: 0; }
  .results td { border: 0; padding: 4px 14px; }
  .results td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: .78rem;
    color: var(--muted);
  }
  .results td.shop::before { content: none; }
  /* Call, WhatsApp and map share one row. */
  .contact { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .contact .btn { padding: 10px 6px; }
}

.empty { text-align: center; padding: 28px 16px; }
.empty ul { list-style: none; padding: 0; margin: 12px 0 0; }
.empty li { margin: 8px 0; }
.empty li a {
  display: block;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  text-decoration: none;
}

/* ── Footer ─────────────────────────────────────────────── */

.site-footer {
  max-width: 1100px;
  margin: 12px auto 0;
  padding: 16px 16px 28px;
  padding-bottom: max(28px, calc(env(safe-area-inset-bottom) + 16px));
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .9rem;
}
.site-footer p { margin: 4px 0; }
.site-footer strong { color: var(--text); }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 8px 0; }
.footer-links a { display: inline-flex; align-items: center; min-height: 32px; }

/* «من نحن» and the policies: text to read on a phone. */
.legal { max-width: 760px; line-height: 1.8; }
.legal h1 { margin-top: 0; }
.legal h2 { font-size: 1.15rem; margin: 24px 0 6px; }
.legal h3 { font-size: 1rem; margin: 16px 0 4px; }
.legal ul { padding-inline-start: 22px; margin: 6px 0 12px; }
.legal li { margin: 4px 0; }

/* A shop's page: where its details came from; the site only points the way. */
.source-note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 16px 0 8px;
}
.guide-note { color: var(--muted); font-size: .9rem; margin: 12px 0; }

/* ── Team screens (/manage) ─────────────────────────────── */

/* Tabs on the start side, the account menu on the end side. */
.topbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.topbar .tab {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.topbar .tab.is-active { background: var(--accent-soft); color: var(--accent); }
.account { position: relative; margin-inline-start: auto; }
.account > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--muted);
}
.account > summary::-webkit-details-marker { display: none; }
.account > summary::after { content: "▾"; font-size: .8rem; }
.account[open] > summary { background: var(--surface-2); color: var(--text); }
.account-menu {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 220px;
  display: grid;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
  padding: 6px;
}
.account-menu p { margin: 4px 10px 6px; }
.account > summary .icon { width: 20px; height: 20px; flex: none; }
.account-who { display: none; font-weight: 700; }

/* A phone: the tabs share the row, the name gives way to the icon, and a
   very narrow screen wraps the bar instead of widening the page. */
@media (max-width: 759px) {
  .topbar { flex-wrap: wrap; gap: 2px; }
  .topbar .tab:not(:only-of-type) { flex: 1 1 auto; justify-content: center; padding: 0 6px; }
  .account > summary { padding: 0 8px; gap: 4px; }
  .account-name {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .account-menu .account-who { display: block; margin-bottom: 0; }
}
.account-menu a, .account-menu .link-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  width: 100%;
  text-align: start;
}
.account-menu form { margin: 0; }
.account-menu .link-button { color: var(--danger); }
@media (hover: hover) { .account-menu a:hover, .account-menu .link-button:hover { background: var(--surface-2); } }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.crumbs a { color: var(--muted); }
h3 { font-size: 1rem; margin: 18px 0 8px; }
.center { text-align: center; }

.stack { display: grid; gap: 14px; }
input[type=text], input[type=tel], input[type=password], textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 46px;
  padding: 10px 12px;
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
.hint { color: var(--muted); font-size: .82rem; margin: 4px 0 0; }
.field-error { color: var(--danger); font-size: .85rem; margin: 4px 0 0; }
.has-error input, .has-error select, .has-error textarea, .has-error .combo-trigger { border-color: var(--danger); }

.check { display: flex; align-items: center; gap: 8px; font-weight: 400; min-height: 36px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.check.strong { font-weight: 700; }
.check.agree { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; }
/* «من أين بيانات المحل؟»: the link box shows only for «صفحة عامة». */
fieldset.source-box { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; }
.source-url { margin: 2px 0 6px; padding-inline-start: 28px; }
.source-box:not(:has(input[name="source"][value="public"]:checked)) .source-url { display: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 12px; }
#models-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-top: 6px; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
/* Phones: dropdowns with long names get a line each, like the search form. */
@media (max-width: 759px) {
  .pair-fields { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
.gps-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.btn-primary { background: var(--accent); color: #fff; font-weight: 700; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); font-weight: 600; }
.link-button {
  background: none;
  border: 0;
  padding: 4px 6px;
  min-height: 0;
  color: var(--call);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.link-button.danger { color: var(--danger); }
.cancel { justify-self: center; color: var(--muted); }

.status { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; vertical-align: middle; }
.status.live { background: var(--badge-bg); color: var(--badge-text); }
.status.draft { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.status.hidden { background: #fff4e6; color: #8a3b00; }

.flash {
  background: var(--badge-bg);
  color: var(--badge-text);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin: 8px 0 12px;
  font-weight: 600;
}
.link-box { display: grid; gap: 8px; }
.link-box .btn-wa { justify-self: start; }
.copy { font-size: .85rem; }
.history { margin: 0; padding-inline-start: 18px; }
.history li { margin: 4px 0; }

.narrow { max-width: 480px; margin: 0 auto; }

/* Anything marked hidden stays hidden, even with a display rule above. */
[hidden] { display: none !important; }

/* ── Searchable dropdowns (select[data-searchable], see app.js) ── */

.combo { position: relative; }
/* The real <select> stays in the form for submitting, just out of sight
   (also when disabled: select:disabled would otherwise show it through). */
.combo > select.combo-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.combo-trigger {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  padding-left: 34px;
  text-align: start;
  font: inherit;
  font-size: .95rem;
  font-weight: 400;
  color: var(--text);
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2.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 10px center;
  background-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (hover: hover) { .combo-trigger:hover:not(:disabled) { border-color: var(--muted); } }
.combo-trigger.is-placeholder { color: var(--muted); }
.combo-trigger:disabled { opacity: .55; cursor: not-allowed; }
.combo.is-open .combo-trigger { border-color: var(--accent); }
.combo.has-error .combo-trigger { border-color: var(--danger); }
.combo-panel {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 4px);
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
  padding: 8px;
}
.combo-search {
  width: 100%;
  font: inherit;
  font-size: 16px; /* 16px stops iPhones zooming in on focus */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 42px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.combo-search:focus { outline: none; border-color: var(--accent); }
.combo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(50vh, 320px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.combo-option { padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.combo-option.is-active, .combo-option:active { background: var(--accent-soft); }
@media (hover: hover) { .combo-option:hover { background: var(--accent-soft); } }
.combo-option[aria-selected="true"] { font-weight: 700; }
.combo-group { padding: 8px 10px 4px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.combo-empty { padding: 10px; color: var(--muted); }
#models-list .combo-search { grid-column: 1 / -1; position: sticky; top: 0; z-index: 1; }

/* × inside a filled searchable field, next to the arrow. */
.combo-clear {
  position: absolute;
  top: 50%;
  left: 30px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
}
@media (hover: hover) { .combo-clear:hover { background: var(--accent-soft); color: var(--text); } }
.combo.is-filled .combo-trigger { padding-left: 64px; }

/* ── Results: priced parts for sale ─────────────────────── */

.results-title { margin: 22px 0 2px; }
.part-name { font-weight: 700; }
.listings .price-cell strong { font-size: 1.1rem; color: var(--badge-text); white-space: nowrap; }
/* Phones: part and car beside the price, then the description, the shop
   and its buttons. No labels needed. */
@media (max-width: 759px) {
  .results.listings tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "part price"
      "part cond"
      "note note"
      "shop shop"
      "contact contact";
    gap: 6px 12px;
    padding: 12px 14px;
  }
  .results.listings td { width: auto; padding: 0; }
  .results.listings td[data-label]::before { content: none; }
  .results.listings td:nth-child(1) { grid-area: part; }
  .results.listings td:nth-child(2) { grid-area: note; }
  .results.listings td:nth-child(3) { grid-area: cond; text-align: end; font-size: .85rem; color: var(--muted); }
  .results.listings td:nth-child(4) { grid-area: price; text-align: end; }
  .results.listings td:nth-child(5) { grid-area: shop; }
  .results.listings td:nth-child(6) { grid-area: contact; margin-top: 4px; }
  .results.listings td.is-empty { display: none; }
  .listings .price-cell strong { font-size: 1.25rem; }
}

/* ── Searchable dropdowns on a phone: a full-screen sheet ───────────
   app.js adds .is-sheet under 760px and sizes it to the part of the
   screen the keyboard leaves free. */

.combo-head { display: none; }
.combo-list { position: relative; }
html.combo-lock, html.combo-lock body { overflow: hidden; }
@media (max-width: 759px) {
  .combo-panel.is-sheet {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0 0 env(safe-area-inset-bottom);
    background: var(--surface);
  }
  .combo-panel.is-sheet:focus { outline: none; }
  .combo-panel.is-sheet .combo-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 6px 8px;
    padding-top: max(6px, env(safe-area-inset-top));
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
  }
  .combo-title { flex: 1; font-weight: 700; font-size: 1.05rem; }
  .combo-close {
    width: 44px;
    height: 44px;
    min-height: 0;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    font-size: 1.9rem;
    line-height: 1;
  }
  .combo-panel.is-sheet .combo-search { width: auto; margin: 10px 12px 4px; }
  .combo-panel.is-sheet .combo-list { flex: 1; max-height: none; padding: 0 4px 16px; }
  .combo-panel.is-sheet .combo-option {
    padding: 13px 14px;
    font-size: 1.02rem;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
  }
  .combo-panel.is-sheet .combo-option[aria-selected="true"] { color: var(--accent); }
  .combo-panel.is-sheet .combo-option[aria-selected="true"]::after { content: "✓"; float: left; font-weight: 700; }
  .combo-panel.is-sheet .combo-group {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 12px 14px 6px;
    background: var(--surface);
  }
}

/* ── Results: the search form folds behind "تعديل البحث" ─────────
   Closed on phones, so the results come first; app.js opens it on wider
   screens. */

.refine-card { padding-top: 4px; padding-bottom: 4px; }
.refine > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}
.refine > summary::-webkit-details-marker { display: none; }
.refine > summary .search-icon { color: var(--accent); }
.refine > summary::after {
  content: "";
  margin-inline-start: auto;
  width: 9px;
  height: 9px;
  border: solid var(--muted);
  border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .15s;
}
.refine[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.refine[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.refine > .finder { padding-bottom: 12px; }

/* ── Results: shops on a phone ────────────────────────────────── */

@media (max-width: 759px) {
  .results.shops tr { display: grid; gap: 6px; padding: 12px 14px; }
  .results.shops td { padding: 0; }
  .results.shops td[data-label]::before {
    display: inline;
    content: attr(data-label) ": ";
    font-size: .85rem;
    font-weight: 600;
  }
  .results.shops td.shop::before,
  .results.shops td.place::before,
  .results.shops td:last-child::before { content: none; }
  .results.shops td:last-child { margin-top: 4px; }
}

/* ── Team screens on a phone ──────────────────────────────────── */

/* The shop list: each shop is one tappable row. */
.list-filter {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 48px;
  padding: 10px 14px;
  margin: 4px 0 8px;
}
.list-filter:focus { outline: none; border-color: var(--accent); }
.shop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.shop-list li + li { border-top: 1px solid var(--border); }
.shop-item { display: grid; gap: 2px; padding: 12px 14px; color: var(--text); text-decoration: none; }
.shop-item:active { background: var(--surface-2); }
@media (hover: hover) { .shop-item:hover { background: var(--surface-2); } }
.shop-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shop-item .shop-name { color: var(--link); }

/* "إضافة محل": always at hand at the bottom of a phone's screen. */
@media (max-width: 759px) {
  .fab {
    position: fixed;
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
    z-index: 30;
    min-height: 52px;
    font-size: 1.05rem;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .3);
  }
  main:has(.fab) + .site-footer { padding-bottom: 100px; }
}

/* Jump links under the shop's name; they stay on top while scrolling. */
.section-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 10px 0 12px;
  padding: 6px 0;
}
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .92rem;
  font-weight: 600;
  text-decoration: none;
}
.section-nav .count {
  min-width: 22px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}
@media (max-width: 759px) {
  .section-nav { position: sticky; top: 0; z-index: 20; background: var(--bg); margin-inline: -16px; padding-inline: 16px; }
}
section[id], .add-box[id] { scroll-margin-top: 64px; }

/* Sheet lines, prices and team members: one row each. */
.item-list { list-style: none; margin: 0 0 12px; padding: 0; }
.item-list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.item-list > li:first-child { padding-top: 4px; }
.item-list > li:last-child { border-bottom: 0; }
.item-main { flex: 1 1 160px; min-width: 0; display: grid; gap: 2px; }
.item-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; overflow-wrap: anywhere; }
.item-title > :not(.tally) { min-width: 0; }
.price-tag { color: var(--badge-text); font-weight: 700; white-space: nowrap; }
.item-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 12px; flex: 1 1 100%; }
.item-list .link-button { min-height: 36px; }
.role { display: inline-block; font-size: .78rem; font-weight: 700; padding: 1px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* A price's or a team member's "تعديل": the form opens below. */
.edit-price { flex: 1 1 auto; }
.edit-price > summary { list-style: none; display: inline-flex; align-items: center; cursor: pointer; }
.edit-price > summary::-webkit-details-marker { display: none; }
.edit-price[open] > summary { font-weight: 700; text-decoration: none; }
.price-edit { display: grid; grid-template-columns: minmax(0, 110px) minmax(0, 1fr) auto; align-items: end; gap: 8px; margin-top: 6px; }
.price-edit label { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
@media (max-width: 759px) {
  .price-edit { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
  .price-edit button { grid-column: 1 / -1; }
}
.team-edit { grid-template-columns: minmax(0, 1fr) minmax(0, 160px) auto; }
@media (max-width: 759px) { .team-edit { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* "+ إضافة سطر" / "+ إضافة سعر": the form opens under the button, which
   becomes its heading (the + turns into a × to fold it again). */
.add-box { margin-top: 8px; }
.add-box > summary { list-style: none; }
.add-box > summary::-webkit-details-marker { display: none; }
.add-box > summary .icon { transition: transform .15s; }
.add-box[open] > summary.btn {
  background: transparent;
  border-color: transparent;
  justify-content: flex-start;
  padding-inline: 0;
  font-weight: 700;
}
.add-box[open] > summary .icon { transform: rotate(45deg); }
.add-box > form { margin-top: 4px; }
@media (max-width: 759px) { .add-box > summary { width: 100%; } }

/* Categories and conditions of a sheet line: a grid of tappable tiles
   (two across on a phone; long names wrap inside the tile). */
.checks.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.checks.chips .check {
  min-height: 46px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: .9rem;
  line-height: 1.35;
}
.checks.chips .check input { width: 18px; height: 18px; }
.checks.chips .check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* A login link and its copy button. */
.copy-row { display: flex; gap: 8px; }
.copy-row .copy { flex: 1; min-width: 0; }
.link-box .btn-wa { justify-self: stretch; }
@media (min-width: 760px) { .link-box .btn-wa { justify-self: start; } }

/* "تم الحفظ ✓" as a short message at the bottom (manage.js). */
.flash.is-toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 60;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  margin: 0;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .3);
  transition: opacity .35s;
}
.flash.is-toast.is-leaving { opacity: 0; }
@media (max-width: 759px) {
  main:has(.fab) .flash.is-toast { bottom: max(84px, calc(env(safe-area-inset-bottom) + 76px)); }
}

/* الطلبات: the period switch and each row's count. */
.range-nav { position: static; }
.range-nav a.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tally { flex: none; color: var(--accent); font-weight: 700; white-space: nowrap; }

/* A shop's page: this month's numbers as tiles, two across on a phone. */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 4px 0 10px; }
.stat { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.stat strong { font-size: 1.5rem; line-height: 1.15; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat small { color: var(--muted); font-size: .78rem; }
@media (max-width: 759px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* A shop's numbers: daily bar charts (charts.dart). Days run right to left;
   the scale's top, middle and zero sit beside the plot. */
.s-call { fill: var(--s-call); background-color: var(--s-call); }
.s-whatsapp { fill: var(--s-whatsapp); background-color: var(--s-whatsapp); }
.s-map { fill: var(--s-map); background-color: var(--s-map); }
.s-seen { fill: var(--s-seen); background-color: var(--s-seen); }
.chart { margin: 0 0 20px; }
.chart figcaption { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 10px; }
.chart-title { font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: .85rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.chart-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; }
.chart-y { position: relative; height: 120px; min-width: 2.2em; color: var(--muted); font-size: .75rem; line-height: 1; font-variant-numeric: tabular-nums; }
.chart-y span { position: absolute; inset-inline-end: 0; transform: translateY(-50%); }
.chart-y span:nth-child(1) { top: 0; }
.chart-y span:nth-child(2) { top: 50%; }
.chart-y span:nth-child(3) { top: 100%; }
.chart-plot { position: relative; }
.chart-svg { display: block; width: 100%; height: 120px; overflow: visible; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--border); stroke-width: 1; }
.chart-svg .day:hover > :not(.hit), .chart-svg .day.is-on > :not(.hit) { opacity: .7; }
.chart-x { grid-column: 2; display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: .75rem; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 120px; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(16, 24, 40, .14); font-size: .85rem; white-space: nowrap; }
.chart-tip .tip-day { color: var(--muted); margin-bottom: 4px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip .tip-row i { width: 12px; height: 2px; border-radius: 1px; }
.chart-tip .tip-row strong { min-width: 1.5em; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.mini-table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.mini-table th, .mini-table td { padding: 7px 8px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
.mini-table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
/* The shops table on الأرقام: each header sorts by its column. */
.mini-table th a { color: inherit; text-decoration: none; }
.mini-table th a.is-sorted { color: var(--text); }
.mini-table.sortable td:first-child { white-space: normal; min-width: 9em; }

/* "المحلات الأقرب إليك أولاً": asks for the location, or says it's in use. */
.near { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.near-pin { display: inline-flex; color: var(--accent); }
.near-pin .icon { width: 26px; height: 26px; }
.near-text { flex: 1 1 220px; min-width: 0; }
.near-text p { margin: 2px 0 0; }
.near .btn { flex: 1 1 auto; }
@media (min-width: 760px) { .near .btn { flex: none; } }
.near-on { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--muted); font-size: .9rem; margin: 0 0 10px; }
.near-on .icon { width: 18px; height: 18px; color: var(--accent); }
.distance { display: inline-block; margin-inline-start: 6px; padding: 0 8px; border-radius: 99px; background: var(--badge-bg); color: var(--badge-text); font-size: .8rem; font-weight: 700; white-space: nowrap; vertical-align: middle; }
td.place .distance { margin: 0 0 2px; }

/* Numbered pages under each results table. On a phone the numbers get their
   own row, with السابق and التالي below. */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.pager-numbers { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.pager a, .pager span:not([aria-hidden]) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 40px; min-height: 44px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-weight: 600; text-decoration: none;
}
.pager .is-current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .is-disabled { opacity: .45; }
.pager .gap { display: inline-flex; align-items: center; min-width: 20px; justify-content: center; color: var(--muted); }
.pager-info { text-align: center; color: var(--muted); font-size: .85rem; margin: 0 0 8px; }
@media (min-width: 760px) {
  .pager { display: flex; justify-content: center; align-items: center; }
  .pager-prev { order: 0; }
  .pager-numbers { order: 1; }
  .pager-next { order: 2; }
}

/* Browse links under the results: a car's categories, a brand's models. */
.browse h2:not(:first-child) { margin-top: 16px; }

/* The shop form: «ماذا يبيع؟», the folded extras, and the two save buttons
   (the draft one first in the page, shown second). */
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 6px; }
fieldset.field > legend { font-weight: 600; padding: 0; margin-bottom: 2px; }
.group-label { margin: 6px 0 0; color: var(--muted); font-size: .85rem; font-weight: 600; }
details.more { border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; background: var(--surface-2); }
details.more > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--muted); }
details.more[open] { padding-bottom: 12px; }
details.more[open] > summary { color: var(--text); }
details.more > .stack, details.more > .checks { margin-top: 8px; }
.brand-list { max-height: 260px; overflow-y: auto; margin-top: 8px; }
.brand-list .check .muted { font-size: .8rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-actions button { flex: 1 1 200px; }
.form-actions .btn-secondary { order: 2; }

/* A shop's page: publishing, what's done (✓) and what's missing (✗). */
.checklist { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 4px; }
.checklist .done { color: var(--badge-text); }
.checklist .todo { color: var(--danger); }
.card.publish.is-live, .card.next-step { border-color: var(--badge-text); }
.card.intro p { margin: 0; }
button:disabled { opacity: .5; cursor: not-allowed; }
.card.next-step button { width: 100%; white-space: normal; }

/* A shop's own page (/shops/<id>). Shop names in the results link to it. */
a.shop-name { color: inherit; }
.shop-contact p { margin: 0 0 8px; }
.sells-group p { margin: 0 0 6px; }
.sells-group + .sells-group { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }

/* A shop's page, for admins: deleting the shop for good. */
.card.danger-zone { border-color: var(--danger); }
.danger-zone h2 { color: var(--danger); }
.btn-danger { background: var(--danger); color: #fff; font-weight: 700; }
:root[data-theme="dark"] .btn-danger { color: #2a0b0b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger { color: #2a0b0b; } }
