:root {
  --bg: #030711;
  --bg-soft: #071325;
  --bg-panel: rgba(8, 20, 39, 0.88);
  --panel-2: rgba(12, 28, 52, 0.96);
  --line: rgba(255, 255, 255, 0.08);
  --text: #edf2fb;
  --muted: #a5b4d1;
  --gold: #f1c66b;
  --gold-2: #ffe5a8;
  --danger: #ff9e9e;
  --success: #92f4bf;
  --blue: #77c4ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius: 26px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(241, 198, 107, 0.14), transparent 24%),
    radial-gradient(circle at 100% 10%, rgba(119, 196, 255, 0.18), transparent 30%),
    linear-gradient(180deg, #02050d 0%, #061122 45%, #030813 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  filter: blur(70px);
  opacity: .65;
}

body::before {
  width: 280px;
  height: 280px;
  left: -60px;
  top: 80px;
  background: rgba(241, 198, 107, 0.18);
}

body::after {
  width: 340px;
  height: 340px;
  right: -120px;
  top: 140px;
  background: rgba(89, 168, 255, 0.15);
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 30%, rgba(241, 198, 107, .12), transparent 22%),
    radial-gradient(circle at 50% 70%, rgba(119, 196, 255, .10), transparent 25%),
    linear-gradient(180deg, #01040a 0%, #020814 100%);
  transition: opacity .5s ease, visibility .5s ease;
}

.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-box {
  text-align: center;
  width: min(92vw, 980px);
  padding: 32px 20px;
}

.loader-mark {
  width: 112px;
  height: 112px;
  margin: 0 auto 26px;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: linear-gradient(145deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02));
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35), inset 0 0 40px rgba(255, 255, 255, .02);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.loader-mark::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 90deg, transparent, rgba(241, 198, 107, .5), transparent, rgba(119, 196, 255, .5), transparent);
  animation: spin 2.1s linear infinite;
}

.loader-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  z-index: 1;
}

.loader-title {
  margin: 0 auto;
  width: max-content;
  max-width: 100%;
  font-size: clamp(28px, 4.8vw, 66px);
  font-weight: 800;
  letter-spacing: -.05em;
  white-space: nowrap;
  overflow: hidden;
  border-right: 2px solid rgba(255, 229, 168, .92);
  color: #fff;
  text-shadow: 0 0 30px rgba(255, 255, 255, .08), 0 0 60px rgba(241, 198, 107, .12);
  animation: typing 1.8s steps(26, end) .2s forwards, caret .9s step-end infinite;
  max-width: 0;
}

.loader-sub {
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: .22em;
  text-transform: uppercase;
  opacity: 0;
  animation: fadeUp .8s ease 1.2s forwards;
}

@keyframes typing { from { max-width: 0 } to { max-width: 26ch } }
@keyframes caret { 50% { border-color: transparent } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: translateY(0) } }
@keyframes spin { to { transform: rotate(360deg) } }

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 28px));
  margin: 18px auto 34px;
}

.top-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .06);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: contain;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: inset 0 0 24px rgba(255, 255, 255, .04), 0 12px 30px rgba(0, 0, 0, .3);
}

.brand-title {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 800;
  letter-spacing: -.04em;
}

.brand-tagline {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-button,
.button,
button,
.button-link {
  border: none;
  cursor: pointer;
  font: inherit;
  transition: .22s ease;
}

.nav-button,
.button-link,
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 18px;
  text-decoration: none;
  font-weight: 700;
}

.nav-button,
.btn-primary {
  color: #111;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  box-shadow: 0 12px 28px rgba(241, 198, 107, .22);
}

.nav-button.secondary,
.btn-secondary,
button.secondary,
button.file-btn,
.button-link.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: none;
}

.nav-button.active-link {
  outline: 2px solid rgba(255, 229, 168, .55);
  outline-offset: 2px;
}

.nav-button:hover,
.btn-primary:hover,
.btn-secondary:hover,
button:hover,
.button-link:hover {
  transform: translateY(-1px);
}

.lang-selector {
  display: flex;
  gap: 6px;
  align-items: center;
}

.lang-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  text-decoration: none;
}

.lang-btn svg {
  width: 24px;
  height: 16px;
  border-radius: 3px;
  overflow: hidden;
}

.lang-btn.active {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  box-shadow: 0 12px 28px rgba(241, 198, 107, .22);
}

.header-note,
.pill,
.small-note {
  color: var(--gold-2);
  font-size: 13px;
  padding: 10px 14px;
  border: 1px solid rgba(241, 198, 107, .18);
  border-radius: 999px;
  background: rgba(241, 198, 107, .07);
}

.main-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero,
.two-column,
.layout {
  display: grid;
  gap: 18px;
}

.hero {
  grid-template-columns: 1.05fr .95fr;
}

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

.layout {
  grid-template-columns: minmax(0, 1.08fr) 370px;
  align-items: start;
}

.card,
.panel,
.history-card,
.stat-card,
.auth-card,
.table-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.card,
.panel,
.history-card,
.auth-card,
.table-card {
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.card::before,
.panel::before,
.auth-card::before,
.table-card::before {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -70px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(241, 198, 107, .15), transparent 66%);
  pointer-events: none;
}

.eyebrow,
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
  color: var(--gold-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.page-title,
.hero-title,
.panel h1,
.panel h2,
.panel h3,
.auth-card h1,
.auth-card h2,
.table-card h2,
.history-card h3 {
  margin: 18px 0 12px;
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1.04;
  letter-spacing: -.05em;
}

.panel h2,
.auth-card h2,
.table-card h2,
.history-card h3 {
  font-size: clamp(24px, 3vw, 34px);
  margin-top: 0;
}

.section-text,
.hero-text,
.muted,
.page-subtitle,
.panel p,
.auth-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 18px;
  background: var(--panel-2);
}

.stat-card .label {
  color: var(--muted);
  font-size: 13px;
}

.stat-card .value {
  margin-top: 10px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.03em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  font-size: 14px;
  font-weight: 700;
  color: #dbe4f6;
}

input,
select,
textarea {
  width: 100%;
  padding: 15px 16px;
  border-radius: 18px;
  color: var(--text);
  font: inherit;
  outline: none;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  transition: .2s ease;
}

select option {
  color: var(--text);
  background-color: var(--bg-soft);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(241, 198, 107, .42);
  box-shadow: 0 0 0 4px rgba(241, 198, 107, .12);
  background: rgba(255, 255, 255, .05);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.actions,
.cta-buttons,
.inline-actions,
.small-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.message,
.notice,
.alert,
.success-box,
.error-box {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .08);
}

.notice,
.success-box {
  background: rgba(146, 244, 191, .08);
  color: var(--success);
  border-color: rgba(146, 244, 191, .18);
}

.alert,
.error-box {
  background: rgba(255, 158, 158, .08);
  color: var(--danger);
  border-color: rgba(255, 158, 158, .18);
}

.result-box {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.result-main {
  padding: 22px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: linear-gradient(145deg, rgba(241, 198, 107, .11), rgba(119, 196, 255, .06));
}

.big {
  font-size: clamp(28px, 3.8vw, 46px);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -.05em;
  margin: 12px 0 10px;
}

.detail-grid,
.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.detail,
.info-card {
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 20px;
  padding: 16px;
}

.detail .label,
.info-card .label {
  font-size: 13px;
  color: var(--muted);
}

.detail .value,
.info-card .value {
  margin-top: 9px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.03em;
  word-break: break-word;
}

.tabs {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.tab-btn {
  padding: 14px 20px;
  border-radius: 18px;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
}

.tab-btn.active {
  color: #111;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  box-shadow: 0 12px 28px rgba(241, 198, 107, .22);
}

.history-card {
  position: sticky;
  top: 16px;
}

.history-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: 960px;
  overflow: auto;
  padding-right: 4px;
}

.history-item {
  border-radius: 20px;
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, .06);
}

.history-item .type {
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold-2);
  font-weight: 800;
}

.history-item .title {
  margin: 8px 0 6px;
  font-size: 16px;
  font-weight: 800;
}

.history-item .meta {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.58;
}

.history-item .time {
  margin-top: 10px;
  font-size: 12px;
  color: #8db0e1;
}

.empty {
  border: 1px dashed rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .03);
  border-radius: 20px;
  padding: 18px;
  color: var(--muted);
  line-height: 1.65;
}

.table-wrap {
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  min-width: 720px;
}

.table th,
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  text-align: left;
  vertical-align: top;
}

.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--gold-2);
}

.table td {
  color: var(--text);
}

.table small,
.small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace;
}

.site-footer {
  background: var(--bg-panel);
  border-top: 1px solid var(--line);
  padding: 40px 20px;
  color: var(--muted);
  margin-top: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.footer-sections {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-bottom: 20px;
}

.footer-card {
  flex: 1 1 280px;
  padding: 16px;
  background: rgba(255, 177, 0, .10);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  border: 1px solid rgba(235, 235, 235, .20);
}

.footer-card h3 {
  color: var(--gold);
  margin: 0 0 12px;
  font-size: 20px;
}

.footer-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.footer-rights {
  margin-top: 20px;
  font-size: 13px;
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted { color: var(--muted); }
.mb-0 { margin-bottom: 0; }
.mt-0 { margin-top: 0; }

@media (max-width: 1160px) {
  .hero,
  .layout,
  .two-column {
    grid-template-columns: 1fr;
  }

  .history-card {
    position: relative;
    top: auto;
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 16px, 1440px);
  }

  .top-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    width: 100%;
    justify-content: flex-start;
  }

  .form-grid,
  .detail-grid,
  .info-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .loader-title {
    white-space: normal;
    border-right: none;
    animation: fadeUp .9s ease .25s forwards;
    max-width: 100%;
  }
}
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-thumb {
    background: var(--panel-2);
    border-radius: 10px;
    border: 2px solid #fcde9a;
}
::-webkit-scrollbar-track {
    background: var(--bg-soft);
}
.menu-toggle {
  display: none;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  border-radius: 999px;
  background: var(--text);
}

.header-stack {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace-layout {
  align-items: start;
}

.workspace-hero .card {
  min-height: 100%;
}

.module-badges,
.preset-row,
.mode-switch,
.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mini-badge,
.preset-chip,
.mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
}

.mini-badge.tiny {
  padding: 6px 10px;
  font-size: 11px;
}

.preset-chip,
.mode-btn {
  cursor: pointer;
}

.mode-btn.active,
.preset-chip:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .08));
}

.compact {
  padding: 16px;
}

.compact .value {
  font-size: 18px;
}

.calculator-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.calc-section-grid {
  align-items: start;
}

.calc-form-card,
.calc-side-card {
  min-height: 100%;
}

.formula-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
}

.search-row {
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}

.search-row input[type="search"] {
  flex: 1 1 320px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

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

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

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

.small-mono {
  font-size: 13px;
  line-height: 1.6;
}

.result-formula {
  font-size: 14px;
  line-height: 1.6;
}

.matrix-wrap {
  margin-top: 16px;
}

.matrix-table td,
.matrix-table th {
  white-space: nowrap;
}

.result-theme.theme-silver,
.theme-silver .result-main {
  background: linear-gradient(145deg, rgba(203, 214, 230, .20), rgba(114, 145, 191, .08));
}

.result-theme.theme-gold,
.theme-gold .result-main {
  background: linear-gradient(145deg, rgba(241, 198, 107, .17), rgba(255, 229, 168, .08));
}

.result-theme.theme-platinum,
.theme-platinum .result-main {
  background: linear-gradient(145deg, rgba(220, 227, 239, .16), rgba(150, 171, 209, .07));
}

.result-theme.theme-palladium,
.theme-palladium .result-main {
  background: linear-gradient(145deg, rgba(191, 206, 226, .17), rgba(102, 140, 199, .08));
}

.theme-silver .eyebrow,
.theme-silver .kicker {
  color: #dfe8f9;
}

.theme-gold .eyebrow,
.theme-gold .kicker {
  color: var(--gold-2);
}

.theme-platinum .eyebrow,
.theme-platinum .kicker,
.theme-palladium .eyebrow,
.theme-palladium .kicker {
  color: #dce6f7;
}

@media (max-width: 1160px) {
  .calculator-banner {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 980px) {
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
    align-items: flex-start;
  }

  .header-stack {
    display: none;
    width: 100%;
    padding-top: 12px;
  }

  .header-stack.open {
    display: grid;
    gap: 12px;
  }

  .header-stack .nav-row,
  .header-stack .lang-selector {
    width: 100%;
  }

  .header-stack .nav-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .header-stack .header-note {
    border-radius: 18px;
  }
}

@media (max-width: 820px) {
  .mini-stats,
  .detail-grid-2,
  .detail-grid-3,
  .detail-grid-4 {
    grid-template-columns: 1fr;
  }

  .search-row {
    align-items: stretch;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-btn {
    flex: 1 1 100%;
  }
}

.admin-grid {
  grid-template-columns: 1fr;
}

.admin-card {
  padding: 0;
  overflow: hidden;
}

.admin-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 18px;
}

.admin-card > summary::-webkit-details-marker {
  display: none;
}

.admin-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.admin-editor {
  padding: 0 18px 18px;
}

.module-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04);
}

.check-chip input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--gold);
}
