:root {
  --bg: #e8edf7;
  --bg-2: #f5f8ff;
  --panel: #edf2fb;
  --panel-strong: #e4ebf7;
  --text: #21324a;
  --muted: #64789a;
  --primary: #6d87ff;
  --primary-dark: #4f6fe8;
  --secondary: #7ce0f7;
  --success: #31b77c;
  --warning: #ffb84d;
  --danger: #ff7e7e;
  --shadow-dark: rgba(155, 169, 192, 0.58);
  --shadow-light: rgba(255, 255, 255, 0.9);
  --border: rgba(125, 142, 171, 0.12);
}

body[data-theme='outdoor'] {
  --bg: #f6f2db;
  --bg-2: #fffdf0;
  --panel: #fffdf4;
  --panel-strong: #f6eecb;
  --text: #1f2a1f;
  --muted: #4a5b45;
  --primary: #0b7a42;
  --primary-dark: #0a5e35;
  --secondary: #f0a62f;
  --success: #0c9d5d;
  --warning: #e68a00;
  --danger: #d93f3f;
  --shadow-dark: rgba(82, 77, 42, 0.24);
  --shadow-light: rgba(255, 255, 255, 0.95);
  --border: rgba(53, 69, 42, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(147, 171, 255, 0.2), transparent 30%),
    linear-gradient(135deg, var(--bg) 0%, #eff4fb 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1280px, calc(100% - 30px));
  margin: 38px auto;
}

.neumorph-card {
  background: linear-gradient(145deg, rgba(239, 244, 251, 0.98), rgba(224, 232, 245, 0.96));
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 14px 14px 28px var(--shadow-dark), -12px -12px 24px rgba(255,255,255,0.9);
}

body[data-theme='outdoor'] .neumorph-card {
  background: linear-gradient(145deg, rgba(255, 252, 246, 0.99), rgba(246, 240, 212, 0.98));
  border: 1px solid rgba(71, 87, 56, 0.2);
  box-shadow: 12px 12px 24px rgba(108, 102, 62, 0.18), -10px -10px 20px rgba(255,255,255,0.8);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px;
  margin-bottom: 22px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-size: 1.4rem;
  font-weight: 800;
  box-shadow: 10px 10px 22px rgba(89, 104, 194, 0.26);
}

.topbar h1 {
  margin: 5px 0 0;
  font-size: clamp(1.7rem, 2vw, 2.5rem);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(49, 183, 124, 0.12);
  color: var(--success);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px rgba(49, 183, 124, 0.9);
}

.soft-btn,
.accent-btn,
.primary-btn,
.close-btn {
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.soft-btn,
.accent-btn {
  padding: 11px 18px;
  border-radius: 14px;
  font-weight: 700;
}

.soft-btn {
  background: linear-gradient(145deg, #edf3ff, #dfeaf8);
  color: var(--text);
  box-shadow: 7px 7px 14px rgba(170, 181, 204, 0.25), -7px -7px 14px rgba(255,255,255,0.85);
}

.accent-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 10px 10px 18px rgba(93, 111, 211, 0.26);
}

.danger-btn {
  background: linear-gradient(145deg, #fff1f1, #f9dfe0);
  color: #a74848;
}

.primary-btn {
  grid-column: 1 / -1;
  appearance: none;
  border: none;
  border-radius: 18px;
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 10px 10px 20px rgba(76, 100, 182, 0.27), -8px -8px 18px rgba(255,255,255,0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 60px;
  position: relative;
  overflow: hidden;
}

.primary-btn .submit-progress {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border-radius: inherit;
}

.primary-btn .submit-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0.22), rgba(255,255,255,0.08));
  transition: width 0.2s ease;
}

.primary-btn .submit-progress-label {
  position: relative;
  z-index: 1;
  font-weight: 800;
}

.primary-btn.is-loading {
  padding-inline: 18px;
}

.primary-btn:disabled {
  opacity: 0.85;
  cursor: wait;
  transform: none;
}

.primary-btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: white;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

.sync-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.sync-meta {
  display: flex;
  flex-direction: column;
  min-width: 180px;
  gap: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.sync-meta strong {
  color: var(--text);
  font-size: 0.9rem;
}

.progress-track {
  position: relative;
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: rgba(111, 130, 170, 0.12);
  overflow: hidden;
  box-shadow: inset 4px 4px 8px rgba(163, 177, 198, 0.2), inset -4px -4px 8px rgba(255,255,255,0.7);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #70d7ff);
  transition: width 0.5s ease;
  box-shadow: 0 0 14px rgba(109, 135, 255, 0.42);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.soft-btn:hover,
.accent-btn:hover,
.primary-btn:hover,
.close-btn:hover {
  transform: translateY(-2px);
}

.nav-tabs {
  display: none !important;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.5fr 0.85fr;
  gap: 22px;
}

.panel {
  padding: 28px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  margin: 6px 0 0;
  font-size: 1.7rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
}

.full-width {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: none;
  outline: none;
  background: rgba(228, 235, 247, 1);
  color: var(--text);
  padding: 16px 18px;
  border-radius: 18px;
  box-shadow: inset 6px 6px 14px rgba(163, 177, 198, 0.25), inset -6px -6px 12px rgba(255,255,255,0.9);
}

body[data-theme='outdoor'] input,
body[data-theme='outdoor'] select,
body[data-theme='outdoor'] textarea {
  background: rgba(250, 247, 234, 0.96);
  border: 1px solid rgba(90, 110, 71, 0.2);
  box-shadow: inset 5px 5px 12px rgba(181, 172, 130, 0.18), inset -5px -5px 12px rgba(255,255,255,0.75);
}

input:focus,
select:focus,
textarea:focus {
  box-shadow: inset 6px 6px 14px rgba(163, 177, 198, 0.25), inset -6px -6px 12px rgba(255,255,255,0.9), 0 0 0 4px rgba(109, 135, 255, 0.12);
}

textarea {
  resize: vertical;
  min-height: 130px;
}

.summary-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-box {
  background: rgba(255,255,255,0.14);
  border-radius: 18px;
  padding: 18px 12px;
  text-align: center;
  box-shadow: inset 6px 6px 10px rgba(163,177,198,0.25), inset -6px -6px 10px rgba(255,255,255,0.72);
}

body[data-theme='outdoor'] .stat-box,
body[data-theme='outdoor'] .mini-list li {
  background: rgba(255, 255, 255, 0.2);
}

.stat-box strong {
  display: block;
  font-size: 1.7rem;
  margin-bottom: 6px;
}

.stat-box span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.mini-list {
  margin-top: 8px;
}

.mini-list h3 {
  margin-bottom: 12px;
  font-size: 1.08rem;
}

.mini-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.mini-list li {
  background: rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  box-shadow: inset 5px 5px 10px rgba(163,177,198,0.18), inset -5px -5px 10px rgba(255,255,255,0.7);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 30, 44, 0.26);
  backdrop-filter: blur(5px);
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: min(900px, calc(100% - 32px));
  max-height: 80vh;
  padding: 22px;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.4rem;
}

.close-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(145deg, #edf3ff, #dfeaf8);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  box-shadow: 7px 7px 12px rgba(170, 181, 204, 0.25), -7px -7px 12px rgba(255,255,255,0.85);
}

.table-wrap {
  overflow: auto;
  max-height: 60vh;
  border-radius: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(100, 120, 154, 0.12);
}

th {
  background: rgba(255,255,255,0.22);
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.04);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: rgba(34, 45, 60, 0.94);
  color: white;
  padding: 12px 18px;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.25s ease;
  box-shadow: 0 18px 32px rgba(19, 26, 38, 0.22);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.barcode-scan-panel {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

.scanner-box {
  position: relative;
  width: 100%;
  min-height: 220px;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.94);
  box-shadow: inset 6px 6px 16px rgba(0, 0, 0, 0.18), inset -8px -8px 18px rgba(255,255,255,0.05);
}

#barcodeVideo {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  background: #0f172a;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.08),
      rgba(255, 255, 255, 0) 18%,
      rgba(255, 255, 255, 0) 82%,
      rgba(255, 255, 255, 0.1)
    );
}

.scanner-overlay::before,
.scanner-overlay::after {
  content: "";
  position: absolute;
  width: 72px;
  height: 72px;
  border: 3px solid rgba(109, 135, 255, 0.9);
  border-radius: 16px;
}

.scanner-overlay::before {
  inset: 24px auto auto 24px;
  border-right: none;
  border-bottom: none;
}

.scanner-overlay::after {
  inset: auto 24px 24px auto;
  border-left: none;
  border-top: none;
}

.scanner-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.barcode-field {
  margin-top: 6px;
}

.barcode-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.barcode-hint strong {
  color: var(--text);
}

.welcome-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(124, 145, 255, 0.28), transparent 24%),
    radial-gradient(circle at bottom right, rgba(124, 224, 247, 0.28), transparent 22%),
    linear-gradient(135deg, #edf4ff 0%, #e7eefb 32%, #f2f6ff 100%);
}

.welcome-card {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: center;
  max-width: 680px;
  width: 100%;
  padding: 28px 28px 26px;
  border-radius: 32px;
  background: linear-gradient(135deg, rgba(245, 248, 255, 0.98), rgba(227, 234, 247, 0.96));
  border: 1px solid rgba(125, 142, 171, 0.12);
  box-shadow: 18px 18px 42px rgba(139, 154, 181, 0.2), -14px -14px 28px rgba(255, 255, 255, 0.9);
}

body[data-theme='outdoor'] .welcome-card {
  background: linear-gradient(135deg, rgba(255, 252, 246, 0.98), rgba(243, 235, 208, 0.98));
  border: 1px solid rgba(71, 87, 56, 0.2);
}

.welcome-visual {
  display: grid;
  place-items: center;
  min-height: 220px;
  border-radius: 26px;
  background: linear-gradient(135deg, rgba(109, 135, 255, 0.18), rgba(124, 224, 247, 0.12));
  border: 1px solid rgba(109, 135, 255, 0.14);
}

.welcome-icon {
  width: 112px;
  height: 112px;
  border-radius: 32px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark), var(--secondary));
  color: #fff;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  box-shadow: 0 22px 38px rgba(91, 112, 212, 0.28);
}

body[data-theme='outdoor'] .welcome-icon {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark), #d7a42a);
}

.welcome-content {
  padding-left: 18px;
  text-align: left;
}

.welcome-badge {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(109, 135, 255, 0.12);
  color: var(--primary-dark);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

body[data-theme='outdoor'] .welcome-badge {
  background: rgba(11, 122, 66, 0.12);
  color: var(--primary-dark);
}

.welcome-card h1 {
  margin: 18px 0 10px;
  font-size: clamp(2.1rem, 4vw, 3.1rem);
  line-height: 1.08;
}

.welcome-card p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1.04rem;
}

.welcome-select-block {
  margin-bottom: 18px;
}

.welcome-select-block span {
  display: block;
  margin-bottom: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.welcome-class-select {
  width: 100%;
  border: 1px solid rgba(109, 135, 255, 0.14);
  border-radius: 16px;
  padding: 15px 18px;
  background: rgba(233, 239, 250, 0.9);
  color: var(--text);
  font-weight: 700;
  box-shadow: inset 6px 6px 12px rgba(163, 177, 198, 0.18), inset -6px -6px 12px rgba(255,255,255,0.8);
}

body[data-theme='outdoor'] .welcome-class-select {
  background: rgba(249, 244, 223, 0.96);
  border: 1px solid rgba(90, 110, 71, 0.2);
}

.welcome-btn {
  width: 100%;
  margin-top: 6px;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 18px, 1200px);
    margin: 22px auto 36px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
  }

  .soft-btn,
  .accent-btn {
    flex: 1;
    text-align: center;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .scanner-actions {
    flex-direction: column;
  }

  .scanner-actions .soft-btn {
    width: 100%;
  }

  .welcome-screen {
    padding: 18px;
  }

  .welcome-card {
    grid-template-columns: 1fr;
    padding: 20px 20px 22px;
  }

  .welcome-visual {
    min-height: 160px;
  }

  .welcome-content {
    padding-left: 0;
    text-align: center;
  }
}

body[data-theme='outdoor'] .soft-btn,
body[data-theme='outdoor'] .accent-btn,
body[data-theme='outdoor'] .primary-btn,
body[data-theme='outdoor'] .close-btn {
  border: 1px solid rgba(89, 112, 71, 0.22);
  box-shadow: 0 12px 26px rgba(93, 108, 69, 0.14), inset 0 1px 0 rgba(255,255,255,0.45);
}

body[data-theme='outdoor'] .soft-btn {
  background: linear-gradient(145deg, #fffef7, #f4f0d9);
  color: var(--text);
}

body[data-theme='outdoor'] .accent-btn {
  background: linear-gradient(135deg, #0d8c55, #0b5c3d);
  color: #f8fff9;
}

body[data-theme='outdoor'] .primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark), #d69b2a);
  box-shadow: 0 16px 30px rgba(11, 122, 66, 0.22), inset 0 1px 0 rgba(255,255,255,0.34);
}

body[data-theme='outdoor'] .close-btn {
  background: linear-gradient(145deg, #fffef7, #f5efdc);
  color: var(--text);
}

body[data-theme='outdoor'] .topbar,
body[data-theme='outdoor'] .sync-bar,
body[data-theme='outdoor'] .panel,
body[data-theme='outdoor'] .summary-panel,
body[data-theme='outdoor'] .welcome-card,
body[data-theme='outdoor'] .modal-content {
  border: 1px solid rgba(82, 97, 70, 0.18);
  box-shadow: 16px 16px 36px rgba(108, 102, 62, 0.16), -12px -12px 24px rgba(255,255,255,0.8);
}

body[data-theme='outdoor'] .panel,
body[data-theme='outdoor'] .summary-panel {
  background: linear-gradient(145deg, rgba(255, 252, 246, 0.99), rgba(247, 240, 218, 0.98));
}

body[data-theme='outdoor'] .stat-box,
body[data-theme='outdoor'] .mini-list li,
body[data-theme='outdoor'] .table-wrap {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(82, 97, 70, 0.1);
}

body[data-theme='outdoor'] th {
  background: rgba(255,255,255,0.3);
}

body[data-theme='outdoor'] .scanner-box {
  border: 1px solid rgba(82, 97, 70, 0.18);
  box-shadow: inset 6px 6px 16px rgba(0, 0, 0, 0.18), inset -8px -8px 18px rgba(255,255,255,0.06);
}

body[data-theme='outdoor'] .scanner-overlay::before,
body[data-theme='outdoor'] .scanner-overlay::after {
  border-color: rgba(11, 122, 66, 0.9);
}

body[data-theme='outdoor'] .welcome-class-select,
body[data-theme='outdoor'] .welcome-btn,
body[data-theme='outdoor'] .welcome-select-block select {
  background: rgba(248, 244, 225, 0.96);
}

body[data-theme='outdoor'] .welcome-icon {
  box-shadow: 0 20px 38px rgba(11, 122, 66, 0.22);
}
