:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #657285;
  --line: #d9dee7;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --accent: #b45f06;
  --danger: #b42318;
  --focus: #1d70b8;
  --shadow: 0 12px 32px rgba(31, 41, 51, 0.08);
  --strong-shadow: 0 18px 48px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.settings-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  letter-spacing: 0;
}

.nav {
  display: none;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nav a {
  padding: 8px 9px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--text);
  background: #eef2f7;
}

.page {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 14px 10px 154px;
}

.sale-flow .page {
  width: min(760px, 100%);
  padding: 14px 12px 118px;
}

.sale-flow .bottom-nav {
  display: none;
}

.auth-shell {
  min-height: calc(100vh - 120px);
  display: grid;
  align-items: center;
}

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

.auth-panel {
  width: min(420px, 100%);
  margin: 0 auto;
}

.form-panel {
  padding: 12px;
}

.wizard-form {
  min-height: calc(100vh - 210px);
  overflow: hidden;
  border-color: #dfe4ec;
  box-shadow: var(--strong-shadow);
}

.wizard-top {
  display: grid;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.wizard-progress {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.wizard-progress span {
  height: 5px;
  border-radius: 999px;
  background: #d9dee7;
  transition: background 180ms ease, transform 180ms ease;
}

.wizard-progress span.active {
  background: var(--primary);
  transform: scaleY(1.18);
}

.wizard-alert {
  margin-bottom: 12px;
  padding: 11px 12px;
  border: 1px solid #f0a6a0;
  border-radius: 8px;
  background: #fff1f0;
  color: #7a1f16;
  font-weight: 700;
}

.wizard-step {
  display: none;
  min-height: 430px;
  padding-bottom: 108px;
}

.wizard-step.active {
  display: block;
  animation: stepIn 220ms ease-out both;
}

.wizard-step.active label,
.wizard-step.active .segmented,
.wizard-step.active .sub-section,
.wizard-step.active .field-note {
  animation: fieldRise 260ms ease-out both;
}

.wizard-step.active label:nth-of-type(2),
.wizard-step.active .grid,
.wizard-step.active .sub-section {
  animation-delay: 45ms;
}

@keyframes fieldRise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes stepIn {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.step-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.step-title {
  margin-bottom: 18px;
}

.step-title h2 {
  margin: 0;
  font-size: 23px;
  line-height: 1.16;
  letter-spacing: 0;
}

.step-title p {
  margin: 5px 0 0;
  color: var(--muted);
}

.manager-entry-select {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.paste-preview {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.paste-preview div {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  animation: softPop 180ms ease-out both;
}

.paste-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.paste-preview strong {
  overflow-wrap: anywhere;
}

@keyframes softPop {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.field-note {
  margin-top: -4px;
  color: var(--muted);
  font-size: 13px;
}

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

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

.section-head {
  margin-bottom: 14px;
}

.section-head h1 {
  margin: 0;
  font-size: clamp(24px, 6vw, 34px);
  line-height: 1.08;
  letter-spacing: 0;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.form-section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

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

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

.section-title h2,
.empty-state h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

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

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

label span,
.segmented > span {
  color: #394656;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid #c7ced9;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  padding: 12px 13px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(29, 112, 184, 0.16);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #f3c46b;
  border-radius: 8px;
  background: #fff7e8;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 3px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
}

.segmented label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.segmented input {
  width: 16px;
  min-height: 16px;
}

.sub-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.split-row {
  display: grid;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.hidden {
  display: none !important;
}

button,
.primary,
.secondary,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:active,
.primary:active,
.secondary:active,
.danger:active {
  transform: translateY(1px);
}

.primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 8px 18px rgba(29, 78, 216, 0.24);
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  background: white;
  color: var(--text);
  border-color: var(--line);
}

.secondary:hover {
  border-color: #b8c1ce;
  background: #f9fafb;
}

.danger {
  background: var(--danger);
  color: white;
}

.small {
  min-height: 36px;
  padding: 7px 11px;
  font-size: 14px;
}

.full {
  width: 100%;
}

.sticky-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.sticky-actions > * {
  flex: 1;
}

.sticky-actions form,
.sticky-actions button,
.sticky-actions a {
  width: 100%;
}

.sale-flow .wizard-actions {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: minmax(96px, 0.74fr) minmax(0, 1.26fr);
  gap: 10px;
  margin: 0;
  padding: 12px max(12px, calc((100vw - 760px) / 2 + 12px)) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -14px 34px rgba(31, 41, 51, 0.13);
  backdrop-filter: blur(14px);
}

.sale-flow .wizard-actions > * {
  min-width: 0;
  width: 100%;
}

.sale-flow .wizard-actions .primary {
  min-height: 54px;
}

.sale-flow .wizard-actions .secondary {
  min-height: 54px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  min-height: 62px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(31, 41, 51, 0.09);
  backdrop-filter: blur(12px);
}

.bottom-nav a {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.bottom-nav a:hover {
  background: #eef2f7;
  color: var(--text);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.button-row form {
  margin: 0;
}

.settings-card {
  display: grid;
  gap: 16px;
  animation: softPop 220ms ease-out both;
}

.settings-card h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

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

.settings-row {
  display: grid;
  gap: 12px;
}

.status-pill {
  display: inline-grid;
  place-items: center;
  justify-self: start;
  min-width: 64px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}

.status-pill.on {
  background: #eff6ff;
  color: var(--primary);
}

.status-pill.off {
  background: #fff1f0;
  color: var(--danger);
}

.toggle-form {
  display: grid;
  gap: 14px;
}

.switch-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 14px;
  align-items: center;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
}

.switch-row span {
  display: grid;
  gap: 3px;
}

.switch-row small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-row i {
  position: relative;
  width: 58px;
  height: 34px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 180ms ease;
}

.switch-row i::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.22);
  transition: transform 180ms ease;
}

.switch-row input:checked + i {
  background: var(--primary);
}

.switch-row input:checked + i::after {
  transform: translateX(24px);
}

.settings-placeholder {
  display: grid;
  place-items: center;
  min-height: 84px;
  border: 1px dashed #b8c1ce;
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--muted);
  font-weight: 800;
}

.maintenance-shell {
  min-height: calc(100vh - 190px);
  display: grid;
  align-items: center;
}

.success-shell {
  min-height: calc(100vh - 190px);
  display: grid;
  align-items: start;
}

.success-card {
  display: grid;
  gap: 18px;
  animation: softPop 240ms ease-out both;
}

.success-hero {
  display: grid;
  gap: 14px;
}

.success-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: #eff6ff;
  color: var(--primary);
  font-size: 18px;
  font-weight: 900;
}

.copy-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
}

.copy-panel small {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.success-actions {
  margin-top: 0;
}

.maintenance-card {
  display: grid;
  gap: 16px;
  text-align: center;
  animation: softPop 240ms ease-out both;
}

.maintenance-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto;
  border-radius: 14px;
  background: #fff1f0;
  color: var(--danger);
  font-size: 30px;
  font-weight: 900;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.flash,
.status-box {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
}

.flash.success,
.status-box.success {
  border-color: #8ed1aa;
  background: #ecfdf3;
  color: #14532d;
}

.flash.error,
.status-box.error {
  border-color: #f0a6a0;
  background: #fff1f0;
  color: #7a1f16;
}

.status-box.pending {
  border-color: #f3c46b;
  background: #fff7e8;
  color: #7a4a07;
}

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

.action-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.action-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--primary);
  font-weight: 900;
}

.action-card strong {
  font-size: 18px;
}

.action-card small,
.empty-state p {
  color: var(--muted);
}

.summary-list {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.summary-list div {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: white;
}

.summary-list div:last-child {
  border-bottom: 0;
}

.summary-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.summary-list.compact {
  margin-top: 12px;
}

.approval-card {
  display: grid;
  gap: 12px;
}

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

.approval-head div {
  display: grid;
  gap: 3px;
}

.approval-head span,
.reason {
  color: var(--muted);
}

code {
  padding: 3px 6px;
  border-radius: 6px;
  background: #eef2f7;
  color: #394656;
  font-size: 12px;
}

@media (min-width: 720px) {
  .nav {
    display: flex;
  }

  .bottom-nav {
    display: none;
  }

  .page {
    padding: 28px 22px 96px;
  }

  .sale-flow .page {
    width: min(760px, 100%);
    padding: 30px 22px 122px;
  }

  .panel,
  .form-panel {
    padding: 24px;
  }

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

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

  .summary-list div {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
  }

  .settings-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .maintenance-card {
    width: min(560px, 100%);
    margin: 0 auto;
  }

  .success-card {
    width: min(720px, 100%);
    margin: 0 auto;
  }

  .sticky-actions {
    position: sticky;
    right: auto;
    bottom: 0;
    left: auto;
    margin: 24px -24px -24px;
    padding: 14px 24px;
  }

  .sticky-actions > * {
    flex: 0 0 auto;
  }

  .sticky-actions form,
  .sticky-actions button,
  .sticky-actions a {
    width: auto;
  }

  .sale-flow .wizard-actions {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: 180px minmax(220px, 320px);
    justify-content: end;
    margin: 0;
    padding: 14px max(22px, calc((100vw - 760px) / 2 + 22px));
  }

  .sale-flow .wizard-actions form,
  .sale-flow .wizard-actions button,
  .sale-flow .wizard-actions a {
    width: 100%;
  }
}
