:root {
  color-scheme: light;
  --ink: #2f211d;
  --muted: #6d5a51;
  --line: #ead7b9;
  --surface: #fff8ea;
  --paper: #fbf3e4;
  --brand: #711515;
  --brand-dark: #541010;
  --brand-soft: #8f2b22;
  --accent: #ead7b9;
  --accent-soft: #fff8ea;
  --success: #711515;
  --shadow: 0 18px 45px rgba(84, 33, 21, 0.16);
  --font-main: Rubik, "Segoe UI", Aptos, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(113, 21, 21, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(113, 21, 21, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 12% 8%, rgba(234, 215, 185, 0.54), transparent 30rem),
    linear-gradient(135deg, #fff8ea 0%, #fbf3e4 100%);
  background-size: 34px 34px, 34px 34px, auto, auto;
  color: var(--ink);
  font-family: var(--font-main);
}

body.auth-locked {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

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

.brand-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  border: 1px solid rgba(113, 21, 21, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(84, 16, 16, 0.88), rgba(113, 21, 21, 0.76)),
    radial-gradient(circle at 88% 18%, rgba(234, 215, 185, 0.28), transparent 13rem),
    linear-gradient(135deg, #541010 0%, #711515 60%, #8f2b22 100%);
  color: #fff8ea;
  overflow: hidden;
  padding: 26px;
  position: relative;
}

.brand-hero > * {
  position: relative;
  z-index: 1;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(84, 16, 16, 0.92), rgba(113, 21, 21, 0.84)),
    linear-gradient(135deg, #541010 0%, #711515 60%, #8f2b22 100%);
  padding: 24px;
}

.login-screen.is-visible {
  display: grid;
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid rgba(255, 248, 234, 0.34);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card h1,
.login-card p {
  margin: 0;
}

.login-card h1 {
  color: var(--brand-dark);
  font-size: clamp(1.55rem, 3vw, 2rem);
  line-height: 1.12;
}

.login-card p {
  color: var(--muted);
  line-height: 1.5;
}

.login-card input::placeholder {
  color: #b8aaa3;
}

.hero-logo {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: min(34vw, 250px);
  min-height: 150px;
  margin: 0;
  border: 1px solid rgba(255, 248, 234, 0.34);
  border-radius: 8px;
  background: rgba(255, 248, 234, 0.92);
  padding: 18px;
  box-shadow: 0 20px 44px rgba(54, 13, 10, 0.2);
}

.hero-logo img {
  width: 100%;
  max-height: 118px;
  object-fit: contain;
}

.hero-logo-small {
  width: 100%;
  min-height: auto;
  padding: 14px;
}

.hero-logo-small img {
  max-height: 104px;
}

.hero-actions-side {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.session-role {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid rgba(255, 248, 234, 0.42);
  border-radius: 999px;
  color: #fff8ea;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0 12px;
}

.view-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 4px;
  color: #fff8ea;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: var(--font-main);
  font-size: clamp(2.6rem, 6vw, 5.2rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 0.96;
}

.web-entry {
  margin: 10px 0 0;
  color: rgba(255, 248, 234, 0.9);
  font-weight: 700;
}

h2 {
  margin-bottom: 6px;
  color: var(--brand-dark);
  font-family: var(--font-main);
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: 0;
}

.panel-heading p,
.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.ghost-button,
button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

button {
  min-height: 44px;
  background: var(--brand);
  color: white;
  padding: 0 18px;
  box-shadow: 0 10px 22px rgba(84, 33, 21, 0.16);
}

button:hover {
  background: var(--brand-dark);
}

.ghost-button {
  background: rgba(255, 248, 234, 0.14);
  border: 1px solid rgba(255, 248, 234, 0.56);
  color: #fff8ea;
  box-shadow: none;
}

.ghost-button.is-active {
  background: var(--surface);
  color: var(--brand);
}

.app-view[hidden] {
  display: none;
}

.admin-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  border: 1px solid rgba(232, 216, 194, 0.96);
  border-radius: 8px;
  background: rgba(255, 248, 234, 0.9);
  box-shadow: var(--shadow);
  padding: 18px;
}

.admin-heading .eyebrow,
.customer-copy .eyebrow {
  color: var(--brand);
}

.admin-heading h2 {
  font-size: 1.72rem;
  margin-bottom: 8px;
}

.admin-heading p:last-child {
  color: var(--muted);
  margin-bottom: 0;
}

.admin-reset {
  flex: 0 0 auto;
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

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

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

.activation-strip article,
.customer-section {
  background: rgba(255, 248, 234, 0.9);
  border: 1px solid rgba(232, 216, 194, 0.96);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.activation-strip article {
  display: grid;
  gap: 4px;
  padding: 14px;
}

.activation-strip strong {
  font-family: var(--font-main);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--brand-dark);
}

.activation-strip span {
  color: var(--muted);
  font-size: 0.92rem;
}

.customer-section {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
  padding: 18px;
}

.customer-section-primary {
  min-height: 260px;
  align-items: center;
  padding: 24px;
}

.customer-copy h2 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.08;
}

.customer-copy p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.lookup-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.customer-result {
  grid-column: 1 / -1;
}

.result-card {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(113, 21, 21, 0.12);
  border-radius: 8px;
  background: rgba(255, 248, 234, 0.72);
  padding: 14px;
}

.result-card.warning {
  border-color: rgba(143, 43, 34, 0.18);
  background: rgba(143, 43, 34, 0.08);
}

.result-card div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.result-card span,
.result-card p,
.result-card small {
  color: var(--muted);
}

.result-card strong {
  color: var(--brand-dark);
  font-family: var(--font-main);
  font-size: 2.25rem;
  font-weight: 600;
}

.customer-summary-card {
  gap: 14px;
}

.customer-summary-main {
  display: grid;
  gap: 6px;
}

.customer-summary-main strong {
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
}

.customer-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.customer-summary-grid p {
  display: grid;
  gap: 3px;
  border: 1px solid rgba(234, 215, 185, 0.96);
  border-radius: 8px;
  background: white;
  margin: 0;
  padding: 12px;
}

.customer-summary-grid strong {
  color: var(--brand);
  font-size: 1.7rem;
  line-height: 1;
}

.customer-summary-grid span {
  color: var(--muted);
  font-size: 0.9rem;
}

.customer-purchases {
  border-top: 1px solid rgba(113, 21, 21, 0.12);
  margin-top: 8px;
  padding-top: 12px;
}

.expiration-note {
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  margin: 4px 0;
  padding: 10px 12px;
}

.expiration-note.ok {
  background: rgba(113, 21, 21, 0.08);
  color: var(--brand-dark);
}

.expiration-note.warning {
  background: rgba(143, 43, 34, 0.14);
  color: var(--brand);
}

.expiration-note.neutral {
  background: rgba(234, 215, 185, 0.42);
  color: var(--muted);
}

.customer-purchases h3 {
  color: var(--brand-dark);
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 10px;
}

.customer-purchases ol {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.customer-purchases li {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(234, 215, 185, 0.96);
  border-radius: 8px;
  background: white;
  padding: 10px 12px;
}

.customer-purchases time,
.customer-purchases span {
  color: var(--muted);
  font-size: 0.9rem;
}

.customer-purchases li strong {
  color: var(--brand);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: right;
}

.customer-purchases .muted-row {
  color: var(--muted);
  grid-template-columns: 1fr;
}

.client-history-row td {
  background: rgba(255, 248, 234, 0.52);
  padding: 0 10px 14px;
}

.client-history-detail {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(113, 21, 21, 0.1);
  border-radius: 8px;
  background: white;
  padding: 12px;
}

.client-history-detail > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.client-history-detail > div strong {
  color: var(--brand-dark);
}

.client-history-detail > div span {
  color: var(--muted);
  font-size: 0.88rem;
}

.client-history-detail ol {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.client-history-detail li {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid rgba(234, 215, 185, 0.9);
  padding-top: 8px;
}

.client-history-detail time,
.client-history-detail span {
  color: var(--muted);
  font-size: 0.9rem;
}

.client-history-detail li strong {
  color: var(--brand);
  text-align: right;
}

.client-history-detail .muted-row {
  color: var(--muted);
  grid-template-columns: 1fr;
}

.metric,
.panel,
.data-section {
  background: rgba(255, 248, 234, 0.9);
  border: 1px solid rgba(232, 216, 194, 0.96);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.metric strong {
  font-family: var(--font-main);
  font-size: 2rem;
  font-weight: 600;
  color: var(--brand-dark);
}

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

body.is-operator .admin-only {
  display: none;
}

body.is-operator .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.panel,
.data-section {
  padding: 18px;
}

.panel-heading {
  margin-bottom: 16px;
}

.stack {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  outline: none;
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(234, 215, 185, 0.56);
}

.data-section {
  margin-top: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.search {
  max-width: 320px;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  text-transform: uppercase;
}

td strong {
  display: block;
}

.points {
  display: inline-flex;
  align-items: center;
  min-width: 74px;
  justify-content: center;
  border-radius: 999px;
  background: rgba(113, 21, 21, 0.1);
  color: var(--success);
  font-weight: 700;
  padding: 6px 10px;
}

.activity-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px 14px;
}

.activity-title {
  margin: 0 0 3px;
  font-weight: 700;
}

.activity-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.delta {
  font-weight: 700;
}

.delta.positive {
  color: var(--success);
}

.delta.negative {
  color: var(--brand);
}

.promo-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.promo-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 14px;
}

.promo-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.promo-card h3 {
  margin: 0;
  color: var(--brand-dark);
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 600;
}

.promo-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 9px;
}

.promo-card p {
  margin: 0 0 12px;
  color: var(--muted);
}

.text-button {
  min-height: auto;
  background: transparent;
  box-shadow: none;
  color: var(--brand);
  padding: 0;
}

.text-button:hover {
  background: transparent;
  color: var(--brand-dark);
}

.danger-button {
  color: #9e1f1f;
  font-weight: 800;
}

.danger-button:hover {
  color: #6f1111;
}

.table-actions {
  white-space: nowrap;
}

.table-actions .text-button + .text-button {
  margin-left: 12px;
}

.activity-actions {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.muted-action {
  color: var(--muted);
  font-size: 0.88rem;
}

.empty-state {
  display: none;
  margin: 16px 0 0;
  color: var(--muted);
}

.empty-state.visible {
  display: block;
  margin: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 880px) {
  .summary-grid,
  .activation-strip,
  .workspace,
  .promo-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .customer-section,
  .lookup-form {
    grid-template-columns: 1fr;
  }
}

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

  .brand-hero,
  .section-heading,
  .admin-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-logo {
    width: 100%;
    min-height: 116px;
  }

  .hero-logo-small {
    justify-self: center;
    width: 100%;
    min-height: auto;
  }

  .hero-actions-side {
    justify-items: center;
  }

  .view-switch {
    justify-content: stretch;
  }

  .view-switch button,
  .admin-reset {
    width: 100%;
  }

  .summary-grid,
  .activation-strip,
  .workspace,
  .promo-list {
    grid-template-columns: 1fr;
  }

  .result-card div {
    align-items: start;
    flex-direction: column;
  }

  .customer-summary-grid {
    grid-template-columns: 1fr;
  }

  .customer-purchases li {
    grid-template-columns: 1fr;
  }

  .customer-purchases li strong {
    text-align: left;
  }

  .client-history-detail > div,
  .client-history-detail li {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .client-history-detail > div {
    display: grid;
  }

  .client-history-detail li strong {
    text-align: left;
  }

  .search {
    max-width: none;
  }

  .activity-list li {
    grid-template-columns: 1fr;
  }
}
