:root {
  --app-bg: #f4f8ff;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0b1533;
  --muted: #64748b;
  --line: #d9e3f0;
  --blue: #075cf8;
  --blue-2: #0ea5ff;
  --cyan: #06b6d4;
  --green: #10a36f;
  --green-soft: #e9fbf4;
  --orange: #d97706;
  --orange-soft: #fff7e6;
  --red: #dc2626;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(14, 165, 255, 0.12), transparent 34rem),
    linear-gradient(180deg, #fbfdff 0%, var(--app-bg) 100%);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  width: min(100%, 1320px);
  margin: 0 auto;
  min-height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--blue);
  font-size: 1.15rem;
  font-weight: 760;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  box-shadow: 0 10px 22px rgba(7, 92, 248, 0.28);
}
.brand-mark svg { width: 22px; height: 22px; }
.top-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.top-nav a {
  padding: 24px 18px;
  color: #0f172a;
  font-weight: 650;
  border-bottom: 3px solid transparent;
}
.top-nav a.active,
.top-nav a:hover {
  color: var(--blue);
  border-bottom-color: var(--blue);
  text-decoration: none;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: 10px;
  color: var(--muted);
  font-weight: 650;
}
.header-actions > a {
  color: var(--muted);
}
.auth-inline-form {
  margin: 0;
  display: inline-flex;
}
.auth-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid #cbd8e6;
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.auth-link:hover {
  border-color: var(--blue);
  color: var(--blue);
  text-decoration: none;
  transform: translateY(-1px);
}
.auth-link.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(7, 92, 248, .18);
}
.auth-link.primary:hover {
  color: #ffffff;
  box-shadow: 0 14px 26px rgba(7, 92, 248, .24);
}
.mobile-menu-button {
  display: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: #eff6ff;
  color: var(--blue);
  font-weight: 760;
  cursor: pointer;
}
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}
.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(86vw, 340px);
  transform: translateX(-102%);
  transition: transform 0.25s ease;
  z-index: 1001;
  background: #071226;
  color: #e2e8f0;
  padding: 18px;
  overflow-y: auto;
}
body.drawer-open .drawer { transform: translateX(0); }
body.drawer-open .drawer-overlay { opacity: 1; pointer-events: auto; }
.drawer h2 { margin: 8px 0 12px; color: #fff; font-size: 1rem; }
.drawer-subtitle {
  margin: 18px 0 8px;
  color: #93a4bb;
  font-size: .8rem;
  font-weight: 720;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.menu-list { display: grid; gap: 8px; }
.menu-item {
  display: block;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #1f334f;
  border-radius: 14px;
  background: rgba(30, 41, 59, .55);
  color: #e2e8f0;
  text-align: left;
}
.menu-button { cursor: pointer; font: inherit; }
.menu-item small { display: block; margin-top: 4px; color: #93c5fd; line-height: 1.35; }
.menu-item.active { border-color: var(--cyan); background: rgba(14, 165, 255, .18); }
.menu-item:hover { text-decoration: none; background: rgba(30, 64, 175, .32); }

.app-main {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 34px 28px 26px;
}
.hero-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-weight: 720;
  letter-spacing: .04em;
  font-size: .78rem;
}
.hero-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}
.hero-subtitle {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}
.primary-action, .btn, .wide-btn, .wide {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), #004ee8);
  color: #fff;
  font-weight: 730;
  padding: 14px 22px;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(7, 92, 248, .22);
}
.primary-action:hover, .btn:hover, .wide-btn:hover, .wide:hover { text-decoration: none; filter: brightness(.97); }
.btn.secondary {
  color: var(--blue);
  background: #fff;
  border: 1px solid #bcd2ff;
  box-shadow: none;
}
.wide, .wide-btn { width: 100%; margin-top: 8px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card, .panel, .item, .info-card, .content-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-card {
  padding: 20px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
}
.stat-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--blue);
  background: #eaf1ff;
  font-size: 1.5rem;
}
.stat-icon.green { color: var(--green); background: var(--green-soft); }
.stat-icon.orange { color: var(--orange); background: var(--orange-soft); }
.stat-label { margin: 0 0 4px; color: var(--muted); font-size: .86rem; font-weight: 680; }
.stat-value { margin: 0; color: var(--text); font-size: 1.55rem; font-weight: 760; letter-spacing: -0.02em; }
.stat-note { margin: 3px 0 0; color: var(--muted); font-size: .86rem; }
.stat-note.up { color: var(--green); font-weight: 700; }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr);
  gap: 18px;
  align-items: start;
}
.side-grid { display: grid; gap: 14px; }
.panel { padding: 20px; }
.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.panel h2 { margin: 0; font-size: 1.28rem; letter-spacing: -0.02em; }
.panel p { color: var(--muted); line-height: 1.55; }
.form-help { margin: -4px 0 18px; font-size: .92rem; }
.language-form {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 12px;
  align-items: center;
}
.language-form label, .field-label, label { color: #334155; font-weight: 680; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd8e6;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 12px 13px;
  font-size: 1rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(7, 92, 248, .12);
}
.row, .form-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 13px;
}
.input-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
  margin-bottom: 14px;
}
.input-section h2, .input-section h3 { margin: 0 0 14px; }
.field-grid { display: grid; gap: 10px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.field-row.sales-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.add-row-btn, .remove-row-btn {
  width: auto;
  border: 0;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-weight: 730;
  padding: 12px 16px;
}
.add-row-btn { margin: 10px 0 16px; background: var(--blue); }
.remove-row-btn { background: #475569; }
.error { color: var(--red); font-weight: 720; }
.result-card, .result {
  border: 1px solid #bdebd7;
  background: linear-gradient(135deg, #f0fff8, #f9fffd);
  border-radius: 18px;
  padding: 18px;
}
.result h2, .result-card h2 { margin-top: 0; }
.results-grid, .result-grid { display: grid; gap: 9px; }
.results-grid p, .result-grid p { margin: 0; color: #334155; line-height: 1.5; }
.ok { color: var(--green); font-weight: 760; }
.warn { color: var(--orange); font-weight: 760; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--green-soft);
  color: var(--green);
  font-size: .82rem;
  font-weight: 720;
}
.chart-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--surface);
}
.chart-box h2 { margin: 0 0 12px; }
.axis { stroke: #475569; stroke-width: 1.1; }
.grid { stroke: #dbe5ef; stroke-width: 1; stroke-dasharray: 4 4; }
.curve { fill: none; stroke: var(--green); stroke-width: 3; }
.point { fill: var(--blue); }
.optimal { fill: var(--orange); }
.tick { fill: #334155; font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; color: var(--muted); font-size: .9rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 13px; height: 13px; border-radius: 50%; display: inline-block; }
.legend-curve { height: 3px; border-radius: 0; background: var(--green); }
.legend-point { background: var(--blue); }
.legend-optimal { background: var(--orange); }

.engine-list, .info-grid {
  display: grid;
  gap: 16px;
}
.engine-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.item { padding: 22px; }
.item h2 { margin: 0 0 8px; }
.item p { color: var(--muted); line-height: 1.55; }
.info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 18px; }
.info-card { padding: 20px; }
.info-card h2 { margin: 0 0 10px; color: var(--blue); }
.info-card p, .info-card li { color: var(--muted); line-height: 1.6; }
.info-card ul { margin: 0; padding-left: 1.1rem; }

.alert-stack { display: grid; gap: 10px; }
.alert {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  color: #334155;
  font-size: .92rem;
}
.alert.success { border-color: #bdebd7; background: #f1fff8; }
.alert.info { border-color: #cfe0ff; background: #f4f8ff; }
.alert.warn { border-color: #fde3aa; background: #fffaf0; }

.app-footer {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 22px 28px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: .92rem;
}
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); font-weight: 650; }
.mobile-bottom-nav { display: none; }

.policy-main { width: min(100%, 980px); margin: 0 auto; padding: 34px 28px; }
.content-card { padding: clamp(22px, 4vw, 42px); }
.content-card h1 { margin: 0 0 12px; font-size: clamp(2rem, 4vw, 3rem); }
.content-card h2 { color: var(--blue); margin-top: 28px; }
.content-card p, .content-card li { color: var(--muted); line-height: 1.75; }
.auth-main {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
}
.auth-card {
  width: min(100%, 520px);
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}
.auth-card.login-card {
  width: min(100%, 720px);
  padding: clamp(30px, 6vw, 54px);
  border: 0;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .08);
}
.login-card .eyebrow {
  margin-bottom: 28px;
}
.auth-card h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -.04em;
}
.auth-card > p {
  color: var(--muted);
  line-height: 1.6;
}
.auth-form {
  display: grid;
  gap: 22px;
  margin-top: 22px;
}
.auth-field {
  display: grid;
  gap: 12px;
}
.auth-field label {
  color: #666;
  font-size: 1.28rem;
  font-weight: 500;
}
.auth-input {
  width: 100%;
  min-height: 64px;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  padding: 14px 32px;
  background: #fff;
  color: var(--text);
  font-size: 1.16rem;
}
.auth-input::placeholder { color: #888; }
.auth-input:focus {
  outline: 3px solid rgba(55, 78, 174, .13);
  border-color: #354daf;
}
.auth-field small {
  color: var(--muted);
  line-height: 1.45;
}
.field-error, .form-errors {
  color: var(--red);
  font-weight: 650;
}
.form-errors ul {
  margin: 0;
  padding-left: 1.2rem;
}
.auth-switch {
  margin: 28px 0 0;
  text-align: center;
  color: #777;
}
.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: -2px;
  color: #666;
  font-size: 1.12rem;
}
.remember-me {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.remember-me input {
  width: 20px;
  height: 20px;
  accent-color: #354daf;
}
.login-card .wide {
  min-height: 68px;
  margin-top: 4px;
  border-radius: 12px;
  background: #354daf;
  box-shadow: none;
  font-size: 1.2rem;
  font-weight: 500;
}
.social-login-stack {
  display: grid;
  gap: 28px;
  margin: 44px auto 0;
  width: min(100%, 460px);
}
.social-login {
  min-height: 66px;
  border-radius: 12px;
  border: 1px solid #d9dde6;
  background: #f8f9fb;
  color: #263244;
  font-size: 1.08rem;
  font-weight: 650;
  cursor: not-allowed;
}
.social-login span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  font-weight: 760;
}
.linkedin-login {
  border-color: #0870cf;
  background: #0870cf;
  color: #fff;
}
.google-login span {
  font-size: 1.25rem;
  color: #263244;
}
.linkedin-login span {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  background: #fff;
  color: #0870cf;
  font-size: .9rem;
}

@media (max-width: 1020px) {
  .top-nav, .header-actions { display: none; }
  .mobile-menu-button { display: grid; place-items: center; margin-left: auto; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .engine-list, .info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  body { padding-bottom: 78px; }
  .header-inner { min-height: 64px; padding: 0 18px; }
  .brand { font-size: 1rem; }
  .brand-mark { width: 32px; height: 32px; }
  .app-main { padding: 22px 14px 18px; }
  .hero-row { grid-template-columns: 1fr; gap: 14px; }
  .primary-action { width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 14px; grid-template-columns: 1fr; gap: 10px; }
  .stat-icon { width: 42px; height: 42px; font-size: 1.15rem; }
  .stat-value { font-size: 1.12rem; }
  .panel { padding: 16px; }
  .language-form, .row, .form-row, .field-row, .field-row.sales-row { grid-template-columns: 1fr; }
  .remove-row-btn, .add-row-btn { width: 100%; }
  .app-footer { display: none; }
  .mobile-bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 850;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(255,255,255,.94);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(16px);
  }
  .mobile-bottom-nav a {
    display: grid;
    place-items: center;
    gap: 3px;
    padding: 8px 4px 10px;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 680;
  }
  .mobile-bottom-nav a.active { color: var(--blue); }
  .policy-main { padding: 22px 14px; }
  .auth-card.login-card {
    width: min(100%, 520px);
    padding: 24px 18px;
  }
  .login-options {
    align-items: flex-start;
    flex-direction: column;
  }
  .social-login-stack {
    gap: 16px;
    margin-top: 30px;
  }
}
