:root {
  color-scheme: dark;
  --bg: #000;
  --bg-soft: #171a20;
  --card: #f7f0e5;
  --card-muted: #e9dfd0;
  --ink: #171512;
  --muted: #6a5f51;
  --line: rgba(255, 255, 255, 0.16);
  --accent: #2d7a64;
  --accent-dark: #195846;
  --danger: #b5473f;
  --danger-dark: #843028;
  --gold: #d5a642;
  --focus: #f4c95d;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(32, 111, 214, 0.18), rgba(255, 255, 255, 0) 19rem),
    var(--bg);
  color: #fff8ee;
  font-size: 16px;
  line-height: 1.45;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 0%, rgba(37, 107, 218, 0.14), transparent 34rem);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.64;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

.boot-brand {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: #000;
  animation: boot-brand-out 480ms ease 360ms both;
  pointer-events: none;
}

.boot-brand img {
  width: min(68vw, 280px);
  height: auto;
  object-fit: contain;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  display: block;
  height: auto;
  object-fit: contain;
  background: #000;
  flex: 0 0 auto;
}

.brand-logo--header {
  width: 74px;
  aspect-ratio: 1448 / 1086;
}

.brand-logo--activation {
  width: min(100%, 210px);
  margin: 0 auto 16px;
}

.brand-logo--records {
  width: 76px;
  margin-left: auto;
}

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

.topbar h1 {
  font-size: 1.5rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: #d9c8af;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.session-badge {
  margin: 3px 0 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #e9dcc8;
  font-size: 0.82rem;
}

.panel,
.summary-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  background: var(--card);
  color: var(--ink);
  padding: 18px;
}

.auth-panel {
  margin-top: 18px;
  background: linear-gradient(180deg, #0a0b0f 0, #11131a 34%, var(--card) 34%);
}

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

.panel-heading .eyebrow {
  color: var(--muted);
}

.row-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #c9bca7;
  border-radius: 8px;
  background: #fffaf2;
  color: var(--ink);
  font-size: 1rem;
  padding: 12px;
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--danger);
}

.primary-button,
.secondary-button,
.danger-button,
.quiet-button,
.switch-button {
  min-height: 44px;
  border-radius: 8px;
  border: 0;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:active {
  background: var(--accent-dark);
}

.secondary-button {
  width: 100%;
  background: var(--bg-soft);
  color: #fff8ee;
}

.danger-button {
  background: var(--danger);
  color: #fff;
}

.danger-button:active {
  background: var(--danger-dark);
}

.quiet-button {
  border: 1px solid #cdbfa8;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.form-message {
  min-height: 1.4em;
  margin: -2px 0 0;
  color: var(--danger-dark);
  font-weight: 700;
}

.input-preview {
  min-height: 1.4em;
  margin: -2px 0 0;
  color: var(--muted);
}

.summary-card {
  margin-bottom: 14px;
  padding: 20px;
  background: #fff7eb;
  color: var(--ink);
}

.summary-card .eyebrow {
  color: var(--muted);
}

.summary-total {
  margin: 2px 0 16px;
  color: var(--ink);
  font-size: clamp(2.4rem, 14vw, 4rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
}

.summary-lines {
  display: grid;
  gap: 8px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid #dfd1bf;
  color: var(--muted);
  font-weight: 750;
}

.summary-line strong {
  color: var(--ink);
  text-align: right;
}

.summary-line.is-profit strong {
  color: var(--accent-dark);
}

.summary-line.is-missing strong {
  color: var(--danger-dark);
}

.view-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
}

.switch-button {
  border: 1px solid var(--line);
  background: transparent;
  color: #eee0ca;
}

.switch-button.is-active {
  background: var(--gold);
  color: #181613;
}

.records-panel {
  display: grid;
  gap: 14px;
}

.records-heading-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.records-state {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.records-list {
  display: grid;
  gap: 10px;
}

.record-card {
  display: grid;
  gap: 10px;
  border: 1px solid #dfd1bf;
  border-radius: 8px;
  background: #fffaf2;
  padding: 14px;
}

.record-card.is-voided {
  border-color: #d8b1ab;
  background: #fff4f2;
}

.record-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.record-amount {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
}

.record-pill {
  align-self: start;
  border-radius: 8px;
  background: #e8ded0;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.record-pill.is-voided {
  background: #f1d0ca;
  color: var(--danger-dark);
}

.record-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.record-details div {
  min-width: 0;
}

.record-details dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.record-details dd {
  margin: 1px 0 0;
  color: var(--ink);
  overflow-wrap: anywhere;
  font-weight: 750;
}

.record-actions {
  display: flex;
  justify-content: flex-end;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  align-items: end;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.62);
}

.dialog-panel {
  width: min(100%, 520px);
  margin: 0 auto;
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  padding: 18px;
  box-shadow: var(--shadow);
}

.dialog-copy {
  margin: 8px 0 16px;
  color: var(--muted);
  font-weight: 700;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (min-width: 700px) {
  .shell {
    padding-top: 28px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .primary-button,
  .secondary-button,
  .danger-button,
  .quiet-button,
  .switch-button {
    transition: background 150ms ease, color 150ms ease, transform 120ms ease;
  }

  button:active {
    transform: translateY(1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .boot-brand {
    display: none;
  }
}

@keyframes boot-brand-out {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    visibility: hidden;
  }
}
