:root {
  color-scheme: light;
  --paper: #f3f3f4;
  --surface: #fff;
  --ink: #201e2c;
  --muted: #5d5a6b;
  --line: #dedee3;
  --accent: #44347f;
  --accent-dark: #332361;
  --accent-pale: #ede8f8;
  --success: #235d45;
  --success-bg: #e7f2e9;
  --warning: #694a12;
  --warning-bg: #faefd4;
  --error: #972f43;
  --error-bg: #f9e8ec;
  --radius: 18px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-height: 100vh; margin: 0; background: radial-gradient(ellipse at 12% 0, #e9e5ed85, transparent 44rem), radial-gradient(ellipse at 93% 10%, #dfe7e984, transparent 41rem); }
a { color: inherit; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #786bc1; outline-offset: 3px; }
button:disabled { cursor: wait; opacity: .65; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 5vw, 3.55rem); line-height: 1.04; letter-spacing: -.065em; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 680; letter-spacing: -.035em; }
h3 { font-size: 1.35rem; font-weight: 675; letter-spacing: -.035em; }

.shell { width: min(100% - 64px, 1232px); margin: 0 auto; }
.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; flex: none; text-decoration: none; font-size: 1.04rem; font-weight: 730; letter-spacing: -.025em; }
.brand-mark { display: block; width: 62px; height: 48px; object-fit: contain; mix-blend-mode: multiply; }
.brand-wordmark { display: grid; gap: 2px; line-height: 1.05; }
.brand-wordmark span { color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .012em; }
.brand-wordmark strong { font-weight: 740; }
.top-nav { display: flex; align-items: center; gap: 5px; margin-inline: auto; white-space: nowrap; }
.top-nav a { padding: 8px 13px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 590; font-size: .91rem; }
.top-nav a:hover, .top-nav a[aria-current='page'] { background: var(--accent-pale); color: var(--accent-dark); }
.guest-nav { margin: 0 0 0 auto; }
.guest-nav a:last-child { color: var(--accent-dark); background: var(--accent-pale); }
.environment { margin-left: auto; white-space: nowrap; border: 1px solid #e7d8af; background: #faf2df; color: #654f20; border-radius: 99px; padding: 5px 10px; font-size: .75rem; font-weight: 650; }
#content { padding: 38px 0 68px; }
#boot { color: var(--muted); }

.button {
  display: inline-flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 650;
  cursor: pointer;
}
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--accent-dark); }
.button-secondary { border-color: var(--line); background: var(--surface); }
.button-secondary:hover:not(:disabled), .button-quiet:hover:not(:disabled) { border-color: #cabfe3; color: var(--accent-dark); }
.button-link { padding-inline: 0; justify-content: flex-start; color: var(--accent); }
.button-link:hover { text-decoration: underline; }

.auth { display: grid; grid-template-columns: 1.22fr .78fr; min-height: 520px; width: min(100%, 1074px); margin: min(6vw, 52px) auto 0; border-radius: 25px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.auth-intro { position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: flex-start; padding: clamp(27px, 5.5vw, 65px); color: #f7f2fb; background: #2d2445; }
.auth-intro p { max-width: 30ch; margin-top: 17px; color: #e5daef; font-size: 1rem; }
.auth-panel { align-self: center; padding: clamp(24px, 4.7vw, 59px); }
.auth-panel h2 { margin-bottom: 19px; font-size: 2rem; }
.auth-intro h1 { letter-spacing: -.055em; }
.auth-illustration { position: absolute; z-index: -1; right: -3%; bottom: -14%; width: 105%; max-width: 620px; aspect-ratio: 1.75; }
.auth-grid { position: absolute; inset: 0; opacity: .22; background-image: linear-gradient(#bbabdc 1px, transparent 1px), linear-gradient(90deg, #bbabdc 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse, #000 12%, transparent 74%); }
.auth-orbit { position: absolute; inset: 6% 5% 15% 9%; border: 1px solid #786a93; border-radius: 50%; transform: rotate(-17deg); opacity: .65; }
.auth-tiles { position: absolute; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 40%; aspect-ratio: 1; right: 21%; top: 5%; transform: rotate(-17deg) skew(5deg, 5deg); }
.auth-tiles i { display: block; border-radius: 17%; background: linear-gradient(140deg, #b1a1d8, #8474ae); box-shadow: 0 13px 0 #453763, 0 18px 33px #1d182b99; }
.auth-tiles i:nth-child(2) { background: linear-gradient(140deg, #ecd2b2, #d39d84); box-shadow: 0 13px 0 #985e63, 0 18px 33px #1d182b99; transform: translateY(-11%); }
.auth-tiles i:nth-child(3) { background: linear-gradient(140deg, #b7cdc0, #789a8b); box-shadow: 0 13px 0 #406568, 0 18px 33px #1d182b99; transform: translateY(7%); }
.auth-tiles i:nth-child(4) { background: linear-gradient(140deg, #d7c4ec, #ac94c8); box-shadow: 0 13px 0 #6d568b, 0 18px 33px #1d182b99; }

.guest-home { display: grid; gap: clamp(35px, 6.2vw, 76px); }
.site-hero {
  display: grid;
  grid-template-columns: 1.13fr .87fr;
  min-height: 372px;
  border: 1px solid #dcdce4;
  border-radius: 26px;
  background: radial-gradient(ellipse at 0 2%, #faf9fa, transparent 66%), linear-gradient(126deg, #eeeef1 36%, #e7e4ed 72%, #dfe7ea);
  overflow: hidden;
}
.site-hero-copy { align-self: center; padding: clamp(24px, 5.3vw, 64px); }
.site-hero h1 { max-width: 12ch; color: #242230; font-size: clamp(2.3rem, 5.45vw, 4.3rem); }
.site-hero-copy p { max-width: 46ch; margin-top: 17px; color: #5a5267; }
.site-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 25px; }
.site-actions .button { min-height: 48px; padding-inline: 17px; }
.site-actions .button-primary { gap: 12px; border-color: #302a40; background: linear-gradient(145deg, #514965, #322d42); box-shadow: 0 4px 10px #30274129; }
.site-actions .button-primary:hover { background: #302a40; }
.site-actions .arrow { color: #f7f4ff; }
.site-hero-art { position: relative; overflow: hidden; isolation: isolate; background: radial-gradient(ellipse at 66% 10%, #9a9bad, transparent 70%), linear-gradient(155deg, #666673, #474655 65%, #545868); }
.site-hero-art .auth-illustration { right: -4%; bottom: -9%; width: 110%; aspect-ratio: 1.38; }
.site-hero-art .auth-tiles { right: 29%; top: 16%; width: 45%; }
.site-hero-art .auth-tiles i { filter: saturate(.35); }
.site-hero-art .auth-grid { mask-image: radial-gradient(ellipse, #000 16%, transparent 74%); }
.site-section, #auth { scroll-margin-top: 18px; }
.site-section h2 { font-size: clamp(1.62rem, 4vw, 2.3rem); }
.site-section .section-head { margin-bottom: 17px; }
.public-catalog .module-body { padding-inline: 8px; }
.public-catalog .module-description { max-width: 100%; }
.catalog-availability { font-size: .8rem; font-weight: 620; color: var(--success); }
.catalog-pending { color: var(--muted); }
.catalog-note { margin-top: 12px; }
.auth-intro .auth-intro-title { margin: 0; max-width: none; color: #f7f2fb; font-size: clamp(1.65rem, 4.2vw, 3rem); font-weight: 700; letter-spacing: -.04em; }

.access-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.access-card { display: flex; flex-direction: column; gap: 7px; min-width: 0; padding: 17px 19px 19px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.access-card h3 { font-size: 1.02rem; }
.access-card strong { color: var(--accent-dark); font-size: clamp(1.4rem, 3.2vw, 2rem); line-height: 1.15; letter-spacing: -.04em; }
.access-card ul { margin: 0; padding-left: 1.15em; }
.access-card li + li { margin-top: 3px; }
.access-card-starter { background: #eee8f8; border-color: #e2d7f0; }
.admin-access-panel .access-grid { margin-top: 12px; }
.admin-access-panel .access-card { border-radius: 12px; }

form, .stack { display: grid; gap: 13px; }
form label { display: grid; gap: 6px; font-weight: 620; font-size: .9rem; }
input, select { min-width: 0; width: 100%; border: 1px solid #cbc8d3; border-radius: 8px; padding: 9px 10px; min-height: 43px; background: var(--surface); color: var(--ink); }
form .button { justify-self: start; }
.auth-panel form .button { justify-self: stretch; margin-top: 4px; }
.auth-panel .button-link { margin-top: 9px; }
.feedback { margin-top: 9px; font-size: .9rem; overflow-wrap: anywhere; color: var(--success); }
.feedback[data-error='true'] { color: var(--error); }
.muted { color: var(--muted); font-size: .92rem; }
.eyeline { color: var(--muted); font-size: .82rem; margin: 0 0 9px; overflow-wrap: anywhere; }

.dashboard-head, .section-head { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 24px; }
.section-head .muted { margin-top: 8px; }
.wallet-peek { display: grid; grid-template-columns: 36px auto 16px; gap: 11px; align-items: center; padding: 10px 14px; min-width: 235px; background: #ece7f6; border-radius: 13px; color: var(--accent-dark); text-decoration: none; }
.wallet-peek:hover { background: #e2d9f1; }
.wallet-peek .muted { display: block; font-weight: 560; font-size: .73rem; color: #5d4e79; }
.wallet-peek strong { font-size: 1.06rem; }
.wallet-icon { width: 30px; height: 23px; border: 2px solid #6f5f90; border-radius: 5px; position: relative; }
.wallet-icon::after { content: ''; position: absolute; right: -3px; top: 6px; width: 10px; height: 7px; border-radius: 2px; background: #6f5f90; }
.arrow { position: relative; display: inline-block; flex: 0 0 10px; width: 10px; height: 10px; color: var(--accent); }
.arrow::before, .arrow::after { content: ''; position: absolute; }
.arrow::before { top: 0; right: 0; width: 6px; height: 6px; border-top: 1.5px solid; border-right: 1.5px solid; }
.arrow::after { top: 4px; left: 0; width: 11px; border-top: 1.5px solid; transform: rotate(-45deg); }

.module-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; gap: 16px; }
.module-card { display: flex; flex-direction: column; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.module-body { display: grid; gap: 8px; padding: 13px 5px 3px; flex: 1; grid-template-rows: auto 1fr auto; }
.module-top, .module-actions { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.module-card h2 { font-size: 1.27rem; }
.module-description { min-height: 2.7em; max-width: 48ch; font-size: .87rem; color: var(--muted); }
.module-actions { margin-top: 5px; }
.module-actions .muted { font-size: .81rem; }
.module-actions .button { border-color: #d9d5e2; background: #f3f0f7; color: var(--accent-dark); }
.module-actions .button:hover { border-color: #bcb1ce; background: #eee8f5; }
.module-art {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  aspect-ratio: 2.1;
  min-height: 125px;
  border-radius: 12px;
  background-color: #e7e7eb;
  background-position: center;
  background-size: cover;
}
.module-art[data-module='sloy'] { background-image: url('/static/art/layered.webp'); }
.module-art[data-module='kontur-v2'] { background-color: #fff; background-image: url('/static/art/stencil.webp'); background-size: auto 100%; background-repeat: no-repeat; }
.module-art[data-module='marketpilot'] { background-image: url('/static/art/marketpilot.webp'); }
.module-art[data-module='budget'] { background-image: url('/static/art/warm-budget.webp'); }
.module-art[data-module='mold-craft'] { background-image: url('/static/art/moldcraft.webp'); }
.marketplace-badges { position: absolute; right: 8px; bottom: 8px; left: 8px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.marketplace-badges span { padding: 2px 7px; border-radius: 6px; background: #fffffff2; color: #272434; box-shadow: 0 1px 4px #29232b2e; font-size: .7rem; font-weight: 670; white-space: nowrap; }
.marketplace-badges span:nth-child(1) { color: #9b2825; }
.marketplace-badges span:nth-child(2) { color: #2941ad; }
.marketplace-badges span:nth-child(3) { background: #ffdfa0; }

.chip { display: inline-flex; align-items: center; border-radius: 99px; padding: 3px 8px; font-size: .72rem; font-weight: 650; line-height: 1.45; width: fit-content; white-space: nowrap; }
.chip-ready { background: var(--success-bg); color: var(--success); }
.chip-conditional, .chip-test { background: var(--warning-bg); color: var(--warning); }
.chip-unavailable { background: #ecebed; color: #5d5964; }
.chip-test { margin-left: 7px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { display: grid; gap: 4px; padding: 13px 16px; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.metric strong { font-size: clamp(1.2rem, 3vw, 1.75rem); line-height: 1.18; letter-spacing: -.045em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric span { color: var(--muted); font-size: .83rem; }
.metric:first-child { background: var(--accent-pale); border-color: #e1d8ed; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 20px; min-width: 0; }
.panel h2 { margin-bottom: 10px; }
.panel p + .stack { margin-top: 12px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.panel-heading h2 { margin-bottom: 0; }
.empty { padding: 12px 0; color: var(--muted); font-size: .92rem; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; font-size: .9rem; }
th { color: var(--muted); font-size: .78rem; font-weight: 630; }
th, td { padding: 10px 9px; border-bottom: 1px solid #eeebef; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tr:last-child td { border-bottom: none; }
.align-right { text-align: right; font-variant-numeric: tabular-nums; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 9px; font-size: .84rem; }
.pagination .button:disabled { cursor: default; }
.result-button { display: block; padding: 0; min-height: 31px; text-align: left; }
.result-dialog { width: min(92vw, 615px); max-height: 90vh; padding: 17px; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); }
.result-dialog::backdrop { background: #211834b5; }
.result-dialog img { display: block; max-width: 100%; max-height: 62vh; margin: 13px auto; object-fit: contain; border-radius: 8px; }

#admin-view { display: grid; gap: 15px; }
#admin-view .section-head { margin-bottom: 5px; }
.admin-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.admin-metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0; }
.admin-metrics .metric { min-height: 73px; }
.tariff-form { grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.tariff-form .button { align-self: end; }
#packages { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 15px; }

@media (max-width: 1000px) {
  .shell { width: min(100% - 42px, 1232px); }
  .module-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .site-hero { min-height: 318px; }
}
@media (max-width: 690px) {
  .shell { width: calc(100% - 30px); }
  #content { padding: 24px 0 44px; }
  .topbar { min-height: 61px; gap: 9px; flex-wrap: wrap; padding-block: 9px; }
  .top-nav { order: 5; width: 100%; margin: 0; overflow: auto; }
  .top-nav a { padding-inline: 9px; }
  .guest-nav { order: 0; width: auto; margin-left: auto; }
  .guest-nav a { padding-inline: 6px; font-size: .8rem; }
  .brand { font-size: .97rem; }
  .brand-mark { width: 48px; height: 39px; }
  .brand + .environment { margin-left: auto; }
  #logout { padding-inline: 6px; }
  .auth { grid-template-columns: minmax(0, 1fr); margin-top: 0; }
  .auth-intro { min-height: 204px; }
  .auth-intro h1 { font-size: 2rem; }
  .auth-intro p { position: relative; max-width: 26ch; font-size: .88rem; }
  .auth-illustration { width: 72%; right: -14%; bottom: -11%; opacity: .7; }
  .site-hero { grid-template-columns: minmax(0, 1fr); min-height: auto; }
  .site-hero-art { height: 178px; }
  .site-hero-art .auth-illustration { right: 4%; bottom: -37%; width: 94%; max-width: 405px; }
  .site-hero-copy p { font-size: .93rem; }
  .site-hero h1 { max-width: 15ch; }
  .site-actions { margin-top: 16px; }
  .access-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard-head, .section-head { flex-wrap: wrap; align-items: start; margin-bottom: 15px; gap: 12px; }
  .wallet-peek { min-width: 183px; padding: 8px 10px; grid-template-columns: 29px auto 12px; gap: 8px; }
  .wallet-icon { width: 25px; height: 20px; }
  .wallet-icon::after { top: 5px; }
  .module-list { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .module-description { min-height: 0; }
  .admin-columns { grid-template-columns: minmax(0, 1fr); }
  .metric-grid { gap: 7px; }
  .metric { padding: 9px; }
  .metric span { font-size: .72rem; }
  .panel { padding: 12px; }
  .history-panel table { table-layout: fixed; white-space: normal; font-size: .8rem; }
  .history-panel th, .history-panel td { padding-inline: 5px; }
  .history-panel th:first-child, .history-panel td:first-child { padding-left: 0; }
  .history-panel th:last-child, .history-panel td:last-child { padding-right: 0; }
  .history-panel th:nth-child(1) { width: 38%; }
  .history-panel th:nth-child(2) { width: 24%; }
  .history-panel th:nth-child(3) { width: 22%; }
  .history-panel .chip-test { margin-left: 3px; }
  .history-panel .result-button { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
