/* ─────────────────────────────────────────────
   Путевой лист · ЮТЕКС РУ
   Mobile-first responsive · Jony Ive minimal
   ───────────────────────────────────────────── */

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

:root {
  --bg:           #f5f5f7;
  --surface:      #ffffff;
  --border:       rgba(0,0,0,0.08);
  --border-md:    rgba(0,0,0,0.12);
  --border-str:   rgba(0,0,0,0.18);
  --text:         #1d1d1f;
  --text-2:       #6e6e73;
  --text-3:       #aeaeb2;
  --accent:       #0071e3;
  --accent-h:     #0077ed;
  --success:      #34c759;
  --warning:      #ff9f0a;
  --danger:       #ff3b30;
  --r:            14px;
  --r-sm:         10px;
  --r-xs:         8px;
  --shadow:       0 1px 8px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-h:     0 4px 20px rgba(0,0,0,0.09), 0 0 0 1px rgba(0,0,0,0.05);
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --ease:         0.18s cubic-bezier(0.4,0,0.2,1);
  --max:          960px;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

/* ═══════════════════════════════
   LAYOUT
═══════════════════════════════ */

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

.main {
  flex: 1;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 28px 16px 100px;   /* bottom = space for mobile nav */
}
@media (min-width: 640px) { .main { padding: 40px 24px 80px; } }
@media (min-width: 960px) { .main { padding: 52px 32px 80px; } }

/* ═══════════════════════════════
   HEADER
═══════════════════════════════ */

.header {
  position: sticky; top: 0; z-index: 200;
  background: rgba(245,245,247,0.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  height: 52px;
}
@media (min-width: 640px) { .header-inner { padding: 0 24px; height: 56px; } }
@media (min-width: 960px) { .header-inner { padding: 0 32px; } }

.logo { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.logo svg { flex-shrink: 0; }
.logo-text { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

/* Desktop nav — pill switcher */
.nav {
  display: none;
  gap: 3px;
  background: rgba(0,0,0,0.06);
  border-radius: 11px;
  padding: 3px;
}
@media (min-width: 600px) { .nav { display: flex; } }

.nav-btn {
  font-family: var(--font); font-size: 13px; font-weight: 500;
  color: var(--text-2); background: transparent; border: none;
  cursor: pointer; padding: 5px 14px; border-radius: 8px;
  transition: color var(--ease), background var(--ease);
  white-space: nowrap;
}
.nav-btn:hover { color: var(--text); }
.nav-btn.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* Mobile bottom nav */
.mobile-nav {
  display: flex;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: rgba(245,245,247,0.94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
@media (min-width: 600px) { .mobile-nav { display: none; } }

.mob-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 6px 4px; border: none; background: none;
  cursor: pointer; font-family: var(--font); font-size: 10px;
  font-weight: 500; color: var(--text-3);
  transition: color var(--ease);
}
.mob-btn.active { color: var(--accent); }
.mob-btn svg { width: 22px; height: 22px; }

/* User info in header */
.header-user { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text-2); display: none; }
@media (min-width: 700px) { .user-name { display: block; } }
.logout-btn { font-size: 13px; color: var(--text-3); text-decoration: none; transition: color var(--ease); }
.logout-btn:hover { color: var(--text); }

/* ═══════════════════════════════
   HERO
═══════════════════════════════ */

.hero { margin-bottom: 28px; }
@media (min-width: 640px) { .hero { margin-bottom: 36px; } }

.hero-title {
  font-size: 26px; font-weight: 600;
  letter-spacing: -0.025em; line-height: 1.15;
}
@media (min-width: 640px) { .hero-title { font-size: 32px; } }
@media (min-width: 960px) { .hero-title { font-size: 38px; } }

.hero-sub {
  font-size: 15px; color: var(--text-2);
  margin-top: 8px; line-height: 1.55; max-width: 480px;
}
@media (min-width: 640px) { .hero-sub { font-size: 17px; } }

/* ═══════════════════════════════
   CARDS
═══════════════════════════════ */

.card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 20px 18px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--ease);
}
@media (min-width: 640px) { .card { padding: 26px 24px; } }
@media (min-width: 960px) { .card { padding: 30px 28px; } }

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (min-width: 720px) {
  .card-grid { grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
}

.card-title {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 18px;
}

/* ═══════════════════════════════
   FORM FIELDS
═══════════════════════════════ */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
/* 3-col groups on mobile → stack */
.field-group.cols-3 { grid-template-columns: 1fr 1fr; }
@media (min-width: 640px) { .field-group.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }

.label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-2); margin-bottom: 6px;
}
.hint { font-size: 12px; color: var(--text-3); margin-top: 5px; line-height: 1.45; }

.input-wrap { position: relative; }

.input {
  width: 100%; font-family: var(--font); font-size: 15px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border-str);
  border-radius: var(--r-sm); padding: 11px 14px;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
  appearance: none; -webkit-appearance: none;
  /* Prevent iOS zoom on focus */
  font-size: max(16px, 15px);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,113,227,0.15); }

.input-big {
  font-size: 24px; font-weight: 300;
  padding: 12px 48px 12px 14px;
  letter-spacing: -0.02em;
}
.input-unit {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--text-3); pointer-events: none;
}

.select {
  cursor: pointer; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23aeaeb2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

.field-error { font-size: 12px; color: var(--danger); margin-top: 5px; display: none; }
.field-error.visible { display: block; }
.input.error { border-color: var(--danger); }
.input.error:focus { box-shadow: 0 0 0 3px rgba(255,59,48,0.15); }

/* ═══════════════════════════════
   BUTTONS
═══════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font); font-size: 15px; font-weight: 500;
  padding: 12px 22px; border-radius: var(--r-sm);
  border: none; cursor: pointer;
  transition: background var(--ease), box-shadow var(--ease), transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.loading { opacity: 0.7; pointer-events: none; }

.btn-ghost {
  width: 100%; margin-top: 18px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-str);
}
.btn-ghost:hover { background: rgba(0,0,0,0.05); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); box-shadow: 0 4px 16px rgba(0,113,227,0.35); }

.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border-str); }
.btn-secondary:hover { background: rgba(0,0,0,0.05); }

.btn-group { display: flex; gap: 10px; margin-top: 18px; }
.btn-group .btn { flex: 1; }

.btn-link {
  background: none; border: none; cursor: pointer; font-family: var(--font);
  font-size: 13px; color: var(--accent); padding: 0; text-decoration: none;
}
.btn-link:hover { opacity: 0.75; }
.btn-link-danger { color: var(--danger); }

/* ═══════════════════════════════
   RESULT STATS
═══════════════════════════════ */

.stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 16px;
}
.stat {
  background: var(--bg); border-radius: var(--r-sm);
  padding: 13px 14px; display: flex; flex-direction: column; gap: 4px;
}
.stat-val { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
@media (min-width: 640px) { .stat-val { font-size: 26px; } }
.stat-label { font-size: 10px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-val.good { color: var(--success); }
.stat-val.warn { color: var(--warning); }

/* ═══════════════════════════════
   ODOMETER BAR
═══════════════════════════════ */

.odo-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border-radius: var(--r-sm);
  padding: 13px 14px; margin-bottom: 14px;
}
.odo-item { flex: 1; min-width: 0; }
.odo-item-right { text-align: right; }
.odo-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-3); display: block; margin-bottom: 3px;
}
.odo-val { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
@media (min-width: 400px) { .odo-val { font-size: 19px; } }
.odo-arrow { font-size: 16px; color: var(--text-3); flex-shrink: 0; }

/* ═══════════════════════════════
   DETAIL ROWS
═══════════════════════════════ */

.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  gap: 12px;
}
.detail-row:last-of-type { border-bottom: none; }
.detail-label { font-size: 13px; color: var(--text-2); flex-shrink: 0; }
.detail-val { font-size: 13px; font-weight: 500; text-align: right; }

.note { font-size: 12px; color: var(--text-3); margin-top: 12px; line-height: 1.5; }

/* ═══════════════════════════════
   TABLES — mobile-scrollable
═══════════════════════════════ */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }

.odo-table, .trips-table {
  width: 100%; border-collapse: collapse; font-size: 13px; min-width: 360px;
}
@media (min-width: 640px) { .odo-table, .trips-table { font-size: 14px; min-width: 0; } }

.odo-table th, .trips-table th {
  text-align: left; font-size: 10px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); padding: 0 8px 12px 0;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.odo-table td, .trips-table td {
  padding: 11px 8px 11px 0; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
.odo-table tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.odo-table tfoot td { border-bottom: none; padding-top: 14px; }
.trips-table tfoot td { border-bottom: none; border-top: 1px solid var(--border-str); padding-top: 12px; }

/* Card-style table rows on very small screens */
@media (max-width: 480px) {
  .odo-table, .odo-table thead, .odo-table tbody, .odo-table tr { display: block; }
  .odo-table thead { display: none; }
  .odo-table td {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border: none; font-size: 13px;
  }
  .odo-table td:first-child { font-weight: 500; }
  .odo-table tbody tr {
    border: 1px solid var(--border); border-radius: var(--r-sm);
    padding: 10px 14px; margin-bottom: 10px; background: var(--bg);
  }
  .odo-table tbody tr:last-child { margin-bottom: 0; }
  .odo-table tfoot { display: block; }
  .odo-table tfoot td { display: flex; justify-content: space-between; border: none; padding-top: 12px; }
}

.badge { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 500; background: var(--bg); color: var(--text-2); }
.badge-total { background: var(--text); color: var(--surface); }

.td-num { color: var(--text-3); font-variant-numeric: tabular-nums; width: 32px; }
.td-dt { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 11px; }
.td-km { font-weight: 500; text-align: right; white-space: nowrap; }
.td-total-label { color: var(--text-2); font-weight: 500; }
.td-total { font-weight: 600; text-align: right; }

/* ═══════════════════════════════
   CONSTANTS GRID
═══════════════════════════════ */

.const-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 480px) { .const-grid { grid-template-columns: 1fr 1fr; } }
.const-item { display: flex; flex-direction: column; gap: 3px; }
.const-key { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.const-val { font-size: 13px; color: var(--text); }

/* ═══════════════════════════════
   LEGAL CARD
═══════════════════════════════ */

.card-legal {
  display: flex; gap: 14px; align-items: flex-start;
  background: rgba(255,159,10,0.06);
  border: 1px solid rgba(255,159,10,0.22);
  margin-bottom: 14px;
}
.legal-icon { flex-shrink: 0; margin-top: 1px; }
.legal-text { font-size: 13px; color: var(--text-2); line-height: 1.55; }
.legal-text strong { font-size: 13px; font-weight: 600; color: var(--text); display: block; margin-bottom: 4px; }

/* ═══════════════════════════════
   LOADING STATE
═══════════════════════════════ */

.loading { color: var(--text-3); font-size: 14px; padding: 8px 0; }

/* ═══════════════════════════════
   FOOTER
═══════════════════════════════ */

.footer { border-top: 1px solid var(--border); padding: 18px 24px; text-align: center; }
.footer p { font-size: 12px; color: var(--text-3); }

/* ═══════════════════════════════
   TOAST
═══════════════════════════════ */

.toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(29,29,31,0.93); color: #fff;
  font-size: 14px; font-weight: 500;
  padding: 12px 20px; border-radius: 12px;
  backdrop-filter: blur(12px);
  transition: transform 0.28s cubic-bezier(0.34,1.4,0.64,1), opacity 0.25s;
  opacity: 0; pointer-events: none; z-index: 9999;
  white-space: nowrap; max-width: calc(100vw - 32px);
}
@media (min-width: 600px) { .toast { bottom: 28px; } }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ═══════════════════════════════
   ALERT
═══════════════════════════════ */

.alert-warn {
  background: rgba(255,159,10,0.08); border: 1px solid rgba(255,159,10,0.25);
  color: #a65e00; font-size: 13px; padding: 10px 14px;
  border-radius: var(--r-sm); margin-bottom: 12px; line-height: 1.45;
}
