@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@400;600;800&family=Onest:wght@400;500;600;700&display=swap');

/* =========================================================================
   РОП 2.0 — F1 Design System
   Premium "warm control-room": warm sand paper + burnt-orange accent.
   One vivid brand accent (orange); green stays for "good".
   ========================================================================= */

:root {
  /* ---- Core palette (warm sand neutrals) ---- */
  --bg: #F5F1E9;        /* warm off-white paper, "чуть темнее белого" */
  --bg-soft: #ECE6DA;   /* deeper sand underlay */
  --ink: #211C16;       /* warm near-black graphite */
  --ink-2: #6B6356;     /* warm taupe-grey */
  --ink-3: #A39A89;     /* light warm grey */
  --line: #E0D8C9;      /* warm hairline */
  --line-soft: #EBE5D8; /* faint warm divider */

  /* ---- Accent (burnt premium orange) ---- */
  --acc: #EA5B0C;       /* saturated burnt orange — brand / CTA */
  --acc-ink: #B8460A;   /* deep burnt orange (links, active text) */
  --acc-soft: #FBE6D5;  /* warm orange tint */

  /* ---- Semantic (meaning preserved) ---- */
  --ok: #1F9D5B;        /* success / good score = green */
  --warn: #E8950C;      /* amber */
  --err: #DC4338;       /* red */
  --info: #2563EB;      /* blue */

  /* ---- Warm paper surface for cards (lifts above --bg) ---- */
  --paper: #FBF8F2;     /* card warm paper, lighter than bg for elevation */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");

  /* ---- Radii ---- */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* ---- Shadows (warm-tinted, multilayer for premium depth) ---- */
  --sh-1: 0 1px 1px rgba(74,52,28,.05), 0 1px 3px rgba(74,52,28,.06);
  --sh-2: 0 2px 4px rgba(74,52,28,.05), 0 10px 28px rgba(74,52,28,.09);
  --sh-3: 0 4px 10px rgba(74,52,28,.07), 0 24px 60px rgba(54,38,20,.16);

  /* ---- Fonts ---- */
  --font-display: 'Unbounded', sans-serif;
  --font-ui: 'Onest', 'Manrope', system-ui, sans-serif;

  /* ---- Type scale (font-size / line-height) ---- */
  --fs-display: 64px;  --lh-display: 1.04;
  --fs-h1: 44px;       --lh-h1: 1.08;
  --fs-h2: 32px;       --lh-h2: 1.14;
  --fs-h3: 24px;       --lh-h3: 1.22;
  --fs-h4: 19px;       --lh-h4: 1.3;
  --fs-lg: 18px;       --lh-lg: 1.55;
  --fs-base: 15px;     --lh-base: 1.6;
  --fs-sm: 13px;       --lh-sm: 1.5;
  --fs-xs: 12px;       --lh-xs: 1.45;

  /* ---- Spacing scale ---- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* ---- Motion ---- */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: .18s;

  /* =====================================================================
     LEGACY ALIASES — keep old pages working when they adopt theme.css
     ===================================================================== */
  --tx: var(--ink); --tx-2: var(--ink-2); --tx-3: var(--ink-2); --tx-4: var(--ink-3);
  --text: var(--ink); --text2: var(--ink-2); --text3: var(--ink-3);
  --surface-1: var(--bg); --surface-2: var(--bg-soft); --surface-3: var(--line-soft); --bg3: var(--bg-soft);
  --line-strong: var(--line); --border: var(--line);
  --acc-hi: var(--acc-ink); --acc-tx: #FFFFFF; --acc-line: var(--acc); --acc-dim: var(--acc-soft);
  --orange: var(--acc); --red: var(--err);
  --ok-dim: #E1F2E6; --warn-dim: #FBEBCF; --err-dim: #FAE2DF;
  --r-md: var(--r); --mono: 'JetBrains Mono','SF Mono',ui-monospace,monospace;
  --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
}

/* =========================================================================
   Reset & base
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--acc-soft); color: var(--acc-ink); }

a { color: var(--acc-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

/* =========================================================================
   Typography
   ========================================================================= */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-ui);
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 .4em;
  letter-spacing: -0.01em;
}

.display, .h-display {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.h-display { font-size: var(--fs-display); line-height: var(--lh-display); }
h1, .h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); }
h2, .h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); }
h3, .h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); }
h4, .h4 { font-size: var(--fs-h4); line-height: var(--lh-h4); }

.lead { font-size: var(--fs-lg); line-height: var(--lh-lg); color: var(--ink-2); }
.body { font-size: var(--fs-base); line-height: var(--lh-base); }
.small, .text-sm { font-size: var(--fs-sm); line-height: var(--lh-sm); }
.text-xs { font-size: var(--fs-xs); line-height: var(--lh-xs); }

.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }
.muted { color: var(--ink-3); }
.divider { height: 1px; background: var(--line); border: 0; margin: var(--sp-5) 0; }

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
  --_bg: var(--bg);
  --_fg: var(--ink);
  --_bd: var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1;
  padding: 11px 18px;
  border-radius: var(--r);
  border: 1px solid var(--_bd);
  background: var(--_bg);
  color: var(--_fg);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.btn:active { transform: translateY(0); box-shadow: var(--sh-1); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--acc-soft); }
.btn:disabled, .btn[disabled] {
  opacity: .5; cursor: not-allowed; transform: none; box-shadow: none;
}

.btn.sm { padding: 7px 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn.lg { padding: 14px 24px; font-size: var(--fs-lg); }
.btn.block { display: flex; width: 100%; }

.btn.primary {
  --_bg: var(--acc); --_fg: #FFFFFF; --_bd: var(--acc);
}
.btn.primary:hover { --_bg: var(--acc-ink); --_bd: var(--acc-ink); }

.btn.ghost {
  --_bg: transparent; --_fg: var(--ink); --_bd: var(--line);
}
.btn.ghost:hover { --_bg: var(--bg-soft); --_bd: var(--ink-3); }

.btn.subtle {
  --_bg: var(--bg-soft); --_fg: var(--ink); --_bd: transparent;
}
.btn.subtle:hover { --_bg: var(--line-soft); }

.btn.danger {
  --_bg: var(--err); --_fg: #FFFFFF; --_bd: var(--err);
}
.btn.danger:hover { filter: brightness(.94); }

.btn.icon { padding: 11px; aspect-ratio: 1; }

/* =========================================================================
   Cards & panels
   ========================================================================= */
.card, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card { padding: var(--sp-5); }
.panel-pad { padding: var(--sp-5); }
.card-soft { background: var(--bg-soft); border-color: var(--line-soft); box-shadow: none; }
.grain { position: relative; }
.grain::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: var(--grain); border-radius: inherit; mix-blend-mode: multiply;
}

.card-title { font-size: var(--fs-h4); font-weight: 700; margin: 0 0 var(--sp-1); }
.card-sub { color: var(--ink-2); font-size: var(--fs-sm); margin: 0 0 var(--sp-4); }

/* =========================================================================
   Fields / forms
   ========================================================================= */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field-lbl {
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2);
  letter-spacing: .01em;
}
.field-hint { font-size: var(--fs-xs); color: var(--ink-3); }

.inp {
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 13px;
  width: auto;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.inp::placeholder { color: var(--ink-3); }
.inp:hover { border-color: var(--ink-3); }
.inp:focus {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-soft);
}
.inp:disabled { background: var(--bg-soft); color: var(--ink-3); cursor: not-allowed; }
.inp.full { width: 100%; }
.inp.num { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
.inp.mono { font-family: var(--mono); }
textarea.inp { min-height: 96px; resize: vertical; line-height: 1.5; }
select.inp {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B6356' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}

/* =========================================================================
   Table
   ========================================================================= */
.tbl-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-1);
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.tbl th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--bg-soft);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background var(--dur) var(--ease); }
.tbl tbody tr:hover { background: var(--bg-soft); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* =========================================================================
   Pills / tags
   ========================================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--line-soft);
  color: var(--ink-2);
  border: 1px solid transparent;
}
.pill::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  opacity: .7;
}
.pill.neutral { background: var(--line-soft); color: var(--ink-2); }
.pill.acc  { background: var(--acc-soft); color: var(--acc-ink); }
.pill.ok   { background: #E1F2E6; color: #157A45; }
.pill.warn { background: #FBEBCF; color: #9A6207; }
.pill.err  { background: #FAE2DF; color: #B22D24; }
.pill.no-dot::before { display: none; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}
.tag .tag-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 14px; line-height: 1;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tag .tag-x:hover { background: var(--line); color: var(--ink); }

/* =========================================================================
   Segmented tabs
   ========================================================================= */
.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.seg button, .seg .seg-item {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  padding: 8px 16px;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.seg button:hover, .seg .seg-item:hover { color: var(--ink); }
.seg button.active, .seg .seg-item.active {
  background: var(--paper);
  color: var(--acc-ink);
  box-shadow: var(--sh-1);
}

/* =========================================================================
   Modal
   ========================================================================= */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(33,28,22,.46);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5);
  opacity: 0; visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
  z-index: 1000;
}
.modal-bg.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  width: 100%; max-width: 480px;
  padding: var(--sp-6);
  transform: translateY(12px) scale(.98);
  transition: transform var(--dur) var(--ease);
}
.modal-bg.open .modal { transform: none; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-3); }
.modal-title { font-size: var(--fs-h3); font-weight: 700; margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-3); margin-top: var(--sp-6); }

/* =========================================================================
   Toast
   ========================================================================= */
.toast-stack {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-3);
  z-index: 1100;
}
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  min-width: 280px; max-width: 380px;
  background: var(--ink);
  color: #FFFFFF;
  border-radius: var(--r);
  padding: 13px 16px;
  box-shadow: var(--sh-3);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.toast .toast-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--acc); flex: none; }
.toast.ok .toast-dot { background: var(--ok); }
.toast.warn .toast-dot { background: var(--warn); }
.toast.err .toast-dot { background: var(--err); }

/* =========================================================================
   Skeleton
   ========================================================================= */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--line-soft);
  border-radius: var(--r-sm);
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  animation: skeleton-shimmer 1.4s infinite;
}
.skeleton.line { height: 12px; margin: 8px 0; }
.skeleton.line.w-60 { width: 60%; }
.skeleton.line.w-40 { width: 40%; }
.skeleton.circle { width: 44px; height: 44px; border-radius: 50%; }
.skeleton.block { height: 96px; border-radius: var(--r); }

@keyframes skeleton-shimmer { 100% { transform: translateX(100%); } }

/* =========================================================================
   Reveal / motion utilities
   ========================================================================= */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.reveal.in { opacity: 1; transform: none; }

.hover-lift { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--sh-2); }

/* =========================================================================
   Small helpers
   ========================================================================= */
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.spacer { flex: 1; }

/* =========================================================================
   Reduced motion
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
  .skeleton::after { display: none; }
}
