:root {
  color-scheme: light;
  --brand: #071f5f;
  --brand-strong: #0b2f8a;
  --accent: #107569;
  --accent-strong: #0b5d53;
  --ink: #172033;
  --muted: #667287;
  --subtle: #8b96a8;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #d7e0eb;
  --line-strong: #b9c6d8;
  --success: #15803d;
  --danger: #b42318;
  --warning: #a16207;
  --shadow: 0 16px 38px rgba(25, 36, 58, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 9px 14px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 750;
  cursor: pointer;
}

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

button:disabled {
  border-color: #c7d1df;
  color: #7a8598;
  background: #eef2f7;
  cursor: not-allowed;
}

.button-secondary {
  color: var(--brand);
  border-color: var(--line-strong);
  background: #ffffff;
}

.button-secondary:hover {
  color: #ffffff;
  border-color: var(--brand);
  background: var(--brand);
}

.small-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(16, 117, 105, 0.16);
  border-color: var(--accent);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

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

h1,
h2,
h3 {
  letter-spacing: 0;
  line-height: 1.15;
}

h1 {
  margin-bottom: 0;
  font-size: 1.32rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

h3 {
  margin-bottom: 2px;
  font-size: 1rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(220px, auto) 1fr auto;
  gap: 18px;
  align-items: center;
  min-height: 64px;
  padding: 0 22px;
  color: #ffffff;
  background: var(--brand);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
}

.brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topnav a {
  border-radius: 6px;
  padding: 8px 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.9rem;
  font-weight: 650;
}

.topnav a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.session {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 190px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.86rem;
  font-weight: 650;
}

.session-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

.portal-shell {
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) 360px;
  gap: 18px;
  align-items: start;
  max-width: 1560px;
  margin: 0 auto;
  padding: 18px;
}

.left-rail,
.right-rail {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 82px;
}

.workspace {
  min-width: 0;
}

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

.panel {
  padding: 16px;
}

.workspace {
  padding: 18px;
}

.panel-heading,
.workspace-heading {
  margin-bottom: 14px;
}

.panel-heading.split,
.workspace-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel-heading p:not(.eyebrow),
.workspace-heading p,
.section-title p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.payment-banner {
  display: grid;
  gap: 1px;
  min-width: 230px;
  padding: 10px 12px;
  border: 1px solid #f0d09b;
  border-radius: 8px;
  color: var(--warning);
  background: #fff8ed;
  font-size: 0.82rem;
}

.payment-banner strong {
  color: #7c4a03;
}

.form-stack,
.delivery-form,
.compact-form {
  display: grid;
  gap: 12px;
}

.create-account {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.create-account summary {
  color: var(--brand);
  font-weight: 750;
  cursor: pointer;
}

.create-account form {
  margin-top: 12px;
}

.button-row,
.utility-grid {
  display: grid;
  gap: 8px;
}

.button-row {
  grid-template-columns: 1fr 1fr;
}

.utility-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.compact-form input,
.compact-form select {
  padding: 9px 10px;
}

.form-section {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.form-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.section-title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.section-title span {
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 6px;
  color: #ffffff;
  background: var(--brand);
  font-weight: 850;
}

.field-grid {
  display: grid;
  gap: 12px;
}

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

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.form-note {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
}

.form-note.error,
.result.error {
  color: var(--danger);
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 8;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 8px -18px -18px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.compact-list {
  display: grid;
  gap: 8px;
  min-height: 38px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.compact-list li {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 0.84rem;
}

.compact-list .muted {
  color: var(--muted);
}

.compact-list .action-row {
  padding: 0;
}

.list-action {
  display: block;
  width: 100%;
  min-height: auto;
  border: 0;
  border-radius: 7px;
  padding: 10px;
  color: var(--ink);
  background: transparent;
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.35;
  text-align: left;
}

.list-action:hover {
  color: var(--brand);
  background: #e9effa;
}

.order-list .list-action {
  min-height: 58px;
}

pre {
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  border: 1px solid #142033;
  border-radius: 7px;
  padding: 12px;
  color: #d9fbe8;
  background: #101827;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.45;
}

.result {
  min-height: 34px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.result.success {
  color: var(--success);
}

.proof-viewer {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: var(--surface-soft);
}

.proof-heading {
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.proof-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--ink);
  font-size: 0.84rem;
}

.proof-media {
  grid-column: 1 / -1;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

@media (max-width: 1240px) {
  .portal-shell {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .right-rail {
    grid-column: 1 / -1;
    position: static;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.7fr);
  }

  .right-rail .panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .topnav {
    display: none;
  }

  .portal-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .left-rail,
  .right-rail {
    position: static;
    grid-template-columns: 1fr;
  }

  .form-section,
  .field-grid.two,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3 {
    grid-column: span 1;
  }

  .workspace-heading {
    display: grid;
  }

  .payment-banner {
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 58px;
    padding: 0 12px;
  }

  .brand span {
    display: none;
  }

  .session {
    min-width: 0;
    max-width: 230px;
    font-size: 0.78rem;
  }

  .button-row,
  .utility-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .workspace {
    padding: 14px;
  }

  .sticky-actions {
    margin: 8px -14px -14px;
    padding: 12px 14px;
  }
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tab-link {
  border-radius: 6px;
  padding: 8px 12px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.9rem;
  font-weight: 750;
  white-space: nowrap;
}

.tab-link:hover,
.tab-link.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}

.tab-panel[hidden] {
  display: none !important;
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 22px;
}

.view-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.view-heading > p {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.delivery-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 20px;
  align-items: start;
}

.book-layout,
.orders-layout,
.account-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.side-stack {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.delivery-form {
  min-width: 0;
}

.setup-warning {
  display: grid;
  gap: 3px;
  margin-bottom: 12px;
  border: 1px solid #f0d09b;
  border-radius: 8px;
  padding: 12px;
  color: var(--warning);
  background: #fff8ed;
}

.setup-warning strong {
  color: #7c4a03;
}

.payment-panel {
  align-self: stretch;
}

.payment-form input:disabled {
  color: #7a8598;
  background: #f2f5f9;
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: minmax(190px, auto) 1fr;
  }

  .session {
    grid-column: 1 / -1;
    justify-content: flex-start;
    min-width: 0;
  }

  .delivery-layout,
  .book-layout,
  .orders-layout,
  .account-layout {
    grid-template-columns: 1fr;
  }

  .side-stack {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px 14px;
  }

  .tabs {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .view-heading {
    display: grid;
  }
}
