/* ALUFIT traceability - tablet-first factory UI.
   Big targets, high contrast, no ambiguity about status. */

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16202b;
  --ink-soft: #5d6b7a;
  --line: #d9e0e7;
  --brand: #0b4f8a;
  --brand-dark: #073c66;
  --green: #1b8a3a;
  --yellow: #d8a900;
  --red: #c62828;
  --orange: #e06d00;
  --blue: #1565c0;
  --grey: #5a5a5a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 32, 48, .10), 0 6px 18px rgba(16, 32, 48, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--brand); }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: #0b2740;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  font-weight: 800;
  letter-spacing: .06em;
  color: #fff;
  text-decoration: none;
  font-size: 18px;
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.brand span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #8fb6d8;
}

.mainnav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 auto; }
.mainnav a {
  color: #cfe0ee;
  text-decoration: none;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
}
.mainnav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.mainnav a.nav-scan {
  background: #12b981;
  color: #04281c;
  font-weight: 700;
}

.searchform input {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #26496b;
  background: #06192b;
  color: #fff;
  min-width: 220px;
  font-size: 14px;
}

.who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.who-name { font-weight: 600; }
.who-role {
  background: #17415f;
  color: #9fc6e6;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .04em;
}
.linkbtn {
  background: none;
  border: 0;
  color: #8fb6d8;
  cursor: pointer;
  text-decoration: underline;
  font-size: 13px;
  padding: 0;
}

/* ---------- layout ---------- */

.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 16px 60px; }
.narrow { max-width: 720px; margin: 0 auto; padding: 22px 16px 60px; }

h1 { font-size: 23px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 26px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.sub { color: var(--ink-soft); margin: 0 0 18px; font-size: 14px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }

.pagehead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ---------- forms ---------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
input[type=text], input[type=password], input[type=number], input[type=search],
input[type=date], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%;
  padding: 12px;
  font-size: 16px;   /* 16px stops iOS zooming on focus */
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}
.hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.btn {
  display: inline-block;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-lg { padding: 18px 26px; font-size: 18px; width: 100%; }
.btn-ghost { background: #fff; color: var(--brand); border-color: var(--line); }
.btn-pass { background: var(--green); }
.btn-rework { background: var(--yellow); color: #2b2200; }
.btn-reject { background: var(--red); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 160px; }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--line);
  padding: 9px 10px;
  white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #f8fbfd; }
.table-scroll { overflow-x: auto; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.serial { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }

/* ---------- status ---------- */

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  color: #fff;
  white-space: nowrap;
}
.pill-lg { font-size: 14px; padding: 8px 16px; }

.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ---------- pending next step (scan screen) ---------- */

.nextup {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 2px solid var(--brand);
  border-left-width: 8px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.nextup-blocked { border-color: var(--red); }
.nextup-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.nextup-step { font-size: 21px; font-weight: 700; line-height: 1.25; }
.nextup-who { color: var(--ink-soft); font-size: 14px; }

/* ---------- key/value ---------- */

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 20px; }
.kv div { min-width: 0; }
.kv dt, .kv .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  font-weight: 700;
}
.kv dd, .kv .v { margin: 2px 0 0; font-size: 15px; word-break: break-word; }

/* ---------- stat cards ---------- */

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: block;
}
.stat .n { font-size: 30px; font-weight: 800; line-height: 1.1; }
.stat .l {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  font-weight: 700;
  margin-top: 3px;
}

/* ---------- timeline ---------- */

.timeline { list-style: none; margin: 0; padding: 0 0 0 6px; }
.timeline li {
  position: relative;
  padding: 0 0 22px 28px;
  border-left: 2px solid var(--line);
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline .dot {
  position: absolute;
  left: -9px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--grey);
  border: 3px solid var(--bg);
}
.timeline .ev { font-weight: 700; font-size: 15px; }
.timeline .meta { font-size: 13px; color: var(--ink-soft); }
.timeline .payload {
  font-size: 12.5px;
  margin-top: 5px;
  background: #f6f8fa;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- genealogy tree ---------- */

.tree { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.85; }
.tree .node { padding-left: 0; }
.tree .lvl { padding-left: 26px; border-left: 1px dashed var(--line); margin-left: 8px; }
.tree b { color: var(--brand); }

/* ---------- flash ---------- */

.flashes { margin-bottom: 16px; display: grid; gap: 8px; }
.flash {
  padding: 12px 15px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 600;
  border-left: 5px solid;
}
.flash-info { background: #e8f2fb; border-color: var(--brand); color: #0a3a63; }
.flash-success { background: #e6f6ec; border-color: var(--green); color: #10532a; }
.flash-warning { background: #fdf5dd; border-color: var(--yellow); color: #6b5400; }
.flash-error { background: #fdeaea; border-color: var(--red); color: #8c1c1c; }

/* ---------- login ---------- */

.loginpage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #0b2740, #113f63 60%, #0b2740);
}
.logincard {
  background: #fff;
  border-radius: 14px;
  padding: 30px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0,0,0,.28);
}
.loginbrand { font-size: 28px; font-weight: 800; letter-spacing: .08em; }
.loginbrand small {
  display: block;
  font-size: 11px;
  letter-spacing: .25em;
  color: var(--ink-soft);
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ---------- scanner ---------- */

.scanwrap { max-width: 620px; margin: 0 auto; padding: 16px; }
#reader-video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.scanbox { position: relative; }
.scanframe {
  position: absolute;
  inset: 14%;
  border: 3px solid rgba(255,255,255,.85);
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.22);
  pointer-events: none;
}
.scanstatus {
  text-align: center;
  font-weight: 700;
  padding: 12px;
  color: var(--ink-soft);
}

/* ---------- customer public page ---------- */

.pubwrap { max-width: 760px; margin: 0 auto; padding: 0 16px 60px; }
.pubhead {
  background: #0b2740;
  color: #fff;
  padding: 26px 16px;
  text-align: center;
  margin-bottom: 22px;
}
.pubhead .b { font-size: 26px; font-weight: 800; letter-spacing: .1em; }
.pubhead .t {
  font-size: 11px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: #8fb6d8;
  margin-top: 4px;
}
.pubserial { font-size: 30px; font-weight: 800; letter-spacing: .04em; margin-top: 14px; }

/* ---------- print ---------- */

@media print {
  .topbar, .btn, .mainnav, .searchform { display: none !important; }
  body { background: #fff; }
  .panel { box-shadow: none; border: 1px solid #999; }
}

@media (max-width: 720px) {
  .topbar { gap: 8px; padding: 8px 12px; }
  .searchform { order: 5; width: 100%; }
  .searchform input { width: 100%; }
  .wrap { padding: 16px 12px 48px; }
  h1 { font-size: 20px; }
}
