/* =========================================================================
   Калькулятор владения авто — тема (bespoke, token-driven)
   Палитра, типографика и сетка заданы дизайн-контрактом.
   ========================================================================= */

:root {
  /* Surfaces & text */
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --ink:       #1a2330;
  --muted:     #5b6473;
  --line:      #e2e6ec;

  /* Accents */
  --brand:     #2f4b7c;   /* графитово-синий — основной акцент / амортизация */
  --brand-2:   #24406e;   /* тень бренда для градиентов */
  --fuel:      #f2994a;   /* топливо */
  --service:   #56a3a6;   /* ТО / обслуживание */
  --insurance: #8f7bb8;   /* страховка */

  /* State colours */
  --danger:    #c0392b;
  --warn:      #b7791f;

  /* Shape & motion */
  --radius:    14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(26, 35, 48, .05);
  --shadow:    0 1px 2px rgba(26, 35, 48, .04), 0 10px 28px rgba(26, 35, 48, .06);
  --ring:      0 0 0 3px rgba(47, 75, 124, .18);
  --ease:      cubic-bezier(.22, .61, .36, 1);

  --font-body: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-head: 'Manrope', 'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: 24px;
}

h1, h2 { font-family: var(--font-head); margin: 0; }

/* ---------------------------------------------------------------- Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  position: relative;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-block: 20px;
}
.brand-mark {
  flex: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 20px;
  box-shadow: var(--shadow-sm);
}
.app-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.15;
}
.app-sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 15px;
}

/* ---------------------------------------------------------------- Layout */
main.wrap { flex: 1 0 auto; padding-block: 28px 40px; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 768px) {
  .layout {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); /* ≈ 40% / 60% */
    gap: 28px;
    align-items: start;
  }
  .col-form {
    position: sticky;
    top: 24px;
  }
}

/* ------------------------------------------------------------- Form card */
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
}
.form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.btn-reset {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #eef1f6;
  color: var(--brand);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 12px;
  font: 600 13px/1 var(--font-body);
  cursor: pointer;
  transition: background .18s var(--ease), transform .18s var(--ease), border-color .18s var(--ease);
}
.btn-reset:hover { background: #e6ebf3; border-color: #d3dae6; }
.btn-reset:active { transform: translateY(1px); }

.field { margin-bottom: 14px; }
.field:last-of-type { margin-bottom: 4px; }

.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.field-label > i { color: var(--brand); width: 16px; text-align: center; font-size: 14px; }
.field-unit {
  margin-left: auto;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
  background: #f3f5f9;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.field-input {
  width: 100%;
  font: 500 16px/1.2 var(--font-body);
  color: var(--ink);
  background: #fbfcfe;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
  -moz-appearance: textfield;
}
.field-input::-webkit-outer-spin-button,
.field-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field-input:hover { border-color: #cdd5e2; }
.field-input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: var(--ring);
}

.field-msg {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.35;
  min-height: 0;
  color: var(--muted);
  display: none;
}
.field.is-warn .field-input { border-color: #e8c58a; background: #fffdf7; }
.field.is-warn .field-msg { display: block; color: var(--warn); }
.field.is-error .field-input { border-color: var(--danger); background: #fff8f7; }
.field.is-error .field-input:focus { box-shadow: 0 0 0 3px rgba(192, 57, 43, .16); }
.field.is-error .field-msg { display: block; color: var(--danger); font-weight: 500; }
.field-msg::before {
  font-family: "Font Awesome 6 Free"; font-weight: 900;
  margin-right: 6px;
}
.field.is-warn  .field-msg::before { content: "\f06a"; }  /* circle-exclamation */
.field.is-error .field-msg::before { content: "\f071"; }  /* triangle-exclamation */

.form-foot {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-foot > i { color: var(--fuel); }

/* --------------------------------------------------------------- Metrics */
.col-results { display: flex; flex-direction: column; gap: 24px; min-width: 0; }

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 18px 16px;
  min-width: 0;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.metric:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.metric-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.metric-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .005em;
}
.metric-dot {
  width: 9px; height: 9px; border-radius: 3px;
  background: var(--dot, var(--brand));
  flex: none;
}
.metric-ico { color: #c3ccda; font-size: 16px; }
.metric-value {
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.metric-sub { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

/* Hero — итог за срок */
.metric--hero {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 12px 30px rgba(47, 75, 124, .28);
  position: relative;
  overflow: hidden;
}
.metric--hero::after {
  content: "\f5e4"; /* car-side */
  font-family: "Font Awesome 6 Free"; font-weight: 900;
  position: absolute;
  right: -10px; bottom: -22px;
  font-size: 120px;
  color: rgba(255, 255, 255, .07);
  pointer-events: none;
}
.metric--hero .metric-label { color: rgba(255, 255, 255, .82); }
.metric--hero .metric-ico { color: rgba(255, 255, 255, .55); }
.metric--hero .metric-value { font-size: 40px; }
.metric--hero .metric-sub { color: rgba(255, 255, 255, .78); }

/* Accent left-border cards */
.metric--accent { border-left: 4px solid var(--dot, var(--brand)); }

/* ----------------------------------------------------------- Chart card */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px 20px 22px;
}
.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  margin-bottom: 14px;
}
.legend { display: flex; flex-wrap: wrap; gap: 12px; }
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}
.legend-dot { width: 11px; height: 11px; border-radius: 4px; display: inline-block; }

.chart-wrap {
  position: relative;
  height: clamp(280px, 42vh, 380px);
}

/* ---------------------------------------------------------------- Footer */
.app-footer {
  flex: none;
  background: var(--surface);
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.app-footer .wrap { padding-block: 22px 26px; }
.foot-main { margin: 0; color: var(--muted); font-size: 13px; max-width: 720px; }
.foot-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.foot-note > i { color: var(--service); }

/* ---------------------------------------------------------- Responsive */
@media (max-width: 767px) {
  .header-inner { padding-block: 16px; }
  .app-title { font-size: 23px; }
  .app-sub { font-size: 14px; }
  main.wrap { padding-block: 20px 30px; }
  .wrap { padding-inline: 16px; }
  .form-card { padding: 18px 16px 14px; }
  .metrics { gap: 12px; }
  .metric { padding: 15px 15px 14px; }
  .metric-value { font-size: 27px; }
  .metric--hero .metric-value { font-size: 33px; }
}
@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr; }
}

/* --------------------------------------------------- Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* Accessible keyboard focus everywhere */
:focus-visible { outline: none; }
.btn-reset:focus-visible { box-shadow: var(--ring); border-color: var(--brand); }
