:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-strong: #fff4f4;
  --line: #dddfe4;
  --text: #18212b;
  --muted: #687483;
  --accent: #e30613;
  --accent-strong: #b90410;
  --accent-soft: #fff1f2;
  --accent-ring: rgba(227, 6, 19, 0.16);
  --success: #0f7b63;
  --success-strong: #095d4b;
  --success-soft: #eaf7f2;
  --amber: #b86b10;
  --red: #e30613;
  --shadow: 0 18px 46px rgba(38, 50, 56, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.is-locked {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  flex: 1 1 360px;
  gap: 12px;
  min-width: 0;
  max-width: min(100%, 560px);
}

.brand-logo {
  display: block;
  width: clamp(150px, 18vw, 240px);
  max-height: 54px;
  object-fit: contain;
  object-position: left center;
}

.brand-copy {
  min-width: 0;
}

.topbar h1,
.section-heading h2,
.form-panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 1.8rem;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions,
.section-heading,
.form-row,
.inline-form,
.summary-strip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.register-panel {
  min-height: 580px;
}

.admin-panel {
  grid-column: 1 / -1;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 1.25rem;
}

.control {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

.control:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-ring);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 700;
}

.status-pill.is-warning {
  border-color: rgba(184, 107, 16, 0.45);
  background: #fff7e8;
  color: var(--amber);
}

.status-pill.is-good {
  border-color: rgba(15, 123, 99, 0.35);
  background: var(--success-soft);
  color: var(--success-strong);
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(246, 247, 249, 0.94);
  padding: 18px;
}

body.is-locked .login-overlay {
  display: flex;
}

.pin-card {
  display: grid;
  width: min(440px, 100%);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 22px;
}

.login-logo {
  display: block;
  width: min(260px, 100%);
  max-height: 62px;
  height: auto;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 2px;
}

.pin-card h2 {
  margin: 0;
  font-size: 1.45rem;
}

.pin-input {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  padding: 9px 12px;
  text-align: center;
}

.pin-input:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-ring);
}

.login-hint {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.primary-button,
.secondary-button,
.product-button,
.quantity-button,
.tab,
.segment {
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  min-height: 52px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 22px rgba(227, 6, 19, 0.18);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  min-height: 42px;
  background: #ffffff;
  border-color: rgba(227, 6, 19, 0.28);
  color: var(--accent-strong);
  padding: 0 14px;
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.event-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.meta-tile {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  padding: 9px 10px;
}

.meta-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-tile strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px;
}

.category-title {
  grid-column: 1 / -1;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.product-button {
  display: grid;
  min-height: 98px;
  border-color: var(--line);
  background: #ffffff;
  padding: 12px;
  text-align: left;
}

.product-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.product-button strong,
.cart-line strong {
  overflow-wrap: anywhere;
}

.product-button span {
  align-self: end;
  color: var(--accent-strong);
  font-size: 1.12rem;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  padding: 18px;
}

.checkout-panel {
  display: flex;
  flex-direction: column;
  min-height: 580px;
}

.cart-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 250px;
}

.cart-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.cart-line small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.quantity-tools {
  display: flex;
  align-items: center;
  gap: 5px;
}

.quantity-button {
  width: 34px;
  height: 34px;
  background: #f4f6f8;
  border-color: var(--line);
}

.quantity-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.checkout-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 2px solid var(--text);
  margin-top: auto;
  padding-top: 16px;
}

.checkout-total strong {
  font-size: 2rem;
  letter-spacing: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 16px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6f8;
}

.segment {
  min-height: 38px;
  background: transparent;
  color: var(--muted);
}

.segment.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin: -2px 0 18px;
  padding-bottom: 10px;
}

.tab {
  min-height: 38px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.tab.is-active {
  background: var(--accent);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.form-panel {
  display: grid;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.form-row {
  align-items: start;
}

.form-row > label,
.inline-form > label {
  flex: 1;
}

.inline-form {
  align-items: end;
  margin-bottom: 16px;
}

.data-table {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #eef2f5;
  color: var(--muted);
  padding: 0 9px;
  font-size: 0.76rem;
  font-weight: 900;
}

.badge.pending {
  background: #fff7e8;
  color: var(--amber);
}

.badge.synced {
  background: var(--success-soft);
  color: var(--success-strong);
}

.badge.error {
  background: #fff0f0;
  color: var(--red);
}

.summary-strip {
  align-items: stretch;
  margin-bottom: 14px;
}

.summary-strip .meta-tile {
  flex: 1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  transform: translateY(120%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 12px 14px;
  transition: transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .checkout-panel {
    min-height: auto;
  }

  .admin-grid,
  .event-meta {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 10px;
  }

  .topbar,
  .section-heading,
  .inline-form,
  .form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    justify-content: stretch;
  }

  .brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .brand-logo {
    width: min(230px, 70vw);
    max-height: 54px;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-button {
    min-height: 108px;
  }

  .tabs {
    overflow-x: auto;
  }
}
