:root {
  --bg: #f5f1e8;
  --bg-soft: #fbf8f3;
  --panel: rgba(255, 252, 247, 0.9);
  --panel-solid: #fffdf9;
  --line: #ddd4c5;
  --line-strong: #cbbba5;
  --text: #221b13;
  --muted: #6e6354;
  --accent: #0d8f77;
  --accent-strong: #08705d;
  --accent-soft: #dbf4ed;
  --warning: #d17d26;
  --warning-soft: #fff0df;
  --danger: #bc4d54;
  --danger-soft: #fde6e8;
  --gold: #c79b2f;
  --gold-soft: #fff6df;
  --shadow: 0 22px 52px rgba(69, 46, 21, 0.09);
  --radius: 1.2rem;
}

* { box-sizing: border-box; }

body {
  position: relative;
  margin: 0;
  color: var(--text);
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(13, 143, 119, 0.14), transparent 28rem),
    radial-gradient(circle at bottom left, rgba(199, 155, 47, 0.12), transparent 24rem),
    linear-gradient(180deg, #f8f3ea 0%, #f4efe6 55%, #f7f4ef 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
    url("/media/background.png") center / cover no-repeat;
  opacity: 0.08;
  pointer-events: none;
  mix-blend-mode: multiply;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 0.75rem; }
p { margin: 0; }
button, input, select, textarea { font: inherit; }

.layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 1.5rem;
  border-right: 1px solid rgba(203, 187, 165, 0.6);
  background: rgba(255, 251, 245, 0.76);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  margin-bottom: 1.6rem;
}

.brand-mark {
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #2ab093);
  color: white;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.brand-logo {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.86);
  padding: 0.28rem;
  box-shadow: var(--shadow);
}

.nav {
  display: grid;
  gap: 0.45rem;
}

.nav a {
  padding: 0.8rem 0.95rem;
  border-radius: 0.95rem;
  color: var(--muted);
  transition: 160ms ease;
}

.nav a.active,
.nav a:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.logout { margin-top: 1.3rem; }

.main {
  padding: 2rem;
  min-width: 0;
}

.header {
  margin-bottom: 1.3rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.card,
.panel,
.hero-panel {
  background: var(--panel);
  border: 1px solid rgba(203, 187, 165, 0.7);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.85rem;
  line-height: 1;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid-three {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.78rem 0.64rem;
  text-align: left;
  border-bottom: 1px solid rgba(203, 187, 165, 0.55);
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

.stack {
  display: grid;
  gap: 0.9rem;
}

.stack.compact {
  gap: 0.65rem;
}

label {
  display: grid;
  gap: 0.35rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(203, 187, 165, 0.8);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

.small-input { width: 7rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 0;
  padding: 0.8rem 1rem;
  border-radius: 0.95rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: 160ms ease;
}

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

.button.ghost {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid rgba(13, 143, 119, 0.4);
}

.button.warning {
  background: var(--warning);
}

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

.button.full { width: 100%; }

.button.compact {
  padding: 0.62rem 0.9rem;
  border-radius: 0.85rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

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

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

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

.details {
  margin: 0;
  display: grid;
  gap: 0.7rem;
}

.details div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(203, 187, 165, 0.5);
}

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

.details dd {
  margin: 0;
  text-align: right;
}

.plain-list {
  margin: 0;
  padding-left: 1.15rem;
}

.codeblock {
  overflow-wrap: anywhere;
  padding: 0.85rem;
  border-radius: 0.95rem;
  background: #f7f1e7;
  border: 1px dashed rgba(203, 187, 165, 0.8);
}

.copy-link-card {
  gap: 0.75rem;
}

.copy-codeblock {
  cursor: copy;
  user-select: all;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.copy-codeblock:hover,
.copy-codeblock:focus-visible {
  border-color: rgba(13, 143, 119, 0.45);
  background: rgba(219, 244, 237, 0.72);
  box-shadow: 0 0 0 3px rgba(13, 143, 119, 0.12);
  outline: none;
}

.copy-codeblock.is-copied {
  border-style: solid;
  border-color: rgba(13, 143, 119, 0.45);
  background: rgba(219, 244, 237, 0.82);
}

.copy-link-toolbar {
  margin-bottom: 0;
}

.copy-link-hint {
  margin: 0;
}

.alert {
  margin-bottom: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  border: 1px solid transparent;
}

.alert.success {
  background: var(--accent-soft);
  border-color: rgba(13, 143, 119, 0.18);
  color: var(--accent-strong);
}

.alert.danger {
  background: var(--danger-soft);
  border-color: rgba(188, 77, 84, 0.18);
  color: var(--danger);
}

.alert.warning {
  background: rgba(246, 191, 56, 0.14);
  border-color: rgba(246, 191, 56, 0.28);
  color: #8a6510;
}

.hero {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.hero-panel {
  position: relative;
  overflow: hidden;
}

.hero-panel::after {
  content: "";
  position: absolute;
  inset: auto -3rem -4rem auto;
  width: 12rem;
  height: 12rem;
  background: radial-gradient(circle, rgba(13, 143, 119, 0.12), transparent 70%);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.plan-card {
  display: grid;
  gap: 0.85rem;
}

.plan-card.selected {
  border-color: rgba(199, 155, 47, 0.9);
  box-shadow: 0 24px 58px rgba(199, 155, 47, 0.18);
}

.plan-price {
  font-size: 2rem;
  font-weight: 800;
}

.plan-period {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(203, 187, 165, 0.8);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.88);
}

.plan-period.selected {
  border-color: rgba(13, 143, 119, 0.5);
  background: linear-gradient(135deg, rgba(219, 244, 237, 0.88), rgba(255, 255, 255, 0.98));
}

.plan-period-price {
  font-size: 1.25rem;
  font-weight: 800;
  white-space: nowrap;
}

.plan-selected-note {
  color: var(--accent-strong);
  font-weight: 700;
}

.status-lock {
  border: 1px solid rgba(209, 125, 38, 0.25);
  background: var(--warning-soft);
}

.chart-box {
  display: grid;
  grid-template-rows: auto minmax(240px, 320px);
  align-items: stretch;
  min-height: 0;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
  max-height: 320px;
}

.center-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-card {
  width: min(460px, 100%);
  background: var(--panel-solid);
  border: 1px solid rgba(203, 187, 165, 0.8);
  border-radius: 1.5rem;
  padding: 1.6rem;
  box-shadow: var(--shadow);
  margin-inline: auto;
}

.portal-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 1rem auto 2rem;
}

.portal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.portal-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.portal-grid .panel,
.portal-grid .hero-panel {
  height: 100%;
}

.qr-box {
  display: grid;
  place-items: center;
  padding: 1rem;
  border-radius: 1rem;
  background: #fff;
  border: 1px solid rgba(203, 187, 165, 0.7);
}

.qr-box img {
  width: min(220px, 100%);
  border-radius: 0.8rem;
}

.split {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.landing-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 1rem auto 2rem;
  display: grid;
  gap: 1rem;
}

.landing-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 0;
}

.landing-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.landing-cabinet-button {
  white-space: nowrap;
}

.landing-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  color: var(--muted);
}

.landing-nav a:hover {
  color: var(--accent-strong);
}

.landing-hero {
  position: relative;
  overflow: visible;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.4rem;
  align-items: center;
  min-height: 24rem;
  padding: 1.4rem clamp(8rem, 14vw, 10rem) 1.4rem 1.4rem;
}

.landing-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(13, 143, 119, 0.16), transparent 22rem),
    radial-gradient(circle at 82% 18%, rgba(199, 155, 47, 0.18), transparent 16rem),
    radial-gradient(circle at 72% 82%, rgba(34, 27, 19, 0.08), transparent 18rem);
  pointer-events: none;
}

.landing-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 1rem;
  max-width: min(42rem, 100%);
}

.landing-copy h1 {
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 0.98;
}

.landing-hero-mark {
  position: absolute;
  top: 2.3rem;
  right: -1.1rem;
  z-index: 0;
  height: min(13.5rem, 56%);
  pointer-events: none;
  opacity: 0.15;
}

.landing-hero-mark img {
  display: block;
  width: auto;
  height: 100%;
  object-fit: contain;
  clip-path: inset(0 0 0 49%);
  filter: blur(0.5px) saturate(0.8) drop-shadow(0 14px 22px rgba(13, 143, 119, 0.08));
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.landing-feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.landing-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}

.landing-metrics .card,
.landing-metrics .card strong {
  min-width: 0;
}

.landing-metrics .card strong {
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.08;
}

.landing-support-handle {
  display: block;
  max-width: 100%;
  font-size: clamp(1.15rem, 5.4vw, 1.7rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.landing-benefits {
  margin-bottom: 0;
}

.landing-plan-period {
  grid-template-columns: minmax(0, 1fr) auto;
}

.landing-story {
  position: relative;
  overflow: hidden;
}

.landing-story-card {
  background: rgba(255, 255, 255, 0.72);
}

.landing-latency {
  gap: 1rem;
}

.landing-latency-head {
  align-items: end;
}

.landing-latency-card {
  display: grid;
  gap: 0.35rem;
  padding: 1.05rem 1.15rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(203, 187, 165, 0.75);
}

.landing-latency-card strong {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.landing-latency-card.is-error {
  border-color: rgba(188, 77, 84, 0.4);
  background: rgba(253, 230, 232, 0.72);
}

.landing-latency-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.latency-disclaimer {
  margin-top: 0.15rem;
}

.landing-latency-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.72rem 0.82rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(203, 187, 165, 0.65);
}

.landing-latency-item strong {
  font-size: 1rem;
  white-space: nowrap;
}

.latency-recheck-note {
  display: inline-flex;
  align-items: center;
  margin-left: 0.4rem;
  padding: 0.16rem 0.45rem;
  border-radius: 999px;
  background: rgba(13, 143, 119, 0.1);
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 700;
}

.landing-latency-item.is-error {
  background: rgba(253, 230, 232, 0.64);
  border-color: rgba(188, 77, 84, 0.26);
}

.portal-server-panel {
  gap: 1rem;
}

.portal-login-grid {
  align-items: stretch;
}

.portal-login-card {
  height: 100%;
}

.portal-login-qr-card {
  align-items: center;
  text-align: center;
}

.portal-login-qr-image {
  display: block;
  width: min(18rem, 100%);
  aspect-ratio: 1;
  object-fit: contain;
  justify-self: center;
  align-self: center;
  margin-inline: auto;
  border-radius: 1rem;
  background: #fff;
  padding: 0.8rem;
  box-shadow: 0 18px 36px rgba(34, 27, 19, 0.08);
}

.portal-server-table th:last-child,
.portal-server-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

.server-latency-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 7.5rem;
  padding: 0.34rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(203, 187, 165, 0.75);
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.92rem;
  font-weight: 700;
}

.server-latency-chip-pending {
  color: var(--muted);
  background: rgba(241, 232, 219, 0.72);
}

.server-latency-chip-ready {
  color: var(--accent-strong);
  background: rgba(219, 244, 237, 0.8);
  border-color: rgba(13, 143, 119, 0.2);
}

.server-latency-chip-muted {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.server-latency-chip-error {
  color: var(--danger);
  background: rgba(253, 230, 232, 0.78);
  border-color: rgba(188, 77, 84, 0.22);
}

.portal-latency-box {
  margin-top: 0.35rem;
  padding-top: 0.25rem;
  border-top: 1px solid rgba(203, 187, 165, 0.55);
}

.portal-latency-head {
  align-items: end;
}

.portal-latency-card strong {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

.balance-showcase {
  justify-content: start;
}

.balance-amount {
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 800;
  line-height: 1;
}

.balance-actions {
  margin-bottom: 0;
}

.balance-note {
  padding: 0.85rem 0.95rem;
  border-radius: 0.95rem;
  background: rgba(219, 244, 237, 0.72);
  color: var(--accent-strong);
  font-weight: 600;
}

.document-body {
  display: grid;
  gap: 1rem;
  line-height: 1.7;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.document-body :where(h1, h2, h3, h4, p, li, blockquote, a, strong, em, span) {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.document-body h1,
.document-body h2,
.document-body h3,
.document-body h4 {
  margin: 0.4rem 0 0;
}

.document-body p,
.document-body ul,
.document-body blockquote {
  margin: 0;
}

.document-body ul {
  padding-left: 1.2rem;
}

.document-body blockquote {
  padding: 0.9rem 1rem;
  border-left: 4px solid rgba(13, 143, 119, 0.35);
  background: rgba(219, 244, 237, 0.45);
  border-radius: 0.8rem;
}

.document-body hr {
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(203, 187, 165, 0.8);
}

.legal-document-body,
.legal-document-body * {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.legal-document-body :where(pre, code, table, img, iframe) {
  max-width: 100%;
}

.legal-document-body pre {
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    padding: 1rem;
    border-right: 0;
    border-bottom: 1px solid rgba(203, 187, 165, 0.7);
  }
  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .main { padding: 1rem; }
  .header {
    align-items: flex-start;
  }
  .split,
  .header,
  .portal-topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .split > *,
  .header > *,
  .portal-topbar > * {
    width: 100%;
  }
  .toolbar,
  .inline-form,
  .hero-meta {
    width: 100%;
  }
  .toolbar,
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar > *,
  .toolbar > form > *,
  .inline-form > *,
  .portal-topbar .toolbar > * {
    width: 100%;
    min-width: 0;
  }
  .details div {
    flex-direction: column;
    align-items: flex-start;
  }
  .details dd {
    text-align: left;
  }
  .table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .portal-shell { width: min(100%, calc(100% - 1rem)); }
  .portal-grid { grid-template-columns: 1fr; }
  .grid-two,
  .grid-three {
    grid-template-columns: 1fr;
  }
  .plan-period { grid-template-columns: 1fr; }
  .landing-shell { width: min(100%, calc(100% - 1rem)); }
  .landing-topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .landing-topbar-actions {
    width: 100%;
    margin-left: 0;
  }
  .landing-topbar-actions .button {
    width: 100%;
  }
  .landing-hero {
    grid-template-columns: 1fr;
    min-height: 20rem;
    padding-right: clamp(5.5rem, 12vw, 7rem);
  }
  .landing-copy { max-width: min(100%, 38rem); }
  .landing-hero-mark {
    top: 2.1rem;
    right: -0.8rem;
    height: min(10rem, 46%);
    opacity: 0.12;
  }
  .copy-link-toolbar {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .main,
  .center-shell,
  .portal-shell,
  .landing-shell {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  .sidebar {
    padding: 0.85rem;
  }
  .nav {
    grid-template-columns: 1fr;
  }
  .card,
  .panel,
  .hero-panel,
  .login-card {
    padding: 1rem;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .chart-box {
    grid-template-rows: auto minmax(220px, 280px);
  }
  .landing-actions,
  .landing-feature-list,
  .hero-meta {
    flex-direction: column;
    align-items: stretch;
  }
  .landing-actions > *,
  .hero-meta > *,
  .landing-topbar-actions .button {
    width: 100%;
  }
  .landing-support-handle {
    font-size: clamp(1rem, 6vw, 1.35rem);
  }
  .legal-document-body {
    font-size: 0.96rem;
    line-height: 1.62;
  }
  .landing-hero-mark { display: none; }
  .landing-hero { padding-right: 1.4rem; }
  .landing-copy { max-width: 100%; }
}
