:root {
  --bg: #FAFAFA;
  --surface: #ffffff;
  --surface-strong: #FAFAFA;
  --text: #0A0A0B;
  --muted: #6B6B72;
  --faint: #9A9AA2;
  --border: #ECECEF;
  --border-strong: #E4E4E7;
  --accent: #0A0A0B;
  --accent-dark: #000000;
  --purple: #5B5BD6;
  --green: #059669;
  --green-bg: #ECFDF5;
  --amber: #B45309;
  --amber-bg: #FFFBEB;
  --red: #DC2626;
  --red-bg: #FEF2F2;
  --shadow: 0 1px 2px rgba(10, 10, 15, 0.04);
  --shadow-lg: 0 16px 40px rgba(10, 10, 15, 0.06);
  --radius: 16px;
  --radius-sm: 11px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Geist", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: #0A0A0B;
  color: #fff;
}

a {
  color: var(--text);
  text-decoration: none;
}

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

h1, h2, h3 {
  letter-spacing: -0.03em;
}

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 24px;
  background: rgba(250, 250, 250, 0.78);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(14px);
}

.brand,
.nav,
.nav form,
.actions-row,
.row-actions,
.status-strip {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: #0A0A0B;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.nav {
  gap: 4px;
}

.nav a {
  height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: color .15s ease, background .15s ease;
}

.nav a.active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 2px rgba(10, 10, 15, .05);
}

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

.primary-link {
  height: 38px;
  padding: 0 18px !important;
  background: #0A0A0B;
  color: #fff !important;
  border-radius: 9px;
  font-weight: 560;
}

.primary-link:hover {
  background: #000;
}

/* ---------- Layout ---------- */
.page {
  flex: 1;
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

.workspace-grid,
.dashboard-grid,
.admin-grid {
  display: grid;
  gap: 24px;
}

.workspace-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  align-items: start;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.8fr);
}

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

.dashboard-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.dashboard-head h1,
.intro-panel h1,
.auth-panel h1 {
  margin: 0;
  line-height: 1.05;
}

.dashboard-head h1 {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 600;
}

/* ---------- Hero (landing) ---------- */
.hero {
  text-align: center;
  padding: 56px 0 48px;
  animation: fadeUp .45s cubic-bezier(.22,1,.36,1) both;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

.hero-tag .dot {
  width: 7px;
  height: 7px;
  background: #10B981;
}

.hero h1 {
  font-size: clamp(40px, 6vw, 60px);
  line-height: 1.04;
  font-weight: 600;
  margin: 0 auto;
  max-width: 760px;
}

.hero-sub {
  font-size: 18px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 560px;
  margin: 24px auto 0;
}

.hero .actions-row {
  justify-content: center;
  margin-top: 36px;
}

.trust-row {
  display: flex;
  gap: 28px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 44px;
}

.trust-row span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.section-center {
  text-align: center;
  margin-bottom: 40px;
}

.section-center h2 {
  font-size: 34px;
  font-weight: 600;
  margin: 0;
}

.section-center p {
  color: var(--muted);
  font-size: 16px;
  margin: 10px 0 0;
}

/* ---------- Plan cards ---------- */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  align-items: start;
}

.plan-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.plan-card.popular {
  border: 1.5px solid var(--purple);
  box-shadow: 0 16px 40px rgba(91, 91, 214, .14);
}

.plan-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--purple);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 999px;
}

.plan-card .plan-name {
  font-size: 15px;
  font-weight: 560;
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 14px;
}

.plan-price b {
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -.03em;
}

.plan-price span {
  color: var(--faint);
  font-size: 15px;
}

.plan-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  min-height: 18px;
}

.plan-card .divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}

.plan-feats {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.plan-feats li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #3F3F46;
}

.plan-feats li::before {
  content: "✓";
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  background: #F0F0F2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0A0A0B;
  font-size: 10px;
  font-weight: 700;
}

/* ---------- How steps ---------- */
.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.how-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.how-num {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #0A0A0B;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
}

.how-card h3 {
  font-weight: 560;
  font-size: 17px;
  margin: 18px 0 0;
}

.how-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 8px 0 0;
}

/* ---------- Intro panel (fallback) ---------- */
.intro-panel {
  padding: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.intro-panel h1 {
  max-width: 780px;
  margin-top: 8px;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 600;
}

.intro-copy {
  max-width: 650px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

/* ---------- Panels ---------- */
.panel,
.auth-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 28px;
}

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

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel h2,
.empty-state h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.section-label {
  margin: 0 0 6px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 560;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---------- Buttons ---------- */
.button,
.ghost-button,
.mini-button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 560;
  letter-spacing: -0.01em;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  font-size: 15px;
}

.button.primary,
.mini-button.success {
  background: #0A0A0B;
  color: #fff;
}

.button.primary:hover {
  transform: translateY(-2px);
}

.mini-button.success:hover {
  background: #000;
}

.button.secondary {
  background: #fff;
  color: #0A0A0B;
  border: 1px solid var(--border-strong);
}

.button.secondary:hover {
  background: #FAFAFA;
}

.ghost-button {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}

.ghost-button:hover {
  background: #FAFAFA;
}

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  background: #0A0A0B;
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
}

.mini-button:hover {
  background: #000;
}

.mini-button.danger {
  background: #fff;
  color: var(--red);
  border: 1px solid var(--border-strong);
}

.mini-button.danger:hover {
  background: var(--red-bg);
}

.inline-button {
  width: fit-content;
  margin-top: 8px;
}

.actions-row {
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.full-button {
  width: 100%;
}

/* ---------- Status strip ---------- */
.status-strip {
  width: fit-content;
  gap: 9px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.dot.success {
  background: #10B981;
}

.dot.warning {
  background: var(--amber);
}

/* ---------- Tariff / compact rows ---------- */
.tariff-list,
.compact-list,
.flash-stack {
  display: grid;
  gap: 10px;
}

.tariff-row,
.compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.tariff-row strong,
.compact-row strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 560;
}

.tariff-row span,
.compact-row span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.tariff-meta {
  display: grid;
  justify-items: end;
  gap: 8px;
  flex-shrink: 0;
}

.tariff-meta b {
  font-size: 18px;
  font-weight: 600;
}

/* ---------- Auth ---------- */
.auth-shell {
  display: grid;
  min-height: calc(100vh - 220px);
  place-items: center;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 36px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .4s cubic-bezier(.22,1,.36,1) both;
}

.auth-panel h1 {
  font-size: 26px;
  font-weight: 600;
}

.form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.form label {
  display: grid;
  gap: 7px;
  color: #3F3F46;
  font-size: 13px;
  font-weight: 500;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #FAFAFA;
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}

input,
select {
  height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 110px;
  resize: vertical;
  padding: 14px;
  font-family: "Geist Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #0A0A0B;
  background: #fff;
}

.form .button {
  width: 100%;
  margin-top: 4px;
}

/* ---------- Flash ---------- */
.flash-stack {
  margin-bottom: 20px;
}

.flash {
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}

.flash.success {
  border-color: rgba(5, 150, 105, 0.25);
  background: var(--green-bg);
  color: var(--green);
}

.flash.error {
  border-color: rgba(220, 38, 38, 0.25);
  background: var(--red-bg);
  color: var(--red);
}

.flash.warning {
  border-color: rgba(180, 83, 9, 0.25);
  background: var(--amber-bg);
  color: var(--amber);
}

/* ---------- Facts ---------- */
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
}

.facts.single-column {
  grid-template-columns: 1fr;
  margin-top: 18px;
}

.facts div {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #FAFAFA;
}

.facts dt {
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}

.facts dd {
  margin: 6px 0 0;
  font-size: 19px;
  font-weight: 600;
}

/* ---------- Key / QR ---------- */
.key-area {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 24px;
  margin-top: 8px;
}

.qr-box {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 12px;
  box-shadow: var(--shadow);
}

.qr-box img {
  width: 100%;
  height: 100%;
}

.key-copy {
  display: grid;
  gap: 10px;
  align-content: start;
}

.key-copy label {
  color: #3F3F46;
  font-size: 13px;
  font-weight: 500;
}

.key-copy textarea {
  background: #FAFAFA;
  color: #3F3F46;
}

/* ---------- Empty state ---------- */
.empty-state {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #FAFAFA;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.warning-state {
  border-color: rgba(180, 83, 9, 0.25);
  background: var(--amber-bg);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 11px;
  border-radius: 7px;
  background: #F4F4F5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.active,
.badge.paid {
  background: var(--green-bg);
  color: var(--green);
}

.badge.pending,
.badge.maintenance {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge.disabled,
.badge.expired,
.badge.offline,
.badge.rejected,
.badge.failed,
.badge.canceled,
.badge.refunded,
.badge.provision_failed {
  background: var(--red-bg);
  color: var(--red);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

thead tr {
  background: #FAFAFA;
}

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--faint);
  font-size: 12px;
  font-weight: 560;
  text-transform: uppercase;
  letter-spacing: .04em;
}

tbody tr:last-child td {
  border-bottom: none;
}

td {
  font-size: 14px;
}

.row-actions {
  justify-content: flex-end;
  gap: 8px;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.mono-cell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "Geist Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

/* ---------- Stat grid / servers ---------- */
.stat-grid,
.server-card-grid,
.server-form-grid {
  display: grid;
  gap: 16px;
}

.stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stat-grid div {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

.stat-grid span {
  display: block;
  color: var(--faint);
  font-size: 13px;
}

.stat-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  font-weight: 600;
}

.server-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.server-card {
  display: grid;
  gap: 16px;
}

.load-line {
  display: grid;
  gap: 10px;
}

.load-line > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.load-line span {
  color: var(--muted);
  font-size: 13px;
}

.load-bar {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #F0F0F2;
}

.load-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #10B981;
}

.load-bar.warning span {
  background: var(--amber);
}

.load-bar.danger span,
.load-bar.full span {
  background: var(--red);
}

.server-facts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.server-facts dd {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.server-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

/* ---------- Public server cards ---------- */
.public-server-grid,
.public-server-stack,
.public-tariff-list {
  display: grid;
  gap: 14px;
}

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

.public-server-card {
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

.public-server-card summary {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 20px;
  cursor: pointer;
  list-style: none;
}

.public-server-card summary::-webkit-details-marker {
  display: none;
}

.public-server-card summary strong,
.public-server-card summary small {
  display: block;
}

.public-server-card summary strong {
  font-size: 20px;
  font-weight: 600;
}

.public-server-card summary small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.public-server-card.compact summary {
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
}

.public-server-card.compact summary strong {
  font-size: 17px;
}

.finland-flag {
  display: block;
  aspect-ratio: 18 / 11;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background:
    linear-gradient(to right, transparent 0 26%, #4549c9 26% 38%, transparent 38% 100%),
    linear-gradient(to bottom, transparent 0 35%, #4549c9 35% 58%, transparent 58% 100%),
    #fff;
}

.public-tariff-list {
  padding: 0 20px 20px;
}

.public-server-card.compact .public-tariff-list {
  padding: 0 16px 16px;
}

.public-tariff-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #FAFAFA;
}

.public-tariff-row strong,
.public-tariff-row span {
  display: block;
}

.public-tariff-row strong {
  font-weight: 560;
}

.public-tariff-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: #fff;
}

.site-footer .inner {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer .brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 11px;
}

.site-footer .copy {
  color: var(--faint);
}

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .topbar {
    padding: 0 16px;
    gap: 8px;
  }

  .nav {
    flex-wrap: wrap;
  }

  .nav a {
    padding: 0 10px;
  }

  .page {
    width: min(100% - 32px, 1120px);
    padding-top: 28px;
  }

  .workspace-grid,
  .dashboard-grid,
  .admin-grid,
  .server-card-grid,
  .server-form-grid,
  .public-server-grid {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: span 1;
  }

  .dashboard-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .intro-panel {
    padding: 26px;
  }

  .facts,
  .key-area {
    grid-template-columns: 1fr;
  }

  .qr-box {
    width: 190px;
  }
}

@media (max-width: 560px) {
  .tariff-row,
  .compact-row,
  .public-tariff-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .tariff-meta {
    align-items: start;
    justify-items: start;
    width: 100%;
  }

  .tariff-meta .mini-button {
    width: 100%;
  }

  .public-server-card summary,
  .public-server-card.compact summary {
    grid-template-columns: 1fr;
  }
}
