:root {
  --bg: #050506;
  --bg2: #0C0D10;
  --bg3: #131518;
  --fg: #FFFFFF;
  --fg2: #E0E2E8;
  --fg3: #B0B4BF;
  --blue: #6EAAFF;
  --green: #4ADE80;
  --yellow: #FBBF24;
  --red: #F87171;
  --line: rgba(255, 255, 255, .08);
  --r: 12px;
  --font: 'Inter', system-ui, sans-serif;
}

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

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

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== LOGIN ========== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.login-logo span { color: var(--blue); }

.login-sub {
  color: var(--fg3);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
  margin-bottom: 16px;
}

.login-input:focus { border-color: var(--blue); }
.login-input::placeholder { color: var(--fg3); }

.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--blue);
  color: #000;
  border: none;
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
}

.login-btn:hover { opacity: .9; }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* ========== APP LAYOUT ========== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 0 20px 20px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.sidebar-logo span { color: var(--blue); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--fg3);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}

.nav-item:hover { color: var(--fg2); background: rgba(255,255,255,.03); }
.nav-item.active { color: var(--blue); background: rgba(110,170,255,.08); }
.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

.nav-spacer { flex: 1; }

.nav-logout {
  color: var(--fg3);
  padding: 12px 20px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  text-align: left;
  transition: color .15s;
}

.nav-logout:hover { color: var(--red); }

.main {
  flex: 1;
  margin-left: 220px;
  padding: 24px;
  max-width: 1200px;
}

/* ========== MOBILE BOTTOM NAV ========== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--line);
  z-index: 100;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
}

.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
}

.btm-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  color: var(--fg3);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
  transition: color .15s;
}

.btm-item .icon { font-size: 20px; }
.btm-item.active { color: var(--blue); }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px 12px 80px; }
  .bottom-nav { display: block; }
}

/* ========== COMMON COMPONENTS ========== */
.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.stat-label.red { color: var(--red); }
.stat-label.yellow { color: var(--yellow); }
.stat-label.green { color: var(--green); }
.stat-label.blue { color: var(--blue); }

.stat-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg2);
  margin-bottom: 12px;
  margin-top: 24px;
}

/* ========== PROGRESS BAR ========== */
.progress-wrap {
  margin-bottom: 24px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--fg3);
  margin-bottom: 6px;
}

.progress-bar {
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width .5s ease;
}

/* ========== TABLES / LISTS ========== */
.list-table {
  width: 100%;
  border-collapse: collapse;
}

.list-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--fg3);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.list-table td {
  padding: 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--fg2);
}

.list-table tr { cursor: pointer; transition: background .15s; }
.list-table tbody tr:hover { background: rgba(255,255,255,.02); }

/* ========== BADGES ========== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
}

.badge-lead { background: rgba(248,113,113,.15); color: var(--red); }
.badge-quoted { background: rgba(251,191,36,.15); color: var(--yellow); }
.badge-booked { background: rgba(110,170,255,.15); color: var(--blue); }
.badge-in_progress { background: rgba(139,92,246,.15); color: #A78BFA; }
.badge-done { background: rgba(74,222,128,.15); color: var(--green); }
.badge-paid { background: rgba(74,222,128,.25); color: var(--green); }
.badge-lost { background: rgba(255,255,255,.08); color: var(--fg3); }

.badge-individual { background: rgba(110,170,255,.12); color: var(--blue); }
.badge-dealer { background: rgba(251,191,36,.12); color: var(--yellow); }
.badge-fleet { background: rgba(139,92,246,.12); color: #A78BFA; }
.badge-bodyshop { background: rgba(74,222,128,.12); color: var(--green); }

/* ========== KANBAN ========== */
.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.kanban-col {
  min-width: 260px;
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}

.kanban-header {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-count {
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--fg3);
}

.kanban-cards {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.kanban-card {
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s;
}

.kanban-card:hover { border-color: var(--blue); }

.kanban-card .kc-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.kanban-card .kc-vehicle {
  font-size: 12px;
  color: var(--fg3);
  margin-bottom: 4px;
}

.kanban-card .kc-service {
  font-size: 12px;
  color: var(--fg2);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-card .kc-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--fg3);
}

.kanban-card .kc-amount {
  color: var(--green);
  font-weight: 600;
}

/* Mobile kanban → list */
@media (max-width: 768px) {
  .kanban { flex-direction: column; }
  .kanban-col { min-width: unset; max-height: unset; }
}

/* ========== FORMS ========== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-group { margin-bottom: 16px; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg3);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue);
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--fg3); }

.form-select {
  appearance: none;
  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 fill='%23B0B4BF' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-select option { background: var(--bg2); color: var(--fg); }

.form-textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
}

.btn-primary { background: var(--blue); color: #000; }
.btn-primary:hover { opacity: .9; }
.btn-secondary { background: var(--bg3); color: var(--fg2); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--fg3); }
.btn-danger { background: rgba(248,113,113,.15); color: var(--red); }
.btn-danger:hover { background: rgba(248,113,113,.25); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn .15s ease;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--fg3);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--fg); }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

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

/* ========== SEARCH BAR ========== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

.search-input:focus { border-color: var(--blue); }
.search-input::placeholder { color: var(--fg3); }

/* ========== ACTIVITY FEED ========== */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-dot.note { background: var(--blue); }
.activity-dot.status_change { background: var(--yellow); }
.activity-dot.quote_sent { background: var(--green); }
.activity-dot.call { background: #A78BFA; }
.activity-dot.follow_up { background: var(--red); }

.activity-content { font-size: 13px; color: var(--fg2); }
.activity-meta { font-size: 11px; color: var(--fg3); margin-top: 2px; }

/* ========== QUOTE CALCULATOR ========== */
.quote-lines { margin-bottom: 16px; }

.quote-line {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

@media (max-width: 600px) {
  .quote-line { grid-template-columns: 1fr; }
}

.quote-total {
  font-size: 24px;
  font-weight: 800;
  color: var(--green);
  text-align: right;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

/* ========== CHARTS (simple canvas-based) ========== */
.chart-container {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--fg2);
}

.chart-canvas { width: 100%; height: 200px; }

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .analytics-grid { grid-template-columns: 1fr; }
}

/* ========== TAGS ========== */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

.tag {
  padding: 2px 8px;
  background: rgba(110,170,255,.12);
  color: var(--blue);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* ========== CLICK TO ACTION ========== */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  font-family: var(--font);
}

.action-btn:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }

/* ========== CUSTOMER PROFILE ========== */
.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.profile-name {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .profile-grid { grid-template-columns: 1fr; }
}

.profile-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg3);
  text-transform: uppercase;
  letter-spacing: .3px;
  margin-bottom: 2px;
}

.profile-field-value {
  font-size: 15px;
  color: var(--fg2);
}

/* ========== LOADING ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--fg3);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-right: 10px;
}

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

/* ========== EMPTY STATE ========== */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg3);
}

.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.empty-text { font-size: 14px; }

/* ========== ATTENTION ITEM ========== */
.attn-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s;
}

.attn-item:hover { border-color: var(--blue); }

.attn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.attn-dot.urgent { background: var(--red); }
.attn-dot.warn { background: var(--yellow); }

.attn-info { flex: 1; }
.attn-name { font-size: 14px; font-weight: 600; }
.attn-detail { font-size: 12px; color: var(--fg3); }
.attn-time { font-size: 11px; color: var(--fg3); }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* ========== HIDDEN ========== */
.hidden { display: none !important; }
