/* Outdoor Education Equipment — Westminster green theme (carried over from tag-app) */
:root {
  --main: #025e37;
  --main-dark: #014c2c;
  --main-soft: #def0e3;
  --main-line: #c5ddd0;
  --sidebar-w: 232px;
}

body { background: var(--main-soft); }

/* ── Brand colours ────────────────────────────────────── */
.bg-nav { background: var(--main) !important; }
.text-main { color: var(--main) !important; }
.bg-lightgreen { background: var(--main-soft) !important; }

.btn-main { background: var(--main); color: #fff; border: none; }
.btn-main:hover, .btn-main:focus, .btn-main:active { background: var(--main-dark) !important; color: #fff !important; }
.btn-main:disabled { background: var(--main); color: #fff; opacity: .5; }
.btn-outline-main { color: var(--main); border: 2px solid var(--main); background: transparent; }
.btn-outline-main:hover, .btn-outline-main:active, .btn-check:checked + .btn-outline-main {
  background: var(--main) !important; color: #fff !important; border-color: var(--main) !important;
}
a { color: var(--main); }
a:hover { color: var(--main-dark); }
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--main); box-shadow: 0 0 0 .2rem rgba(2, 94, 55, .2);
}
.form-check-input:checked { background-color: var(--main); border-color: var(--main); }
.page-link { color: var(--main); }
.active > .page-link { background: var(--main); border-color: var(--main); }
.nav-tabs .nav-link { color: var(--main); }
.nav-tabs .nav-link.active { font-weight: 600; color: #212529; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .5px; white-space: nowrap; }
.card { border: 0; overflow: hidden; }
.card-header { background: #fff; border-bottom: 1px solid #e8f1eb; font-weight: 600; color: var(--main); }
h1.page-title { color: var(--main); font-size: 1.6rem; font-weight: 700; margin: 0; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: .75rem; overflow-y: auto; }
.sidebar-brand {
  display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none;
  font-weight: 700; padding: .6rem .6rem 1rem; line-height: 1.15;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand i { font-size: 1.7rem; }
.sidebar-brand small, .sidebar-user small { display: block; font-weight: 400; opacity: .7; font-size: .75rem; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: .7rem; color: rgba(255, 255, 255, .78);
  border-radius: 6px; padding: .5rem .7rem; margin-bottom: 2px; border: 0; background: none;
  transition: background .15s, color .15s;
}
.sidebar .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { color: #fff; background: rgba(255, 255, 255, .15); }
.sidebar-user { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .18); padding-top: .6rem; }

@media (min-width: 992px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w); z-index: 1000; }
  .main { margin-left: var(--sidebar-w); }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { width: 260px; }
}

/* ── Phone / installed app (PWA) ──────────────────────── */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; background: #fff;
  border-top: 1px solid var(--main-line); box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 58px; padding: 6px 2px; border: 0; background: none; color: #5a7566; text-decoration: none;
  font-size: .7rem; font-weight: 600; line-height: 1.1;
}
.bottom-nav i { font-size: 1.35rem; line-height: 1; }
.bottom-nav a.active { color: var(--main); box-shadow: inset 0 3px 0 var(--main); }
#toasts { bottom: 0; }
@media (max-width: 991.98px) {
  .main { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(62px + env(safe-area-inset-bottom)); }
  header.navbar { padding-top: calc(.5rem + env(safe-area-inset-top)); }
  .sidebar-inner { padding-top: calc(.75rem + env(safe-area-inset-top)); padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
  h1.page-title { font-size: 1.35rem; }
  .table { font-size: .92rem; }
  .table > :not(caption) > * > * { padding: .5rem .5rem; }
  .table .btn-sm { white-space: nowrap; margin-bottom: 2px; }
  .scan-input { font-size: 1.25rem; padding: .7rem .6rem; }
  .item-photo { width: 76px; height: 76px; }
  .card-header-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
  .card-header-tabs .nav-link { white-space: nowrap; }
}
/* Finger-sized targets on touch screens */
@media (pointer: coarse) {
  .btn-sm { min-height: 40px; min-width: 40px; padding: .4rem .7rem; }
  .btn:not(.btn-sm):not(.btn-lg) { min-height: 44px; }
  .form-control, .form-select { min-height: 44px; font-size: 1rem; }
  .form-check-input { width: 1.35em; height: 1.35em; }
  .form-switch .form-check-input { width: 2.6em; }
  .form-check-label { padding-left: .3rem; padding-top: .15rem; }
  .page-link { min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; }
  .list-group-item-action, .picker-results .list-group-item { min-height: 48px; }
  .sidebar .nav-link { padding: .7rem .7rem; }
}
html { -webkit-tap-highlight-color: rgba(2, 94, 55, .15); }
body { overscroll-behavior-y: contain; }

/* ── Tables ───────────────────────────────────────────── */
.table > :not(caption) > * > * { vertical-align: middle; }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: #5a7566; white-space: nowrap; background: #f6faf7; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--main); }
tr.row-overdue > * { background: #fdecec; }
.badge-flag { font-weight: 500; white-space: normal; text-align: left; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--main-soft); }
.thumb-placeholder { display: inline-flex; align-items: center; justify-content: center; color: #8fb3a0; }

/* ── Dashboard ────────────────────────────────────────── */
.stat-card { display: block; text-decoration: none; color: inherit; height: 100%; }
.stat-card .card-body { display: flex; align-items: center; gap: .9rem; }
.stat-icon {
  width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; background: var(--main-soft); color: var(--main); flex-shrink: 0;
}
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .82rem; color: #5a7566; }
.stat-card.is-alert .stat-icon { background: #fde2e2; color: #b02a37; }
.stat-card.is-alert .stat-value { color: #b02a37; }
.stat-card.is-warn .stat-icon { background: #fff3cd; color: #856404; }

/* ── Scanning ─────────────────────────────────────────── */
.scan-input {
  font-size: 1.6rem; padding: .8rem 1rem; text-align: center; border: 3px solid var(--main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 1px;
}
.scan-input:focus { border-color: var(--main); box-shadow: 0 0 0 .3rem rgba(2, 94, 55, .25); }
.item-photo { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; background: var(--main-soft); flex-shrink: 0; }
.item-photo-placeholder { display: flex; align-items: center; justify-content: center; font-size: 2.6rem; color: #8fb3a0; }
.detail-photo { width: 100%; max-height: 320px; object-fit: contain; border-radius: 10px; background: var(--main-soft); }
.warning-list .alert { margin-bottom: .5rem; padding: .6rem .9rem; }
.scan-list .list-group-item { display: flex; align-items: center; gap: .75rem; }
.scan-flash { animation: scanflash .9s ease-out; }
@keyframes scanflash { from { background-color: #b9e4c9; } }
.btn-condition { padding: .9rem 1rem; font-size: 1.05rem; font-weight: 600; }
.picker-results { position: absolute; z-index: 20; left: 0; right: 0; max-height: 280px; overflow-y: auto; box-shadow: 0 6px 18px rgba(0, 0, 0, .15); }
#cameraVideo { width: 100%; border-radius: 8px; background: #000; max-height: 60vh; }
.qr-box svg { display: block; width: 100%; height: auto; }

/* ── Timeline (notes / activity) ──────────────────────── */
.timeline-item { border-left: 3px solid var(--main-line); padding: .1rem 0 .9rem .9rem; margin-left: .3rem; }
.timeline-item.is-critical { border-left-color: #dc3545; }
.timeline-item.is-warning { border-left-color: #ffc107; }
.timeline-item.is-info { border-left-color: #0dcaf0; }
.timeline-meta { font-size: .8rem; color: #6c757d; }

/* ── Plain pages (login, setup, errors) ───────────────── */
body.plain:not(.plain-wide) { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.plain-box { width: 100%; max-width: 440px; }
.plain-box-wide { max-width: 560px; }
.login-mark { width: 64px; height: 64px; border-radius: 16px; background: var(--main); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 2rem; }
body.plain-wide { background: #fff; }

/* ── TV display ───────────────────────────────────────── */
body.display { background: var(--main); color: #fff; min-height: 100vh; font-size: clamp(13px, .92vw, 34px); padding: 1.2em 1.6em; overflow-x: hidden; }
.display h1 { font-size: 2em; font-weight: 700; margin: 0; }
.display .display-clock { font-size: 1.5em; opacity: .9; text-align: right; line-height: 1.2; }
.display .display-clock small { display: block; font-size: .55em; opacity: .8; }
.display-cards { display: grid; grid-template-columns: repeat(8, 1fr); gap: .9em; margin: 1.1em 0; }
.display-card { background: rgba(255, 255, 255, .12); border-radius: .7em; padding: .9em 1em; }
.display-card .v { font-size: 2.8em; font-weight: 700; line-height: 1; }
.display-card .l { font-size: .85em; opacity: .85; margin-top: .35em; }
.display-card.alert-on { background: #fff; color: #b02a37; }
.display-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: .9em; }
.display-panel { background: #fff; color: #212529; border-radius: .7em; padding: 1em 1.2em; }
.display-panel h2 { font-size: 1.15em; color: var(--main); font-weight: 700; margin-bottom: .6em; }
.display-panel table { width: 100%; font-size: .95em; }
.display-panel th { font-size: .7em; text-transform: uppercase; color: #5a7566; padding: .3em .5em; border-bottom: 2px solid var(--main-soft); }
.display-panel td { padding: .42em .5em; border-bottom: 1px solid #edf3ef; }
.display-panel .badge { font-size: .8em; }
.display-stack { display: grid; gap: .9em; align-content: start; }
@media (max-width: 1100px) {
  .display-cards { grid-template-columns: repeat(4, 1fr); }
  .display-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) { .display-cards { grid-template-columns: repeat(2, 1fr); } }

/* ── QR labels ────────────────────────────────────────── */
body.labels { background: #f1f3f2; }
.label-sheet { display: flex; flex-wrap: wrap; gap: 3mm; padding: 5mm; background: #fff; }
.qr-label {
  display: flex; align-items: center; gap: 2.5mm; border: 1px dashed #b5b5b5; border-radius: 2mm;
  padding: 2mm; page-break-inside: avoid; break-inside: avoid; overflow: hidden; background: #fff; color: #000;
}
.qr-label .qr-box { flex-shrink: 0; }
.qr-label .label-text { min-width: 0; line-height: 1.15; }
.qr-label .label-name { font-weight: 700; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.qr-label .label-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }
.qr-label .label-org { color: #444; }
.labels-medium .qr-label { width: 63mm; height: 30mm; font-size: 8.5pt; }
.labels-medium .qr-box { width: 25mm; }
.labels-small .qr-label { width: 40mm; height: 20mm; font-size: 6pt; gap: 1.5mm; padding: 1.2mm; }
.labels-small .qr-box { width: 17mm; }
.labels-small .label-name { -webkit-line-clamp: 2; }
.labels-large .qr-label { width: 95mm; height: 48mm; font-size: 12pt; }
.labels-large .qr-box { width: 42mm; }

/* ── Print ────────────────────────────────────────────── */
@media print {
  body { background: #fff !important; }
  .main { margin-left: 0 !important; }
  .card { box-shadow: none !important; }
  .table { font-size: 10pt; }
  a { color: inherit; text-decoration: none; }
  .label-sheet { padding: 0; }
  .qr-label { border-color: #ddd; }
  @page { margin: 10mm; }
}
