/* ════════════════════════════════════════════════════════════
   AutoParts Parser — CSS
   Шрифты: Onest (UI) + JetBrains Mono (код/числа)
   Тема: тёмная, индустриальная, без "AI-slop"
   ════════════════════════════════════════════════════════════ */

:root {
  --bg:        #080b10;
  --bg2:       #0d1117;
  --surface:   #111720;
  --surface2:  #161d2a;
  --border:    #1c2535;
  --border2:   #243044;

  --accent:    #2563eb;
  --accent-h:  #1d4ed8;
  --accent-glow: rgba(37,99,235,.25);

  --success:   #16a34a;
  --success-bg:#0f2919;
  --warning:   #d97706;
  --warning-bg:#1f1a0e;
  --danger:    #dc2626;
  --danger-bg: #200d0d;
  --purple:    #7c3aed;
  --purple-bg: #150f1f;

  --text:      #d1d9e6;
  --text-muted:#4e6080;
  --text-dim:  #2d3f56;

  --radius:    10px;
  --radius-lg: 16px;
  --mono:      'JetBrains Mono', 'Fira Code', monospace;
  --sans:      'Onest', system-ui, sans-serif;

  --header-h:  60px;
}

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

html { font-size: 15px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

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

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(8,11,16,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 100%;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  box-shadow: 0 0 16px var(--accent-glow);
}
.logo-text {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.logo-text em { font-style: normal; color: var(--accent); font-weight: 800; }

.header-nav {
  display: flex;
  gap: .25rem;
  flex: 1;
}

.nav-link {
  padding: .4rem .85rem;
  border-radius: 7px;
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--text); background: var(--surface2); }

.header-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}
.user-name {
  font-size: .85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.role-badge {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .15rem .45rem;
  border-radius: 4px;
  background: rgba(37,99,235,.2);
  color: #60a5fa;
  border: 1px solid rgba(37,99,235,.3);
}

/* ════════════════════ AUTH PAGE ════════════════════ */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 50% at 15% 20%, rgba(37,99,235,.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 80%, rgba(124,58,237,.06) 0%, transparent 60%),
    var(--bg);
}

.auth-wrap { width: 100%; max-width: 400px; padding: 1.5rem; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: 2rem;
}
.auth-logo .logo-icon { width: 44px; height: 44px; font-size: 1.3rem; }
.auth-logo .logo-text { font-size: 1.2rem; }

/* ════════════════════ SECTIONS ════════════════════ */

.section { margin-bottom: 2.5rem; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-header h2, .section > h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
  margin-bottom: 1.25rem;
}
.section-header h2 { margin-bottom: 0; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.supplier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.supplier-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color .2s;
}
.supplier-card:hover { border-color: var(--border2); }

.supplier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.supplier-name {
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.supplier-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.supplier-dot.autoeuro { background: #3b82f6; box-shadow: 0 0 6px rgba(59,130,246,.6); }
.supplier-dot.favorit  { background: #f97316; box-shadow: 0 0 6px rgba(249,115,22,.6); }
.supplier-dot.autokontinent { background: #10b981; box-shadow: 0 0 6px rgba(16,185,129,.6); }

.account-select-wrap { margin-bottom: .75rem; }

/* ════════════════════ FORMS ════════════════════ */

.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

input[type="text"],
input[type="password"],
input[type="email"],
textarea,
.select {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: .9rem;
  padding: .6rem .85rem;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  appearance: none;
}
textarea {
  min-height: 7.5rem;
  resize: vertical;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.45;
}
.field-hint {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.45;
  margin-top: .2rem;
}
input:focus, .select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.select option { background: var(--bg2); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.input-with-btn {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.input-with-btn input { flex: 1; }

.input-inline {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--sans);
  font-size: .85rem;
  padding: .4rem .75rem;
  outline: none;
}
.input-inline:focus { border-color: var(--accent); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, background .15s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h); box-shadow: 0 4px 20px var(--accent-glow); }

.btn-ghost {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border2); }

.btn-danger  { background: var(--danger-bg); color: #f87171; border: 1px solid rgba(220,38,38,.3); }
.btn-danger:hover:not(:disabled)  { background: rgba(220,38,38,.2); }

.btn-success { background: var(--success-bg); color: #4ade80; border: 1px solid rgba(22,163,74,.3); }
.btn-success:hover:not(:disabled) { background: rgba(22,163,74,.2); }

.btn-sm  { padding: .35rem .75rem; font-size: .8rem; border-radius: 7px; }
.btn-full { width: 100%; }
.mt-sm { margin-top: .75rem; }

/* ════════════════════ BADGES ════════════════════ */

.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .6rem;
  border-radius: 99px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-admin    { background: rgba(37,99,235,.15);  color: #60a5fa; border-color: rgba(37,99,235,.3); }
.badge-user     { background: var(--surface2); color: var(--text-muted); }
.badge-running  { background: rgba(217,119,6,.15); color: #fbbf24; border-color: rgba(217,119,6,.3); animation: pulse 1.5s infinite; }
.badge-done     { background: var(--success-bg); color: #4ade80; border-color: rgba(22,163,74,.3); }
.badge-failed   { background: var(--danger-bg); color: #f87171; border-color: rgba(220,38,38,.3); }
.badge-error    { background: var(--danger-bg); color: #f87171; border-color: rgba(220,38,38,.3); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.6} }

/* ════════════════════ ALERTS ════════════════════ */

.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  font-size: .88rem;
  margin-bottom: 1.25rem;
}
.alert-error   { background: var(--danger-bg); color: #fca5a5; border: 1px solid rgba(220,38,38,.3); }
.alert-success { background: var(--success-bg); color: #86efac; border: 1px solid rgba(22,163,74,.3); }

/* ════════════════════ TABLES ════════════════════ */

.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
}
.table thead { background: var(--surface2); }
.table th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}
.table td {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:hover { background: rgba(255,255,255,.02); }
.table .row-disabled td { opacity: .45; }

/* ════════════════════ LOG BOX ════════════════════ */

.log-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  height: 360px;
  overflow-y: auto;
  padding: .5rem 0;
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.8;
  margin-bottom: 1rem;
}

.log-line {
  display: flex;
  gap: .75rem;
  padding: .1rem 1.1rem;
  border-left: 2px solid transparent;
  transition: background .1s;
}
.log-line:hover { background: rgba(255,255,255,.02); }

.log-time { color: var(--text-dim); flex-shrink: 0; min-width: 52px; }
.log-msg  { color: var(--text); word-break: break-all; }

.log-line.success { border-color: var(--success); }
.log-line.success .log-msg { color: #4ade80; }
.log-line.already { border-color: var(--purple); }
.log-line.already .log-msg { color: #a78bfa; }
.log-line.warning .log-msg { color: #fbbf24; }
.log-line.error   { border-color: var(--danger); }
.log-line.error   .log-msg { color: #f87171; }
.log-line.pause   .log-msg { color: var(--text-muted); }

/* ════════════════════ REPORT ════════════════════ */

.report-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}
@media(max-width: 600px) { .report-grid { grid-template-columns: repeat(2,1fr); } }

.stat-cell { background: var(--surface); padding: 1.1rem 1.25rem; }
.stat-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: .3rem; }
.stat-val { font-family: var(--mono); font-size: 2rem; font-weight: 700; }
.stat-cell.total  .stat-val { color: #60a5fa; }
.stat-cell.joined .stat-val { color: #4ade80; }
.stat-cell.already .stat-val { color: #a78bfa; }
.stat-cell.error  .stat-val { color: #f87171; }

.report-joined {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  font-size: .85rem;
}
.report-joined strong { display: block; margin-bottom: .5rem; color: var(--text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.report-joined ul { list-style: none; }
.report-joined li { padding: .3rem 0; border-bottom: 1px solid var(--border); }
.report-joined li:last-child { border: none; }
.report-joined a { color: #4ade80; text-decoration: none; }
.report-joined a:hover { text-decoration: underline; }

/* ════════════════════ EMPTY STATE ════════════════════ */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state p { margin-bottom: 1rem; }

/* ════════════════════ UTILS ════════════════════ */

.mono         { font-family: var(--mono); }
.text-muted   { color: var(--text-muted); }
.text-success { color: #4ade80; }
.text-danger  { color: #f87171; }
.text-purple  { color: #a78bfa; }
.text-sm      { font-size: .82rem; }

.action-btns { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

/* ════════════════════ AUTH FORM ════════════════════ */

.auth-form { display: flex; flex-direction: column; gap: 1.1rem; }

/* ════════════════════ RESPONSIVE ════════════════════ */

@media(max-width: 640px) {
  .header-nav { display: none; }
  .header-inner { gap: 1rem; }
  .supplier-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
