@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --font-title: 'Cinzel', serif;
  --font-body: 'Manrope', sans-serif;
  --navy: #1d2a61;
  --navy-dark: #0b1338;
  --navy-soft: #273272;
  --gold: #c79b3a;
  --gold-strong: #b78122;
  --cream: #fbf7f0;
  --sand: #efe1cf;
  --ink: #0b122a;
  --slate: #455065;
  --success: #1f8a70;
  --danger: #b42318;
  --border: rgba(15, 23, 42, 0.12);
  --panel: rgba(255, 255, 255, 0.9);
  --glass: rgba(255, 255, 255, 0.7);
  --shadow: 0 30px 60px rgba(15, 23, 42, 0.16);
  --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.12);
  --radius: 22px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  min-height: 100vh;
  background: var(--cream);
  line-height: 1.6;
}

.ambient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 10% 20%, rgba(199, 155, 58, 0.22), transparent 45%),
    radial-gradient(circle at 80% 15%, rgba(29, 42, 97, 0.2), transparent 45%),
    radial-gradient(circle at 70% 85%, rgba(31, 138, 112, 0.18), transparent 45%),
    linear-gradient(130deg, #fffaf2, #efe1cf);
  z-index: -2;
}

.ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(120deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 60%),
    repeating-linear-gradient(90deg, rgba(15, 23, 42, 0.03) 0px, rgba(15, 23, 42, 0.03) 1px, transparent 1px, transparent 6px);
  opacity: 0.6;
}

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 80px;
  height: auto;
}

.brand-title {
  font-family: var(--font-title);
  font-size: 24px;
  letter-spacing: 1px;
  color: var(--navy-dark);
}

.brand-sub {
  color: var(--slate);
  font-size: 14px;
}

.masthead-info {
  background: rgba(255, 255, 255, 0.8);
  padding: 14px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.info-label {
  font-size: 11px;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.info-value {
  font-weight: 600;
  color: var(--navy);
}

.card,
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.card.login {
  max-width: 480px;
}

main {
  min-height: calc(100vh - 180px);
}

#login-view:not(.hidden) {
  width: min(480px, 100%);
  margin: auto;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 4px;
  font-family: var(--font-title);
}

.card p {
  margin: 0;
  color: var(--slate);
}

.helper {
  font-size: 13px;
  color: var(--slate);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  background: rgba(29, 42, 97, 0.1);
  color: var(--navy);
}

.pill.primary {
  background: rgba(199, 155, 58, 0.2);
  color: var(--navy-dark);
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

.sidebar {
  background: rgba(11, 19, 56, 0.95);
  border-radius: var(--radius);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: auto;
  align-self: start;
  box-shadow: var(--shadow);
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.logo-sm {
  width: 120px;
  filter: brightness(10);
}

.sidebar-title {
  font-family: var(--font-title);
  font-size: 16px;
  letter-spacing: 1px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.nav-item {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.4);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: auto;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(199, 155, 58, 0.85);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #0f1b4a;
}

.user-name {
  font-weight: 600;
}

.user-role {
  font-size: 12px;
  opacity: 0.8;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.crumb {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--slate);
}

.topbar h1 {
  margin: 6px 0 0;
  font-family: var(--font-title);
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.global-search {
  position: relative;
  flex: 1 1 220px;
  min-width: 220px;
}

.global-search input {
  width: 100%;
  padding-right: 36px;
  background: var(--panel);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  max-height: 280px;
  overflow: auto;
  z-index: 5;
}

.search-item {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  cursor: pointer;
  transition: background 0.2s ease;
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:hover {
  background: rgba(29, 42, 97, 0.06);
}

.search-label {
  font-weight: 600;
}

.search-meta {
  font-size: 12px;
  color: var(--slate);
}

.auth-fields {
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed rgba(15, 23, 42, 0.2);
  background: rgba(29, 42, 97, 0.04);
}

.auth-fields .helper {
  grid-column: 1 / -1;
  margin-top: -6px;
}

.view {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.view.active {
  display: flex;
  animation: rise 0.5s ease;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  padding: 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 10px;
}

.stat-card.warn {
  border-color: rgba(180, 35, 24, 0.3);
  background: rgba(255, 245, 244, 0.86);
}

.stat-card.accent {
  border-color: rgba(199, 155, 58, 0.35);
  background: rgba(255, 248, 236, 0.9);
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--slate);
}

.stat-trend {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(29, 42, 97, 0.08);
  color: var(--navy);
}

.stat-trend.up {
  background: rgba(31, 138, 112, 0.16);
  color: var(--success);
}

.stat-trend.down {
  background: rgba(180, 35, 24, 0.16);
  color: var(--danger);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy-dark);
}

.stat-sub {
  font-size: 13px;
  color: var(--slate);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.chart-card {
  display: grid;
  gap: 12px;
}

.list {
  display: grid;
  gap: 12px;
}

.list-item {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-item strong {
  display: block;
  font-size: 14px;
}

.list-meta {
  font-size: 12px;
  color: var(--slate);
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
  gap: 10px;
  align-items: end;
  min-height: 160px;
  margin-top: 12px;
}

.bar {
  height: calc(var(--value) * 1%);
  background: linear-gradient(180deg, rgba(199, 155, 58, 0.9), rgba(29, 42, 97, 0.85));
  border-radius: 12px 12px 6px 6px;
  position: relative;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.15);
}

.bar span {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--slate);
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--slate);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--navy);
}

.spark-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.spark-bar {
  display: grid;
  gap: 8px;
}

.spark-bar .bar {
  height: calc(var(--value) * 1%);
  border-radius: 12px;
}

.spark-label {
  font-size: 12px;
  color: var(--slate);
  text-align: center;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.panel-head h3 {
  margin: 0 0 4px;
  font-family: var(--font-title);
}

.panel-head p {
  margin: 0;
  color: var(--slate);
}

.panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filters {
  display: flex;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--slate);
  padding-bottom: 12px;
}

td {
  padding: 14px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

td .muted {
  color: var(--slate);
  font-size: 12px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid.two {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--slate);
}

.field-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.field-row input {
  flex: 1;
}

.field-row .btn {
  white-space: nowrap;
}

input,
select,
textarea {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
}

input[type='file'] {
  padding: 8px;
  background: rgba(255, 255, 255, 0.7);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(29, 42, 97, 0.12);
}

.toggle {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--navy), var(--navy-soft));
  color: #fff;
  box-shadow: 0 12px 24px rgba(29, 42, 97, 0.2);
}

.btn.primary:hover {
  transform: translateY(-1px);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(29, 42, 97, 0.2);
  color: var(--navy);
}

.sidebar .btn.ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn.ghost:hover {
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.pill.success {
  background: rgba(31, 138, 112, 0.18);
  color: var(--success);
}

.pill.danger {
  background: rgba(180, 35, 24, 0.15);
  color: var(--danger);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.modal {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(640px, 90vw);
  box-shadow: var(--shadow);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.icon-btn {
  border: none;
  background: rgba(15, 23, 42, 0.1);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.duration {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: rgba(29, 42, 97, 0.05);
  border-radius: 12px;
}

.manual-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.manual-field.hidden {
  display: none;
}

.duration input[type='number'] {
  max-width: 120px;
}

.due-preview {
  padding: 12px;
  background: rgba(199, 155, 58, 0.12);
  border-radius: 12px;
  font-size: 13px;
  color: var(--navy-dark);
}

.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--navy-dark);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none;
}

.mobile-nav {
  display: none;
}

.flash {
  animation: flash 1.6s ease;
  background: rgba(199, 155, 58, 0.18);
}

.login-view {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 28px;
  align-items: stretch;
}

.login-hero {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: grid;
  gap: 24px;
  min-height: 520px;
}

.hero-copy h1 {
  margin: 12px 0;
  font-family: var(--font-title);
  font-size: 36px;
  color: var(--navy-dark);
}

.hero-tag {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 12px;
  color: var(--slate);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.mini-stat {
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(29, 42, 97, 0.06);
  border: 1px solid rgba(29, 42, 97, 0.12);
}

.mini-stat span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--slate);
}

.mini-stat strong {
  font-size: 20px;
  color: var(--navy-dark);
}

.hero-quote {
  background: rgba(199, 155, 58, 0.12);
  border-radius: 18px;
  padding: 20px 24px;
  position: relative;
  color: var(--navy-dark);
}

.quote-mark {
  font-size: 32px;
  font-family: var(--font-title);
  color: var(--gold-strong);
  position: absolute;
  top: -12px;
  left: 16px;
}

.hero-quote p {
  margin: 0 0 8px;
  font-weight: 600;
}

.hero-quote span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--slate);
}

.login-panel {
  display: grid;
  gap: 18px;
  align-content: start;
}

.home-highlights {
  display: grid;
  gap: 12px;
}

.highlight-card {
  padding: 16px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: var(--shadow-soft);
}

.highlight-card h3 {
  margin: 0 0 6px;
  font-family: var(--font-title);
  font-size: 16px;
}

.highlight-card p {
  margin: 0;
  color: var(--slate);
  font-size: 13px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline.compact .timeline-item {
  padding: 10px 12px;
}

.timeline-item {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid rgba(15, 23, 42, 0.1);
  display: grid;
  gap: 6px;
}

.timeline-item strong {
  font-size: 14px;
}

.timeline-item .meta {
  font-size: 12px;
  color: var(--slate);
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.summary-card {
  padding: 16px;
  border-radius: 16px;
  background: rgba(29, 42, 97, 0.05);
  border: 1px solid rgba(29, 42, 97, 0.12);
}

.summary-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--slate);
}

.summary-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy-dark);
  margin-top: 6px;
}

.summary-sub {
  font-size: 12px;
  color: var(--slate);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.management-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.status-card {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 6px;
}

.status-label {
  text-transform: uppercase;
  letter-spacing: 1.4px;
  font-size: 11px;
  color: var(--slate);
}

.status-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy-dark);
}

.status-meta {
  font-size: 12px;
  color: var(--slate);
}

.action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.scan-box {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 1fr;
  gap: 16px;
  align-items: center;
}

.scan-video {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #0b1338;
  box-shadow: var(--shadow-soft);
  object-fit: cover;
}

.scan-meta {
  display: grid;
  gap: 8px;
}

.scan-status {
  font-weight: 600;
  color: var(--navy-dark);
}

.admin-only.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.print-area {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes flash {
  0% {
    background: rgba(199, 155, 58, 0.35);
  }
  100% {
    background: transparent;
  }
}

@media (max-width: 1200px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-hero {
    min-height: auto;
  }
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: auto;
  }

  .sidebar-top {
    flex-direction: row;
    align-items: center;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    margin-top: 0;
  }

  .sidebar-footer {
    flex-direction: row;
    align-items: center;
  }

  .user-chip {
    display: none;
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .content {
    padding-bottom: calc(110px + env(safe-area-inset-bottom));
  }

  .mobile-only {
    display: inline-flex;
  }

  .mobile-nav {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    display: flex;
    gap: 8px;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: rgba(11, 19, 56, 0.95);
    border-radius: 18px;
    box-shadow: var(--shadow);
    z-index: 20;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-nav .nav-item {
    flex: 0 0 auto;
    padding: 10px 12px;
    font-size: 12px;
    border-radius: 12px;
    border-color: rgba(255, 255, 255, 0.2);
  }

  .mobile-nav .nav-item.active {
    background: rgba(199, 155, 58, 0.28);
    border-color: rgba(199, 155, 58, 0.5);
    color: #fff;
  }

  .topbar-actions {
    gap: 8px;
  }

  .toast {
    right: 16px;
    left: 16px;
    bottom: 120px;
  }
}

@media (max-width: 720px) {
  .page {
    padding: 20px;
  }

  .masthead {
    flex-direction: column;
    align-items: flex-start;
  }

  .card.login {
    max-width: 100%;
  }

  .card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .global-search {
    width: 100%;
    min-width: 0;
  }

  .sidebar {
    padding: 16px;
    gap: 12px;
  }

  .sidebar-top {
    gap: 8px;
  }

  .nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-top: 8px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    white-space: nowrap;
    padding: 10px 12px;
    font-size: 13px;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .filters {
    flex-direction: column;
  }

  .filters input,
  .filters select {
    width: 100%;
  }

  .field-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .scan-box {
    grid-template-columns: 1fr;
  }

  .modal-body {
    padding: 20px;
  }

  .modal-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 0;
  }

  table thead {
    display: none;
  }

  table tbody tr {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  }

  table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0;
    border-bottom: none;
  }

  table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--slate);
  }

  table tbody td[colspan] {
    display: block;
  }

  table tbody td[colspan]::before {
    display: none;
    content: '';
  }

  table tbody td:last-child {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
  }

  .status-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero-copy h1 {
    font-size: 28px;
  }
}

@media (max-width: 520px) {
  .page {
    padding: 16px;
  }

  .card,
  .panel {
    padding: 18px;
  }

  .stat-value {
    font-size: 24px;
  }

  .modal {
    width: 94vw;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }
}

body[data-theme='classic'] {
}

body[data-theme='midnight'] {
  --navy: #21357d;
  --navy-dark: #090f24;
  --navy-soft: #2c448f;
  --gold: #8ba8ff;
  --gold-strong: #5f7cf0;
  --cream: #0c122b;
  --sand: #121a3c;
  --ink: #e8eeff;
  --slate: #b4c0ef;
  --success: #5ac49d;
  --danger: #ef7373;
  --border: rgba(200, 214, 255, 0.2);
  --panel: rgba(14, 24, 59, 0.92);
  --glass: rgba(20, 33, 74, 0.76);
  --shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.35);
}

body[data-theme='earth'] {
  --navy: #5f3f2f;
  --navy-dark: #3d261b;
  --navy-soft: #7a5642;
  --gold: #be8745;
  --gold-strong: #9f6c2e;
  --cream: #f6efe6;
  --sand: #eadcca;
  --ink: #2f2118;
  --slate: #6a5344;
  --success: #4a8d5a;
  --danger: #b54a3a;
  --border: rgba(62, 41, 29, 0.16);
  --panel: rgba(255, 252, 247, 0.9);
  --glass: rgba(250, 244, 236, 0.72);
}

body[data-theme='emerald'] {
  --navy: #0f3d36;
  --navy-dark: #07231f;
  --navy-soft: #146155;
  --gold: #2d9a7d;
  --gold-strong: #1f7e66;
  --cream: #eef8f3;
  --sand: #dff1e9;
  --ink: #0b2a24;
  --slate: #3f5f56;
  --success: #1d8f68;
  --danger: #b94747;
  --border: rgba(11, 42, 36, 0.14);
  --panel: rgba(251, 255, 253, 0.88);
  --glass: rgba(239, 249, 245, 0.72);
}

body[data-theme='sunset'] {
  --navy: #6b2330;
  --navy-dark: #3a1019;
  --navy-soft: #8f3244;
  --gold: #d26a43;
  --gold-strong: #b54e2d;
  --cream: #fff3ec;
  --sand: #f7ddcf;
  --ink: #3a141b;
  --slate: #6f4a4f;
  --success: #2c8f74;
  --danger: #af2433;
  --border: rgba(58, 20, 27, 0.14);
  --panel: rgba(255, 251, 248, 0.9);
  --glass: rgba(255, 244, 238, 0.74);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.theme-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--glass);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-card strong {
  font-size: 14px;
}

.theme-card .theme-meta {
  font-size: 12px;
  color: var(--slate);
}

.theme-card .theme-swatches {
  display: inline-flex;
  gap: 6px;
  margin-top: 4px;
}

.theme-card .theme-swatches i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sw);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.theme-card:hover {
  transform: translateY(-1px);
  border-color: rgba(199, 155, 58, 0.55);
}

.theme-card.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(199, 155, 58, 0.25);
}

#audit-table td {
  vertical-align: top;
}

#audit-table td small {
  color: var(--slate);
}

.inventory-filters {
  align-items: end;
}

.inventory-session {
  display: grid;
  gap: 6px;
  min-width: 240px;
}

.inventory-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

#inventory-status {
  margin-top: 12px;
}

#inventory-table input[type='number'],
#inventory-table input[type='text'] {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

#inventory-table input[type='number'] {
  min-width: 88px;
}

#inventory-table .inventory-book strong {
  display: block;
}

#inventory-table .inventory-book small {
  color: var(--slate);
}

.inventory-diff {
  font-weight: 700;
  display: inline-flex;
  min-width: 48px;
}

.inventory-diff.ok {
  color: var(--success);
}

.inventory-diff.warn {
  color: var(--danger);
}

@media (max-width: 720px) {
  .theme-grid {
    grid-template-columns: 1fr;
  }

  .inventory-session {
    min-width: 100%;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  .print-area,
  .print-area * {
    visibility: visible;
  }

  .print-area {
    display: block;
    position: absolute;
    inset: 20px;
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    border: 1px solid #ddd;
  }
}
