:root {
  --brand-bg-900: #1f2a24;
  --brand-bg-860: #24332c;
  --brand-bg-820: #2d4037;
  --brand-bg-780: #354940;
  --brand-text-100: #f6efdf;
  --brand-text-180: #efe6d4;
  --brand-text-220: #dfd3be;
  --brand-text-320: #b8ab95;
  --brand-accent-red: #d85050;
  --brand-accent-blue: #4f84ab;
  --brand-accent-gold: #c7a464;

  --surface-100: rgba(255, 255, 255, 0.07);
  --surface-200: rgba(255, 255, 255, 0.11);
  --surface-300: rgba(255, 255, 255, 0.15);
  --surface-border: rgba(246, 239, 223, 0.24);
  --success: #4db073;
  --warning: #d9ad4f;
  --danger: #d85050;

  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 13px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Libre Franklin", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--brand-text-100);
  line-height: 1.45;
  background:
    radial-gradient(circle at 6% 6%, rgba(79, 132, 171, 0.18), transparent 30%),
    radial-gradient(circle at 92% 12%, rgba(216, 80, 80, 0.12), transparent 34%),
    radial-gradient(circle at 40% 120%, rgba(199, 164, 100, 0.08), transparent 40%),
    linear-gradient(155deg, #17211c, var(--brand-bg-900) 40%, #111a16);
}

a {
  color: var(--brand-text-100);
}

.page-shell {
  width: min(960px, 94vw);
  margin: 1.35rem auto 2.5rem;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  padding: 0.95rem 1.05rem;
  background:
    linear-gradient(140deg, rgba(47, 71, 63, 0.84), rgba(34, 49, 42, 0.7));
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(4px);
}

.brand-logo {
  width: 66px;
  height: 66px;
  border-radius: 999px;
  border: 1px solid rgba(248, 240, 224, 0.24);
  background: rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
  min-width: 0;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}

.brand-title {
  margin: 0;
  font-size: clamp(1.18rem, 1.8vw, 1.42rem);
  letter-spacing: 0.01em;
  color: var(--brand-text-180);
}

.brand-subtitle {
  margin: 0;
  color: var(--brand-text-320);
  font-size: 0.92rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.86rem;
}

.nav-chip {
  text-decoration: none;
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 0.42rem 0.78rem;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--brand-text-220);
  background: rgba(0, 0, 0, 0.14);
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease,
    color 0.18s ease;
}

.nav-chip:hover,
.nav-chip:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(79, 132, 171, 0.82);
  background: rgba(79, 132, 171, 0.18);
  color: var(--brand-text-100);
}

.nav-chip.active {
  border-color: rgba(79, 132, 171, 0.78);
  color: var(--brand-text-100);
  background: rgba(79, 132, 171, 0.23);
}

.panel {
  margin-top: 1.02rem;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  background: var(--surface-100);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.25s ease;
}

h1,
h2,
h3 {
  margin: 0 0 0.56rem;
  letter-spacing: 0.01em;
}

h2 {
  font-size: clamp(1.36rem, 2vw, 1.86rem);
}

h3 {
  font-size: 1.08rem;
}

p {
  margin: 0 0 0.65rem;
  color: var(--brand-text-220);
}

.small-note {
  color: var(--brand-text-320);
  font-size: 0.87rem;
  line-height: 1.42;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.95rem;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

.action-card {
  display: block;
  text-decoration: none;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 0.95rem;
  background: rgba(0, 0, 0, 0.16);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

a.action-card,
button.action-card {
  cursor: pointer;
}

a.action-card:hover,
a.action-card:focus-visible,
button.action-card:hover,
button.action-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(79, 132, 171, 0.82);
  background: rgba(79, 132, 171, 0.16);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

.action-card h3 {
  margin: 0 0 0.3rem;
  color: var(--brand-text-100);
}

.action-card p {
  margin: 0;
  color: var(--brand-text-220);
}

.stat-card {
  display: block;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 0.95rem;
  background: rgba(0, 0, 0, 0.16);
}

.stat-card h3 {
  margin: 0 0 0.3rem;
  color: var(--brand-text-100);
}

.stat-card p {
  margin: 0;
  color: var(--brand-text-220);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.34rem;
}

label {
  font-size: 0.91rem;
  color: var(--brand-text-220);
}

input,
textarea,
select {
  width: 100%;
  color: var(--brand-text-100);
  background: rgba(8, 15, 12, 0.44);
  border: 1px solid rgba(248, 240, 224, 0.26);
  border-radius: var(--radius-sm);
  padding: 0.68rem 0.74rem;
  font-size: 0.98rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input::placeholder {
  color: rgba(232, 224, 208, 0.58);
}

input:hover,
textarea:hover,
select:hover {
  border-color: rgba(248, 240, 224, 0.34);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(79, 132, 171, 0.9);
  box-shadow: 0 0 0 3px rgba(79, 132, 171, 0.22);
  background: rgba(8, 15, 12, 0.52);
}

button,
.btn-primary,
.btn-secondary,
.btn-danger {
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 0.64rem 0.96rem;
  font-size: 0.95rem;
  font-weight: 650;
  text-decoration: none;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.btn-primary {
  color: var(--brand-text-100);
  background: linear-gradient(130deg, #497a9d, #335d7c);
  border-color: rgba(79, 132, 171, 0.9);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(24, 40, 51, 0.28);
}

.btn-secondary {
  color: var(--brand-text-180);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(248, 240, 224, 0.27);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(248, 240, 224, 0.36);
}

.btn-danger {
  color: var(--brand-text-100);
  background: rgba(216, 80, 80, 0.25);
  border-color: rgba(216, 80, 80, 0.62);
}

.btn-danger:hover,
.btn-danger:focus-visible {
  transform: translateY(-1px);
  background: rgba(216, 80, 80, 0.34);
}

.btn-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

a.btn-primary,
a.btn-secondary,
a.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
  box-shadow: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(199, 164, 100, 0.9);
  outline-offset: 2px;
}

.badge {
  display: inline-block;
  width: fit-content;
  padding: 0.28rem 0.58rem;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  color: var(--brand-text-220);
  background: rgba(0, 0, 0, 0.14);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

.stage-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.stage-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(248, 240, 224, 0.2);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  color: var(--brand-text-320);
  background: rgba(0, 0, 0, 0.12);
}

.stage-chip.active {
  color: var(--brand-text-100);
  border-color: rgba(79, 132, 171, 0.8);
  background: rgba(79, 132, 171, 0.24);
}

.state {
  margin-top: 0.2rem;
  min-height: 1.35rem;
  color: var(--brand-text-220);
  font-size: 0.93rem;
}

.state.error {
  color: #f3b5b5;
}

.state.success {
  color: #bde7cb;
}

.result-card {
  margin-top: 0.9rem;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 0.95rem;
  background: rgba(0, 0, 0, 0.16);
}

.result-card.success {
  border-color: rgba(77, 176, 115, 0.65);
  background: rgba(77, 176, 115, 0.11);
}

.result-card.warning {
  border-color: rgba(217, 173, 79, 0.62);
  background: rgba(217, 173, 79, 0.1);
}

.result-card.error {
  border-color: rgba(216, 80, 80, 0.62);
  background: rgba(216, 80, 80, 0.1);
}

.result-title {
  margin-bottom: 0.44rem;
  font-size: 1.03rem;
}

.kv {
  display: grid;
  grid-template-columns: minmax(126px, 206px) 1fr;
  gap: 0.34rem 0.64rem;
  font-size: 0.93rem;
}

.kv-key {
  color: var(--brand-text-320);
}

.kv-val {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.qr-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 310px;
  border: 1px dashed rgba(248, 240, 224, 0.26);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 12% 15%, rgba(79, 132, 171, 0.12), transparent 42%),
    rgba(0, 0, 0, 0.17);
}

.qr-canvas {
  width: min(310px, 82vw);
  background: linear-gradient(145deg, #ffffff, #f4f4f4);
  border-radius: 16px;
  padding: 12px;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(16, 19, 20, 0.08) inset;
}

.qr-canvas canvas,
.qr-canvas img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.qr-canvas table {
  margin: 0 auto;
}

#reader,
#progress-reader {
  width: 100%;
  min-height: 250px;
  border: 1px dashed rgba(248, 240, 224, 0.25);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.18);
}

#reader video,
#progress-reader video {
  border-radius: var(--radius-md);
}

.hidden {
  display: none !important;
}

.customer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid rgba(248, 240, 224, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.78rem;
  background: rgba(0, 0, 0, 0.14);
}

.customer-row-details {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.customer-row-details strong {
  color: var(--brand-text-100);
  font-size: 0.97rem;
}

.customer-row-details p {
  margin: 0;
  color: var(--brand-text-320);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.customer-row-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 10, 0.68);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  width: min(980px, 95vw);
  max-height: min(86vh, 860px);
  overflow: auto;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: linear-gradient(145deg, rgba(30, 43, 37, 0.98), rgba(18, 27, 23, 0.96));
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.4);
}

.sep {
  margin: 0.95rem 0;
  border: 0;
  border-top: 1px solid rgba(248, 240, 224, 0.2);
}

.scan-feedback-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(10, 14, 12, 0.6);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.scan-feedback-card {
  width: min(460px, 92vw);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 1.05rem;
  background: rgba(18, 27, 23, 0.94);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

.scan-feedback-badge {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid rgba(248, 240, 224, 0.3);
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  color: var(--brand-text-220);
  margin-bottom: 0.35rem;
}

.scan-feedback-title {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.1;
}

.scan-feedback-detail {
  margin: 0.45rem 0 0;
  font-size: 1.02rem;
  color: var(--brand-text-180);
}

.scan-feedback-overlay.success .scan-feedback-card {
  border-color: rgba(77, 176, 115, 0.68);
  background: rgba(24, 53, 36, 0.95);
}

.scan-feedback-overlay.success .scan-feedback-title {
  color: #d2f2df;
}

.scan-feedback-overlay.success .scan-feedback-badge {
  border-color: rgba(77, 176, 115, 0.7);
  color: #c0ebd2;
}

.scan-feedback-overlay.error .scan-feedback-card {
  border-color: rgba(216, 80, 80, 0.7);
  background: rgba(56, 24, 24, 0.95);
}

.scan-feedback-overlay.error .scan-feedback-title {
  color: #ffd0d0;
}

.scan-feedback-overlay.error .scan-feedback-badge {
  border-color: rgba(216, 80, 80, 0.68);
  color: #f4baba;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .brand-header {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 0.7rem;
    row-gap: 0.15rem;
    padding: 0.72rem 0.78rem;
  }

  .brand-copy {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    gap: 0.06rem;
  }

  .header-actions {
    grid-column: 3;
    grid-row: 1;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 0.3rem;
  }

  .header-actions .badge {
    font-size: 0.73rem;
    padding: 0.2rem 0.46rem;
    max-width: 42vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions .btn-secondary {
    padding: 0.42rem 0.65rem;
    font-size: 0.88rem;
  }

  .brand-logo {
    grid-column: 1;
    grid-row: 1;
    width: 56px;
    height: 56px;
  }

  .brand-title {
    font-size: 1.05rem;
    line-height: 1.16;
  }

  .brand-subtitle {
    font-size: 0.84rem;
    line-height: 1.2;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: 95vw;
    margin-top: 0.95rem;
  }

  .panel {
    padding: 0.92rem;
  }

  .brand-header {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    padding: 0.64rem 0.7rem;
  }

  .brand-logo {
    width: 52px;
    height: 52px;
  }

  .brand-subtitle {
    display: none;
  }

  .header-actions .badge {
    max-width: 38vw;
  }

  .row {
    align-items: stretch;
  }

  .row .btn-primary,
  .row .btn-secondary,
  .row .btn-danger,
  .row button,
  .row a.btn-primary,
  .row a.btn-secondary,
  .row a.btn-danger {
    width: 100%;
    justify-content: center;
  }

  .customer-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .customer-row-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .customer-row-actions .btn-primary,
  .customer-row-actions .btn-secondary,
  .customer-row-actions .btn-danger {
    width: auto;
  }

  .modal-card {
    width: 96vw;
    max-height: 88vh;
    padding: 0.86rem;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .kv-key {
    margin-top: 0.44rem;
  }

  .kv-key:first-child {
    margin-top: 0;
  }
}

@media (max-width: 900px) {
  body.scan-focus-active .brand-header,
  body.scan-focus-active .nav-links,
  body.scan-focus-active #config-warning,
  body.scan-focus-active .scanner-panel > h2,
  body.scan-focus-active .scanner-panel > .scanner-intro,
  body.scan-focus-active .scanner-manual,
  body.scan-focus-active #scan-result {
    display: none !important;
  }

  body.scan-focus-active .page-shell {
    width: 100vw;
    margin: 0;
    padding: 0.55rem;
  }

  body.scan-focus-active .scanner-panel {
    margin-top: 0;
    padding: 0.72rem;
  }

  body.scan-focus-active .scanner-grid {
    gap: 0.58rem;
  }

  body.scan-focus-active .scanner-controls {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(18, 27, 23, 0.94);
    border: 1px solid rgba(248, 240, 224, 0.18);
    border-radius: var(--radius-sm);
    padding: 0.52rem;
  }

  body.scan-focus-active #reader {
    min-height: calc(100vh - 240px);
  }
}

@media (min-width: 780px) {
  .grid-two {
    grid-template-columns: 1fr 1fr;
  }

  .action-grid {
    grid-template-columns: 1fr 1fr;
  }
}
