:root {
  --rm-bg: #f7f5ef;
  --rm-paper: #fff;
  --rm-paper-soft: #fbfaf6;
  --rm-ink: #121416;
  --rm-muted: #667078;
  --rm-line: rgba(18, 20, 22, .12);
  --rm-dark: #05090c;
  --rm-dark-2: #0b1014;
  --rm-gold: #f6b72b;
  --rm-gold-2: #ffd071;
  --rm-gold-soft: rgba(246, 183, 43, .15);
  --rm-green: #2d9850;
  --rm-danger: #d85145;
  --rm-radius-lg: 28px;
  --rm-radius-md: 20px;
  --rm-radius-sm: 14px;
  --rm-shadow: 0 24px 70px rgba(16, 20, 24, .12);
  --rm-shadow-soft: 0 16px 44px rgba(16, 20, 24, .08);
  --rm-wrap: 1180px;
  --rm-sidebar: 318px;
  /* Compatibility tokens: legacy templates now inherit the new system. */
  --paper: #f7f5ef;
  --white: #fff;
  --ink: #121416;
  --muted: #667078;
  --line: rgba(18, 20, 22, .12);
  --blue: #f6b72b;
  --blue2: #ffd071;
  --blue-soft: rgba(246, 183, 43, .15);
  --red: #d85145;
  --green: #2d9850;
  --orange: #d99012;
  --dark: #05090c;
  --width: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--rm-ink);
  background: var(--rm-bg);
  font-family: Inter, Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, .section-header h1, .auth-card h1, .login-copy h1,
.login-panel-head b, .billing-price, .integration-flow b,
.analytics-kpis strong, .legal-document > h1 {
  font-family: Inter, Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }

/* Shared primitives */
.button, .btn, button.button {
  display: inline-flex;
  min-height: 44px;
  padding: 0 20px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 760;
  line-height: 1.1;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.button:hover, .btn:hover { transform: translateY(-1px); }
.button-primary, .btn-primary {
  color: #201603;
  background: linear-gradient(180deg, var(--rm-gold-2), #f3ad1e);
  box-shadow: 0 12px 28px rgba(246, 183, 43, .22), inset 0 1px rgba(255,255,255,.45);
}
.button-secondary, .btn-light {
  color: var(--rm-ink);
  background: var(--rm-paper);
  border-color: var(--rm-line);
  box-shadow: 0 8px 22px rgba(10, 15, 19, .06);
}
.section-card, .metric-card, .card {
  background: var(--rm-paper);
  border: 1px solid var(--rm-line);
  border-radius: var(--rm-radius-sm);
  box-shadow: var(--rm-shadow-soft);
}
.section-card, .metric-card { padding: 26px; }
.pill, .status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #6d4800;
  background: var(--rm-gold-soft);
  border: 1px solid rgba(246,183,43,.28);
  font-size: 12px;
  font-weight: 750;
}
.alert {
  padding: 14px 17px;
  margin: 0 0 18px;
  border: 1px solid rgba(246,183,43,.4);
  border-radius: 12px;
  color: #5c3b00;
  background: #fff7e6;
}
.muted { color: var(--rm-muted); }
.eyebrow {
  color: #9d6a0a;
  font-size: 12px;
  font-weight: 820;
  letter-spacing: .09em;
  text-transform: uppercase;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, select {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  color: var(--rm-ink);
  background: var(--rm-paper);
  border: 1px solid var(--rm-line);
  border-radius: 10px;
  outline: none;
}
textarea { min-height: 112px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: var(--rm-gold);
  box-shadow: 0 0 0 3px var(--rm-gold-soft);
}
table { width: 100%; border-collapse: collapse; }
th { color: var(--rm-muted); font-size: 12px; text-align: left; text-transform: uppercase; letter-spacing: .05em; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--rm-line); }

/* App shell */
.app-body { background: #f3f1eb; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--rm-sidebar) minmax(0, 1fr); }
.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 20px 20px;
  color: rgba(255,255,255,.76);
  background: linear-gradient(180deg, #070b0e, #0c1217);
  border-right: 1px solid rgba(246,183,43,.16);
  overflow-y: auto;
}
.app-brand { display: flex; align-items: center; gap: 14px; min-height: 68px; padding-bottom: 20px; color: #fff; font-weight: 820; letter-spacing: .02em; border-bottom: 1px solid rgba(255,255,255,.1); }
.app-brand img { width: 54px; height: 54px; object-fit: contain; }
.account-card {
  display: grid;
  gap: 5px;
  margin: 22px 0 12px;
  padding: 17px;
  border: 1px solid rgba(246,183,43,.18);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
}
.account-card small { color: var(--rm-gold-2); font-size: 10px; letter-spacing: .08em; }
.account-card b { color: #fff; overflow-wrap: anywhere; }
.account-card span { color: rgba(255,255,255,.52); font-size: 12px; overflow-wrap: anywhere; }
.app-nav { display: grid; gap: 6px; }
.app-nav-label { margin: 15px 12px 4px; color: rgba(255,255,255,.35); font-size: 10px; font-weight: 800; letter-spacing: .09em; }
.app-nav a {
  display: grid;
  grid-template-columns: 28px minmax(0,1fr) auto;
  align-items: center;
  min-height: 50px;
  padding: 0 14px;
  border-radius: 12px;
  transition: background .18s ease, color .18s ease;
}
.app-nav a:hover { color: #fff; background: rgba(255,255,255,.055); }
.app-nav a.active { color: #fff; background: linear-gradient(90deg, rgba(246,183,43,.22), rgba(246,183,43,.06)); border: 1px solid rgba(246,183,43,.28); }
.app-nav a b { min-width: 22px; padding: 3px 6px; border-radius: 999px; text-align: center; font-size: 11px; background: rgba(255,255,255,.12); }
.nav-icon { width: 20px; height: 20px; color: var(--rm-gold); }
.nav-symbol { width: 20px; color: var(--rm-gold); text-align: center; font-size: 17px; }
.app-nav a.active .nav-icon { color: var(--rm-gold); }
.app-sidebar-foot { display: grid; gap: 9px; margin-top: auto; padding: 16px 12px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.app-sidebar-foot a:hover { color: #fff; }
.app-main { min-width: 0; }
.app-topbar {
  position: sticky;
  z-index: 8;
  top: 0;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 34px;
  background: rgba(247,245,239,.88);
  border-bottom: 1px solid var(--rm-line);
  backdrop-filter: blur(14px);
}
.breadcrumbs { color: var(--rm-muted); font-size: 12px; letter-spacing: .05em; }
.breadcrumbs b { color: var(--rm-ink); }
.role-switch { display: flex; align-items: center; gap: 7px; }
.role-switch a { padding: 8px 11px; border: 1px solid var(--rm-line); border-radius: 9px; background: var(--rm-paper); font-size: 13px; }
.app-content { width: min(1560px, 100%); margin: 0 auto; padding: 40px 36px 72px; }
.section-header { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.section-header h1 { margin: 8px 0 11px; font-size: clamp(38px, 4vw, 60px); line-height: 1.02; letter-spacing: -.058em; }
.section-header p { max-width: 760px; margin: 0; line-height: 1.6; }
.section, .split-layout, .cards-grid { margin-bottom: 20px; }
.split-layout { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.cards-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.section-header-inline, .card-topline, .cta-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.section-header-inline h2, .metric-card h2 { margin: 0; letter-spacing: -.03em; }
.metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin: 18px 0 0; }
.metrics > div { min-width: 0; padding: 13px; border: 1px solid var(--rm-line); border-radius: 11px; background: var(--rm-paper-soft); }
.metrics dt { margin-bottom: 6px; color: var(--rm-muted); font-size: 12px; }
.metrics dd { margin: 0; font-size: 16px; font-weight: 760; overflow-wrap: anywhere; }
.plain-list { padding-left: 19px; color: #363c41; line-height: 1.6; }
.cta-row { justify-content: flex-start; flex-wrap: wrap; margin-top: 18px; }
.mobile-nav { display: none; }
.workspace-nav {
  position: sticky;
  z-index: 7;
  top: 70px;
  display: flex;
  gap: 7px;
  margin: -8px 0 24px;
  padding: 9px;
  overflow-x: auto;
  background: rgba(247,245,239,.92);
  border: 1px solid var(--rm-line);
  border-radius: 13px;
  backdrop-filter: blur(14px);
}
.workspace-nav a {
  display: inline-flex;
  min-width: max-content;
  min-height: 39px;
  padding: 0 13px;
  align-items: center;
  gap: 7px;
  border-radius: 9px;
  color: var(--rm-muted);
  font-size: 13px;
  font-weight: 700;
}
.workspace-nav a:hover { color: var(--rm-ink); background: var(--rm-paper); }
.workspace-nav a.active { color: #211600; background: var(--rm-gold); }
.workspace-nav b { min-width: 21px; padding: 2px 6px; border-radius: 999px; background: rgba(0,0,0,.08); text-align: center; font-size: 10px; }
.owner-view { animation: ownerViewIn .28s ease both; }
.owner-next-step { background: linear-gradient(145deg, #0b1014, #151b1f); color: #fff; border-color: rgba(246,183,43,.2); }
.owner-next-step p { color: rgba(255,255,255,.68); }
@keyframes ownerViewIn { from { opacity: 0; transform: translateY(8px); } }
.owner-dashboard-head { padding: 6px 0 8px; }
.owner-kpi-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; }
.owner-kpi { padding: 20px; border: 1px solid var(--rm-line); border-radius: 14px; background: var(--rm-paper); box-shadow: var(--rm-shadow-soft); }
.owner-kpi span, .owner-kpi strong, .owner-kpi small { display: block; }
.owner-kpi span { color: var(--rm-muted); font-size: 12px; }
.owner-kpi strong { margin: 12px 0 5px; font-size: clamp(22px,2vw,31px); letter-spacing: -.045em; }
.owner-kpi small { color: #8b5c05; }
.owner-account-strip > .section-card { padding-block: 18px; }
.owner-program-grid .metric-card { position: relative; overflow: hidden; }
.owner-program-grid .metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--rm-gold); }
.mode-gateway { width: min(1080px,100%); margin: 0 auto; padding: 20px 0 60px; }
.mode-gateway-hero { padding: 34px 0 30px; }
.mode-gateway-hero h1 { margin: 10px 0 12px; font-size: clamp(42px,5vw,68px); line-height: 1; letter-spacing: -.06em; }
.mode-gateway-hero p { max-width: 650px; color: var(--rm-muted); font-size: 17px; }
.mode-choice-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.mode-choice { position: relative; min-height: 340px; display: flex; flex-direction: column; padding: 30px; overflow: hidden; border: 1px solid var(--rm-line); border-radius: 20px; background: var(--rm-paper); box-shadow: var(--rm-shadow-soft); transition: transform .2s ease,border-color .2s ease; }
.mode-choice:hover { transform: translateY(-4px); border-color: rgba(246,183,43,.55); }
.mode-choice-primary { color: #fff; background: linear-gradient(145deg,#080c0f,#151b1f); border-color: rgba(246,183,43,.2); }
.mode-choice-icon { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 44px; border-radius: 50%; color: #211600; background: var(--rm-gold); font-size: 22px; }
.mode-choice small { color: #9b6809; font-weight: 800; letter-spacing: .08em; }
.mode-choice-primary small { color: var(--rm-gold-2); }
.mode-choice h2 { margin: 10px 0; font-size: 34px; letter-spacing: -.045em; }
.mode-choice p { max-width: 430px; color: var(--rm-muted); line-height: 1.6; }
.mode-choice-primary p { color: rgba(255,255,255,.64); }
.mode-choice strong { display: flex; justify-content: space-between; gap: 16px; margin-top: auto; padding-top: 22px; border-top: 1px solid var(--rm-line); }
.mode-choice-primary strong { border-color: rgba(255,255,255,.1); }
.mode-choice i { color: #9b6809; font-style: normal; }
.mode-choice-primary i { color: var(--rm-gold-2); }

/* Public chrome shared by landing, login and legal pages */
.public-header {
  position: relative;
  z-index: 20;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 max(24px, calc((100vw - var(--rm-wrap)) / 2));
  color: #fff;
  background: var(--rm-dark);
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.public-brand { display: flex; align-items: center; gap: 11px; }
.public-brand img { width: 44px; height: 44px; object-fit: contain; }
.public-brand span { display: grid; gap: 3px; }
.public-brand small { color: rgba(255,255,255,.55); font-size: 10px; }
.public-header nav { display: flex; gap: 25px; color: rgba(255,255,255,.74); font-size: 13px; }
.public-header nav a:hover { color: #fff; }
.public-actions { display: flex; align-items: center; gap: 9px; }
.public-demo, .public-login {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  border: 1px solid rgba(246,183,43,.42);
  border-radius: 9px;
  color: #fff;
  background: rgba(255,255,255,.04);
}
.public-login { color: #211600; background: var(--rm-gold); font-weight: 760; }
.legal-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 25px max(24px, calc((100vw - var(--rm-wrap)) / 2));
  color: rgba(255,255,255,.58);
  background: var(--rm-dark);
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
}
.legal-footer nav { display: flex; flex-wrap: wrap; gap: 16px; }
.legal-footer a:hover { color: #fff; }

/* Public functional pages */
.public-body:not(.ref-landing) { background: var(--rm-bg); }
.public-body:not(.ref-landing) .public-header {
  color: #fff;
  background: var(--rm-dark);
  border-bottom-color: rgba(255,255,255,.09);
}
.public-body:not(.ref-landing) .public-header nav { color: rgba(255,255,255,.75); }
.public-body:not(.ref-landing) .public-header nav a:hover { color: var(--rm-gold-2); }
.public-body:not(.ref-landing) .public-brand > span { border-left-color: rgba(255,255,255,.16); }
.public-body:not(.ref-landing) .public-brand b { color: #fff; }
.public-body:not(.ref-landing) .public-brand small { color: rgba(255,255,255,.56); }
.login-page {
  width: min(1220px, calc(100% - 48px));
  min-height: calc(100vh - 126px);
  margin: 0 auto;
  padding: clamp(44px, 6vw, 84px) 0;
  grid-template-columns: minmax(0, 1.05fr) minmax(390px, .95fr);
  gap: 22px;
  background: transparent;
}
.login-copy, .login-panel { padding: clamp(38px, 4vw, 62px); border-radius: var(--rm-radius-md); }
.login-copy {
  min-height: 610px;
  color: #fff;
  background-image: linear-gradient(145deg, rgba(5,9,12,.98), rgba(5,9,12,.82)), url('/static/img/rekometrika-dark.jpg');
  background-size: cover;
  border: 1px solid rgba(246,183,43,.16);
  box-shadow: var(--rm-shadow);
}
.login-copy h1 { margin: 34px 0 26px; font-size: clamp(42px, 4.5vw, 66px); letter-spacing: -.055em; }
.login-copy h1 em { color: var(--rm-gold); }
.overline, .login-panel-head span { color: var(--rm-gold); }
.overline i { background: currentColor; }
.login-panel { background: var(--rm-paper); border: 1px solid var(--rm-line); box-shadow: var(--rm-shadow-soft); }
.login-panel-head b { font-size: 30px; letter-spacing: -.035em; }
.telegram-login { border-color: rgba(246,183,43,.24); border-radius: 12px; background: rgba(255,255,255,.055); }
.telegram-login:hover { border-color: rgba(246,183,43,.55); }
.telegram-login > span { color: #211600; background: var(--rm-gold); }
.telegram-login small { color: var(--rm-gold-2); }
.login-mode-switch {
  display: inline-flex;
  gap: 5px;
  margin-bottom: 28px;
  padding: 5px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 12px;
  background: rgba(255,255,255,.05);
}
.login-mode-switch a {
  padding: 10px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,.66);
  font-size: 13px;
  font-weight: 700;
}
.login-mode-switch a.active { color: #211600; background: var(--rm-gold); }
.check-block a, .alert a, .link-box, .integration-card strong { color: #8c5d05; text-decoration: underline; text-underline-offset: 3px; }
.demo-login { background: #fff7e6; border: 1px solid rgba(246,183,43,.28); }
.demo-login small { color: #8c5d05; }

/* Dashboard components that previously carried the blue legacy palette. */
.eyebrow, .pill, .section-number, .integration-flow b, .guide-steps article > b,
.analytics-bar span, .analytics-bar small { color: #9b6809; }
.eyebrow::before { background: var(--rm-gold); }
.pill { color: #684400; background: var(--rm-gold-soft); }
.metric-card, .section-card, .analytics-main, .analytics-side, .billing-plan-card,
.guide-steps article, .settings-form, .integration-flow div {
  border-color: var(--rm-line);
  border-radius: var(--rm-radius-sm);
  background: var(--rm-paper);
  box-shadow: var(--rm-shadow-soft);
}
.analytics-kpis > div, .status-summary span, .metrics div { background: var(--rm-paper-soft); border: 1px solid var(--rm-line); }
.analytics-bar i, .source-list > div > i span { background: var(--rm-gold); }
.guide-note { color: #684400; background: var(--rm-gold-soft); }
.integration-card:hover { border-color: var(--rm-gold); }
.code-sample { color: #fff4d4; background: var(--rm-dark-2); border: 1px solid rgba(246,183,43,.18); }
.data-table th { background: #f4f1e8; }
.data-table tbody tr:hover { background: #fff9ed; }
.settings-form input, .settings-form select, .settings-form textarea, .auth-form input,
.compact-input { border-color: var(--rm-line); border-radius: 10px; }
.button-primary { color: #211600; background: linear-gradient(180deg, var(--rm-gold-2), #f3ad1e); }

/* Legal pages use the same product shell and readable document typography. */
.legal-page { width: min(1040px, calc(100% - 40px)); margin: 54px auto 78px; }
.legal-document { line-height: 1.72; }
.legal-document > h1 { letter-spacing: -.045em; }
.legal-document > section:not(.section-card) { padding-top: 12px; border-top: 1px solid var(--rm-line); }
.app-body > .legal-footer { margin-left: var(--rm-sidebar); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 220px minmax(0,1fr); }
  .app-sidebar { padding-inline: 12px; }
  .app-content { padding: 26px 22px 90px; }
  .split-layout, .cards-grid { grid-template-columns: 1fr; }
  .public-header nav { display: none; }
  .owner-kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .login-page { grid-template-columns: 1fr; }
  .login-copy { min-height: auto; }
  .app-body > .legal-footer { margin-left: 220px; }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  .app-sidebar { display: none; }
  .app-topbar { min-height: 60px; padding: 0 16px; }
  .breadcrumbs { max-width: 50vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .app-content { padding: 22px 14px 90px; }
  .workspace-nav { top: 60px; margin-inline: -6px; border-radius: 11px; }
  .mobile-nav {
    position: fixed;
    z-index: 40;
    left: 8px;
    right: 8px;
    bottom: 8px;
    display: flex;
    overflow-x: auto;
    padding: 8px;
    color: rgba(255,255,255,.72);
    background: rgba(5,9,12,.94);
    border: 1px solid rgba(246,183,43,.2);
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0,0,0,.28);
    backdrop-filter: blur(14px);
  }
  .mobile-nav a { min-width: max-content; padding: 9px; font-size: 10px; }
  .metrics { grid-template-columns: 1fr; }
  .owner-kpi-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .mode-choice-grid { grid-template-columns: 1fr; }
  .mode-choice { min-height: 280px; padding: 24px; }
  .mode-choice-icon { margin-bottom: 28px; }
  .owner-kpi { padding: 15px; }
  .section-card, .metric-card { padding: 18px; }
  .section-header h1 { font-size: 32px; }
  .public-header { min-height: 66px; padding: 0 14px; }
  .public-brand small, .public-demo { display: none; }
  .public-brand img { width: 38px; height: 38px; }
  .public-login { min-height: 38px; padding: 0 12px; font-size: 13px; }
  .legal-footer { display: grid; padding: 24px 16px 92px; }
  .login-page { width: calc(100% - 28px); padding: 20px 0 34px; }
  .login-copy, .login-panel { padding: 36px 20px; border-radius: 14px; }
  .login-copy h1 { font-size: 39px; }
  .app-body > .legal-footer { margin-left: 0; }
}
