:root {
  color-scheme: dark;
  --bg: #101827;
  --surface: #162033;
  --surface-2: #1d2a42;
  --text: #edf5ff;
  --muted: #9fb0c7;
  --line: rgba(255, 255, 255, .1);
  --primary: #2dd4bf;
  --primary-2: #60a5fa;
  --danger: #fb7185;
  --success: #34d399;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(45, 212, 191, .16), transparent 34rem), var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  outline: none;
}
select {
  appearance: none;
  background-color: var(--surface-2);
  color: var(--text);
  color-scheme: dark;
}
select:focus, input:focus, textarea:focus {
  border-color: color-mix(in srgb, var(--primary) 72%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
select option, select optgroup {
  background: #162033;
  color: #edf5ff;
}
select option:checked, select option:hover {
  background: #2dd4bf;
  color: #06121f;
}
.theme-light select {
  background-color: var(--surface);
  color: var(--text);
  color-scheme: light;
}
.theme-light select option, .theme-light select optgroup {
  background: #ffffff;
  color: #182235;
}
.theme-light select option:checked, .theme-light select option:hover {
  background: #d9f7f2;
  color: #182235;
}
textarea { min-height: 110px; resize: vertical; }
label { display: grid; gap: 8px; color: var(--muted); font-weight: 700; font-size: .9rem; }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input { width: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; }

.theme-light {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #182235;
  --muted: #60708a;
  --line: rgba(24, 34, 53, .12);
  --shadow: 0 16px 42px rgba(29, 42, 66, .12);
}
.auth-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px;
}
.auth-shell {
  width: min(420px, calc(100vw - 32px));
  max-width: 420px;
}
.auth-card, .panel, .action-card, .scanner-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .025)), var(--surface);
  box-shadow: var(--shadow);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 28px;
  overflow: hidden;
}
.brand-mark, .brand-fallback, .card-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #06121f;
  font-weight: 900;
}
.brand-mark {
  width: 72px;
  height: 72px;
  max-width: 72px;
  max-height: 72px;
  overflow: hidden;
  font-size: 1.05rem;
  line-height: 1;
}
.brand-logo, .auth-logo, .dashboard-logo {
  display: block;
  object-fit: contain;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}
.auth-logo {
  width: 72px;
  height: 72px;
  max-width: 72px;
  max-height: 72px;
}
.dashboard-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 10px;
}
.auth-card h1, .page-head h1 { margin: 12px 0 4px; }
.muted, .muted-link { color: var(--muted); }
.inline-actions { display: flex; gap: 12px; margin-top: 18px; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 14px; }
.btn {
  border: 0;
  border-radius: 8px;
  min-height: 52px;
  padding: 14px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  text-align: center;
  line-height: 1.15;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #06121f; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-small { min-height: 44px; padding: 10px 14px; font-size: .86rem; }
.alert { border-radius: 8px; padding: 14px 16px; margin: 12px 0; font-weight: 900; font-size: 1rem; }
.alert-success { background: rgba(52, 211, 153, .14); color: var(--success); }
.alert-danger { background: rgba(251, 113, 133, .14); color: var(--danger); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-fallback { width: 34px; height: 34px; border-radius: 8px; }
.top-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; min-width: 0; }
.pill, .badge, .icon-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .06);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--text);
  font-weight: 800;
  font-size: .82rem;
}
.pill { min-height: 42px; display: inline-flex; align-items: center; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; }
.content { width: min(1120px, 100%); margin: 0 auto; padding: 18px 16px 96px; }
.page-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.page-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.eyebrow { margin: 0; color: var(--primary); text-transform: uppercase; font-size: .72rem; font-weight: 900; }
.quick-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.action-card { min-height: 144px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; }
.action-card strong { font-size: 1.08rem; line-height: 1.25; }
.action-card .card-icon { width: 54px; height: 54px; font-size: 1.05rem; }
.panel { padding: 16px; margin-bottom: 16px; }
.simple-intro h2 { margin: 0 0 6px; font-size: 1.45rem; }
.simple-intro p { margin: 0; font-size: 1rem; }
.dashboard-section-title { margin: 18px 0 10px; color: var(--muted); font-size: .9rem; font-weight: 900; text-transform: uppercase; }
.details-panel summary {
  list-style: none;
  cursor: pointer;
}
.details-panel summary::-webkit-details-marker { display: none; }
.details-panel[open] summary { margin-bottom: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-actions form { margin: 0; }
.search-form { flex: 1; min-width: 220px; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-flex; padding: 5px 9px; font-size: .72rem; color: var(--muted); }
.nav-badge, .count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
}
.status-ok { color: var(--success); }
.status-due_soon { color: #fbbf24; }
.status-expired { color: var(--danger); }
.choice-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.choice-card {
  min-height: 118px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 900;
  font-size: 1.1rem;
  line-height: 1.22;
  cursor: pointer;
}
.wizard-shell { max-width: 720px; margin: 0 auto; }
.wizard-shell h2 { margin: 0; }
.wizard-shell h3 { margin: 4px 0 10px; font-size: 1.45rem; line-height: 1.2; }
.wizard-help { margin: -4px 0 8px; }
.wizard-choice-panel, .wizard-scanner, .photo-actions {
  display: grid;
  gap: 12px;
}
.wizard-scanner[hidden] { display: none; }
.file-choice input { display: none; }
.big-input { font-size: 1.2rem; padding: 16px; }
.results-grid { display: grid; gap: 12px; }
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  display: grid;
  gap: 12px;
}
.result-card-head { display: flex; gap: 12px; align-items: flex-start; }
.stock-list { display: grid; gap: 4px; color: var(--muted); font-size: .9rem; }
.lookup-card { display: grid; gap: 10px; }
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(18px);
}
.bottom-nav a { display: grid; gap: 3px; place-items: center; padding: 10px 4px; color: var(--muted); font-size: .76rem; font-weight: 900; min-height: 58px; }
.bottom-nav span { font-size: 1.1rem; color: var(--text); }
.scanner-box { padding: 16px; display: grid; gap: 14px; }
.scanner-video { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; background: #050b14; }
.scanner-video video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border-radius: 8px;
}
.scanner-video > div {
  border: 0 !important;
}
.wizard-steps { display: grid; gap: 14px; }
.custom-fields-wrap { display: grid; gap: 12px; }
.custom-fields-wrap h3 { margin: 0; }
.field-hint { color: var(--muted); font-size: .78rem; font-weight: 800; }
.thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.thumb-placeholder {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 900;
}
.media-row { display: flex; gap: 12px; align-items: center; }
.preview-image {
  width: min(220px, 100%);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}

@media (max-width: 759px) {
  .auth-page {
    align-items: center;
    padding: 20px 16px 28px;
  }
  .auth-card { padding: 22px; }
  .brand-mark {
    width: 64px;
    height: 64px;
    max-width: 64px;
    max-height: 64px;
  }
  .auth-logo {
    width: 64px;
    height: 64px;
    max-width: 64px;
    max-height: 64px;
  }
  .topbar {
    padding: 10px 12px;
    align-items: center;
  }
  .brand {
    flex: 1 1 auto;
    max-width: 46vw;
    font-size: .92rem;
    gap: 8px;
  }
  .brand-logo {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
  }
  .brand-fallback {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
  }
  .top-actions {
    flex: 0 1 auto;
    gap: 6px;
  }
  .top-actions .pill {
    max-width: 112px;
    min-height: 38px;
    padding: 8px 9px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .74rem;
  }
  .top-actions .icon-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
  }
  .page-head { display: grid; gap: 12px; }
  .page-actions { justify-content: stretch; }
  .page-actions .btn, .page-actions .pill { flex: 1; }
  .toolbar { align-items: stretch; }
  .toolbar .btn, .toolbar a.btn { width: 100%; }
  .row-actions .btn, .row-actions a.btn { flex: 1 1 140px; }
  .table-wrap { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
  th, td { padding: 14px 12px; }
}

@media (min-width: 760px) {
  .quick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-nav { display: none; }
  .content { padding-bottom: 32px; }
}
