:root {
  color-scheme: dark;
  font-family: "DM Sans", sans-serif;
  background: #171a1c;
  color: #eee9dc;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #202426;
  --surface-raised: #262b2c;
  --line: #383d3b;
  --muted: #9a9d92;
  --gold: #d3a85e;
  --gold-bright: #f0c77b;
  --green: #879d77;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 4%, rgb(91 85 61 / 18%), transparent 48rem),
    #171a1c;
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(100% - 48px, 980px);
  margin: 0 auto;
}

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgb(238 233 220 / 9%);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: #e7dfca;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-decoration: none;
}

.calculator-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
}

.calculator-nav a {
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #c4c5bb;
  font-size: 12px;
  text-decoration: none;
}

.calculator-nav a[aria-current="page"] {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgb(211 168 94 / 7%);
}

.calculator-nav a:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.eyebrow,
.total-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.intro {
  max-width: 690px;
  margin: 38px auto;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
}

h1,
h2 {
  font-family: "Spectral", Georgia, serif;
  font-weight: 500;
}

h1 {
  margin: 13px 0 10px;
  font-size: clamp(36px, 6vw, 57px);
  letter-spacing: -0.035em;
  line-height: 1.12;
}

h1 em {
  color: var(--gold-bright);
  font-weight: 500;
}

.intro-copy {
  max-width: 490px;
  margin: 0 auto;
  color: #a8aaa1;
  font-size: 14px;
  line-height: 1.7;
}

.ledger-card {
  overflow: hidden;
  border: 1px solid #414541;
  border-radius: 8px;
  background: linear-gradient(145deg, rgb(255 255 255 / 1.5%), transparent 45%), var(--surface);
  box-shadow: 0 24px 70px rgb(0 0 0 / 23%);
}

.card-heading {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 21px 30px;
  border-bottom: 1px solid var(--line);
}

.card-heading .eyebrow {
  font-size: 9px;
}

h2 {
  margin: 4px 0 0;
  color: #eee9dc;
  font-size: 24px;
}

.reset-button,
.edit-prices-button {
  padding: 9px 13px;
  border: 1px solid #4b514c;
  border-radius: 4px;
  background: transparent;
  color: #c4c5bb;
  cursor: pointer;
  font-size: 12px;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.reset-button:hover,
.edit-prices-button:hover {
  border-color: var(--gold);
  background: rgb(211 168 94 / 7%);
  color: var(--gold-bright);
}

.reset-button:focus-visible,
.edit-prices-button:focus-visible,
.quantity-input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

thead {
  background: rgb(255 255 255 / 1.4%);
}

th {
  height: 43px;
  padding: 0 20px;
  color: #8f948b;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  padding-left: 30px;
}

th:last-child,
td:last-child {
  padding-right: 30px;
}

.numeric {
  text-align: right;
}

tbody tr {
  border-top: 1px solid rgb(255 255 255 / 5%);
}

tbody tr:hover {
  background: rgb(255 255 255 / 1.4%);
}

td {
  height: 55px;
  padding: 7px 20px;
  color: #d7d6cc;
  font-size: 13px;
}

.good-name {
  font-weight: 600;
}

.price-value,
.row-total {
  color: #d6bd8b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.unpriced {
  color: #858980;
  font-size: 12px;
}

.quantity-input {
  width: 88px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #4a504b;
  border-radius: 4px;
  background: #191d1e;
  color: #f0eadc;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.quantity-input::placeholder {
  color: #646a63;
}

.quantity-input[aria-invalid="true"] {
  border-color: #d47c68;
}

.price-note {
  min-height: 18px;
  margin: 9px 30px 16px;
  color: #999d91;
  font-size: 11px;
}

.price-api-notice {
  margin: 0 30px 14px;
  color: #e2b875;
  font-size: 12px;
}

.storage-notice {
  margin: 0 30px 14px;
  color: #e2b875;
  font-size: 12px;
}

.price-editor {
  width: min(560px, calc(100% - 32px));
  max-height: min(84vh, 760px);
  margin: auto;
  padding: 24px;
  border: 1px solid #50564f;
  border-radius: 8px;
  background: var(--surface);
  color: #eee9dc;
  box-shadow: 0 24px 70px rgb(0 0 0 / 45%);
}

.price-editor::backdrop {
  background: rgb(0 0 0 / 68%);
}

.price-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.price-editor-heading h2 {
  margin: 0;
}

.editor-status {
  min-height: 18px;
  margin: 14px 0;
  color: var(--green);
  font-size: 12px;
}

.editor-status.error {
  color: #e39b83;
}

.editor-login-form {
  display: grid;
  gap: 9px;
  color: #c4c5bb;
  font-size: 13px;
}

.login-controls {
  display: flex;
  gap: 10px;
}

.login-controls input,
.price-field input {
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #4a504b;
  border-radius: 4px;
  background: #191d1e;
  color: #f0eadc;
}

.login-controls input {
  flex: 1;
}

.login-controls input:focus-visible,
.price-field input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

.price-fields {
  display: grid;
  max-height: 48vh;
  overflow-y: auto;
}

.price-field {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgb(255 255 255 / 6%);
  color: #d7d6cc;
  font-size: 13px;
}

.price-field input {
  width: 100%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
}

.total-panel {
  min-height: 91px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 30px;
  border-top: 1px solid #504a3d;
  background: linear-gradient(100deg, rgb(211 168 94 / 9%), rgb(211 168 94 / 3%));
}

.total-panel > div {
  display: grid;
  gap: 6px;
}

.total-label {
  color: #c5a363;
}

.total-caption {
  color: #999b91;
  font-size: 11px;
}

.total-value {
  color: var(--gold-bright);
  font-family: "Spectral", Georgia, serif;
  font-size: clamp(23px, 4vw, 32px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 28px, 980px);
  }

  .topbar {
    height: 66px;
  }

  .brand {
    font-size: 8px;
    letter-spacing: 0.07em;
  }

  .intro {
    margin: 36px auto 30px;
  }

  .intro-copy {
    max-width: 350px;
    font-size: 13px;
  }

  .card-heading {
    min-height: 82px;
    padding: 17px 18px;
  }

  h2 {
    font-size: 21px;
  }

  th {
    padding: 0 12px;
    font-size: 8px;
    letter-spacing: 0.09em;
  }

  th:first-child,
  td:first-child {
    padding-left: 16px;
  }

  th:last-child,
  td:last-child {
    padding-right: 16px;
  }

  td {
    padding: 6px 12px;
    font-size: 12px;
  }

  .quantity-input {
    width: 68px;
  }

  .price-note,
  .price-api-notice,
  .storage-notice {
    margin-left: 17px;
    margin-right: 17px;
  }

  .total-panel {
    padding: 17px;
  }

  .total-caption {
    max-width: 150px;
    line-height: 1.5;
  }

  .price-editor {
    padding: 18px;
  }

  .login-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .price-field {
    grid-template-columns: minmax(0, 1fr) 105px;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
