:root {
  --navy: #0B2545;
  --navy-dark: #071a33;
  --sea: #1B6CA8;
  --sea-light: #E8F4FB;
  --bg-top: #f3f7fb;
  --bg-bottom: #e9eef5;
  --header-text: #ffffff;
  --white: #ffffff;
  --muted: #5a6b7d;
  --border: #d7e0ea;
  --danger: #b42318;
  --success: #027a48;
  --warning: #b54708;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-family, "Segoe UI", system-ui, -apple-system, sans-serif);
  font-size: var(--font-size-body, 16px);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  color: var(--navy);
  min-height: 100vh;
}

a { color: var(--sea); }

.app-header {
  background: var(--navy);
  color: var(--header-text);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--navy) 40%, transparent);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.app-header .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--sea), var(--navy));
  border: 2px solid color-mix(in srgb, var(--header-text) 35%, transparent);
  color: var(--header-text);
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.app-header .brand-logo {
  height: 36px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  flex-shrink: 0;
  background: transparent;
  padding: 0;
  /* Dark artwork → header text color on navy bar */
  filter: brightness(0) invert(1);
  opacity: 0.96;
}

/* Logo already carries brand; keep title compact beside it */
.app-header.has-logo .brand-text {
  min-width: 0;
}

.app-header .brand-text {
  min-width: 0;
}

.app-header .brand-title {
  font-size: var(--font-size-title, 0.95rem);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Desktop = full labels; mobile = short (toggled below) */
.brand-title-short,
.brand-sub-short,
.label-short,
.nav-short,
.title-short {
  display: none;
}
.brand-title-full,
.brand-sub-full,
.label-full,
.nav-full,
.title-full {
  display: inline;
}

.row-has-attachment {
  background: color-mix(in srgb, #f59e0b 14%, white) !important;
}
.row-has-attachment td {
  border-bottom-color: color-mix(in srgb, #f59e0b 35%, var(--border));
}

.app-header .brand-sub {
  font-size: 0.72rem;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.checklist-page-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  line-height: 1.25;
}

.forklift-pick-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  margin: 0.55rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.forklift-pick-meta[hidden] {
  display: none !important;
}

.forklift-pick-desc {
  min-width: 0;
  line-height: 1.3;
}

.forklift-qr-note {
  margin-top: 0.45rem;
}

.container {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 6px 20px rgba(11, 37, 69, 0.06);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-weight: 650;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  line-height: 1.1;
}

.btn-primary { background: var(--sea); color: white; }
.btn-primary:hover { background: #155a8d; }
.btn-navy { background: var(--navy); color: white; }
.btn-navy:hover { background: var(--navy-dark); }
.btn-ghost {
  background: color-mix(in srgb, var(--header-text) 12%, transparent);
  color: var(--header-text);
  border: 1px solid color-mix(in srgb, var(--header-text) 25%, transparent);
}
.btn-outline {
  background: white;
  color: var(--navy);
  border: 1px solid var(--border);
}
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.45rem 0.7rem; font-size: 0.82rem; border-radius: 8px; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  font-size: 1rem;
  background: white;
  color: var(--navy);
}

textarea { min-height: 100px; resize: vertical; }

.field { margin-bottom: 0.9rem; }

.alert {
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.alert-error { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; }
.alert-success { background: #ecfdf3; color: var(--success); border: 1px solid #abefc6; }
.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.alert-info {
  background: var(--sea-light);
  color: var(--navy);
  border: 1px solid color-mix(in srgb, var(--sea) 35%, white);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-electric { background: #e0f2fe; color: #075985; }
.badge-diesel { background: #ffedd5; color: #9a3412; }
.badge-open { background: #fef3c7; color: #92400e; }
.badge-fixed { background: #d1fae5; color: #065f46; }
.badge-ok { background: #e5e7eb; color: #374151; }

.question-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.85rem;
  background: white;
}

.question-text {
  font-weight: 650;
  margin-bottom: 0.75rem;
  line-height: 1.35;
}

.yn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.yn-btn {
  border: 2px solid var(--border);
  background: #f8fafc;
  border-radius: 12px;
  padding: 0.95rem 0.5rem;
  font-size: 1.05rem;
  font-weight: 750;
  cursor: pointer;
  color: var(--navy);
}
.yn-btn.yes.active {
  background: #ecfdf3;
  border-color: #12b76a;
  color: #027a48;
}
.yn-btn.no.active {
  background: #fef3f2;
  border-color: #f04438;
  color: #b42318;
}
/* Safety concern: No = all OK (green), Yes = problem (red) */
.question-card.safety-concern .yn-btn.yes.active {
  background: #fef3f2;
  border-color: #f04438;
  color: #b42318;
}
.question-card.safety-concern .yn-btn.no.active {
  background: #ecfdf3;
  border-color: #12b76a;
  color: #027a48;
}

.photo-preview {
  margin-top: 0.75rem;
  display: none;
}
.photo-preview img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.nav-tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  padding-bottom: 0.25rem;
}
.nav-tabs a {
  white-space: nowrap;
  text-decoration: none;
  color: var(--navy);
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.nav-tabs .nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #b54708;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
}
.unapproved-count-link {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0 0.35rem;
  border-radius: 6px;
  background: #b54708;
  color: #fff !important;
  font-size: 1.15rem;
  font-weight: 800;
  text-decoration: none !important;
  text-align: center;
}
.unapproved-count-link:hover {
  filter: brightness(1.08);
}
.nav-tabs a.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 26, 51, 0.55);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: white;
  width: min(560px, 100%);
  border-radius: 16px 16px 12px 12px;
  padding: 1rem;
  max-height: 90vh;
  overflow: auto;
}
.modal h2 { margin: 0 0 0.85rem; font-size: 1.15rem; }

.view-switcher select {
  background: color-mix(in srgb, var(--header-text) 12%, transparent);
  color: var(--header-text);
  border: 1px solid color-mix(in srgb, var(--header-text) 25%, transparent);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}
.view-switcher option { color: var(--navy); }

.appearance-swatch {
  width: 100%;
  height: 2.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0;
  cursor: pointer;
  background: transparent;
}
.appearance-preview-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.appearance-preview-header {
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.appearance-preview-header .brand-logo {
  height: 36px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  background: transparent;
  filter: brightness(0) invert(1);
  opacity: 0.96;
}
.appearance-preview-body {
  padding: 1rem;
}

.admin-version {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.75rem 1rem 1.25rem;
  opacity: 0.85;
}

.confirm-hero {
  text-align: center;
  padding: 2rem 1rem;
}
.confirm-hero .check {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: #ecfdf3;
  color: var(--success);
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
}

/* —— Professional A4 checklist print sheet —— */
.print-sheet {
  background: #fff;
  color: #0b2545;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.35rem 1rem;
  max-width: 210mm;
  margin: 0 auto 1.5rem;
  font-size: 11pt;
  line-height: 1.35;
}
.print-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 2.5px solid var(--navy);
  margin-bottom: 0.9rem;
}
.print-sheet-branding {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.print-sheet-logo {
  height: 42px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  filter: none !important;
  opacity: 1 !important;
  background: transparent !important;
}
.print-sheet-org {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.print-sheet-title {
  margin: 0.1rem 0 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
}
.print-sheet-ref {
  text-align: right;
  flex-shrink: 0;
}
.print-sheet-ref-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.print-sheet-ref-id {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--navy);
}
.print-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 1rem;
  margin-bottom: 0.95rem;
  padding: 0.65rem 0.75rem;
  background: #f7fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.print-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.print-meta-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.print-meta-value {
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--navy);
}
.print-answers {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.9rem;
  font-size: 0.86rem;
}
.print-answers th,
.print-answers td {
  border: 1px solid #c9d4e0;
  padding: 0.4rem 0.5rem;
  vertical-align: top;
}
.print-answers thead th {
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.print-answers .col-num {
  width: 2.2rem;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}
.print-answers .col-ans {
  width: 2.6rem;
  text-align: center;
  font-weight: 800;
}
.print-answers .col-ans.marked {
  background: #ecfdf3;
  color: #027a48;
}
.print-answers tbody tr:nth-child(even) td.col-q {
  background: #fafcfe;
}
.print-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  page-break-inside: avoid;
}
.print-block-title {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--navy);
}
.print-block-body {
  margin: 0;
  font-size: 0.9rem;
  white-space: pre-wrap;
}
.print-block-meta {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.print-photo img {
  max-width: 100%;
  max-height: 55mm;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.print-sign {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
  page-break-inside: avoid;
}
.print-sign-box {
  border: 1px solid #c9d4e0;
  border-radius: 8px;
  padding: 0.65rem 0.75rem 0.5rem;
  min-height: 22mm;
}
.print-sign-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.85rem;
}
.print-sign-line {
  border-bottom: 1px solid #94a3b8;
  min-height: 1.35rem;
  font-weight: 650;
  margin-bottom: 0.25rem;
}
.print-sign-hint {
  font-size: 0.68rem;
  color: var(--muted);
}
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }
  html, body {
    background: white !important;
    color: #0b2545;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .app-header,
  .no-print,
  .nav-tabs,
  .header-actions,
  .admin-version,
  .alert {
    display: none !important;
  }
  .container {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }
  .print-sheet {
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
  }
  .print-sheet-logo {
    filter: none !important;
  }
  /* Black & white print mode */
  body.print-bw .print-sheet {
    filter: grayscale(1) contrast(1.05);
  }
  body.print-bw .print-answers thead th {
    background: #111 !important;
    color: #fff !important;
  }
  body.print-bw .print-answers .col-ans.marked {
    background: #d4d4d4 !important;
    color: #000 !important;
  }
  body.print-bw .print-meta {
    background: #f0f0f0 !important;
  }
  body.print-bw .print-sheet-header {
    border-bottom-color: #111 !important;
  }
  body.print-bw .print-sheet-logo {
    filter: grayscale(1) !important;
  }
  .print-a4 {
    width: auto;
    min-height: auto;
    margin: 0;
    padding: 0;
  }
}

/* Live preview of B&W on screen when selected */
body.print-bw .print-sheet {
  filter: grayscale(1) contrast(1.05);
}

.qr-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--qr-size, 40mm), 1fr));
  gap: 8mm;
  padding: 10mm;
}
.qr-item {
  text-align: center;
  page-break-inside: avoid;
}
.qr-item img {
  width: var(--qr-size, 40mm);
  height: var(--qr-size, 40mm);
}
.qr-item .meta {
  margin-top: 2mm;
  font-size: 11pt;
  font-weight: 700;
}
.qr-item .meta small {
  display: block;
  font-weight: 500;
  font-size: 9pt;
}

/* —— Mobile / phone layout (all roles) —— */
@media (max-width: 767px) {
  /* Keep short brand/user text; buttons & nav stay full */
  .brand-title-full,
  .brand-sub-full {
    display: none;
  }
  .brand-title-short,
  .brand-sub-short {
    display: inline;
  }
  .label-short,
  .nav-short,
  .title-short {
    display: none;
  }
  .label-full,
  .nav-full,
  .title-full {
    display: inline;
  }

  .app-header {
    flex-wrap: nowrap;
    align-items: center;
    padding: 0.5rem 0.65rem;
    gap: 0.4rem;
  }
  .app-header .brand {
    flex: 1 1 auto;
    min-width: 0;
    gap: 0.4rem;
  }
  .app-header.has-logo .brand-logo {
    height: 20px;
    max-width: 96px;
  }
  .app-header .brand-mark {
    width: 24px;
    height: 24px;
    font-size: 0.65rem;
  }
  .app-header .brand-title {
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .app-header .brand-sub {
    font-size: 0.62rem;
  }
  .header-actions {
    flex: 0 0 auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 0.3rem;
    margin-left: 0;
  }
  .header-actions .btn-sm {
    padding: 0.32rem 0.5rem;
    font-size: 0.72rem;
    border-radius: 7px;
  }
  .view-switcher select {
    max-width: 5.75rem;
    font-size: 0.7rem;
    padding: 0.28rem 0.35rem;
  }

  .container {
    padding: 0.65rem;
  }

  .card {
    padding: 0.7rem 0.75rem;
    border-radius: 11px;
  }

  .btn {
    padding: 0.55rem 0.8rem;
    font-size: 0.88rem;
    border-radius: 9px;
  }
  .btn-sm {
    padding: 0.35rem 0.55rem;
    font-size: 0.75rem;
  }

  .checklist-page-title {
    font-size: 0.98rem;
    margin-bottom: 0.5rem;
  }

  label {
    font-size: 0.78rem;
    margin-bottom: 0.28rem;
  }

  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="file"],
  select,
  textarea {
    padding: 0.55rem 0.7rem;
    font-size: 0.92rem;
    border-radius: 9px;
  }

  .forklift-select {
    font-size: 0.92rem;
    padding: 0.55rem 0.7rem;
  }

  .forklift-pick-meta {
    font-size: 0.75rem;
    margin-top: 0.4rem;
  }

  .question-card {
    padding: 0.75rem;
    margin-bottom: 0.65rem;
    border-radius: 11px;
  }

  .question-text {
    font-size: 0.9rem;
    margin-bottom: 0.55rem;
  }

  .yn-btn {
    padding: 0.65rem 0.35rem;
    font-size: 0.92rem;
    border-radius: 10px;
  }

  .nav-tabs {
    gap: 0.28rem;
    margin-bottom: 0.75rem;
  }
  .nav-tabs a {
    padding: 0.32rem 0.55rem;
    font-size: 0.72rem;
    border-radius: 999px;
  }

  .alert {
    font-size: 0.8rem;
    padding: 0.55rem 0.65rem;
  }

  .badge {
    font-size: 0.65rem;
    padding: 0.12rem 0.45rem;
  }

  .modal {
    border-radius: 14px 14px 0 0;
    padding: 0.75rem;
  }
  .modal h2 {
    font-size: 1.02rem;
  }

  table.data {
    font-size: 0.78rem;
  }
  table.data th,
  table.data td {
    padding: 0.45rem 0.35rem;
  }
}

@media (min-width: 768px) {
  .modal-backdrop { align-items: center; }
  .app-header .brand-title { font-size: 1.05rem; }

  .brand-title-short,
  .brand-sub-short,
  .label-short,
  .nav-short,
  .title-short {
    display: none;
  }
  .brand-title-full,
  .brand-sub-full,
  .label-full,
  .nav-full,
  .title-full {
    display: inline;
  }
}

/* Very narrow phones */
@media (max-width: 380px) {
  .app-header {
    padding: 0.45rem 0.55rem;
  }
  .app-header.has-logo .brand-text .brand-title {
    font-size: 0.74rem;
  }
  .app-header.has-logo .brand-logo {
    height: 18px;
    max-width: 88px;
  }
  .header-actions .btn-sm {
    padding: 0.28rem 0.42rem;
    font-size: 0.68rem;
  }
  .nav-tabs a {
    padding: 0.28rem 0.48rem;
    font-size: 0.68rem;
  }
  .view-switcher select {
    max-width: 5.2rem;
    font-size: 0.65rem;
  }
}
