@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --wine: #7a1f15;
  --wine-deep: #5c160f;
  --wine-soft: #9a3a2e;
  --pine: #297373;
  --pine-deep: #1f5858;
  --pine-soft: #3a8a8a;
  --parchment: #f5efed;
  --parchment-dark: #e8dfdb;
  --ink: #2a1614;
  --muted: #6b534e;
  --error: #8b1a12;
  --ok: #2d5a3d;
  --radius: 4px;
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--parchment);
  line-height: 1.5;
}

/* ——— Login ——— */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(122, 31, 21, 0.08), transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(122, 31, 21, 0.06), transparent 50%),
    linear-gradient(160deg, #f5efed 0%, #ebe3df 45%, #f5efed 100%);
}

.login-brand {
  background: linear-gradient(165deg, var(--wine) 0%, var(--wine-deep) 100%);
  color: var(--parchment);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 3.5rem 3rem 4rem;
  position: relative;
  overflow: hidden;
}

.login-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 28px,
      rgba(245, 239, 237, 0.03) 28px,
      rgba(245, 239, 237, 0.03) 29px
    );
  pointer-events: none;
}

.login-brand::after {
  content: '';
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  border: 1px solid rgba(245, 239, 237, 0.12);
  top: -120px;
  right: -100px;
  animation: drift 18s ease-in-out infinite;
}

.brand-mark {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: clamp(3rem, 6vw, 4.5rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  margin-bottom: 0.75rem;
  animation: fadeUp 0.8s ease both;
}

.brand-tagline {
  position: relative;
  z-index: 1;
  font-size: 1.05rem;
  font-weight: 400;
  opacity: 0.85;
  max-width: 22ch;
  animation: fadeUp 0.8s ease 0.15s both;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
}

.login-form-wrap {
  width: 100%;
  max-width: 380px;
  animation: fadeUp 0.7s ease 0.1s both;
}

.login-form-wrap h1 {
  font-family: var(--font-display);
  font-size: 2.35rem;
  font-weight: 600;
  color: var(--wine);
  margin-bottom: 0.35rem;
}

.login-form-wrap .subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--wine);
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--parchment-dark);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus {
  border-color: var(--wine);
  box-shadow: 0 0 0 3px rgba(122, 31, 21, 0.12);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  width: 100%;
  padding-right: 2.75rem;
}

.password-toggle {
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius);
}

.password-toggle:hover {
  color: var(--wine);
}

.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--parchment-dark);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(41, 115, 115, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 90px;
}

.app-form {
  max-width: 720px;
}

.app-form-wide {
  max-width: 920px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.15rem;
}

.form-group-full {
  grid-column: 1 / -1;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.option-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  text-transform: none;
  letter-spacing: normal;
  background: rgba(41, 115, 115, 0.06);
  border: 1px solid var(--parchment-dark);
  border-radius: var(--radius);
  cursor: pointer;
}

.option-chip input {
  width: auto;
  margin: 0;
  accent-color: var(--pine);
}

.form-group input[type="file"] {
  padding: 0.65rem 0.75rem;
  background: #fff;
  cursor: pointer;
}

.form-group input:disabled {
  background: #f3f1ef;
  color: var(--muted);
  cursor: not-allowed;
}

.form-group input[readonly] {
  background: #f7f5f4;
  color: var(--ink);
}

.panel-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.panel-heading-row h2 {
  margin-bottom: 0;
}

.panel-mode-btn {
  flex-shrink: 0;
  padding: 0.55rem 1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--pine);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.panel-mode-btn:hover {
  background: var(--pine-deep);
}

.panel-mode-btn:active {
  transform: scale(0.98);
}

.panel-mode-btn.is-old-active {
  background: var(--wine);
}

.panel-mode-btn.is-old-active:hover {
  background: var(--wine-deep);
}

.lookup-box {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  background: rgba(41, 115, 115, 0.05);
  border: 1px solid var(--parchment-dark);
  border-radius: var(--radius);
}

.lookup-input-row {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
}

.lookup-input-row input {
  flex: 1;
}

.lookup-input-row .btn-submit {
  white-space: nowrap;
}

.lookup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.camera-reader {
  display: none;
  position: relative;
  margin-top: 0.85rem;
  width: 100%;
  max-width: 520px;
  height: 320px;
  overflow: hidden;
  border: 1px solid var(--parchment-dark);
  border-radius: var(--radius);
  background: #111;
}

.camera-reader.is-open {
  display: block;
}

.camera-reader video {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  background: #000;
}

/* html5-qrcode draws scan overlay on canvas — must sit ON TOP of video, not below it */
.camera-reader canvas {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  min-height: 0 !important;
  object-fit: cover;
  pointer-events: none;
}

.camera-reader img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#siNewBarcodeReader > div,
#siCameraReader > div {
  width: 100% !important;
  height: 100% !important;
  position: relative !important;
}

#qr-shaded-region {
  border-width: 2px !important;
}

.barcode-decode-host {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 400px;
  height: 300px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.capture-preview {
  margin-top: 0.85rem;
  max-width: 520px;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid var(--parchment-dark);
  border-top: 3px solid var(--pine);
  border-radius: var(--radius);
}

.capture-preview-head {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--wine);
  margin-bottom: 0.55rem;
}

.capture-preview img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: #111;
  border-radius: var(--radius);
}

.manual-barcode-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.manual-barcode-row {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.manual-barcode-row input {
  flex: 1;
  padding: 0.75rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--parchment-dark);
  border-radius: var(--radius);
  outline: none;
}

.manual-barcode-row input:focus {
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(41, 115, 115, 0.15);
}

.manual-barcode-row .btn-remove-barcode {
  flex-shrink: 0;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  background: var(--wine);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.capture-photo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
}

.scan-details {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid var(--parchment-dark);
  border-top: 3px solid var(--pine);
  border-radius: var(--radius);
}

.scan-details-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.scan-details-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--wine);
}

.scan-status {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(41, 115, 115, 0.12);
  color: var(--pine-deep);
}

.scan-preview-wrap {
  margin-bottom: 0.85rem;
}

.scan-preview-wrap img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: var(--radius);
  background: #f5f2f1;
  border: 1px solid var(--parchment-dark);
}

.scan-details-grid {
  margin-top: 0.25rem;
}

.so-scan-cart-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.so-scan-item {
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid var(--parchment-dark);
  border-top: 3px solid var(--pine);
  border-radius: var(--radius);
}

.so-scan-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.so-scan-item-head h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--wine);
}

.so-scan-item-remove {
  border: 0;
  background: transparent;
  color: var(--wine);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.so-scan-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.so-scan-item-actions .form-group {
  margin: 0;
  min-width: 110px;
  flex: 1;
}

.so-scan-item-actions .btn-submit {
  margin-top: 0;
}

.btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1.25rem;
  padding: 0.85rem 1.75rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--pine);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.btn-submit:hover {
  background: var(--pine-deep);
}

.btn-submit:active {
  transform: scale(0.98);
}

.field-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: -0.15rem 0 0.75rem;
}

.authority-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem 0.75rem;
  padding: 0.9rem 1rem;
  background: rgba(41, 115, 115, 0.05);
  border: 1px solid var(--parchment-dark);
  border-radius: var(--radius);
}

.authority-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

.authority-item input {
  width: auto;
  accent-color: var(--pine);
}

.section-subheading {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--wine);
  margin: 1.75rem 0 0.85rem;
}

@media (max-width: 800px) {
  .authority-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .authority-grid {
    grid-template-columns: 1fr;
  }
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.95rem 1.25rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--parchment);
  background: var(--wine);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.btn-primary:hover {
  background: var(--wine-deep);
}

.btn-primary:active {
  transform: scale(0.98);
}

.alert {
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  border-radius: var(--radius);
  border-left: 3px solid;
  transition: opacity 0.35s ease, transform 0.35s ease, max-height 0.35s ease, margin 0.35s ease, padding 0.35s ease;
}

.alert.is-hiding {
  opacity: 0;
  transform: translateY(-6px);
  max-height: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  border-width: 0;
}

.alert-error {
  background: rgba(122, 31, 21, 0.08);
  border-color: var(--error);
  color: var(--error);
}

.alert-ok {
  background: rgba(45, 90, 61, 0.1);
  border-color: var(--ok);
  color: var(--ok);
}

/* ——— App shell + sidenav ——— */
.app-body {
  min-height: 100vh;
  background: var(--parchment);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.side-nav {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--wine) 0%, var(--wine-deep) 100%);
  color: var(--parchment);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.side-nav-brand {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.75rem 0.9rem 0.65rem;
  border-bottom: 1px solid rgba(245, 239, 237, 0.15);
  flex-shrink: 0;
}

.side-nav-links {
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.45rem 0.5rem;
  gap: 0.2rem;
}

.side-nav-link {
  display: block;
  padding: 0.42rem 0.7rem;
  color: rgba(245, 239, 237, 0.88);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.25;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.side-nav-link:hover {
  background: rgba(245, 239, 237, 0.1);
  color: var(--parchment);
}

.side-nav-link.active {
  background: rgba(245, 239, 237, 0.14);
  color: var(--parchment);
  border-left-color: var(--parchment);
  font-weight: 600;
}

.app-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 70% 40% at 100% 0%, rgba(122, 31, 21, 0.06), transparent 50%),
    var(--parchment);
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: rgba(245, 239, 237, 0.92);
  border-bottom: 1px solid var(--parchment-dark);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-topbar-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--wine);
  margin-right: auto;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1.5px solid var(--wine);
  color: var(--wine);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius);
  cursor: pointer;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.9rem;
  color: var(--ink);
}

.user-meta a {
  color: var(--wine);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.user-meta a:hover {
  border-bottom-color: var(--wine);
}

.app-main {
  padding: 2rem 1.75rem 2.5rem;
  max-width: 100%;
  width: 100%;
}

.app-main h1 {
  font-family: var(--font-display);
  font-size: 2.25rem;
  color: var(--wine);
  margin-bottom: 0.5rem;
}

.app-main p {
  color: var(--muted);
  font-size: 1.05rem;
}

/* ——— Users action buttons ——— */
.page-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.65rem;
  margin-top: 1.5rem;
}

.action-btn {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 56px;
  padding: 0.75rem 0.5rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  line-height: 1.25;
}

.action-btn:active {
  transform: scale(0.98);
}

.action-btn-wine {
  background: var(--wine);
  color: var(--parchment);
}

.action-btn-wine:hover {
  background: var(--wine-deep);
  box-shadow: 0 4px 14px rgba(122, 31, 21, 0.25);
}

.action-btn-pine {
  background: var(--pine);
  color: #fff;
}

.action-btn-pine:hover {
  background: var(--pine-deep);
  box-shadow: 0 4px 14px rgba(41, 115, 115, 0.28);
}

.action-btn-wine.is-active {
  background: var(--wine-deep);
  box-shadow: inset 0 0 0 2px rgba(245, 239, 237, 0.45);
}

.action-btn-pine.is-active {
  background: var(--pine-deep);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.panel-area {
  margin-top: 1.5rem;
}

.content-panel {
  padding: 1.35rem 1.4rem;
  background: #fff;
  border: 1px solid var(--parchment-dark);
  border-top: 3px solid var(--pine);
  border-radius: var(--radius);
}

.content-panel h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--wine);
  margin-bottom: 0.75rem;
}

.panel-placeholder {
  color: var(--muted);
  font-size: 0.95rem;
}

.data-table-wrap {
  overflow-x: hidden;
  width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--parchment-dark);
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.data-table th {
  background: var(--pine);
  color: #fff;
  font-weight: 600;
  white-space: normal;
}

.data-table tr:hover td {
  background: rgba(41, 115, 115, 0.06);
}

.vendor-list-section {
  margin-top: 1.75rem;
}

.vendor-list-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--wine);
}

.vendor-list-scroll {
  max-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--parchment-dark);
  border-radius: var(--radius);
  background: #fff;
  padding: 0.35rem 0.5rem 0.65rem;
}

.vendor-list-scroll .data-table-wrap {
  overflow-x: visible;
}

.vendor-list-scroll .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.row-action-icons {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--parchment-dark);
  border-radius: var(--radius);
  background: #fff;
  color: var(--pine-deep);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-action-btn:hover {
  background: rgba(41, 115, 115, 0.1);
  border-color: var(--pine);
}

.icon-action-danger {
  color: var(--wine);
}

.icon-action-danger:hover {
  background: rgba(122, 31, 21, 0.1);
  border-color: var(--wine);
}

.link-action {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  color: var(--pine);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.link-action:hover {
  color: var(--pine-deep);
}

.barcode-only-card {
  position: relative;
  width: min(720px, 95vw);
  max-height: 90vh;
  padding: 1.5rem 1.25rem 1rem;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.barcode-only-close {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  z-index: 2;
}

.barcode-view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 1.75rem 0.85rem 0;
  flex-shrink: 0;
}

.barcode-view-heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--wine);
  text-align: left;
  flex: 1;
  min-width: 0;
}

.barcode-pdf-btn {
  flex-shrink: 0;
  padding: 0.45rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--pine);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.15s ease;
}

.barcode-pdf-btn:hover {
  background: var(--pine-deep);
}

.barcode-pdf-btn:active {
  transform: scale(0.98);
}

.barcode-pdf-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.barcode-view-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
  overflow-y: auto;
  max-height: calc(90vh - 5.5rem);
  padding: 0.35rem 0.15rem 0.5rem;
  flex: 1;
  min-height: 0;
}

.barcode-view-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.5rem;
  background: #ffffff;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.barcode-view-cell svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.row-inactive td {
  opacity: 0.72;
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-active {
  background: rgba(45, 90, 61, 0.12);
  color: var(--ok);
}

.status-inactive {
  background: rgba(122, 31, 21, 0.1);
  color: var(--wine);
}

.action-cell {
  width: 48px;
  text-align: center;
}

.action-menu {
  position: relative;
  display: inline-block;
}

.action-dots {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius);
}

.action-dots:hover {
  background: rgba(41, 115, 115, 0.12);
  color: var(--pine);
}

.action-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 50;
  min-width: 170px;
  padding: 0.35rem 0;
  background: #fff;
  border: 1px solid var(--parchment-dark);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(42, 22, 20, 0.12);
}

.action-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.55rem 0.9rem;
  border: none;
  background: transparent;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
}

.action-dropdown-item:hover {
  background: rgba(41, 115, 115, 0.08);
}

.action-dropdown-item.danger {
  color: var(--wine);
}

.action-dropdown form {
  margin: 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(42, 22, 20, 0.45);
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem 1.5rem;
  border-top: 3px solid var(--pine);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-header h3 {
  font-size: 1.15rem;
  color: var(--wine);
  font-weight: 600;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.modal-card-wide {
  max-width: 680px;
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
}

.details-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.65rem 0.75rem;
  background: rgba(41, 115, 115, 0.05);
  border-radius: var(--radius);
}

.details-item span {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pine);
}

.details-item strong {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.details-item-full {
  grid-column: 1 / -1;
}

.details-permissions {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--parchment-dark);
}

.details-permissions h4 {
  font-size: 0.95rem;
  color: var(--wine);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.permission-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.permission-chip {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: #fff;
  background: var(--pine);
  border-radius: 999px;
}

@media (max-width: 560px) {
  .details-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .page-actions {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .action-btn {
    flex: 0 0 auto;
    min-width: 120px;
    font-size: 0.78rem;
  }
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(42, 22, 20, 0.4);
  z-index: 30;
}

.nav-overlay.show {
  display: block;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(-24px, 18px);
  }
}

@media (max-width: 800px) {
  .login-page {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 220px;
    padding: 2rem 1.5rem 2.25rem;
    justify-content: flex-end;
  }

  .brand-mark {
    font-size: 2.75rem;
  }

  .side-nav {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .side-nav.open {
    transform: translateX(0);
  }

  .nav-toggle {
    display: inline-flex;
  }

  .app-main {
    padding: 1.5rem 1.15rem 2rem;
  }

  .app-topbar {
    padding: 0.85rem 1rem;
  }
}
