:root {
  color-scheme: light;
  --bg: #f7faf8;
  --surface: #ffffff;
  --surface-soft: #f1fbf5;
  --ink: #1a1a1a;
  --muted: #686f6b;
  --line: #dfe8e2;
  --brand: #00a651;
  --brand-dark: #008f45;
  --brand-soft: #e7f8ef;
  --accent: #7d7d00;
  --danger: #b42318;
  --ok: #16a34a;
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07130d;
  --surface: #101f17;
  --surface-soft: #14291f;
  --ink: #edf7f1;
  --muted: #a8b8ae;
  --line: #244135;
  --brand-soft: rgba(0, 166, 81, 0.16);
  --accent: #d8c75f;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Montserrat, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(390px, 480px);
}

.login-visual {
  min-height: 100vh;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(rgba(5, 35, 32, 0.38), rgba(5, 35, 32, 0.7)),
    url("https://images.unsplash.com/photo-1493238792000-8113da705763?auto=format&fit=crop&w=1600&q=80") center/cover;
  color: white;
}

.login-visual h1 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(2.7rem, 6vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.login-visual p {
  max-width: 560px;
  margin: 20px 0 0;
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.86);
}

.login-panel {
  display: grid;
  place-items: center start;
  min-height: 100vh;
  padding: 32px 36px 32px 28px;
}

.login-card {
  width: min(100%, 430px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: block;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid rgba(15, 36, 33, .12);
  padding: 4px;
  box-shadow: 0 8px 20px rgba(15, 36, 33, 0.08);
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.field label {
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 46px;
  background: white;
  color: var(--ink);
  outline: none;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 166, 81, 0.14);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.between {
  justify-content: space-between;
}

.btn {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  color: var(--ink);
  background: #eef2ef;
}

.btn.primary {
  color: white;
  background: var(--brand);
}

.btn.primary:hover {
  background: var(--brand-dark);
}

.btn.ghost {
  background: transparent;
  color: var(--brand-dark);
}

.btn.danger {
  color: white;
  background: var(--danger);
}

.danger-text {
  color: var(--danger);
  font-weight: 800;
}

.warn-text {
  color: #a16207;
  font-weight: 800;
}

.demo-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px 1fr;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 78px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  color: #eafff1;
  background: linear-gradient(165deg, #064927, #087d40);
  border-right: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
}

.sidebar .eyebrow,
.sidebar .brand-copy p,
.sidebar .nav-group-label {
  color: rgba(234, 255, 241, 0.76);
}

.sidebar .brand-copy,
.sidebar .brand-copy strong {
  color: #ffffff;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--brand-dark);
  background: var(--surface-soft);
}

.sidebar .icon-btn {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}

.sidebar .icon-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.22);
}

.app-shell.sidebar-collapsed .sidebar {
  padding: 18px;
  align-items: center;
}

.app-shell.sidebar-collapsed .brand-copy,
.app-shell.sidebar-collapsed .nav span,
.app-shell.sidebar-collapsed #logout span {
  display: none;
}

.app-shell.sidebar-collapsed .brand-lockup {
  margin: 0;
}

.app-shell.sidebar-collapsed .sidebar-head {
  flex-direction: column;
}

.app-shell.sidebar-collapsed .nav button,
.app-shell.sidebar-collapsed .nav a,
.app-shell.sidebar-collapsed #logout {
  width: 42px;
  padding: 0;
  justify-content: center;
}

.nav {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--brand) transparent;
}

.nav::-webkit-scrollbar {
  width: 8px;
}

.nav::-webkit-scrollbar-thumb {
  background: var(--brand);
  border-radius: 999px;
}

.nav::-webkit-scrollbar-track {
  background: transparent;
}

.nav button,
.nav a {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: #eafff1;
  font-weight: 800;
  text-align: left;
}

.nav a {
  text-decoration: none;
}

.nav button.active,
.nav button:hover,
.nav a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.17);
}

.nav button.nav-group-toggle {
  margin-top: 8px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.nav button.nav-group-toggle strong {
  margin-left: auto;
  font-size: 1rem;
  line-height: 1;
}

.nav button.nav-group-toggle.open {
  background: rgba(255, 255, 255, 0.17);
}

.sidebar #logout {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.30);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar #logout:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
}

.nav-group-label {
  margin: 12px 8px 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-shell.sidebar-collapsed .nav-group-label {
  width: 100%;
  height: 1px;
  margin: 8px 0;
  overflow: hidden;
  background: var(--line);
}

.app-shell.sidebar-collapsed .nav button.nav-group-toggle strong {
  display: none;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 72px;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(246, 248, 247, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar.operational-status-ok {
  background: linear-gradient(90deg, rgba(225, 248, 235, 0.96), rgba(246, 248, 247, 0.9));
  border-bottom-color: rgba(22, 130, 75, 0.3);
}

.topbar.operational-status-alert {
  background: linear-gradient(90deg, rgba(255, 231, 231, 0.97), rgba(255, 246, 242, 0.92));
  border-bottom-color: rgba(192, 46, 46, 0.38);
}

.operational-status-pill {
  display: grid;
  gap: 2px;
  min-width: 190px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 0.76rem;
  line-height: 1.2;
}

.operational-status-pill strong {
  font-size: 0.82rem;
}

.operational-status-pill small {
  font-size: 0.7rem;
  opacity: 0.84;
}

.operational-status-pill.ok {
  color: #0c6337;
  background: rgba(207, 244, 222, 0.9);
  border-color: rgba(22, 130, 75, 0.26);
}

.operational-status-pill.alert {
  color: #9d2020;
  background: rgba(255, 214, 214, 0.94);
  border-color: rgba(192, 46, 46, 0.3);
}

.content {
  padding: 28px;
  display: grid;
  gap: 22px;
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.section-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.section-head > div {
  min-width: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat,
.panel,
.item-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(15, 36, 33, 0.04);
}

.stat {
  padding: 18px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.bar-chart {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) 2fr auto;
  gap: 10px;
  align-items: center;
}

.bar-row span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-weight: 800;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ece9;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.panel.grid-2,
.panel.grid-3 {
  align-items: end;
}

.user-filter-panel {
  margin-bottom: 16px;
}

.user-filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.report-export-group {
  padding: 14px;
  border: 1px solid var(--border);
  background: #fff;
  display: grid;
  gap: 8px;
}

.report-export-group h4 {
  margin: 0;
  font-size: 1rem;
}

.report-section-head {
  margin-top: 18px;
  padding-top: 6px;
}

.form-wide {
  grid-column: 1 / -1;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.managed-company-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.managed-company-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--brand);
}

.managed-company-option span {
  min-width: 0;
  line-height: 1.25;
}

.managed-company-option:hover {
  border-color: var(--brand);
}

.managed-company-option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.panel.grid-3.company-form {
  align-items: start;
  grid-auto-rows: minmax(0, auto);
}

.company-form .field {
  margin-top: 0;
}

.company-form-actions {
  display: flex;
  flex-direction: column;
  justify-content: start;
}

.company-form-actions .row {
  min-height: 44px;
}

.template-vehicle-selection {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 340px));
  gap: 8px;
  margin-top: 8px;
  max-width: 720px;
  max-height: 230px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.check-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.check-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--brand);
}

.check-option span {
  overflow-wrap: anywhere;
}

.damage-flag {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid #f0b44d;
  border-radius: 10px;
  background: #fff7e6;
  cursor: pointer;
}

.damage-flag input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin: 2px 0 0;
  padding: 0;
  accent-color: #c2410c;
}

.damage-flag span { display: grid; gap: 3px; }
.damage-flag small { color: var(--muted); line-height: 1.35; }

html[data-theme="dark"] .damage-flag {
  background: rgba(194, 65, 12, 0.16);
  border-color: rgba(251, 146, 60, 0.5);
}

.vehicle-settings-grid {
  align-items: start;
  gap: 16px;
}

.vehicle-settings-panel { padding: 16px; }
.vehicle-settings-panel h3 { margin: 0; font-size: 1rem; }

.vehicle-settings-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-top: 10px;
}

.vehicle-settings-form .field label { margin-bottom: 5px; font-size: 0.78rem; }
.vehicle-settings-form .field input { min-height: 38px; }
.vehicle-settings-form .btn { min-height: 38px; white-space: nowrap; }
.vehicle-settings-list { gap: 8px; margin-top: 12px; }

.vehicle-setting-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 12px;
}

.vehicle-setting-card .row.between,
.vehicle-setting-card > .row { display: contents; }
.vehicle-setting-card .pill { justify-self: end; }
.vehicle-setting-card .btn { min-height: 32px; padding: 6px 9px; font-size: 0.82rem; }

@media (max-width: 980px) {
  .vehicle-settings-form,
  .vehicle-setting-card { grid-template-columns: 1fr; }
  .vehicle-setting-card .pill { justify-self: start; }
}

@media (max-width: 680px) {
  .company-form-actions .row {
    width: 100%;
  }

  .company-form-actions .btn {
    flex: 1 1 160px;
  }
}

.managed-companies {
  display: grid;
  gap: 8px;
}

.notice {
  padding: 14px;
  border-radius: 8px;
  display: grid;
  gap: 5px;
  line-height: 1.45;
}

.notice.warn {
  border: 1px solid #f8d36b;
  background: #fffbeb;
  color: #713f12;
}

.notice.danger {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
}

.list {
  display: grid;
  gap: 12px;
}

.item-card {
  padding: 16px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.checklist-card {
  border-left: 4px solid var(--brand);
}

.checklist-card-head,
.checklist-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.checklist-card-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.checklist-card-title strong {
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.checklist-card-title span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.checklist-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.checklist-meta span {
  min-height: 42px;
  padding: 8px;
  display: grid;
  align-content: center;
  gap: 3px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.checklist-meta strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.muted {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.pill {
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-size: 0.78rem;
  font-weight: 900;
  background: #edf2f7;
  color: #334155;
}

.pill.ok {
  background: #dcfce7;
  color: #008f45;
}

.pill.warn {
  background: #fef3c7;
  color: #92400e;
}

.pill.danger {
  background: #fee2e2;
  color: #991b1b;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.photo-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.photo-box {
  border: 1px dashed #a7b8b2;
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
  display: grid;
  gap: 8px;
}

.photo-box input {
  font-size: 0.82rem;
}

.thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.thumbs img {
  width: 62px;
  height: 62px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.photo-gallery {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 112px));
  gap: 12px;
  align-items: start;
}

.photo-preview {
  display: grid;
  gap: 8px;
  width: 112px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left;
}

.photo-preview img {
  width: 112px;
  height: 84px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f5f3;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  background: rgba(7, 20, 18, 0.94);
}

.photo-viewer-head {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: white;
}

.photo-viewer img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.signature-pad {
  width: 100%;
  min-height: 150px;
  border: 1px dashed #8aa39b;
  border-radius: 8px;
  background: #ffffff;
  touch-action: none;
}

.signature-preview {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.email-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

body.viewer-open {
  overflow: hidden;
}

.qr-card {
  display: inline-grid;
  gap: 6px;
  justify-items: center;
  color: var(--brand-dark);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.qr-card img {
  width: 86px;
  height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 4px;
}

.qr-scanner {
  display: grid;
  gap: 14px;
}

.qr-video {
  width: 100%;
  max-height: 420px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1f1c;
}

.qr-manual {
  display: grid;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #10201d;
  color: white;
  box-shadow: var(--shadow);
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .login-shell,
  .app-shell,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 42vh;
  }

  .sidebar {
    position: static;
    height: auto;
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .app-shell.sidebar-collapsed .sidebar {
    align-items: stretch;
  }

  .app-shell.sidebar-collapsed .brand-copy,
  .app-shell.sidebar-collapsed .nav span,
  .app-shell.sidebar-collapsed #logout span {
    display: inline;
  }

  .app-shell.sidebar-collapsed .sidebar-head {
    flex-direction: row;
  }

  .app-shell.sidebar-collapsed .nav {
    display: none;
  }

  .app-shell.sidebar-collapsed #logout {
    display: none;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
  }

  .nav button,
  .nav a {
    white-space: nowrap;
  }

  .stats-grid,
  .photo-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
  }

  .table-wrap {
    overflow: visible;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap th,
  .table-wrap td {
    display: block;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: 0 8px 22px rgba(15, 36, 33, 0.04);
  }

  .table-wrap td {
    min-height: 42px;
    padding: 10px 0;
    border-bottom: 1px solid #edf2ef;
    display: grid;
    grid-template-columns: minmax(96px, 34%) 1fr;
    gap: 12px;
    align-items: start;
  }

  .table-wrap td:last-child {
    border-bottom: 0;
  }

  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
  }
}

@media (max-width: 620px) {
  .login-visual,
  .login-panel,
  .content,
  .topbar {
    padding: 20px;
  }

  .section-head,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .login-shell {
    min-height: 100vh;
  }

  .login-visual {
    min-height: 34vh;
  }

  .login-panel {
    display: block;
    min-height: auto;
    padding: 12px 20px 24px;
  }

  .login-card {
    margin: 0 auto;
  }

  .login-visual h1 {
    font-size: 2.25rem;
    line-height: 1;
  }

  .login-visual p {
    font-size: 0.96rem;
  }

  .login-card {
    padding: 20px;
  }

  .sidebar {
    padding: 16px;
  }

  .sidebar-head .brand-lockup {
    margin-bottom: 0;
  }

  .nav button {
    flex: 0 0 auto;
  }

  .topbar .row,
  .item-card .row.between {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar .pill,
  .item-card .pill {
    width: 100%;
    justify-content: center;
  }

  .panel,
  .item-card,
  .stat {
    padding: 14px;
  }

  .stats-grid,
  .photo-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
    min-height: 46px;
    white-space: normal;
    text-align: center;
  }

  .field {
    margin-top: 12px;
  }

  .photo-box {
    padding: 12px;
  }

  .table-wrap tr {
    padding: 14px;
  }

  .table-wrap td {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .bar-row {
    grid-template-columns: 1fr auto;
  }

  .bar-track {
    grid-column: 1 / -1;
    order: 3;
  }

  .qr-card {
    width: 100%;
    justify-items: center;
  }

  .qr-card img {
    width: 112px;
    height: 112px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
  }
}

@media (max-width: 900px) {
  body {
    background:
      linear-gradient(180deg, #e7f8ef 0, #f7faf8 230px, #f7faf8 100%);
  }

  .app-shell {
    position: relative;
  }

  .sidebar {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 30;
    width: auto;
    height: auto;
    padding: 0;
    gap: 8px;
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .app-shell.mobile-menu-open .sidebar {
    width: min(306px, calc(100vw - 28px));
    max-height: min(74vh, 620px);
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    background: linear-gradient(165deg, #064927, #087d40);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
    overflow: hidden;
  }

  .sidebar-head {
    justify-content: flex-start;
  }

  .sidebar .brand-lockup,
  .sidebar-head .brand-lockup {
    display: none;
  }

  .icon-btn {
    width: 52px;
    height: 52px;
    color: white;
    background: var(--brand);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 12px 26px rgba(0, 166, 81, 0.3);
  }

  .sidebar .icon-btn {
    color: #ffffff;
    background: var(--brand);
    border-color: rgba(255, 255, 255, 0.72);
  }

  .nav {
    display: none;
    margin: 0;
    padding: 8px 0 0;
    gap: 6px;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    max-height: calc(74vh - 128px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  .nav button {
    width: 100%;
    min-height: 48px;
    justify-content: flex-start;
    white-space: normal;
    background: transparent;
  }

  #logout {
    display: none;
    margin-top: 0 !important;
  }

  .app-shell.mobile-menu-open .nav {
    display: grid;
  }

  .app-shell.mobile-menu-open .nav button,
  .app-shell.mobile-menu-open #logout {
    width: 100%;
    padding: 0 12px;
    justify-content: flex-start;
  }

  .app-shell.mobile-menu-open #logout {
    display: inline-flex;
  }

  .main {
    padding-top: 0;
    padding-bottom: 76px;
  }

  .topbar {
    min-height: auto;
    margin: 0 12px 12px;
    padding: 15px 16px;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(219, 229, 225, 0.9);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(12px);
  }

  .topbar h2 {
    font-size: 1.35rem;
    line-height: 1.1;
  }

  .topbar .row {
    gap: 8px;
  }

  .content {
    padding: 0 12px 18px;
    gap: 14px;
  }

  .section-head {
    padding: 2px 2px 0;
    gap: 10px;
  }

  .section-head h2 {
    font-size: 1.35rem;
    line-height: 1.15;
  }

  .section-head p {
    margin-top: 4px;
    font-size: 0.86rem;
    line-height: 1.45;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat,
  .panel,
  .item-card,
  .table-wrap tr {
    border-color: rgba(219, 229, 225, 0.95);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.06);
  }

  .stat {
    min-height: 104px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff 0, #f8fbfa 100%);
  }

  .stat .muted,
  .stat > span {
    font-size: 0.82rem;
    line-height: 1.25;
  }

  .stat strong {
    margin-top: 10px;
    font-size: 1.85rem;
    line-height: 1;
    color: var(--brand-dark);
  }

  .panel,
  .item-card {
    background: rgba(255, 255, 255, 0.97);
  }

  .panel {
    padding: 16px;
  }

  .item-card {
    gap: 11px;
    padding: 14px;
  }

  .btn {
    min-height: 52px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
  }

  .btn.primary {
    background: linear-gradient(180deg, var(--brand) 0, var(--brand-dark) 100%);
    box-shadow: 0 10px 22px rgba(0, 166, 81, 0.24);
  }

  .btn.ghost {
    background: #eef7f4;
  }

  .field {
    margin-top: 10px;
  }

  .field label {
    font-size: 0.86rem;
  }

  .field input,
  .field select,
  .field textarea {
    min-height: 48px;
    background: #fbfdfc;
  }

  .photo-box {
    padding: 14px;
    background: #fbfdfc;
  }

  .photo-box strong {
    font-size: 0.98rem;
    line-height: 1.25;
  }

  .notice {
    padding: 13px;
  }

  .pill {
    min-height: 30px;
  }

  .checklist-card {
    gap: 10px;
    border-left-width: 5px;
  }

  .checklist-card-head,
  .checklist-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .checklist-card-head .pill {
    width: 100%;
    justify-content: center;
  }

  .checklist-card-title strong {
    font-size: 1.02rem;
  }

  .checklist-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .checklist-meta span {
    min-height: 40px;
    padding: 7px 8px;
  }

  .panel.grid-3,
  .panel.grid-2 {
    gap: 8px;
    padding: 12px;
  }

  .bar-chart {
    gap: 12px;
  }

  .bar-track {
    height: 10px;
    background: #dfe9e5;
  }

  .bar-fill {
    background: linear-gradient(90deg, var(--brand-dark), var(--brand), var(--accent));
  }

  .qr-video {
    max-height: 360px;
  }
}
}

@media (max-width: 480px) and (orientation: portrait) {
  body {
    background:
      linear-gradient(180deg, #e7f8ef 0, #f7faf8 220px, #f7faf8 100%);
  }

  .login-visual,
  .login-panel,
  .topbar {
    padding: 16px;
  }

  .content {
    padding: 0 12px 18px;
  }

  .login-visual {
    min-height: 30vh;
  }

  .login-visual h1 {
    font-size: 2rem;
  }

  .brand-lockup {
    gap: 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .sidebar {
    padding: 0;
  }

  .app-shell.mobile-menu-open .sidebar {
    padding: 8px;
  }

  .sidebar-head {
    align-items: center;
  }

  .sidebar .brand-copy strong {
    font-size: 0.95rem;
  }

  .icon-btn {
    width: 52px;
    height: 52px;
  }

  .nav button {
    min-height: 50px;
    padding: 0 12px;
    font-size: 0.9rem;
  }

  .content {
    gap: 16px;
  }

  .section-head {
    gap: 12px;
  }

  .section-head h2,
  .topbar h2 {
    font-size: 1.35rem;
  }

  .section-head p {
    font-size: 0.84rem;
    line-height: 1.45;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat strong {
    font-size: 1.7rem;
  }

  .grid-2,
  .grid-3,
  .photo-stack {
    gap: 12px;
  }

  .field input,
  .field select,
  .field textarea {
    min-height: 48px;
    padding: 12px 13px;
    font-size: 1rem;
  }

  .field textarea {
    min-height: 118px;
  }

  .panel,
  .item-card,
  .stat,
  .login-card {
    border-radius: 8px;
    padding: 12px;
  }

  .item-card {
    gap: 10px;
  }

  .checklist-meta {
    grid-template-columns: 1fr 1fr;
  }

  .checklist-actions .btn {
    min-height: 52px;
  }

  .row {
    gap: 8px;
  }

  .pill {
    min-height: 30px;
    white-space: normal;
    text-align: center;
  }

  .photo-box {
    gap: 10px;
  }

  .photo-box strong {
    font-size: 1rem;
  }

  .photo-box input[type="file"] {
    width: 100%;
  }

  .photo-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .photo-preview {
    width: 100%;
    min-width: 0;
    font-size: 0.76rem;
  }

  .photo-preview img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }

  .photo-preview span {
    overflow-wrap: anywhere;
  }

  .photo-viewer {
    padding: 12px;
  }

  .table-wrap tr {
    margin-bottom: 10px;
  }

  .table-wrap td {
    min-height: 0;
    padding: 9px 0;
  }

  .notice {
    padding: 12px;
    font-size: 0.92rem;
  }

  .qr-card img {
    width: 128px;
    height: 128px;
  }
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(0, 166, 81, 0.14), transparent 34rem),
    linear-gradient(135deg, #06110c 0%, var(--bg) 100%);
  color: var(--ink);
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .stat,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .item-card,
html[data-theme="dark"] .table-wrap tr,
html[data-theme="dark"] .report-export-group {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .brand-mark {
  background: #ffffff;
  border-color: rgba(255, 255, 255, .18);
}

html[data-theme="dark"] .topbar {
  background: rgba(7, 19, 13, 0.9);
}

html[data-theme="dark"] .topbar.operational-status-ok {
  background: linear-gradient(90deg, rgba(9, 72, 42, 0.96), rgba(7, 30, 19, 0.94));
  border-bottom-color: rgba(94, 220, 145, 0.38);
}

html[data-theme="dark"] .topbar.operational-status-alert {
  background: linear-gradient(90deg, rgba(112, 26, 26, 0.96), rgba(62, 20, 20, 0.94));
  border-bottom-color: rgba(255, 140, 140, 0.44);
}

html[data-theme="dark"] .operational-status-pill.ok {
  color: #b8f4ce;
  background: rgba(13, 91, 51, 0.85);
  border-color: rgba(94, 220, 145, 0.34);
}

html[data-theme="dark"] .operational-status-pill.alert {
  color: #ffe0e0;
  background: rgba(135, 36, 36, 0.86);
  border-color: rgba(255, 140, 140, 0.36);
}

html[data-theme="dark"] .sidebar {
  background: #0b1711;
}

@media (max-width: 900px) {
  html[data-theme="dark"] .sidebar {
    background: transparent;
    box-shadow: none;
  }

  html[data-theme="dark"] .app-shell.mobile-menu-open .sidebar {
    background: #0b1711;
    border-color: var(--line);
  }
}

html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .signature-pad,
html[data-theme="dark"] .signature-preview,
html[data-theme="dark"] .qr-card img,
html[data-theme="dark"] .photo-box input,
html[data-theme="dark"] .check-item,
html[data-theme="dark"] .template-item,
html[data-theme="dark"] .nav button.nav-group-toggle {
  background: #0b1711;
  color: var(--ink);
  border-color: var(--line);
}

html[data-theme="dark"] .btn {
  background: #182c21;
  color: var(--ink);
}

html[data-theme="dark"] .btn.primary {
  color: #ffffff;
  background: var(--brand);
}

html[data-theme="dark"] .btn.ghost,
html[data-theme="dark"] .icon-btn,
html[data-theme="dark"] .nav button.active,
html[data-theme="dark"] .nav button:hover,
html[data-theme="dark"] .nav button.nav-group-toggle.open,
html[data-theme="dark"] .checklist-meta span {
  background: var(--brand-soft);
  color: var(--ink);
}


html[data-theme="dark"] th,
html[data-theme="dark"] td {
  border-color: var(--line);
}

html[data-theme="dark"] .pill {
  background: #182c21;
  color: var(--ink);
  border-color: var(--line);
}

html[data-theme="dark"] .pill.ok {
  background: rgba(22, 163, 74, 0.18);
  color: #86efac;
}

html[data-theme="dark"] .pill.warn,
html[data-theme="dark"] .notice.warn {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.35);
}

html[data-theme="dark"] .pill.danger,
html[data-theme="dark"] .notice.danger {
  background: rgba(180, 35, 24, 0.18);
  color: #fca5a5;
  border-color: rgba(180, 35, 24, 0.35);
}
