/* ===== CSS Variables ===== */
:root {
  --bg:         #f1f5f9;
  --surface:    #ffffff;
  --surface-2:  #f8fafc;
  --border:     #e2e8f0;
  --border-mid: #cbd5e1;
  --text:       #0f172a;
  --text-2:     #475569;
  --text-3:     #94a3b8;
  --accent:     #2563eb;
  --accent-bg:  #eff6ff;
  --accent-bdr: #bfdbfe;
  --green:      #10b981;
  --green-bg:   #dcfce7;
  --green-text: #15803d;
  --yellow:     #f59e0b;
  --yellow-bg:  #fef9c3;
  --yellow-text:#854d0e;
  --red:        #ef4444;
  --red-bg:     #fee2e2;
  --red-text:   #b91c1c;
  --sidebar-w:  72px;
  --max-w:      1280px;
  --radius:     8px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06);
  --shadow:     0 2px 8px rgba(0,0,0,.08);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 4px;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.sidebar-logo {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #fff;
  margin-bottom: 16px; flex-shrink: 0;
}
.nav-item {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; color: var(--text-3);
  font-size: 9px; font-weight: 600;
  border: none; background: transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg); color: var(--text-2); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); }
.nav-item svg { width: 20px; height: 20px; }

/* ===== Main ===== */
.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }
.content { max-width: var(--max-w); margin: 0 auto; padding: 24px; }

/* ===== Sections ===== */
.section { display: none; }
.section.active { display: block; }

/* ===== Auction Bar ===== */
.auction-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}
.status-dot.inactive { background: var(--border-mid); box-shadow: none; }

/* ===== Type Badges ===== */
.type-badge {
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
}
.type-dollar   { background: #dbeafe; color: #1d4ed8; }
.type-extra    { background: #ede9fe; color: #6d28d9; }
.type-separate { background: #dcfce7; color: #166534; }
.type-other    { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }

/* ===== Buttons ===== */
.btn {
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; border: none;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline  { background: var(--surface); border: 1px solid var(--border-mid); color: var(--text-2); }
.btn-outline:hover { border-color: var(--text-3); opacity: 1; }
.btn-link     { background: var(--accent-bg); border: 1px solid var(--accent-bdr); color: var(--accent); }
.btn-danger   { background: var(--red-bg); border: 1px solid #fca5a5; color: var(--red-text); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ===== Filters ===== */
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.input-search {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  color: var(--text); font-size: 13px; outline: none;
  width: 260px; box-shadow: var(--shadow-sm);
}
.input-search::placeholder { color: var(--text-3); }
.input-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.filter-select {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  color: var(--text-2); font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.count-badge {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 14px;
  font-size: 12px; color: var(--text-3);
  margin-left: auto; box-shadow: var(--shadow-sm);
}

/* ===== Table ===== */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--surface-2); padding: 10px 14px;
  text-align: left; font-size: 11px; font-weight: 700;
  color: var(--text-3); letter-spacing: .5px; text-transform: uppercase;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--surface-2);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #fafbff; }

/* ===== Car thumbnail ===== */
.car-thumb {
  width: 64px; height: 46px; border-radius: 6px;
  object-fit: cover; background: var(--bg); display: block;
}
.car-thumb-placeholder {
  width: 64px; height: 46px; border-radius: 6px;
  background: var(--bg); display: flex; align-items: center;
  justify-content: center; color: var(--border-mid);
}

/* ===== HP confidence ===== */
.hp-cell { display: flex; align-items: center; gap: 6px; }
.hp-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hp-dot.verified { background: var(--green); }
.hp-dot.auto     { background: var(--yellow); }
.hp-dot.none     { background: var(--red); }

/* ===== Grade badges ===== */
.grade {
  display: inline-block; padding: 2px 8px;
  border-radius: 5px; font-size: 11px; font-weight: 700;
}
.grade-a { background: var(--green-bg); color: var(--green-text); }
.grade-b { background: var(--yellow-bg); color: var(--yellow-text); }
.grade-c { background: var(--red-bg); color: var(--red-text); }

/* ===== Spec confidence ===== */
.conf-badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 5px; font-size: 11px; font-weight: 600;
}
.conf-verified { background: var(--green-bg); color: var(--green-text); }
.conf-auto     { background: var(--yellow-bg); color: var(--yellow-text); }
.conf-medium   { background: var(--accent-bg); color: var(--accent); }

/* ===== Drawer ===== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 440px; background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 201; display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between;
}
.drawer-body {
  flex: 1; padding: 20px 24px;
  overflow-y: auto; display: flex;
  flex-direction: column; gap: 20px;
}
.drawer-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}

/* ===== Form fields ===== */
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
}
.field-hint { font-size: 11px; color: var(--text-3); }
.input-field {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  color: var(--text); font-size: 14px; outline: none; width: 100%;
}
.input-field:focus { border-color: var(--accent); background: var(--surface); }
textarea.input-field { resize: vertical; min-height: 72px; }
select.input-field { cursor: pointer; }

/* ===== Days selector ===== */
.days-row { display: flex; gap: 6px; }
.day-btn {
  flex: 1; padding: 8px 4px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface-2);
  color: var(--text-3); font-size: 13px; text-align: center;
}
.day-btn.selected {
  background: var(--accent-bg); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

/* ===== Photo grid ===== */
.photos-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; }
.photo-pick {
  aspect-ratio: 4/3; border-radius: 6px;
  border: 2px solid var(--border); cursor: pointer;
  overflow: hidden; position: relative; background: var(--bg);
}
.photo-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pick.selected { border-color: var(--accent); }
.photo-pick.selected::after {
  content: '✓'; position: absolute; top: 3px; right: 5px;
  font-size: 11px; color: var(--accent); font-weight: 700;
  text-shadow: 0 0 4px rgba(255,255,255,.9);
}

/* ===== Field toggles ===== */
.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.field-toggle {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; cursor: pointer;
  user-select: none;
}
.field-toggle.off { opacity: .45; }
.toggle-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
}
.field-toggle.off .toggle-dot { background: var(--border-mid); }

/* ===== Section head ===== */
.section-head {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

/* ===== Empty / Loading ===== */
.loading-cell { text-align: center; color: var(--text-3); padding: 40px !important; }
.empty-state { text-align: center; color: var(--text-3); padding: 60px 20px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 18px;
  font-size: 13px; z-index: 500; box-shadow: var(--shadow);
  transform: translateY(20px); opacity: 0;
  transition: all .25s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }

/* ===== Responsive — Tablet ===== */
@media (max-width: 1279px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .mobile-header {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 16px; position: sticky; top: 0; z-index: 90;
    box-shadow: var(--shadow-sm);
  }
  .mobile-logo {
    width: 28px; height: 28px; background: var(--accent);
    border-radius: 6px; display: flex; align-items: center;
    justify-content: center; font-weight: 800; font-size: 11px; color: #fff;
  }
  .burger-btn {
    background: none; border: none; color: var(--text-2);
    display: flex; align-items: center; padding: 4px;
  }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.35); z-index: 99;
  }
  .sidebar-overlay.open { display: block; }
}
@media (min-width: 1280px) {
  .mobile-header { display: none; }
  .sidebar-overlay { display: none !important; }
}

/* ===== Responsive — Mobile ===== */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    z-index: 100; box-shadow: 0 -2px 8px rgba(0,0,0,.06);
  }
  .bottom-nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; padding: 8px 0;
    font-size: 9px; font-weight: 600; color: var(--text-3);
    background: none; border: none;
  }
  .bottom-nav-item.active { color: var(--accent); }
  .bottom-nav-item svg { width: 20px; height: 20px; }
  .main { padding-bottom: 64px; }
  .drawer { width: 100%; }
  .content { padding: 16px; }
}
@media (min-width: 768px) {
  .bottom-nav { display: none; }
}
