:root {
  /* Palette taken from the Bytenex logo: deep blue (primary) and cyan (accent) */
  --brand: #2B1BF0;
  --brand-dark: #2013B8;
  --brand-light: #E9F9FE;
  --accent: #3DD9F9;
  --ink: #1f2937;
  --muted: #6b7280;
  --rule: #e5e7eb;
}

html { font-size: 14px; position: relative; min-height: 100%; }
@media (min-width: 768px) { html { font-size: 15px; } }

body {
  margin-bottom: 60px;
  background: #f6f8f7;
  color: var(--ink);
}

.footer { position: absolute; bottom: 0; width: 100%; white-space: nowrap; line-height: 60px; font-size: .85rem; color: var(--muted); }

/* ---- Navbar ------------------------------------------------------------------ */
.navbar-brand-ea { font-weight: 700; color: var(--brand) !important; letter-spacing: .01em; }
.navbar-brand-ea small { display: block; font-size: .62rem; font-weight: 600; letter-spacing: .08em; color: var(--muted); }
.navbar-ea { border-bottom: 3px solid var(--accent); background: #fff; }
.navbar-brand-ea img { height: 40px; width: auto; }
.navbar-ea .nav-link.active { color: var(--brand); font-weight: 600; }

/* ---- Buttons / accents ------------------------------------------------------- */
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-outline-brand { border-color: var(--brand); color: var(--brand); }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }
.text-brand { color: var(--brand) !important; }
.bg-brand-light { background: var(--brand-light); }

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }

/* ---- Cards / sections -------------------------------------------------------- */
.card-section { border: 1px solid var(--rule); border-radius: .6rem; background: #fff; }
.card-section > .card-header {
  background: #fff; border-bottom: 1px solid var(--rule); font-weight: 600; color: var(--brand);
  text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; padding: .7rem 1rem;
}

.stat-card { border: 1px solid var(--rule); border-radius: .6rem; background: #fff; padding: 1rem 1.1rem; height: 100%; }
.stat-card .stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }

/* ---- Report detail table (mirrors the PDF label/value layout) ---------------- */
.report-sheet { background: #fff; border: 1px solid var(--rule); border-radius: .6rem; padding: 1.5rem 1.75rem; }
.report-sheet .sheet-title { font-size: 1.6rem; font-weight: 400; margin: 0; }
.report-sheet .sheet-number { color: var(--muted); }
.report-sheet .sheet-rule { border-top: 2px solid var(--accent); margin: .75rem 0 1.25rem; }
.detail-row { display: grid; grid-template-columns: 260px 1fr; gap: .5rem 1rem; padding: .45rem 0; border-bottom: 1px dashed #f0f0f0; }
.detail-row:last-child { border-bottom: 0; }
.detail-row .label { font-weight: 600; }
.detail-row .value { white-space: pre-line; word-break: break-word; }
@media (max-width: 767.98px) { .detail-row { grid-template-columns: 1fr; gap: .1rem; } }

.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin: .5rem 0 1rem; }
@media (min-width: 992px) { .photo-grid { grid-template-columns: repeat(3, 1fr); } }
.photo-grid img { width: 100%; height: 220px; object-fit: cover; border-radius: .4rem; border: 1px solid var(--rule); background: #fafafa; }

.signature-img { max-width: 260px; max-height: 110px; border-bottom: 1px solid #333; padding-bottom: 4px; }

/* ---- Signature pad ----------------------------------------------------------- */
.signature-pad { border: 1px dashed #9ca3af; border-radius: .5rem; background: #fff; position: relative; }
.signature-pad canvas { display: block; width: 100%; cursor: crosshair; border-radius: .5rem; touch-action: none; }
.signature-pad.is-signed { border-color: var(--brand); border-style: solid; }
.signature-pad .signature-hint {
  position: absolute; left: 0; right: 0; top: 45%; text-align: center; color: #c4c8cf; pointer-events: none; font-size: .95rem;
}
.signature-pad.is-signed .signature-hint { display: none; }
.signature-line { position: absolute; left: 8%; right: 8%; bottom: 34px; border-top: 1px solid #d1d5db; pointer-events: none; }

/* ---- Photo uploader / thumbnails --------------------------------------------- */
.photo-uploader { border: 1px dashed #c9ced6; border-radius: .5rem; padding: .75rem; background: #fafbfa; }
.photo-uploader.has-photos { border-style: solid; border-color: var(--rule); background: #fff; }
.thumb-list { display: flex; flex-wrap: wrap; gap: .75rem; }
.thumb-item { position: relative; width: 120px; }
.thumb-item img { width: 120px; height: 90px; object-fit: cover; border-radius: .35rem; border: 1px solid var(--rule); background: #f3f4f6; display: block; }
.thumb-item .thumb-caption { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .2rem; }
.thumb-item .thumb-size { font-size: .68rem; color: #9ca3af; }
.thumb-item .thumb-index {
  position: absolute; left: 4px; top: 4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: rgba(0,0,0,.6); color: #fff; font-size: .7rem; font-weight: 600; line-height: 20px; text-align: center;
}
.thumb-item .thumb-remove {
  position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff;
  background: #dc3545; color: #fff; font-size: 17px; line-height: 20px; padding: 0; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.thumb-item .thumb-remove:hover { background: #b02a37; }
.thumb-item.removing img { opacity: .35; filter: grayscale(1); }
.thumb-item.removing .thumb-remove { background: #198754; }
.thumb-item.removing .thumb-caption::after { content: " (will be removed)"; color: #dc3545; }
.thumb-item.thumb-pending .thumb-spinner { width: 120px; height: 90px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--rule); border-radius: .35rem; color: var(--muted); }
@media (max-width: 575.98px) {
  .thumb-item { width: calc(33.333% - .5rem); }
  .thumb-item img, .thumb-item.thumb-pending .thumb-spinner { width: 100%; height: 26vw; max-height: 120px; }
}

/* ---- Tables ------------------------------------------------------------------ */
.table-reports th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.table-reports td { vertical-align: middle; }
.table-reports .report-no { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.status-badge { font-weight: 600; font-size: .72rem; letter-spacing: .03em; }

/* ---- Login ------------------------------------------------------------------- */
.login-wrap { min-height: calc(100vh - 140px); display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 420px; }
.login-card .brand-mark { height: 96px; width: auto; }

.required-mark::after { content: " *"; color: #dc3545; }
.form-section-help { font-size: .8rem; color: var(--muted); }

/* ---- Date / time picker (flatpickr) ------------------------------------------ */
.flatpickr-input[readonly], .form-control.flatpickr-input { background-color: #fff; cursor: pointer; }
.flatpickr-calendar { font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.flatpickr-day.selected, .flatpickr-day.selected:hover,
.flatpickr-day.startRange, .flatpickr-day.endRange { background: var(--brand); border-color: var(--brand); }
.flatpickr-day.today { border-color: var(--brand); }
.flatpickr-day.today:hover { background: var(--brand-light); color: var(--ink); }
.flatpickr-months .flatpickr-month, .flatpickr-current-month .flatpickr-monthDropdown-months { color: var(--ink); }
.flatpickr-time input:hover, .flatpickr-time .flatpickr-am-pm:hover,
.flatpickr-time input:focus, .flatpickr-time .flatpickr-am-pm:focus { background: var(--brand-light); }
@media (max-width: 575.98px) {
  .flatpickr-calendar { font-size: 16px; }              /* bigger touch targets on phones */
  .flatpickr-day { line-height: 39px; height: 39px; max-width: 39px; }
  .flatpickr-time input, .flatpickr-time .flatpickr-am-pm { font-size: 16px; }
}

/* ---- Mobile: stack table rows as cards --------------------------------------- */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack tbody tr { display: block; margin: .75rem; padding: .35rem .85rem; border: 1px solid var(--rule); border-radius: .5rem; background: #fff; }
  .table-stack tbody td { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border: 0; padding: .4rem 0; text-align: right !important; white-space: normal !important; }
  .table-stack tbody td + td { border-top: 1px dashed #f0f0f0; }
  .table-stack tbody td::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: .15rem; }
  .table-stack tbody td.td-actions { justify-content: flex-end; flex-wrap: wrap; gap: .4rem; padding-top: .6rem; }
  .table-stack tbody td.td-actions::before { display: none; }
  .table-stack tbody td.td-actions .btn { flex: 1 1 auto; }
  .table-stack .d-block { display: inline !important; }
  .table-stack .d-block::before { content: " · "; }
}

/* ---- Mobile: full-width primary actions and tighter spacing ------------------- */
@media (max-width: 575.98px) {
  html { font-size: 15px; }
  .page-actions { width: 100%; }
  .page-actions .btn, .page-actions form { flex: 1 1 auto; }
  .page-actions form .btn { width: 100%; }
  .btn-mobile-block { width: 100%; }
  .report-sheet { padding: 1rem 1rem; }
  .stat-card { padding: .75rem .85rem; }
  .stat-card .stat-value { font-size: 1.35rem; }
  .card-section > .card-body { padding: .9rem; }
  .photo-grid img { height: 160px; }
  .signature-pad canvas { min-height: 160px; }
  .navbar-brand-ea span { font-size: .95rem; }
  .footer { position: static; line-height: 1.4; white-space: normal; padding: 1rem 0; text-align: center; }
  .footer .container-xl { flex-direction: column; gap: .25rem; }
  body { margin-bottom: 0; }
}

/* Inputs: avoid iOS zoom-on-focus (needs >= 16px font) */
@media (max-width: 767.98px) {
  .form-control, .form-select { font-size: 16px; }
}
