:root,
[data-theme="neon"] {
  --ink: #e8f7fb;
  --muted: #8eb4bd;
  --line: rgba(34, 224, 255, 0.38);
  --paper: #070b10;
  --card: #0c1622;
  --copper: #22e0ff;
  --copper-dark: #06b6d4;
  --accent-ink: #041018;
  --accent-hover: #7af3ff;
  --nav: rgba(5, 8, 12, 0.92);
  --nav-link: #d7f7fc;
  --field: #071018;
  --placeholder: #6f9098;
  --option: #0c1622;
  --stat: #ffffff;
  --shadow: 0 0 0 1px rgba(34, 224, 255, 0.05), 0 0 28px rgba(34, 224, 255, 0.08);
  --btn-shadow: 0 0 18px rgba(34, 224, 255, 0.28);
  --focus: rgba(34, 224, 255, 0.45);
  --table-line: rgba(34, 224, 255, 0.18);
  --ghost-hover: rgba(34, 224, 255, 0.12);
  --ghost-ink: #ffffff;
  --private-bg: rgba(34, 224, 255, 0.06);
  --private-line: rgba(34, 224, 255, 0.4);
  --photo-bg: #071018;
  --circuit: url("../img/circuit.svg");
  --body: radial-gradient(900px 420px at 100% -10%, rgba(34, 224, 255, 0.12), transparent 55%), linear-gradient(180deg, #101820 0%, #070b10 280px);
  color-scheme: dark;
}

[data-theme="classic"] {
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --paper: #f6f3ee;
  --card: #fffdf8;
  --copper: #c2410c;
  --copper-dark: #9a3412;
  --accent-ink: #ffffff;
  --accent-hover: #9a3412;
  --nav: #1c1917;
  --nav-link: #f5f5f4;
  --field: #ffffff;
  --placeholder: #a8a29e;
  --option: #fffdf8;
  --stat: #1c1917;
  --shadow: 0 1px 0 rgba(28, 25, 23, 0.04);
  --btn-shadow: none;
  --focus: rgba(194, 65, 12, 0.35);
  --table-line: #e7e5e4;
  --ghost-hover: #f5f5f4;
  --ghost-ink: #1c1917;
  --private-bg: #fff7ed;
  --private-line: #fdba74;
  --photo-bg: #e7e5e4;
  --circuit: none;
  --body: #f6f3ee;
  color-scheme: light;
}

[data-theme="slate"] {
  --ink: #e8eef5;
  --muted: #93a4b8;
  --line: rgba(148, 176, 212, 0.35);
  --paper: #12161c;
  --card: #1b222c;
  --copper: #8eb4e8;
  --copper-dark: #6f9ad4;
  --accent-ink: #10141a;
  --accent-hover: #d5e6fa;
  --nav: #0e1319;
  --nav-link: #d5deea;
  --field: #121820;
  --placeholder: #7e8da1;
  --option: #1b222c;
  --stat: #ffffff;
  --shadow: none;
  --btn-shadow: none;
  --focus: rgba(142, 180, 232, 0.45);
  --table-line: rgba(148, 176, 212, 0.22);
  --ghost-hover: rgba(142, 180, 232, 0.12);
  --ghost-ink: #ffffff;
  --private-bg: rgba(142, 180, 232, 0.08);
  --private-line: rgba(142, 180, 232, 0.4);
  --photo-bg: #121820;
  --circuit: none;
  --body: #12161c;
  color-scheme: dark;
}

[data-theme="daylight"] {
  --ink: #142033;
  --muted: #5c6b80;
  --line: #d5deea;
  --paper: #f4f7fb;
  --card: #ffffff;
  --copper: #1d4e89;
  --copper-dark: #163e6e;
  --accent-ink: #ffffff;
  --accent-hover: #163e6e;
  --nav: #142033;
  --nav-link: #e8eef5;
  --field: #ffffff;
  --placeholder: #8aa0b8;
  --option: #ffffff;
  --stat: #142033;
  --shadow: 0 1px 0 rgba(20, 32, 51, 0.04);
  --btn-shadow: none;
  --focus: rgba(29, 78, 137, 0.35);
  --table-line: #d5deea;
  --ghost-hover: #e8eef5;
  --ghost-ink: #142033;
  --private-bg: #eef4fb;
  --private-line: #9eb6d4;
  --photo-bg: #e8eef5;
  --circuit: none;
  --body: #f4f7fb;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--body);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 16px;
}

a { color: var(--copper); }

.app-nav {
  background: var(--nav);
  color: white;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.nav-inner, .page {
  width: min(1100px, calc(100% - 1.5rem));
  margin: 0 auto;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(1100px, 100%);
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  text-decoration: none;
  background: #05080c;
  border-radius: 14px;
  padding: 0.1rem 0.35rem;
}

.brand-logo {
  display: block;
  height: 74px;
  width: auto;
  max-width: min(220px, 42vw);
  object-fit: contain;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.8rem;
  align-items: center;
  justify-content: flex-end;
}

.nav-links a {
  color: var(--nav-link);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav-links a:hover { color: var(--copper); }

.badge-count {
  background: var(--copper);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.75rem;
}

.page { padding: 1.25rem 0 3rem; }

.card, .stat, .empty-card, .login-card {
  background-color: var(--card);
  background-image: var(--circuit);
  background-repeat: no-repeat;
  background-position: right top;
  background-size: 220px auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card { width: min(420px, 100%); text-align: center; }
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.7rem; }
.login-card label,
.login-card .help,
.login-card .flash { text-align: left; }
.login-logo {
  display: block;
  width: min(210px, 72%);
  height: auto;
  margin: 0 auto 0.4rem;
  background: #05080c;
  border-radius: 16px;
  padding: 0.45rem;
}
.login-captcha {
  display: block;
  width: 220px;
  height: 72px;
  margin: 0.15rem 0 0.45rem;
  border-radius: 8px;
  background: #fff48c;
}
.eyebrow {
  color: var(--copper);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.grid-stats, .split, .photo-grid {
  display: grid;
  gap: 0.8rem;
}

.grid-stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.split { grid-template-columns: 1fr; }
.photo-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.stat strong { display: block; font-size: 1.7rem; margin-top: 0.2rem; color: var(--stat); }
.stat span, .muted { color: var(--muted); }

label { display: block; font-size: 0.92rem; margin-bottom: 0.25rem; }
input, select, textarea, button {
  font: inherit;
  font-size: 16px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  margin-bottom: 0.75rem;
}
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus);
  border-color: var(--copper);
}
select option { background: var(--option); color: var(--ink); }
.check-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.2rem 0 0.4rem;
}
.check-line input {
  width: auto;
  margin: 0;
}
textarea { min-height: 90px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  min-height: 46px;
  text-decoration: none;
  cursor: pointer;
  background: var(--copper);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: var(--btn-shadow);
}
.btn:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn.secondary { background: #123042; color: var(--ink); }
.btn.ghost {
  background: transparent;
  color: var(--copper);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--ghost-hover); color: var(--ghost-ink); }
.btn.small { min-height: 36px; padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn.block { width: 100%; }

.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
details.fold > summary { cursor: pointer; font-weight: 700; margin: 0.45rem 0; }
.till-slip { margin: 0.7rem 0; }
.till-slip p { display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; margin: 0.35rem 0; }
.stack { display: grid; gap: 0.8rem; }
.section-title { margin: 1.4rem 0 0.6rem; font-size: 1.15rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.65rem 0.4rem; border-bottom: 1px solid var(--table-line); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.flash { padding: 0.75rem 0.9rem; border-radius: 10px; margin-bottom: 0.8rem; }
.flash.success { background: rgba(16, 80, 70, 0.55); color: #b7fff0; }
.flash.danger { background: rgba(127, 29, 29, 0.45); color: #fecdd3; }
.flash.warning { background: rgba(120, 53, 15, 0.45); color: #fde68a; }
.flash.lockout {
  background: #fde047;
  color: #713f12;
  border: 2px solid #eab308;
  font-weight: 700;
}
.flash.info { background: rgba(34, 224, 255, 0.1); }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  background: rgba(34, 224, 255, 0.08);
  color: var(--ink);
  border: 1px solid transparent;
}
.pill.active { background: rgba(34, 224, 255, 0.16); color: #b6fbff; border-color: rgba(34, 224, 255, 0.45); }
.pill.pending { background: rgba(251, 191, 36, 0.15); color: #fde68a; }
.pill.rejected { background: rgba(244, 63, 94, 0.15); color: #fecdd3; }
.pill.invoiced { background: rgba(56, 189, 248, 0.15); color: #bae6fd; }
.pill.closed { background: rgba(148, 163, 184, 0.15); color: #e2e8f0; }
.pill.approved { background: rgba(52, 211, 153, 0.15); color: #a7f3d0; }

.private {
  background: var(--private-bg);
  border: 1px dashed var(--private-line);
  border-radius: 12px;
  padding: 0.8rem;
}
.private h2 { margin: 0 0 0.4rem; font-size: 1rem; }

.photo-grid img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--photo-bg);
}
.code-box.compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.unit-serials { margin-top: 0.8rem; }
.unit-serials .row-actions { margin-top: 0.35rem; }
.code-box.compact input {
  width: 9rem;
  margin: 0;
}
.bill-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.7rem;
}
.bill-photos figure { margin: 0; }
.bill-photos .photo-open { width: 276px; }
.bill-photos img {
  width: 276px;
  height: 220px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
}

.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 680px; }
.help { color: var(--muted); font-size: 0.9rem; margin-top: 0; }

.inventory-head {
  margin-bottom: 0.85rem;
  text-align: left;
}
.inventory-head h1 { margin: 0; font-weight: 700; }
.inventory-totals { margin: 0.35rem 0 0; text-align: left; }
.inventory-totals div { font-weight: 700; }
.inventory-grand { font-size: 1.2rem; }
.inventory-totals span { display: block; font-weight: 400; color: var(--muted); font-size: 0.85rem; }

.inventory-table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}
.inventory-table th,
.inventory-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--table-line);
  font-weight: 400;
}
.inventory-table thead th,
.inventory-table tfoot th,
.inventory-table tfoot td {
  font-weight: 700;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.95rem;
}
.inventory-table tbody tr:last-child td { border-bottom: 1px solid var(--table-line); }
.inventory-table .sub {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}
.inventory-table tr.is-hidden td { color: var(--muted); }
.inventory-table details summary { cursor: pointer; }
.inventory-table details form { margin-top: 0.6rem; }
.inventory-add { margin-top: 0.8rem; }

@media (max-width: 720px) {
  .app-nav { padding: 0.65rem 0.75rem 0.45rem; }
  .nav-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }
  .brand-logo {
    height: 88px;
    max-width: min(180px, 62vw);
  }
  .nav-links {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    width: 100%;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
  }
  .nav-links a { white-space: nowrap; }
  .page, .nav-inner { width: min(1100px, calc(100% - 1rem)); }
  .card, .stat, .login-card { padding: 0.85rem; }
  h1 { font-size: 1.4rem; }
  .login-logo { width: min(180px, 68%); }
}

[data-theme="classic"] .pill.active,
[data-theme="daylight"] .pill.active { background: #ecfdf3; color: #166534; border-color: transparent; }
[data-theme="classic"] .pill.pending,
[data-theme="daylight"] .pill.pending { background: #fff7ed; color: #9a3412; }
[data-theme="classic"] .pill.rejected,
[data-theme="daylight"] .pill.rejected { background: #fff1f2; color: #9f1239; }
[data-theme="classic"] .pill.invoiced,
[data-theme="daylight"] .pill.invoiced { background: #e0f2fe; color: #075985; }
[data-theme="classic"] .pill.closed,
[data-theme="daylight"] .pill.closed { background: #f5f5f4; color: #44403c; }
[data-theme="classic"] .pill.approved,
[data-theme="daylight"] .pill.approved { background: #ecfdf3; color: #166534; }

.theme-pick {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  flex: 0 0 auto;
  color: var(--nav-link);
  font-size: 0.85rem;
}
.theme-pick.on-card {
  justify-content: center;
  color: var(--ink);
  margin: 0 auto 0.6rem;
}
.theme-pick select {
  width: auto;
  min-width: 7.2rem;
  margin: 0;
  min-height: 36px;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

@media (max-width: 720px) {
  .nav-inner { display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .nav-links { grid-column: 1 / -1; }
  .theme-pick select { min-width: 6.4rem; }
}

@media (min-width: 860px) {
  .split { grid-template-columns: 1.1fr 0.9fr; align-items: start; }
  .page { padding-top: 1.6rem; }
  .brand-logo { height: 84px; }
}

.code-preview {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.55rem;
  padding: 0.4rem;
  background: #fff;
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
}
.code-preview[hidden] { display: none; }
.code-bars { width: min(220px, 58vw); height: auto; }
.code-qr { width: 96px; height: 96px; flex: 0 0 auto; }
.code-qr img, .code-qr canvas { width: 96px !important; height: 96px !important; }
.code-print[hidden] { display: none; }
.code-scan-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.code-scan-panel[hidden] { display: none; }
.code-scan-sheet {
  width: min(520px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--card);
  color: var(--ink);
  border-radius: 18px 18px 0 0;
  padding: 0.9rem 0.9rem 1.2rem;
}
#code-reader { min-height: 180px; }
#code-reader video { width: 100% !important; border-radius: 12px; }
.code-photo { position: relative; margin-top: 0.35rem; }
.item-line { display: flex; gap: 0.55rem; align-items: flex-start; }
.item-line details { flex: 1; min-width: 0; }
.item-thumb-btn {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
}
.item-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: #fff;
}
.item-photo-pop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1rem;
}
.item-photo-pop[hidden] { display: none; }
.photo-frame {
  position: relative;
  max-width: min(920px, 92vw);
}
.item-photo-pop img {
  display: block;
  max-width: 100%;
  max-height: 86vh;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
}
.photo-x {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  width: 52px;
  height: 52px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.photo-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.code-photo input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}
