/*
 * الصفحات العامة (الماسح، تسجيل المالك، حسابه). نفس هوية الصفحة الرئيسية:
 * ورق أبيض، حبر شبه أسود، حدود شعرية، والأصفر لون الستيكر نفسه.
 * الموبايل أول: معظم الزوار جايين من سكان.
 */

@font-face { font-family: "Geist"; src: url(/static/fonts/geist.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url(/static/fonts/geist-mono.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url(/static/fonts/plex-arabic-400.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url(/static/fonts/plex-arabic-500.woff2) format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url(/static/fonts/plex-arabic-600.woff2) format("woff2"); font-weight: 600 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC; }

:root {
  --paper: #fafafa;
  --white: #ffffff;
  --hairline: #ebebeb;
  --ash: #c9c9c9;
  --stone: #666666;
  --ink: #171717;
  --sticker: #ffc400;
  --green: #297a3a;
  --green-soft: #eaf5ec;
  --red: #c4312b;
  --red-soft: #fcecea;
  --amber-soft: #fff6d9;
  --font: "Geist", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", "IBM Plex Sans Arabic", ui-monospace, monospace;
  --radius: 6px;
  --ring: 0 0 0 1px rgba(0, 0, 0, .08);
  --focus: 0 0 0 2px var(--white), 0 0 0 4px var(--ink);
}

* { box-sizing: border-box; }

body.public {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius); }

.p-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 36rem;
  margin: 0 auto;
  padding: 1rem 1rem 0;
}

.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 600; font-size: 1.05rem; text-decoration: none; }
.brand svg { width: 1.8rem; height: .8rem; }
.p-head nav { display: flex; gap: 1rem; font-size: .9rem; color: var(--stone); }

.p-main {
  max-width: 36rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.p-main h1 { margin: 0; font-size: 1.6rem; font-weight: 600; line-height: 1.35; }
.p-lede { margin: 0; color: var(--stone); }

.p-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--ring);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.p-card h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.p-card > p { margin: 0; color: var(--stone); font-size: .92rem; }

/* الستيكر نفسه: مربّع أصفر صغير فيه الرمز. هو العنصر اللي بيربط الصفحة بالشي اللي بإيد الزائر. */
.sticker {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  align-self: flex-start;
  padding: .45rem .8rem .45rem .6rem;
  background: var(--sticker);
  color: var(--ink);
  border-radius: var(--radius);
  font: 600 .95rem/1 var(--mono);
  letter-spacing: .04em;
  direction: ltr;
}

.sticker svg { width: 1.5rem; height: .7rem; }

/* بطاقة السيارة للماسح: الماركة واللون وآخر رقمين من اللوحة بس */
.car-id {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .25rem 1rem;
}

.car-id strong { font-size: 1.25rem; font-weight: 600; }
.car-id span { color: var(--stone); }

.plate-tail {
  grid-row: span 2;
  min-width: 4.5rem;
  padding: .5rem .75rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  text-align: center;
  font: 700 1.3rem/1 var(--font);
}

.plate-tail small { display: block; font-size: .65rem; font-weight: 500; color: var(--stone); margin-bottom: .2rem; }

/* الفورمات */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span { font-size: .92rem; font-weight: 500; }
.field small { color: var(--stone); font-size: .82rem; }
/* بس حقول الكتابة: الـ radio و checkbox جوّا الحقل (متل ألوان السيارة) إلهم ستايلهم. */
.field input:not([type="radio"]):not([type="checkbox"]), .field select, .field textarea {
  font: inherit;
  font-size: 1rem;
  height: 3rem;
  padding: 0 .85rem;
  border: 0;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--ash);
  background: var(--white);
  color: var(--ink);
  width: 100%;
}

.field textarea { height: auto; min-height: 6rem; padding: .7rem .85rem; resize: vertical; }
.field input:not([type="radio"]):not([type="checkbox"]):focus, .field select:focus, .field textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ink); }
.field.has-error input, .field.has-error select, .field.has-error textarea { box-shadow: inset 0 0 0 2px var(--red); }
.field-error { color: var(--red); font-size: .85rem; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }

.check { display: flex; gap: .7rem; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; accent-color: var(--ink); flex: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  height: 3rem;
  padding: 0 1.25rem;
  border: 0;
  border-radius: var(--radius);
  font: 500 1rem/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  background: var(--ink);
  color: var(--white);
}

.btn:hover { background: #383838; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: var(--ring); }
.btn-ghost:hover { background: var(--white); }

/* الرسائل الجاهزة: أزرار اختيار كبيرة سهلة باللمس */
.choices { display: flex; flex-direction: column; gap: .5rem; }

.choice {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--ash);
  background: var(--white);
  cursor: pointer;
}

.choice input { width: 1.15rem; height: 1.15rem; accent-color: var(--ink); flex: none; }
.choice:has(input:checked) { box-shadow: inset 0 0 0 2px var(--ink); }

.notice { margin: 0; padding: .85rem 1rem; border-radius: var(--radius); font-size: .95rem; }
.notice.ok { background: var(--green-soft); }
.notice.bad { background: var(--red-soft); }
.notice.warn { background: var(--amber-soft); }

/* نتيجة كبيرة: انبعت / انرفض */
.result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .75rem; padding: 2rem 1rem; }
.result-mark {
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  font-size: 1.75rem;
  font-weight: 700;
  background: var(--green-soft);
  color: var(--green);
}

.result-mark.bad { background: var(--red-soft); color: var(--red); }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; margin: 0; }
.facts div { display: flex; flex-direction: column; }
.facts dt { font-size: .8rem; color: var(--stone); }
.facts dd { margin: 0; font-weight: 500; }

.muted { color: var(--stone); }
.small { font-size: .85rem; }

.p-foot {
  max-width: 36rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  display: flex;
  gap: 1rem;
  font-size: .82rem;
  color: var(--stone);
}

.prose { line-height: 1.8; }
.prose h2 { font-size: 1.1rem; margin: 1.75rem 0 .5rem; }
.prose p, .prose li { color: #333; }

@media (prefers-reduced-motion: no-preference) {
  .result-mark { animation: pop .35s cubic-bezier(.2, .9, .3, 1.3); }
  @keyframes pop { from { transform: scale(.6); opacity: 0; } }
}

/* الدفتر */
.book-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.book-head .btn { flex: none; height: 2.5rem; font-size: .9rem; }

.odo { flex-direction: row; align-items: flex-end; gap: .75rem; }
.odo-input { position: relative; }
.field .odo-input input { font: 600 1.35rem/1 var(--mono); letter-spacing: .02em; padding-inline-end: 3rem; }
.odo-input em { position: absolute; inset-block: 0; inset-inline-end: .85rem; display: grid; place-items: center; font-style: normal; color: var(--stone); font-size: .9rem; }

/* الملخص: شبكة أرقام بخط mono، هي اللي بتخلّي الدفتر يحكي بدل ما يكون قائمة بس */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 1px; margin: 0; background: var(--hairline); border-radius: var(--radius); overflow: hidden; box-shadow: var(--ring); }
.stats > div { background: var(--white); padding: .85rem 1rem; display: flex; flex-direction: column; gap: .1rem; }
.stats dt { font-size: .78rem; color: var(--stone); }
.stats dd { margin: 0; font: 600 1.2rem/1.3 var(--mono); }
.stats small { font-size: .75rem; color: var(--stone); }

.due { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.due li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem .85rem; border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--hairline); border-inline-start: 4px solid var(--ash); }
.due li > div { display: flex; flex-direction: column; }
.due-left { font-size: .85rem; font-weight: 500; text-align: end; }
.due-late { border-inline-start-color: var(--red) !important; background: var(--red-soft); }
.due-late .due-left { color: var(--red); }
.due-soon { border-inline-start-color: var(--sticker) !important; background: var(--amber-soft); }
.due-ok { border-inline-start-color: var(--green) !important; }

details.add > summary { list-style: none; }
details.p-card > summary::-webkit-details-marker { display: none; }
details[open] > summary { background: var(--white); color: var(--ink); box-shadow: var(--ring); }

/* حقول حسب النوع: بتطلع بس لما النوع إله هالحقل */
.if-parts, .if-due, .if-fuel { display: none; }
form:has(select[name="kind"] option[data-parts]:checked) .if-parts,
form:has(select[name="kind"] option[data-due]:checked) .if-due,
form:has(select[name="kind"] option[data-fuel]:checked) .if-fuel { display: flex; }

.parts { display: flex; flex-wrap: wrap; gap: .4rem; }
.part { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .7rem; border-radius: 9999px; box-shadow: inset 0 0 0 1px var(--ash); background: var(--white); font-size: .88rem; cursor: pointer; user-select: none; }
.part input { position: absolute; opacity: 0; pointer-events: none; }
.part:has(input:checked) { background: var(--ink); color: var(--white); box-shadow: none; }
.part:has(input:focus-visible) { box-shadow: var(--focus); }

.spend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.spend li { display: grid; grid-template-columns: 6.5rem 1fr auto; align-items: center; gap: .75rem; font-size: .88rem; }
.spend i { height: .5rem; border-radius: 9999px; background: linear-gradient(to left, var(--ink) var(--w), var(--hairline) var(--w)); }
.spend b { font: 500 .85rem var(--mono); }

.filters { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; }
.filters a {
  flex: none;
  padding: .35rem .8rem;
  border-radius: 9999px;
  box-shadow: var(--ring);
  background: var(--white);
  text-decoration: none;
  font-size: .88rem;
}
.filters a[aria-current="true"] { background: var(--ink); color: var(--white); box-shadow: none; }

/* الخط الزمني: سنة سنة، وكل سجل نقطة على خط */
.year > header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }
.year h2 { margin: 0; font: 600 1rem var(--mono); }
.timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--hairline); margin-inline-start: .4rem; }
.tl { position: relative; margin: 0 0 .75rem; padding: 1rem 1.1rem; margin-inline-start: 1.1rem; background: var(--white); border-radius: var(--radius); box-shadow: var(--ring); display: flex; flex-direction: column; gap: .5rem; }
.tl::before { content: ""; position: absolute; inset-inline-start: -1.6rem; top: 1.25rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--white); box-shadow: 0 0 0 2px var(--ash); }
.k-oil::before, .k-service::before { background: var(--sticker); box-shadow: 0 0 0 2px var(--ink); }
.k-repair::before, .k-brakes::before, .k-tires::before, .k-battery::before { background: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.k-fuel::before { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.tl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.tl-facts { display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; margin: 0; }
.tl-facts div { display: flex; gap: .35rem; align-items: baseline; }
.tl-facts dt { font-size: .78rem; color: var(--stone); }
.tl-facts dd { margin: 0; font: 500 .92rem var(--mono); }
.tl-facts dd.txt { font-family: var(--font); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.chips li { padding: .15rem .55rem; border-radius: 9999px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--hairline); font-size: .8rem; }
.tl-note { margin: 0; white-space: pre-line; color: #333; font-size: .95rem; }
.tl-edit { align-self: flex-start; color: var(--stone); }
.empty h2 { font-size: 1.1rem; }

/* تقرير الصيانة */
.report { max-width: 52rem; }
.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; padding-bottom: 1rem; border-bottom: 2px solid var(--ink); }
.report-page .p-head { max-width: 52rem; }
.eyebrow { margin: 0; font-size: .8rem; font-weight: 600; color: var(--stone); }
.report-facts { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.table-wrap { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--white); }
.report-table th, .report-table td { padding: .55rem .6rem; text-align: start; vertical-align: top; border-bottom: 1px solid var(--hairline); }
.report-table thead th { font-size: .78rem; color: var(--stone); font-weight: 500; border-bottom: 1px solid var(--ink); }
.report-year th, .report-year td { background: var(--paper); font: 600 .85rem var(--mono); }
.nowrap { white-space: nowrap; }
.report-foot { border-top: 1px solid var(--hairline); padding-top: .75rem; }

@media print {
  @page { size: A4; margin: 14mm; }
  body.public { background: #fff; font-size: 11pt; }
  .p-head, .p-foot, .no-print { display: none !important; }
  .p-main { padding: 0; max-width: none; }
  .report-table tr { break-inside: avoid; }
}

/* فورم التسجيل: مفتاح البلد، عين كلمة السر، الماركة التانية، ودوائر الألوان */
.field > label, .field > legend { font-size: .92rem; font-weight: 500; padding: 0; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }

.phone-row { display: grid; grid-template-columns: minmax(0, 9.5rem) 1fr; gap: .5rem; }
.phone-row select { padding: 0 .6rem; }

.pw { position: relative; }
.pw input { padding-inline-end: 3rem; }
.pw-toggle {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: 3rem;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--stone);
  cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); }
.pw-toggle svg { width: 1.25rem; height: 1.25rem; }
.pw-toggle .eye-off, .pw-toggle[aria-pressed="true"] .eye-on { display: none; }
.pw-toggle[aria-pressed="true"] .eye-off { display: block; }

/* الحقل بيطلع بس لما يختار "ماركة تانية…"، من غير JS */
.make-other { display: none; }
form:has(select[name="make"] option[value="__other"]:checked) .make-other { display: flex; }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: .5rem; }
.swatch {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .65rem;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--ash);
  background: var(--white);
  font-size: .9rem;
  cursor: pointer;
}
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch i {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18);
}
.swatch:has(input:checked) { box-shadow: inset 0 0 0 2px var(--ink); font-weight: 500; }
.swatch:has(input:focus-visible) { box-shadow: var(--focus); }
.field.has-error .swatch { box-shadow: inset 0 0 0 1px var(--red); }
