:root {
  color-scheme: light;
  --background: #f5f7f6;
  --surface: #ffffff;
  --surface-muted: #edf1ef;
  --text: #171a19;
  --text-muted: #66706c;
  --line: #dce2df;
  --accent: #17765a;
  --accent-hover: #105f48;
  --accent-soft: #dcefe7;
  --danger: #b94c43;
  --danger-soft: #f7e6e3;
  --warning: #956516;
  --warning-soft: #f6edd8;
  --shadow: 0 12px 32px rgba(25, 34, 30, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
}

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

.app-shell {
  width: min(100%, 620px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 20px calc(94px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark,
.link-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
}

.brand-mark svg,
.link-icon svg {
  width: 18px;
  height: 18px;
}

.service-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2e9b71;
  box-shadow: 0 0 0 3px #dcefe7;
}

main {
  padding: 28px 0;
}

.view {
  animation: view-in 180ms ease-out;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.loading-view {
  display: grid;
  min-height: 52vh;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 14px;
}

.loader {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 760ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.page-heading {
  max-width: 520px;
  padding: 16px 0 30px;
}

.compact-heading {
  padding-top: 2px;
  padding-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.16;
  letter-spacing: 0;
}

.compact-heading h1 {
  font-size: 25px;
}

.page-heading > p:last-child {
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.55;
}

.guest-actions,
.primary-actions {
  display: flex;
  gap: 10px;
}

.guest-actions {
  flex-wrap: wrap;
  padding-bottom: 24px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.button {
  gap: 9px;
  padding: 0 18px;
}

.button svg,
.icon-button svg {
  width: 19px;
  height: 19px;
}

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

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

.button-secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.icon-button {
  width: 48px;
  flex: 0 0 48px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.info-band {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 17px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
}

.info-band > svg {
  width: 21px;
  height: 21px;
  color: var(--accent);
}

.info-band div {
  display: grid;
  gap: 4px;
}

.info-band strong,
.info-band span {
  font-size: 14px;
}

.info-band span {
  color: var(--text-muted);
  line-height: 1.45;
}

.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-panel > div {
  display: grid;
  gap: 5px;
}

.status-label,
.metric span {
  color: var(--text-muted);
  font-size: 12px;
}

.status-panel strong {
  font-size: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 22px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.metric {
  display: grid;
  min-height: 86px;
  align-content: center;
  gap: 8px;
  padding: 16px;
  background: var(--surface);
}

.metric-wide {
  grid-column: 1 / -1;
}

.metric strong {
  overflow-wrap: anywhere;
  font-size: 17px;
}

.primary-actions .button {
  flex: 1;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 34px 22px;
  border: 1px dashed #c8d1cd;
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.empty-state > svg {
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
  color: var(--accent);
}

.empty-state strong {
  font-size: 16px;
}

.empty-state span {
  max-width: 380px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.empty-state .button {
  margin-top: 8px;
}

.error-state > svg {
  color: var(--danger);
}

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

.link-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.link-list > a {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
}

.link-list > a:last-child {
  border-bottom: 0;
}

.link-list > a > span:nth-child(2) {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.link-list strong,
.link-list small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-list strong {
  font-size: 14px;
}

.link-list small {
  color: var(--text-muted);
  font-size: 12px;
}

.link-list > a > svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.link-icon {
  width: 36px;
  height: 36px;
  background: var(--surface-muted);
  color: var(--accent);
}

.bottom-nav {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: calc(68px + var(--safe-bottom));
  padding: 7px max(12px, calc((100vw - 620px) / 2 + 12px)) var(--safe-bottom);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
}

.bottom-nav button {
  display: grid;
  min-width: 0;
  place-items: center;
  align-content: center;
  gap: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
}

.bottom-nav button svg {
  width: 20px;
  height: 20px;
}

.bottom-nav button.active {
  color: var(--accent);
  font-weight: 750;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 20px;
  bottom: calc(84px + var(--safe-bottom));
  left: 20px;
  width: min(calc(100% - 40px), 460px);
  min-height: 46px;
  margin: 0 auto;
  padding: 13px 16px;
  border-radius: 8px;
  background: #202522;
  color: #ffffff;
  box-shadow: var(--shadow);
  text-align: center;
  font-size: 13px;
  font-weight: 650;
}

.document-page {
  width: min(calc(100% - 40px), 760px);
  margin: 0 auto;
  padding: 56px 0;
}

.document-back {
  display: inline-flex;
  margin-bottom: 44px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.document-notice {
  margin-top: 30px;
  padding: 20px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--warning);
  border-radius: 6px;
  background: var(--surface);
}

.document-notice p {
  margin: 10px 0 0;
  color: var(--text-muted);
  line-height: 1.6;
}

[hidden] {
  display: none !important;
}

@media (max-width: 460px) {
  .app-shell {
    padding-right: 16px;
    padding-left: 16px;
  }

  h1 {
    font-size: 27px;
  }

  .guest-actions {
    display: grid;
  }

  .guest-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
