/* ============================================================
   DD Transport — дорожная диспетчерская.
   Light, calm, high-contrast; designed for uncertain users.
   Tokens speak the road's language: asphalt, chalk, signal.
   ============================================================ */

:root {
  /* Surfaces: warm daylight asphalt -> white cabin cards */
  --chalk:        #f4f4f1;   /* page canvas */
  --cabin:        #ffffff;   /* cards */
  --cabin-2:      #fafaf8;   /* nested panels inside cards */
  --inset:        #eeeeea;   /* inputs are inset — slightly darker */

  /* Ink */
  --asphalt:      #23272b;   /* primary text */
  --gravel:       #5b6167;   /* secondary text */
  --dust:         #93999f;   /* muted / metadata */
  --ghost:        #c3c8cc;   /* disabled */

  /* Structure */
  --lane:         rgba(35, 39, 43, 0.10);  /* standard border */
  --lane-soft:    rgba(35, 39, 43, 0.06);  /* soft separation */
  --lane-strong:  rgba(35, 39, 43, 0.18);  /* emphasis */

  /* The one accent: highway-sign green */
  --signal:       #1a7f4b;
  --signal-dark:  #14663c;
  --signal-soft:  #e3f2e9;
  --signal-ring:  rgba(26, 127, 75, 0.28);

  /* Semantic (used sparingly, desaturated toward the road world) */
  --amber:        #b45309;   /* warnings, mid scores */
  --amber-soft:   #fdf0e0;
  --brake:        #bb3a2e;   /* errors, dislikes, spam */
  --brake-soft:   #fbe9e7;
  --sky:          #2563a8;   /* informational, unclear */
  --sky-soft:     #e7eff9;
  --plum:         #7c5cb0;   /* bot verdicts */
  --plum-soft:    #f0ebf9;

  /* Elevation — light theme lifts with layered shadow, not color */
  --lift-1: 0 0 0 1px rgba(35,39,43,.05), 0 1px 2px -1px rgba(35,39,43,.06), 0 2px 4px rgba(35,39,43,.04);
  --lift-2: 0 0 0 1px rgba(35,39,43,.05), 0 4px 10px -2px rgba(35,39,43,.10), 0 2px 4px rgba(35,39,43,.05);
  --lift-3: 0 0 0 1px rgba(35,39,43,.06), 0 14px 34px -6px rgba(35,39,43,.18), 0 6px 12px rgba(35,39,43,.06);

  /* Radius scale */
  --r-s: 8px;   /* inputs, chips */
  --r-m: 12px;  /* buttons, list rows */
  --r-l: 16px;  /* cards */
  --r-xl: 22px; /* sheets, modals */

  /* Type: 16px base, ratio 1.25 — larger than usual, for older eyes */
  --f-caption: 12px;
  --f-small:   13.5px;
  --f-body:    16px;
  --f-h4:      17px;
  --f-h3:      20px;
  --f-h2:      25px;
  --f-h1:      31px;

  --tabbar-h: 64px;
  font-size: 16px;
}

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

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

body {
  font-family: 'Golos Text', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--f-body);
  line-height: 1.5;
  color: var(--asphalt);
  background: var(--chalk);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.015em; text-wrap: balance; }
p { text-wrap: pretty; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--signal); text-decoration: none; }
img { max-width: 100%; }
.num { font-variant-numeric: tabular-nums; }

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

/* ============ App frame ============ */

#app { min-height: 100dvh; }

.frame { display: flex; min-height: 100dvh; }

.content {
  flex: 1;
  min-width: 0;
  padding: 20px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px);
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

/* Top header of each tab */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: var(--f-h2); font-weight: 700; }
.page-head .sub { color: var(--gravel); font-size: var(--f-small); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Bottom tab bar (mobile-first) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--lane);
  display: flex; justify-content: space-around; align-items: stretch;
}
.tabbar button {
  flex: 1; max-width: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--dust); font-size: 11px; font-weight: 500;
  transition: color .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.tabbar button:active { transform: scale(.94); }
.tabbar button.on { color: var(--signal); }
.tabbar button .ico { transition: transform .18s cubic-bezier(.23,1,.32,1); }
.tabbar button.on .ico { transform: translateY(-1px); }
.tabbar .badge-dot { position: relative; }
.tabbar .badge-dot::after {
  content: attr(data-n); position: absolute; top: -6px; right: -12px;
  background: var(--brake); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; line-height: 16px; text-align: center;
  border-radius: 8px; padding: 0 4px;
}

/* Desktop: left rail */
@media (min-width: 900px) {
  .content { padding: 32px 32px 48px; max-width: 860px; }
  .tabbar {
    top: 0; bottom: 0; left: 0; right: auto; width: 232px; height: auto;
    flex-direction: column; justify-content: flex-start; gap: 2px;
    padding: 20px 12px; border-top: 0; border-right: 1px solid var(--lane);
    background: var(--chalk);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .tabbar button {
    flex: 0 0 auto; max-width: none; width: 100%;
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 14px; border-radius: var(--r-m);
    font-size: var(--f-small); font-weight: 500;
  }
  .tabbar button:hover { background: var(--lane-soft); color: var(--gravel); }
  .tabbar button.on { background: var(--signal-soft); color: var(--signal-dark); font-weight: 600; }
  .tabbar .brand { display: flex !important; }
  .frame .content-wrap { margin-left: 232px; flex: 1; min-width: 0; }
}
.tabbar .brand {
  display: none; align-items: center; gap: 10px; padding: 6px 14px 22px;
  font-weight: 700; font-size: var(--f-h4); color: var(--asphalt); letter-spacing: -0.01em;
}
.tabbar .brand .mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--signal);
  display: grid; place-items: center; color: #fff;
}
.content-wrap { width: 100%; }

/* ============ Cards & sections ============ */

.card {
  background: var(--cabin);
  border-radius: var(--r-l);
  box-shadow: var(--lift-1);
  padding: 18px;
  margin-bottom: 14px;
}
.card.tight { padding: 0; overflow: hidden; }
.card h3 { font-size: var(--f-h4); font-weight: 650; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.card .card-sub { color: var(--gravel); font-size: var(--f-small); margin-bottom: 14px; }

.section-label {
  font-size: var(--f-caption); font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--dust); margin: 22px 2px 10px; display: flex; align-items: center; gap: 6px;
}
.section-label:first-child { margin-top: 0; }

/* Road-marking divider — the signature dashed lane line */
.lane-divider { border: 0; border-top: 2px dashed var(--lane-strong); margin: 16px 0; opacity: .5; }

/* ============ Forms ============ */

.field { margin-bottom: 15px; }
.field > label {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--f-small); font-weight: 600; color: var(--asphalt); margin-bottom: 6px;
}
.field .hint { font-size: var(--f-caption); color: var(--dust); margin-top: 5px; line-height: 1.45; }

.inp, textarea.inp, select.inp {
  width: 100%; min-height: 46px;
  background: var(--inset);
  border: 1px solid transparent;
  border-radius: var(--r-s);
  padding: 11px 13px;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  appearance: none;
}
.inp::placeholder { color: var(--dust); }
.inp:focus { outline: none; background: var(--cabin); border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-ring); }
textarea.inp { resize: vertical; min-height: 90px; line-height: 1.5; }
textarea.inp.code { font-size: 14.5px; min-height: 200px; }
select.inp {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%235b6167' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px;
}
.inp-row { display: flex; gap: 10px; }
.inp-row > * { flex: 1; min-width: 0; }

/* Range slider */
input[type="range"].inp-range { -webkit-appearance: none; width: 100%; height: 44px; background: transparent; }
input[type="range"].inp-range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--signal) 0%, var(--signal) var(--fill, 50%), var(--lane) var(--fill, 50%)); }
input[type="range"].inp-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px;
  border-radius: 50%; background: #fff; border: 2px solid var(--signal); box-shadow: var(--lift-1); cursor: grab;
}

/* Toggle switch — big, obvious */
.toggle { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; -webkit-tap-highlight-color: transparent; }
.toggle input { position: absolute; opacity: 0; width: 0; }
.toggle .knob {
  width: 54px; height: 32px; border-radius: 16px; background: var(--ghost); flex-shrink: 0;
  transition: background .18s ease; position: relative;
}
.toggle .knob::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .18s cubic-bezier(.23,1,.32,1);
}
.toggle input:checked + .knob { background: var(--signal); }
.toggle input:checked + .knob::after { transform: translateX(22px); }
.toggle .tlabel { font-size: var(--f-small); font-weight: 600; display: flex; align-items: center; gap: 6px; }

/* ============ Buttons ============ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 18px;
  border-radius: var(--r-m); font-weight: 600; font-size: var(--f-small);
  background: var(--signal); color: #fff;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:hover { background: var(--signal-dark); }
.btn:active { transform: scale(.97); }
.btn:disabled { background: var(--ghost); cursor: default; transform: none; }
.btn.ghost { background: transparent; color: var(--asphalt); box-shadow: inset 0 0 0 1px var(--lane-strong); }
.btn.ghost:hover { background: var(--lane-soft); }
.btn.soft { background: var(--signal-soft); color: var(--signal-dark); }
.btn.soft:hover { background: #d5ebde; }
.btn.danger { background: transparent; color: var(--brake); box-shadow: inset 0 0 0 1px rgba(187,58,46,.35); }
.btn.danger:hover { background: var(--brake-soft); }
.btn.small { min-height: 38px; padding: 7px 13px; font-size: var(--f-caption); border-radius: 10px; }
.btn.block { width: 100%; }
.btn .spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border-radius: var(--r-m); color: var(--gravel);
  transition: background .15s ease, color .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--lane-soft); color: var(--asphalt); }
.icon-btn:active { transform: scale(.92); }

/* Info "i" next to field labels */
.info-btn {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  color: var(--dust); position: relative; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.info-btn::before { content: ''; position: absolute; inset: -9px; } /* 44px hit area */
.info-btn:hover, .info-btn:active { color: var(--signal); }

/* ============ Chips & badges ============ */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--f-caption); font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  background: var(--lane-soft); color: var(--gravel);
}
.chip.lead    { background: var(--signal-soft); color: var(--signal-dark); }
.chip.spam    { background: var(--brake-soft);  color: var(--brake); }
.chip.bot     { background: var(--plum-soft);   color: var(--plum); }
.chip.unclear { background: var(--sky-soft);    color: var(--sky); }
.chip.ignored { background: var(--amber-soft);  color: var(--amber); }
.chip.new     { background: var(--lane-soft);   color: var(--gravel); }

/* Score ring (lead score 0-100) */
.score-ring { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .val {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* Route chip — the signature: A → B with road dots */
.route-chip { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--f-small); }
.route-chip .dotline { display: inline-flex; align-items: center; gap: 0; color: var(--dust); }
.route-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--signal); flex-shrink: 0; }
.route-chip .dot.end { background: var(--asphalt); }
.route-chip .dash { width: 26px; border-top: 2px dashed var(--lane-strong); margin: 0 3px; }

/* ============ Lists ============ */

.rowlist { display: flex; flex-direction: column; }
.rowitem {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--lane-soft);
  transition: background .12s ease; text-align: left; width: 100%;
  -webkit-tap-highlight-color: transparent;
}
.rowitem:last-child { border-bottom: 0; }
button.rowitem:hover { background: var(--cabin-2); }
button.rowitem:active { background: var(--inset); }
.rowitem .grow { flex: 1; min-width: 0; }
.rowitem .title { font-weight: 600; font-size: var(--f-small); }
.rowitem .meta { color: var(--dust); font-size: var(--f-caption); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
  background: var(--signal-soft); color: var(--signal-dark);
}

/* ============ Stat tiles ============ */

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--cabin); border-radius: var(--r-l); box-shadow: var(--lift-1);
  padding: 14px 15px 13px;
}
.stat .k { font-size: var(--f-caption); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--dust); display: flex; align-items: center; gap: 5px; }
.stat .v { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.stat .d { font-size: var(--f-caption); color: var(--gravel); margin-top: 1px; }
.stat.hero { grid-column: span 2; background: var(--asphalt); color: #fff; }
.stat.hero .k { color: rgba(255,255,255,.55); }
.stat.hero .d { color: rgba(255,255,255,.65); }
.stat.hero .v { font-size: 34px; color: #7ed9a7; }

/* ============ Messenger ============ */

.chatlist-search { position: sticky; top: 0; z-index: 5; background: var(--chalk); padding: 2px 0 10px; }
.filter-row { display: flex; gap: 7px; overflow-x: auto; padding: 10px 2px 2px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row .chip { padding: 7px 13px; font-size: var(--f-caption); cursor: pointer; flex-shrink: 0; border: 1px solid transparent; min-height: 34px; }
.filter-row .chip.sel { background: var(--asphalt); color: #fff; }

.unread-pill {
  min-width: 22px; height: 22px; border-radius: 11px; padding: 0 6px;
  background: var(--signal); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
}

/* Chat screen */
.chat-screen {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  background: var(--chalk);
  animation: slide-in .22s cubic-bezier(.23,1,.32,1);
}
@keyframes slide-in { from { transform: translateX(6%); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 900px) { .chat-screen { left: 232px; } }

.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--cabin); border-bottom: 1px solid var(--lane);
  flex-shrink: 0;
}
.chat-head .cname { font-weight: 650; font-size: var(--f-small); }
.chat-head .cphone { font-size: var(--f-caption); color: var(--dust); }

.chat-body { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.bubble-day { align-self: center; font-size: var(--f-caption); color: var(--dust); background: var(--lane-soft); padding: 3px 12px; border-radius: 999px; margin: 12px 0 6px; }

.bubble { max-width: 82%; padding: 9px 13px; border-radius: 16px; font-size: 15px; line-height: 1.45; position: relative; word-wrap: break-word; white-space: pre-wrap; }
.bubble .btime { display: inline-block; font-size: 10.5px; color: inherit; opacity: .55; margin-left: 8px; float: right; margin-top: 8px; font-variant-numeric: tabular-nums; }
.bubble.in  { align-self: flex-start; background: var(--cabin); box-shadow: var(--lift-1); border-bottom-left-radius: 6px; }
.bubble.ai  { align-self: flex-end; background: var(--signal-soft); border-bottom-right-radius: 6px; }
.bubble.op  { align-self: flex-end; background: var(--asphalt); color: #fff; border-bottom-right-radius: 6px; }
.bubble.sys { align-self: center; background: var(--amber-soft); color: var(--amber); font-size: var(--f-caption); border-radius: 10px; }

.author-tag { display: flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 3px; }
.bubble.ai .author-tag { color: var(--signal-dark); }
.bubble.op .author-tag { color: rgba(255,255,255,.6); }

.bubble .media-img { border-radius: 10px; max-height: 280px; display: block; margin-bottom: 4px; cursor: zoom-in; outline: 1px solid rgba(0,0,0,.1); outline-offset: -1px; }
.bubble audio { width: 230px; max-width: 100%; height: 40px; display: block; }
.bubble .transcription { font-size: var(--f-caption); color: var(--gravel); border-top: 1px dashed var(--lane-strong); margin-top: 7px; padding-top: 6px; font-style: italic; }
.bubble.ai .transcription { color: var(--signal-dark); }
.bubble .docfile { display: flex; align-items: center; gap: 9px; font-size: var(--f-small); font-weight: 600; padding: 4px 0; color: inherit; }

.fb-row { display: flex; gap: 3px; align-self: flex-end; margin: 1px 4px 4px 0; }
.fb-row .icon-btn { width: 34px; height: 34px; border-radius: 10px; color: var(--dust); }
.fb-row .icon-btn.liked { color: var(--signal); background: var(--signal-soft); }
.fb-row .icon-btn.disliked { color: var(--brake); background: var(--brake-soft); }

.chat-compose {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--cabin); border-top: 1px solid var(--lane); flex-shrink: 0;
}
.chat-compose textarea {
  flex: 1; max-height: 120px; min-height: 46px;
  background: var(--inset); border: 1px solid transparent; border-radius: 23px;
  padding: 11px 16px; resize: none; line-height: 1.4;
}
.chat-compose textarea:focus { outline: none; border-color: var(--signal); background: #fff; }
.chat-compose .btn { border-radius: 50%; width: 46px; min-height: 46px; padding: 0; flex-shrink: 0; }

.ai-pause-strip {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-size: var(--f-caption); font-weight: 600; color: var(--amber);
  background: var(--amber-soft); padding: 7px 12px;
}

/* ============ Sheets & modals ============ */

.sheet-veil {
  position: fixed; inset: 0; z-index: 80; background: rgba(23,26,29,.42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: veil-in .18s ease;
}
@keyframes veil-in { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  background: var(--cabin); border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--lift-3);
  animation: sheet-up .26s cubic-bezier(.23,1,.32,1);
}
@keyframes sheet-up { from { transform: translateY(48px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .sheet-veil { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--r-xl); padding-bottom: 24px; }
}
.sheet .grip { width: 42px; height: 5px; border-radius: 3px; background: var(--ghost); margin: 4px auto 14px; }
@media (min-width: 640px) { .sheet .grip { visibility: hidden; margin-bottom: 4px; } }
.sheet h3 { font-size: var(--f-h3); font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 9px; }
.sheet .sheet-body { color: var(--gravel); font-size: var(--f-small); line-height: 1.6; }
.sheet .sheet-body p { margin-bottom: 10px; }
.sheet .sheet-body b { color: var(--asphalt); }
.sheet .sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet .sheet-actions .btn { flex: 1; }

/* Image lightbox */
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(12,14,15,.92); display: grid; place-items: center; animation: veil-in .15s ease; }
.lightbox img { max-width: 96vw; max-height: 92dvh; border-radius: 8px; }
.lightbox .icon-btn { position: absolute; top: calc(12px + env(safe-area-inset-top, 0)); right: 14px; color: #fff; }

/* ============ Toasts ============ */

.toasts { position: fixed; top: calc(14px + env(safe-area-inset-top, 0)); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(94vw, 420px); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--asphalt); color: #fff; font-size: var(--f-small); font-weight: 500;
  padding: 12px 16px; border-radius: var(--r-m); box-shadow: var(--lift-3);
  animation: toast-in .25s cubic-bezier(.23,1,.32,1);
}
.toast.err { background: var(--brake); }
.toast.ok .ico { color: #7ed9a7; }
@keyframes toast-in { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ Login ============ */

.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 50% -10%, #e6efe9 0%, transparent 60%),
    var(--chalk);
}
.login-card { width: 100%; max-width: 400px; background: var(--cabin); border-radius: var(--r-xl); box-shadow: var(--lift-2); padding: 30px 26px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; text-align: center; }
.login-brand .mark { width: 62px; height: 62px; border-radius: 18px; background: var(--signal); color: #fff; display: grid; place-items: center; box-shadow: var(--lift-2); }
.login-brand h1 { font-size: var(--f-h3); font-weight: 700; }
.login-brand .sub { color: var(--gravel); font-size: var(--f-small); }
.login-road { display: flex; align-items: center; gap: 6px; margin: 20px auto 0; width: 150px; opacity: .6; }
.login-road .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--signal); }
.login-road .dash { flex: 1; border-top: 2px dashed var(--lane-strong); }
.login-road .dot.end { background: var(--asphalt); }

/* ============ QR / WhatsApp screen ============ */

.qr-box {
  display: grid; place-items: center; background: var(--cabin-2);
  border: 2px dashed var(--lane-strong); border-radius: var(--r-l);
  min-height: 300px; padding: 20px; text-align: center;
}
.qr-box img { width: 260px; height: 260px; border-radius: 8px; image-rendering: pixelated; }
.conn-status { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--f-small); }
.conn-status .pulse { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.conn-status .pulse.on { background: var(--signal); box-shadow: 0 0 0 0 var(--signal-ring); animation: pulse 1.8s infinite; }
.conn-status .pulse.off { background: var(--ghost); }
.conn-status .pulse.qr { background: var(--amber); }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(26,127,75,0); } }

/* ============ Charts (pure SVG) ============ */

.chart-wrap { overflow-x: auto; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: var(--f-caption); color: var(--gravel); }
.chart-legend .lg { display: flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 10px; height: 10px; border-radius: 3px; }

/* Reason bars */
.reason-bar { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.reason-bar .rlabel { flex: 1; min-width: 0; font-size: var(--f-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reason-bar .rtrack { flex: 1.4; height: 8px; border-radius: 4px; background: var(--lane-soft); overflow: hidden; }
.reason-bar .rfill { height: 100%; border-radius: 4px; background: var(--signal); transition: width .5s cubic-bezier(.23,1,.32,1); }
.reason-bar .rnum { font-size: var(--f-caption); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gravel); min-width: 26px; text-align: right; }

/* ============ Misc ============ */

.empty-state { text-align: center; padding: 44px 20px; color: var(--dust); }
.empty-state .ico { opacity: .5; margin-bottom: 10px; }
.empty-state .et { font-weight: 600; color: var(--gravel); font-size: var(--f-small); margin-bottom: 4px; }
.empty-state .es { font-size: var(--f-caption); max-width: 300px; margin: 0 auto; line-height: 1.5; }

.skeleton { border-radius: var(--r-m); background: linear-gradient(90deg, var(--lane-soft) 25%, var(--inset) 50%, var(--lane-soft) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.dropzone {
  border: 2px dashed var(--lane-strong); border-radius: var(--r-l); background: var(--cabin-2);
  padding: 30px 18px; text-align: center; color: var(--gravel); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.over { border-color: var(--signal); background: var(--signal-soft); color: var(--signal-dark); }
.dropzone .dz-title { font-weight: 650; font-size: var(--f-small); margin: 8px 0 3px; color: var(--asphalt); }
.dropzone .dz-sub { font-size: var(--f-caption); }

.progressbar { height: 8px; border-radius: 4px; background: var(--lane-soft); overflow: hidden; }
.progressbar .fill { height: 100%; background: var(--signal); border-radius: 4px; transition: width .4s ease; }

.tag-status { display: inline-flex; align-items: center; gap: 5px; font-size: var(--f-caption); font-weight: 600; }
.tag-status.done { color: var(--signal-dark); }
.tag-status.indexing { color: var(--amber); }
.tag-status.failed { color: var(--brake); }
.tag-status.uploaded { color: var(--gravel); }

.help-topbtn { display: inline-flex; align-items: center; gap: 6px; color: var(--signal-dark); background: var(--signal-soft); font-size: var(--f-caption); font-weight: 600; padding: 8px 13px; border-radius: 999px; min-height: 38px; transition: background .15s; }
.help-topbtn:hover { background: #d5ebde; }

.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--lane-soft); font-size: var(--f-small); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--gravel); }
.kv .v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.fade-in { animation: fade-in .25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.stagger > * { animation: fade-in .3s cubic-bezier(.23,1,.32,1) backwards; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
