:root {
  --bg-a: #eef1fb;
  --bg-b: #f7f8fc;
  --panel: #ffffff;
  --accent: #4f6bf0;
  --accent-hover: #3d59db;
  --accent-press: #3149bd;
  --accent-soft: #eef1ff;
  --text: #14161f;
  --muted: #767c8c;
  --border: #e6e8f0;
  --danger: #d63d3d;
  --danger-bg: #fdecec;
  --danger-border: #f4baba;
  --warn: #b7791f;
  --warn-bg: #fdf3e0;
  --warn-border: #f1d99a;
  --secondary: #eef0f5;
  --secondary-hover: #e1e4ec;
  --radius: 999px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 31, 0.05);
  --shadow-md: 0 8px 24px rgba(20, 22, 31, 0.08);
  --shadow-btn: 0 4px 14px rgba(79, 107, 240, 0.28);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: linear-gradient(180deg, var(--bg-a) 0%, var(--bg-b) 55%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#screen-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 28px 0;
  min-height: 0;
  animation: fadeIn 0.28s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* --------------------------------------------------------------- stepper */

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 4px auto 8px;
  max-width: 720px;
  width: 100%;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--panel);
  border: 2px solid var(--border);
  color: var(--muted);
  transition: all 0.2s ease;
}

.step-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.step.active .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.step.active .step-label { color: var(--text); font-weight: 700; }

.step.done .step-dot {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.step.done .step-label { color: var(--accent); }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
  min-width: 16px;
  max-width: 56px;
  margin-bottom: 20px;
}

@media (max-width: 720px) {
  .step-label { display: none; }
  .step-line { max-width: 24px; }
}

/* --------------------------------------------------------------- layout */

.center-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
  padding-bottom: 100px;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.title {
  font-size: 30px;
  font-weight: 800;
  margin: 0 0 22px;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 16px;
  font-weight: 700;
  margin-top: 22px;
  display: block;
}

.muted {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 6px 0;
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 10px;
  max-width: 420px;
}

.row-gap {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.row-gap-wide {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

/* --------------------------------------------------------------- inputs */

input[type="text"], input[type="number"], input[type="password"], select {
  font-family: inherit;
  font-size: 14.5px;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder { color: #b3b7c4; }

input[type="text"]:disabled, input[type="number"]:disabled {
  background: var(--secondary);
  color: var(--muted);
  border-style: dashed;
  cursor: not-allowed;
}

.input-wide {
  width: min(420px, 90vw);
  text-align: center;
}

select { cursor: pointer; }

/* --------------------------------------------------------------- buttons */

button, .btn-primary, .btn-secondary, .btn-outline {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 14px 30px;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { background: var(--accent-press); transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
  padding: 10px 20px;
  font-size: 13.5px;
}
.btn-secondary:hover { background: var(--secondary-hover); }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  padding: 12px 26px;
}
.btn-outline:hover { background: var(--accent-soft); }

.btn-wide { min-width: 190px; }

.btn-back {
  position: fixed;
  left: 28px;
  bottom: 24px;
  z-index: 5;
}

.footer-right {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 5;
}

.logout-link {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 10;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 16px;
  box-shadow: var(--shadow-sm);
  transition: color 0.15s, border-color 0.15s;
}
.logout-link:hover { color: var(--danger); border-color: var(--danger-border); }

/* --------------------------------------------------------- форма шапки */

.mode-toggle {
  display: flex;
  gap: 8px;
  background: var(--secondary);
  padding: 5px;
  border-radius: var(--radius);
  margin-top: 8px;
}

.mode-toggle button {
  padding: 9px 22px;
  font-size: 13.5px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
}

.mode-toggle button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------- лоты */

.lot-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin: 20px auto 16px;
  width: min(1140px, 100%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px 16px;
  position: relative;
}

.lot-form label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  display: block;
  margin-bottom: 6px;
  padding-left: 4px;
}

.lot-form input, .lot-form select {
  width: 100%;
  text-align: left;
  padding: 11px 16px;
}

.lot-form .field { display: flex; flex-direction: column; position: relative; }

.lot-form .field.name-field input {
  background: var(--secondary);
  color: var(--muted);
  border-style: dashed;
}

/* searchable combobox */

.combo { position: relative; }

.combo-options {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
  display: none;
}

.combo-options.open { display: block; }

.combo-option {
  padding: 10px 16px;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.combo-option:last-child { border-bottom: none; }
.combo-option:hover, .combo-option.highlighted { background: var(--accent-soft); }

.combo-option .g-num { font-weight: 700; color: var(--accent); margin-right: 6px; }
.combo-empty { padding: 12px 16px; font-size: 13px; color: var(--muted); }

.lot-form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
}

.lot-form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: left;
}

.lots-table-wrap {
  width: min(1140px, 100%);
  margin: 0 auto 110px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: auto;
  max-height: 38vh;
}

.lots-empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

table.lots-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

table.lots-table th, table.lots-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

table.lots-table th {
  background: #f7f8fb;
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
}

table.lots-table tbody tr:hover { background: #fafbfe; }
table.lots-table tbody tr:last-child td { border-bottom: none; }

.row-delete {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.row-delete:hover { background: var(--danger-bg); color: var(--danger); }

.lots-footer {
  position: fixed;
  left: 28px;
  bottom: 24px;
  z-index: 5;
}

.lots-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

/* --------------------------------------------------------------- топливо */

.fuel-fields {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 20px;
}

.fuel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 180px;
}

.fuel-card strong { font-size: 15px; }
.fuel-card input { width: 150px; text-align: center; }

/* --------------------------------------------------------------- чекбокс */

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  font-size: 14.5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 22px;
  box-shadow: var(--shadow-sm);
}

.check-row input[type="checkbox"] {
  width: 19px;
  height: 19px;
  accent-color: var(--accent);
  cursor: pointer;
}
.check-row label { cursor: pointer; }

.quarter-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: var(--radius);
  margin-top: 12px;
}

/* --------------------------------------------------------------- баннеры */

.banner {
  border-radius: var(--radius-md);
  padding: 13px 18px;
  max-width: 560px;
  margin: 0 auto 14px;
  font-size: 13.5px;
  white-space: pre-line;
  text-align: left;
}
.banner.error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 10px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  background: var(--text);
  color: #fff;
  padding: 13px 22px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  max-width: min(480px, 90vw);
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast.error { background: var(--danger); }
#toast.warn { background: #b7791f; }

/* --------------------------------------------------------------- финиш */

.result-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin-bottom: 18px;
}

/* ------------------------------------------- проверка "сработал ли индекс" */

.check-result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(480px, 100%);
  margin-top: 8px;
}

.check-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.check-result-row > span:first-child {
  font-weight: 600;
  font-size: 14px;
}

.check-result-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.check-result-label > span:first-child { font-weight: 600; font-size: 14px; }

.badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-yes { background: #e4f7ea; color: #1f8a4c; }
.badge-no { background: var(--secondary); color: var(--muted); }
.badge-error { background: var(--danger-bg); color: var(--danger); }

@media (max-width: 720px) {
  .lot-form { grid-template-columns: 1fr 1fr; }
  .lot-form-actions { flex-direction: column; align-items: stretch; }
  .footer-right { left: 20px; right: 20px; display: flex; justify-content: center; }
  .footer-right button { width: 100%; }
  .btn-back { left: 20px; bottom: 84px; }
}

/* --------------------------------------------------------- фон и бренд */

body::before, body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  z-index: 0;
  pointer-events: none;
}
body::before {
  width: 440px;
  height: 440px;
  top: -140px;
  left: -140px;
  background: radial-gradient(circle, rgba(79, 107, 240, 0.16), transparent 70%);
}
body::after {
  width: 500px;
  height: 500px;
  bottom: -180px;
  right: -140px;
  background: radial-gradient(circle, rgba(79, 107, 240, 0.12), transparent 70%);
}
#app, .login-wrap, .account-wrap, .admin-wrap { position: relative; z-index: 1; }

.brand-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  box-shadow: var(--shadow-btn);
}
.brand-badge svg { width: 26px; height: 26px; }

/* -------------------------------------------------- карточки-фичи (стартовый экран) */

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: min(760px, 100%);
  margin-top: 44px;
}

.feature-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 18px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.feature-icon svg { width: 18px; height: 18px; }

.feature-card h3 { font-size: 14px; margin: 0 0 6px; font-weight: 700; }
.feature-card p { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; }

@media (max-width: 720px) {
  .feature-row { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------- личный кабинет */

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0 8px;
}

.stat-card {
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  text-align: left;
}
.stat-card.alt { background: var(--secondary); }

.stat-card .stat-label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.stat-card .stat-num { font-size: 24px; font-weight: 800; color: var(--accent); margin-top: 4px; }
.stat-card.alt .stat-num { color: var(--text); }

@media (max-width: 560px) {
  .stat-row { grid-template-columns: 1fr; }
}

.amount-plus::before { content: "↑ "; }
.amount-minus::before { content: "↓ "; }

/* --------------------------------------------------------------- админка */

.admin-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 4px; }
.admin-stats .stat-pill {
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 12.5px;
  color: var(--muted);
}
.admin-stats .stat-pill b { color: var(--text); font-weight: 700; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* --------------------------------------------------------- ссылки в шапке */

.top-links a.logout-link { display: inline-flex; align-items: center; gap: 6px; }
.top-links a.logout-link svg { width: 14px; height: 14px; }

.back-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 7px 14px;
  transition: background 0.15s, color 0.15s;
}
.back-pill:hover { background: var(--accent-soft); color: var(--accent); }
.back-pill svg { width: 13px; height: 13px; }

/* --------------------------------------------------------- покупка расчётов */

.buy-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, var(--accent-soft), #ffffff);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin: 18px 0 8px;
  text-align: left;
}

.buy-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.buy-card-icon svg { width: 20px; height: 20px; }

.buy-card-text { flex: 1; }
.buy-card-text h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 700; }
.buy-card-text p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.buy-card .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  padding: 10px 18px;
  font-size: 13px;
  flex-shrink: 0;
  text-decoration: none;
}
.buy-card .btn-primary svg { width: 15px; height: 15px; }

.btn-logout-wide {
  background: var(--accent-press);
}
.btn-logout-wide:hover { background: #26398f; }

@media (max-width: 560px) {
  .buy-card { flex-direction: column; align-items: flex-start; }
  .buy-card .btn-primary { width: 100%; justify-content: center; }
}

/* ---------- Правовые документы и подвал ---------- */

.site-footer {
  margin-top: auto;
  padding: 24px 20px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}

.site-footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.legal-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px 0;
}

.legal-wrap .back-pill { align-self: flex-start; margin-bottom: 16px; }

.legal-doc {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 44px;
  width: min(820px, 100%);
  font-size: 14px;
  line-height: 1.65;
}

.legal-doc h1 {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin: 0 0 6px;
}

.legal-doc .legal-subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0 0 24px;
}

.legal-doc h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 26px 0 8px;
}

.legal-doc p { margin: 0 0 10px; text-align: justify; }
.legal-doc ul { margin: 0 0 10px; padding-left: 22px; }
.legal-doc li { margin-bottom: 6px; }

@media (max-width: 640px) {
  .legal-doc { padding: 28px 20px; }
}

/* Галочки согласий на экране входа */

.consent-box {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  cursor: pointer;
}

.consent-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 1px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.consent-row a { color: var(--accent); text-decoration: none; }
.consent-row a:hover { text-decoration: underline; }

/* ссылка на политику на стартовом экране расчёта */
.welcome-footer { margin-top: 36px; padding: 0; }
