/* Surveying Systems - calibration certificate system
   Arabic-first, RTL. Palette sampled from the client SSC logo. */

@font-face {
  font-family: 'Cairo';
  src: url('/static/fonts/cairo-arabic.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E;
}
@font-face {
  font-family: 'Cairo';
  src: url('/static/fonts/cairo-latin.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+2212;
}

:root {
  --ink: #0b2641;
  --ink-soft: #4a5b6c;
  --muted: #83919e;
  --line: #e3e9ef;
  --line-strong: #cbd5e0;
  --bg: #f4f6f9;
  --card: #ffffff;

  /* Brand colours read off the SSC logo: navy + gold.
     Gold NEVER carries white text (1.9:1). White goes on navy (15.4:1),
     and navy text on gold is 8.1:1. */
  --brand: #f2b10a;
  --brand-dark: #d89a00;
  --navy: #0b2641;
  --navy-dark: #061a2e;
  --blue: #0b6fa8;
  --blue-dark: #08557f;

  --ok: #0f7a52;
  --ok-bg: #e6f6ee;
  --bad: #bf2f26;
  --bad-bg: #fdeceb;
  --warn: #a86a00;
  --warn-bg: #fff5e2;
  --gone: #5b6b7b;
  --gone-bg: #eef1f4;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 34, 49, .06), 0 8px 24px rgba(15, 34, 49, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Cairo', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.8;
}

body[dir="ltr"] { line-height: 1.65; }

a { color: var(--blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 2.1; margin: 0 0 .4rem; font-weight: 700; }
body[dir="ltr"] h1, body[dir="ltr"] h2, body[dir="ltr"] h3 { line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

/* ------------------------------------------------------------- app shell */

.app { display: flex; min-height: 100vh; }

.side {
  width: 246px;
  flex: 0 0 246px;
  background: var(--ink);
  color: #dfe7ee;
  padding: 18px 14px 28px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.side .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  margin-bottom: 14px;
}
.side .brand img { width: 58px; height: auto; background: #fff; border-radius: 8px; padding: 5px; }
.side .brand b { display: block; font-size: .95rem; color: #fff; line-height: 1.5; }
.side .brand span { font-size: .72rem; color: #93a6b6; }
/* The brand block is a link home, so it must not pick up the global a:hover underline. */
.side .brand:hover { text-decoration: none; }

.side nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; margin-bottom: 2px;
  color: #c6d3de; border-radius: 8px; font-size: .92rem;
}
.side nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.side nav a.on { background: var(--brand); color: var(--navy); font-weight: 700; }
.side nav .sep {
  margin: 14px 11px 6px; font-size: .68rem; letter-spacing: .04em;
  text-transform: uppercase; color: #6f8496;
}
.side nav a .ic { width: 18px; text-align: center; opacity: .9; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 11px 22px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .who { margin-inline-start: auto; font-size: .85rem; color: var(--ink-soft); }
.topbar .who b { color: var(--ink); }

.content { padding: 22px; flex: 1; }
.content > .page-head {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.content > .page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.page-head p.sub { margin: 0; color: var(--muted); font-size: .88rem; }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card .card-head {
  display: flex; align-items: center; gap: 10px; margin: -18px -18px 16px;
  padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fafbfc;
  border-radius: var(--radius) var(--radius) 0 0;
}
.card .card-head h2, .card .card-head h3 { margin: 0; }
.card .card-head .actions { margin-inline-start: auto; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .n { font-size: 1.9rem; font-weight: 700; line-height: 1.3; }
.stat .l { color: var(--muted); font-size: .82rem; }
.stat.ok .n { color: var(--ok); }
.stat.bad .n { color: var(--bad); }
.stat.warn .n { color: var(--warn); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td {
  padding: 9px 11px; text-align: start; border-bottom: 1px solid var(--line);
  vertical-align: middle; white-space: nowrap;
}
table.data th {
  background: #f8fafb; color: var(--ink-soft); font-weight: 600; font-size: .8rem;
  position: sticky; top: 0;
}
table.data tbody tr:hover { background: #fbfcfd; }
table.data td.wrap { white-space: normal; min-width: 180px; }
table.data .num { font-variant-numeric: tabular-nums; }
.mono {
  font-family: 'Cairo', ui-monospace, monospace;
  letter-spacing: .02em; font-variant-numeric: tabular-nums;
  direction: ltr; unicode-bidi: isolate; display: inline-block;
}
/* inline-block is there so a Latin serial number keeps its own direction
   inside Arabic text. On a <td> it takes the cell out of the table layout
   entirely: the column stops lining up and the row's bottom rule is drawn only
   as wide as the text. A cell keeps being a cell. */
td.mono, th.mono { display: table-cell; }

.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty .big { font-size: 2rem; opacity: .35; display: block; margin-bottom: 6px; }

/* ---------------------------------------------------------------- chips */

.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; line-height: 1.9; white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.gone { background: var(--gone-bg); color: var(--gone); }
.chip.plain { background: #eef2f6; color: var(--ink-soft); }

/* ----------------------------------------------------------------- forms */

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: 5px; color: var(--ink-soft); }
.field .hint { font-size: .76rem; color: var(--muted); margin-top: 4px; }
.field.req > label::after { content: ' *'; color: var(--bad); }

input[type=text], input[type=password], input[type=date], input[type=email],
input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: .92rem;
  color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 8px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(24, 144, 215, .15);
}
input[readonly], input:disabled, select:disabled, textarea[readonly] {
  background: #f2f5f7; color: var(--ink-soft); cursor: default;
}
textarea { min-height: 92px; resize: vertical; line-height: 1.9; }

.row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: .89rem; font-weight: 600; cursor: pointer;
  background: #fff; color: var(--ink); border-color: var(--line-strong);
}
.btn:hover { text-decoration: none; background: #f6f8fa; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); }
.btn.gold { background: var(--brand); color: var(--navy); border-color: var(--brand); }
.btn.gold:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.blue { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.blue:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn.ghost { background: transparent; border-color: var(--line-strong); }
.btn.danger { color: var(--bad); border-color: #f0c4c1; background: #fff; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { padding: 5px 11px; font-size: .8rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { margin-bottom: 0; }
.toolbar .grow { flex: 1; min-width: 180px; }

.flash {
  padding: 11px 15px; border-radius: 8px; margin-bottom: 16px;
  border: 1px solid; font-size: .9rem;
}
.flash.ok { background: var(--ok-bg); border-color: #b7e2cd; color: #0b5c3e; }
.flash.warn { background: var(--warn-bg); border-color: #f0d9a8; color: #7d4f00; }
.flash.err { background: var(--bad-bg); border-color: #f2c3bf; color: #932019; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: .9rem; }
.kv dt { color: var(--muted); font-size: .82rem; }
.kv dd { margin: 0; font-weight: 600; }

.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager span {
  padding: 5px 11px; border: 1px solid var(--line-strong); border-radius: 7px;
  font-size: .84rem; background: #fff;
}
.pager span.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager span.dots { border: 0; background: none; }

/* ------------------------------------------------- searchable combobox */
/* Sits in front of a real <select> (see public/js/combobox.js): gives the
   customer and model lists type-to-search, and sidesteps the blank-panel
   rendering Firefox gave the native model dropdown. */

.cbx { position: relative; }
.cbx .cbx-native { display: none; }

.cbx .cbx-input {
  width: 100%; padding: 9px 32px 9px 11px; font: inherit; font-size: .92rem;
  color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 8px;
}
body[dir="rtl"] .cbx .cbx-input { padding: 9px 11px 9px 32px; }
.cbx .cbx-input::placeholder { color: var(--muted); }
.cbx.has-value .cbx-input::placeholder { color: var(--ink); }

.cbx .cbx-caret {
  position: absolute; inset-inline-end: 11px; top: 9px;
  color: var(--muted); font-size: .9rem; line-height: 1.4; pointer-events: auto; cursor: pointer;
}

.cbx-list {
  position: absolute; z-index: 60; inset-inline-start: 0; inset-inline-end: 0; top: calc(100% + 4px);
  max-height: 288px; overflow-y: auto; background: #fff;
  border: 1px solid var(--line-strong); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 34, 49, .14);
}
.cbx-opt { padding: 7px 12px; font-size: .9rem; cursor: pointer; line-height: 1.5; }
.cbx-opt.on { background: #eef4fa; }
.cbx-opt.sel { font-weight: 700; }
.cbx-group {
  padding: 8px 12px 3px; font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
.cbx-none { padding: 12px; font-size: .86rem; color: var(--muted); text-align: center; }

/* The search box is a real text input, so a browser's own autofill must not
   treat it as an address or a name field. */
.cbx .cbx-input { text-overflow: ellipsis; }

/* A filter bar that applies itself does not need its button taking up room,
   but it stays in the DOM: it is the no-JS path and the Enter-key target. The
   class is added by app.js, so with JS off the button is still visible. */
form.autosubmit-on .autosubmit-hides { display: none; }

/* ------------------------------------------------------- public: verify */

.pub { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.pub-head {
  background: var(--ink); color: #fff; padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
}
.pub-head img { width: 62px; background: #fff; border-radius: 8px; padding: 5px; }
.pub-head b { display: block; font-size: 1rem; }
.pub-head span { font-size: .76rem; color: #9db0c0; }
.pub-head .home { display: flex; align-items: center; gap: 12px; color: inherit; }
.pub-head .home:hover { text-decoration: none; }
.pub-head .lang { margin-inline-start: auto; }
.pub-head .lang a {
  color: #cfdae4; border: 1px solid rgba(255, 255, 255, .25);
  padding: 3px 12px; border-radius: 999px; font-size: .8rem;
}
.pub-head .lang a:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }

.pub-body { flex: 1; padding: 26px 18px 40px; }
.pub-wrap { max-width: 860px; margin: 0 auto; }

.searchbox { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); }
.searchbox h1 { font-size: 1.35rem; margin-bottom: 4px; }
.searchbox p.lead { color: var(--muted); margin: 0 0 18px; font-size: .92rem; }

.modes { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.modes label {
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 16px;
  font-size: .85rem; cursor: pointer; background: #fff; user-select: none;
}
.modes input { position: absolute; opacity: 0; pointer-events: none; }
.modes input:checked + span { color: #fff; }
.modes label:has(input:checked) { background: var(--ink); border-color: var(--ink); color: #fff; }

.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; font-size: 1rem; padding: 12px 14px; }
.search-row .btn { padding: 12px 26px; font-size: .95rem; }

.result {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; box-shadow: var(--shadow); margin-top: 20px;
}
.result .banner {
  padding: 18px 22px; display: flex; align-items: center; gap: 14px;
  color: #fff; font-weight: 700;
}
.result .banner .mark { font-size: 1.9rem; line-height: 1; }
.result .banner .t { font-size: 1.2rem; }
.result .banner .s { font-size: .84rem; font-weight: 500; opacity: .92; display: block; }
.result.ok .banner { background: linear-gradient(100deg, #0f7a52, #14996a); }
.result.bad .banner { background: linear-gradient(100deg, #a82720, #c4342b); }
.result.gone .banner { background: linear-gradient(100deg, #4a5866, #64748b); }
.result .body { padding: 20px 22px; }
.result .foot {
  padding: 14px 22px; border-top: 1px solid var(--line); background: #fafbfc;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 22px; }
.detail-grid .it .l { font-size: .78rem; color: var(--muted); }
.detail-grid .it .v { font-weight: 700; font-size: .98rem; }

.pub-foot { padding: 16px; text-align: center; color: var(--muted); font-size: .8rem; }
.pub-foot a { color: var(--ink-soft); }

/* --------------------------------------------------------------- login */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: radial-gradient(1100px 520px at 50% -10%, #143b5e, #0b2641);
}
.login-card {
  width: 100%; max-width: 396px; background: #fff; border-radius: 16px;
  padding: 30px 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
.login-card .lg { text-align: center; margin-bottom: 18px; }
.login-card .lg img { width: 104px; }
.login-card h1 { font-size: 1.2rem; text-align: center; margin-bottom: 2px; }
.login-card p.sub { text-align: center; color: var(--muted); font-size: .84rem; margin: 0 0 20px; }

/* ------------------------------------------------------------ QR + misc */

.qr-box { text-align: center; }
.qr-box img { width: 158px; height: 158px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.qr-box .u {
  font-size: .7rem; color: var(--muted); word-break: break-all; margin-top: 8px;
  direction: ltr; text-align: center;
}

.hr { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.text-end { text-align: end; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.inline-form { display: inline; }

.pill-note {
  background: #f0f6fb; border: 1px solid #cfe4f4; color: #14557d;
  border-radius: 8px; padding: 10px 14px; font-size: .85rem; margin-bottom: 14px;
}

/* --------------------------------------------------------------- mobile */

.menu-btn { display: none; background: none; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px; cursor: pointer; }

@media (max-width: 1000px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  /* The off-canvas sidebar sits outside the viewport; without this it drags
     the page into a horizontal scroll. */
  html, body { overflow-x: hidden; }
  .app { display: block; }
  .side {
    position: fixed; inset-inline-start: 0; top: 0; z-index: 40; height: 100vh;
    transform: translateX(100%); transition: transform .22s ease;
  }
  body[dir="ltr"] .side { transform: translateX(-100%); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .grid.c2, .grid.c3, .grid.c4, .row, .row.c3, .row.c4, .detail-grid { grid-template-columns: 1fr; }
  .search-row { flex-direction: column; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}

@media print {
  .side, .topbar, .toolbar, .btn, .pager, .pub-head, .pub-foot { display: none !important; }
  .content, .pub-body { padding: 0; }
  .card, .result { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}
