/* Al Watania Precast — site and plant system.
   Colours come from the dashboard: --brand and --bg are set on <html>. */

:root {
  --ink: #15181f;
  --muted: #6b7280;
  --line: #e5e7eb;
  --card: #ffffff;
  --page: #f5f6f8;
  --radius: 14px;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Tajawal, "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background: var(--page);
  line-height: 1.7;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 12px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-line; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
/* .num is also put on table cells to keep figures LTR inside an RTL page.
   Without this the inline-block above collapses the cell and the totals
   table stops short of the items table above it. */
td.num, th.num { display: table-cell; }
.center { text-align: center; }
.end { text-align: end; }
.nowrap { white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  /* Navy on the brand orange, not white. White is 2.83:1 and fails AA at
     this size, and the plant reads these buttons on a phone in the yard in
     full sun. Navy on the same orange is 5.98:1 - the brand does not
     change, only which of its two colours carries the label. */
  background: var(--brand); color: var(--bg); font-weight: 700;
  padding: 11px 20px; border: 0; border-radius: 10px; cursor: pointer;
  text-decoration: none; font-size: 15px; font-family: inherit;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn.dark { background: var(--bg); color: #fff; }
.btn.small { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.btn.full { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Public header ---------- */
.nav { background: var(--bg); color: #fff; position: sticky; top: 0; z-index: 30; }
.nav-inner { display: flex; align-items: center; gap: 20px; height: 72px; }
.brand { font-weight: 900; font-size: 20px; color: #fff; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand img { height: 40px; width: auto; display: block; }
.brand span { color: var(--brand); }
.nav-links { display: flex; gap: 22px; margin-inline-start: auto; font-size: 15px; }
.nav-links a { color: rgba(255,255,255,.82); text-decoration: none; }
.nav-links a:hover { color: var(--brand); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.lang { border: 1px solid var(--brand); color: var(--brand); border-radius: 8px;
  padding: 4px 12px; font-size: 13px; font-weight: 700; text-decoration: none; }

/* ---------- Hero ---------- */
.hero { background: var(--bg); background-size: cover; background-position: center; color: #fff; padding: 96px 0; }
.hero-inner { max-width: 780px; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); font-weight: 900; }
.hero h1 em { color: var(--brand); font-style: normal; }
.hero p { font-size: 18px; color: rgba(255,255,255,.85); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.strip { background: var(--brand); color: var(--bg); }
.strip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 18px; padding: 22px 0; }
.strip strong { display: block; font-size: 19px; }
.strip span { font-size: 14px; color: rgba(255,255,255,.9); }

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
.section.alt { background: #fff; }
.section h2 { font-size: 27px; font-weight: 900; margin-bottom: 6px; }
.section .lead { color: var(--muted); margin: 0 0 26px; max-width: 70ch; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card .body { padding: 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { font-size: 17px; margin: 0; }
.card .thumb { aspect-ratio: 4/3; object-fit: cover; background: #eceef2; width: 100%; }
.card .thumb.ph { display: grid; place-items: center; color: #aeb4bf; font-size: 13px; }
.spec { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-top: auto; }
.spec div { display: flex; justify-content: space-between; gap: 10px; border-top: 1px dashed var(--line); padding-top: 4px; }
.tagline { display: inline-block; background: #fff2e6; color: #9a4a06; font-size: 12px;
  font-weight: 700; padding: 3px 10px; border-radius: 999px; }

.about-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 44px; align-items: start; }
.points { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.points li { background: var(--page); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; }
.section.alt .points li { background: var(--page); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.gallery figure { margin: 0; border-radius: 12px; overflow: hidden; background: #fff; border: 1px solid var(--line); }
.gallery img { aspect-ratio: 4/3; object-fit: cover; width: 100%; }
.gallery figcaption { padding: 10px 14px; font-size: 14px; color: var(--muted); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
/* The bot honeypot. NOT left:-9999px: on an RTL page that pushes the input
   far outside the document and the page gains ten thousand pixels of
   horizontal scroll - the whole site then sits in a narrow strip on one
   side. This is the standard visually-hidden recipe, which hides the field
   without moving it anywhere. */
.hp { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---------- Footer ---------- */
.site-footer { background: var(--bg); color: rgba(255,255,255,.75); padding: 54px 0 0; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 30px; }
.footer-brand { color: var(--brand); font-weight: 900; font-size: 18px; margin-bottom: 8px; }
.footer-brand img { display: block; height: 42px; width: auto; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--brand); }
.footer-social { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.credit { margin-top: 40px; padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.12);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; font-size: 13px; color: rgba(255,255,255,.55); }
.credit .dev a { color: var(--brand); font-weight: 700; }

.wa { position: fixed; inset-inline-end: 18px; bottom: 18px; width: 52px; height: 52px;
  border-radius: 50%; background: #25d366; color: #fff; display: grid; place-items: center;
  font-size: 24px; text-decoration: none; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 40; }

/* ---------- Flash ---------- */
.flashes { position: fixed; top: 16px; inset-inline: 0; display: grid; justify-items: center; gap: 8px; z-index: 60; }
.flash { background: #111827; color: #fff; padding: 10px 20px; border-radius: 999px; font-size: 14px; max-width: 90vw; }
.flash.ok { background: var(--ok); }
.flash.error { background: var(--bad); }

/* ---------- Dashboard shell ---------- */
body.admin { background: var(--page); }
.admin-shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--bg); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 18px; }
.side-brand { color: var(--brand); font-weight: 900; font-size: 17px; line-height: 1.4; }
.side-brand img { display: block; width: 100%; max-width: 186px; height: auto; }
.side-brand small { display: block; color: rgba(255,255,255,.5); font-weight: 400; font-size: 12px; }
.side nav { display: grid; gap: 2px; }
.side nav a { color: rgba(255,255,255,.78); text-decoration: none; padding: 9px 12px; border-radius: 9px; font-size: 14.5px; }
.side nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side nav a.on { background: var(--brand); color: var(--bg); font-weight: 700; }
.side nav .sep { margin-top: 12px; padding: 4px 12px; font-size: 11px; color: rgba(255,255,255,.4); letter-spacing: .04em; }
.side-foot { margin-top: auto; display: grid; gap: 6px; font-size: 13.5px; }
.side-foot a { color: rgba(255,255,255,.7); text-decoration: none; }
.side-foot .muted { color: rgba(255,255,255,.45); }
.side-foot .muted a { color: var(--brand); }
.main { padding: 28px 32px 60px; min-width: 0; }
.main h1 { font-size: 23px; font-weight: 900; margin-bottom: 4px; }
.main .sub { color: var(--muted); margin: 0 0 22px; }
.main h2 { font-size: 17px; margin: 26px 0 12px; }
.head-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.head-row h1 { margin: 0; }
.head-row .spacer { margin-inline-start: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 2px; }
.kpi span { color: var(--muted); font-size: 13.5px; }
.kpi strong { font-size: 25px; font-variant-numeric: tabular-nums; }
.kpi.accent { border-color: var(--brand); box-shadow: inset 0 -3px 0 var(--brand); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.panel > h2:first-child { margin-top: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px,1fr)); gap: 13px; margin-bottom: 14px; }
.fields .full { grid-column: 1 / -1; }
.form.narrow { max-width: 430px; }
.image-field { display: flex; align-items: center; gap: 10px; }
.image-field { display: flex; align-items: center; gap: 10px; min-width: 0; }
.image-field img { height: 34px; width: auto; max-width: 140px; object-fit: contain;
  border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 3px; flex: none; }
/* A white-on-transparent logo needs a dark swatch behind it or the preview
   shows an empty box. */
.image-field.on-dark img { background: var(--bg); border-color: var(--bg); }
.image-field input[type=file] { flex: 1 1 auto; min-width: 0; font-size: 12.5px; }
input[type=color] { height: 42px; padding: 3px; cursor: pointer; }

.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table th, .table td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.table th { background: #fafafa; color: var(--muted); font-weight: 500; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tfoot td { background: #fafafa; font-weight: 700; }
.table .note { max-width: 260px; color: var(--muted); }
.table-scroll { overflow-x: auto; }
.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline { display: inline; }
.link { background: none; border: 0; color: var(--ink); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }
.link.danger { color: var(--bad); }

.tag { padding: 3px 10px; border-radius: 999px; font-size: 12px; background: #eef2ff; color: #3730a3; white-space: nowrap; }
.tag.green, .tag.won, .tag.ready, .tag.paid, .tag.delivered { background: #dcfce7; color: #166534; }
.tag.amber, .tag.sent, .tag.curing, .tag.open, .tag.part_paid, .tag.dispatched { background: #fef3c7; color: #92400e; }
.tag.red, .tag.lost, .tag.expired, .tag.rejected, .tag.cancelled, .tag.busy { background: #fee2e2; color: #991b1b; }
.tag.grey, .tag.draft, .tag.planned, .tag.on_hold { background: #f1f3f6; color: #475569; }
.tag.blue, .tag.cast, .tag.invoiced, .tag.issued, .tag.done { background: #e0f2fe; color: #075985; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; text-decoration: none; font-size: 14px; }
.chip.on { background: var(--bg); color: #fff; border-color: var(--bg); }

/* ---------- Alerts ---------- */
.alerts { display: grid; gap: 8px; margin-bottom: 20px; }
.alert { display: flex; gap: 10px; align-items: center; padding: 11px 15px; border-radius: 11px;
  font-size: 14px; border: 1px solid; text-decoration: none; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.warn  { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert.ok    { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert b { margin-inline-start: auto; font-weight: 700; white-space: nowrap; }

/* ---------- Progress ---------- */
.bar { height: 8px; border-radius: 999px; background: #eceef2; overflow: hidden; min-width: 90px; }
.bar i { display: block; height: 100%; background: var(--brand); }
.bar.full i { background: var(--ok); }
.prog { display: flex; align-items: center; gap: 10px; }
.prog .num { font-size: 13px; color: var(--muted); min-width: 36px; }
.out { font-weight: 700; color: var(--bad); }
.out.zero { color: var(--ok); font-weight: 400; }

/* ---------- Production board ---------- */
.board { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #eef0f4; border-radius: 12px; padding: 10px; min-height: 120px; }
.col > h3 { font-size: 13px; color: var(--muted); margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.cast { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px; margin-bottom: 9px; font-size: 13.5px; }
.cast b { display: block; font-size: 14px; }
.cast .meta { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.cast form { display: inline; }
.timer { font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.due { color: var(--ok); }
.timer.wait { color: var(--warn); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login { background: #fff; border-radius: 18px; padding: 32px; width: min(390px,100%); display: grid; gap: 14px; }
.login-brand { color: var(--brand); font-weight: 900; font-size: 22px; }
.login-brand img { display: block; height: 52px; width: auto; margin: 0 auto 2px; }

@media (max-width: 980px) {
  .about-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .admin-shell { grid-template-columns: 1fr; min-width: 0; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; min-width: 0; }
  /* min-width: 0 is load-bearing. The nav scrolls inside itself only if it
     is allowed to be narrower than its own content; without it the whole
     admin shell was 2117px wide on a 390px phone. */
  .side nav { grid-auto-flow: column; overflow-x: auto; min-width: 0; }
  .side-foot { margin: 0; grid-auto-flow: column; gap: 14px; min-width: 0; }
  .main { padding: 18px 14px 50px; }
}

/* ---------- Printed documents ---------- */
.doc { background: #fff; max-width: 820px; margin: 18px auto; padding: 34px 38px; color: #111;
  box-shadow: 0 1px 10px rgba(0,0,0,.08); font-size: 13.5px; }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-bottom: 3px solid var(--brand); padding-bottom: 12px; margin-bottom: 4px; }
.doc-head .en { font-weight: 900; font-size: 17px; color: var(--bg); line-height: 1.25; }
.doc-head .en small { display: block; font-size: 11px; font-weight: 500; letter-spacing: .06em; color: var(--muted); }
.doc-head .ar { font-weight: 900; font-size: 19px; color: var(--bg); }
.doc-head img { height: 50px; width: auto; }
.doc-head .ar small { display: block; font-size: 10.5px; font-weight: 500; letter-spacing: .04em; color: var(--muted); }
.doc h1 { text-align: center; font-size: 19px; margin: 18px 0; text-decoration: underline; }
.doc .meta { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.doc .meta td { border: 1px solid #999; padding: 5px 9px; }
.doc .meta td:first-child { background: #f3f4f6; font-weight: 700; width: 170px; }
.doc .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 16px 0; }
.doc .parties h4 { background: #dbeafe; margin: 0 0 6px; padding: 3px 8px; font-size: 13px; }
.doc .parties p { margin: 0; line-height: 1.6; }
.doc table.items { width: 100%; border-collapse: collapse; margin-top: 10px; }
.doc table.items th, .doc table.items td { border: 1px solid #999; padding: 5px 8px; }
.doc table.items th { background: #f3f4f6; }
.doc table.items td.n { text-align: end; font-variant-numeric: tabular-nums; direction: ltr; }
.doc .sums td { border: 1px solid #999; padding: 5px 9px; }
.doc .sums td:first-child { text-align: end; font-weight: 700; background: #fafafa; }
.doc .sums tr.grand td { background: #fff3e8; font-weight: 900; }
.doc .terms { margin-top: 20px; }
.doc .terms h3 { font-size: 14px; margin: 14px 0 4px; }
.doc .terms p { margin: 0; white-space: pre-line; line-height: 1.7; }
.doc .signs { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; margin-top: 40px; font-size: 12.5px; }
.doc .signs div { border-top: 1px solid #999; padding-top: 6px; }
.doc .foot { margin-top: 26px; border-top: 2px solid var(--brand); padding-top: 8px;
  text-align: center; font-size: 11px; color: #555; line-height: 1.6; }
.doc-bar { max-width: 820px; margin: 14px auto 0; display: flex; gap: 10px; }

@media print {
  .doc-bar, .flashes, .wa { display: none !important; }
  .doc-head img { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body { background: #fff; }
  .doc { box-shadow: none; margin: 0; max-width: none; padding: 0; }
  @page { margin: 14mm; }
}

@media (max-width: 980px) {
  .side-brand { display: flex; align-items: center; gap: 10px; }
  .side-brand img { max-width: 150px; }
  .side-brand small { display: inline; }
}

/* The notices badge in the sidebar. */
.side nav .bell { display: inline-block; min-width: 20px; padding: 0 6px; margin-inline-start: 6px;
  border-radius: 10px; background: var(--brand); color: var(--bg); font-size: 12px;
  font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.side nav a.on .bell { background: var(--bg); color: #fff; }
