/* ============================================================
   OK TIRE LADNER CRM — Stylesheet
   Matches website: yellow + graphite, motorsport typography.
   ============================================================ */

:root {
  /* Brand — official OK Tire spec */
  --ok-yellow: #FEDA08;
  --ok-yellow-deep: #D6B807;
  --ok-yellow-bright: #FFE234;
  --ok-black: #000000;
  --ok-graphite: #1a1a1a;
  --ok-graphite-2: #242424;
  --ok-charcoal: #2e2e2e;
  --ok-line: #2f2f2f;
  --ok-gray: #BCBCBC;

  /* Neutrals */
  --bg: #f4f4f2;
  --bg-card: #ffffff;
  --bg-alt: #f6f6f4;
  --bg-dark: #0a0a0a;
  --sidebar-bg: #111111;
  --text: #161616;
  --text-soft: #555;
  --text-muted: #8a8a8a;
  --border: #e6e6e6;
  --border-strong: #d0d0d0;

  /* Status */
  --green: #2e9c5d;
  --green-bg: #e7f6ed;
  --red: #d23535;
  --red-bg: #fbe9e9;
  --blue: #2f6fd2;
  --blue-bg: #e8f0fc;
  --amber: #d98a00;
  --amber-bg: #fdf2dc;

  /* Type */
  --f-display: "Archivo Black", "Oswald", system-ui, sans-serif;
  --f-head: "Oswald", "Archivo Black", system-ui, sans-serif;
  --f-body: "Manrope", system-ui, -apple-system, sans-serif;

  /* Spacing */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --sidebar-w: 248px;

  /* Shadow */
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --shadow-md: 0 8px 24px rgba(0,0,0,.08);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.12);
}

/* =========== RESET =========== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* =========== BUTTONS =========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: all .2s ease;
  white-space: nowrap;
}
.btn i { width: 16px; height: 16px; }
.btn-primary {
  background: var(--ok-yellow);
  color: var(--ok-black);
  box-shadow: 0 4px 14px rgba(254,218,8,.35);
}
.btn-primary:hover {
  background: var(--ok-yellow-bright);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(254,218,8,.45);
}
.btn-dark {
  background: var(--ok-black);
  color: #fff;
}
.btn-dark:hover { background: var(--ok-graphite-2); }
.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover {
  color: var(--ok-black);
  border-color: var(--ok-black);
}
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-block { width: 100%; }

/* =========== LOGIN SCREEN =========== */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ok-black);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(254,218,8,.08), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(254,218,8,.06), transparent 40%);
  z-index: 1000;
  padding: 20px;
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  animation: loginSlide .4s ease;
}
@keyframes loginSlide {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.login-logo {
  text-align: center;
  margin-bottom: 8px;
}
.login-logo-mark {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--ok-black);
  padding: 8px 14px;
  border-radius: 6px;
}
.login-logo-mark .logo-ok {
  font-family: var(--f-display);
  color: var(--ok-yellow);
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}
.login-logo-mark .logo-tire {
  font-family: var(--f-display);
  color: #fff;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}
.login-branch {
  text-align: center;
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 10px 0 4px;
}
.login-title {
  text-align: center;
  font-family: var(--f-display);
  font-size: 1.5rem;
  text-transform: uppercase;
  margin: 16px 0 6px;
  letter-spacing: -0.01em;
}
.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 28px;
}
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-family: var(--f-head);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: #fff;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--ok-yellow);
  box-shadow: 0 0 0 3px rgba(254,218,8,.2);
}
.login-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }
.login-foot {
  text-align: center;
  margin-top: 22px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

/* =========== SIDEBAR =========== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform .3s ease;
}
.sidebar-head {
  padding: 22px 22px 18px;
  border-bottom: 1px solid #222;
}
.sidebar-logo {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.sidebar-logo .logo-ok {
  font-family: var(--f-display);
  color: var(--ok-yellow);
  font-size: 1.3rem;
}
.sidebar-logo .logo-tire {
  font-family: var(--f-display);
  color: #fff;
  font-size: 1.3rem;
}
.sidebar-branch {
  font-family: var(--f-head);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: #b8b8b8;
  font-weight: 500;
  font-size: 0.92rem;
  transition: all .18s ease;
  cursor: pointer;
}
.nav-link i { width: 19px; height: 19px; }
.nav-link:hover {
  background: #1d1d1d;
  color: #fff;
}
.nav-link.active {
  background: var(--ok-yellow);
  color: var(--ok-black);
  font-weight: 700;
}
.nav-link .nav-badge {
  margin-left: auto;
  background: var(--ok-yellow);
  color: var(--ok-black);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
}
.nav-link.active .nav-badge {
  background: var(--ok-black);
  color: var(--ok-yellow);
}
.nav-section-label {
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #666;
  padding: 14px 14px 6px;
  font-weight: 600;
}
.sidebar-foot {
  padding: 16px;
  border-top: 1px solid #222;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ok-yellow);
  color: var(--ok-black);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-display);
  font-size: 1rem;
  flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-name {
  font-weight: 600;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.logout-btn {
  color: #888;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  transition: all .18s ease;
}
.logout-btn:hover { color: var(--red); background: #1d1d1d; }
.logout-btn i { width: 18px; height: 18px; }

/* =========== MAIN AREA =========== */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.menu-toggle {
  display: none;
  color: var(--text);
  padding: 4px;
}
.menu-toggle i { width: 24px; height: 24px; }
.page-title {
  font-family: var(--f-display);
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  margin: 0;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.content {
  padding: 28px;
  flex: 1;
}

/* =========== PAGE / VIEWS =========== */
.view { display: none; animation: fadeIn .3s ease; }
.view.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========== STAT CARDS =========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 4px; height: 100%;
  background: var(--ok-yellow);
}
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--ok-yellow);
  color: var(--ok-black);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.stat-icon i { width: 22px; height: 22px; }
.stat-icon.alt { background: var(--ok-black); color: var(--ok-yellow); }
.stat-num {
  font-family: var(--f-display);
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-trend {
  font-size: 0.78rem;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}
.stat-trend.up { color: var(--green); }
.stat-trend.flat { color: var(--text-muted); }

/* =========== CARD / PANEL =========== */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}
.panel-title {
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0;
}
.panel-head .panel-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}
.panel-body { padding: 22px; }
.panel-body.flush { padding: 0; }

/* =========== SEARCH / TOOLBAR =========== */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-muted);
}
.search-box input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--bg-card);
}
.search-box input:focus {
  outline: none;
  border-color: var(--ok-yellow);
  box-shadow: 0 0 0 3px rgba(254,218,8,.18);
}
.filter-select {
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--bg-card);
  cursor: pointer;
}

/* =========== TABLE =========== */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th {
  text-align: left;
  padding: 13px 18px;
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr {
  transition: background .15s ease;
}
table.data tbody tr:hover { background: var(--bg-alt); }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--text-muted); font-size: 0.84rem; }
.cell-mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
}

/* =========== BADGES =========== */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-new { background: var(--blue-bg); color: var(--blue); }
.badge-contacted { background: var(--amber-bg); color: var(--amber); }
.badge-converted { background: var(--green-bg); color: var(--green); }
.badge-coupon {
  background: var(--ok-black);
  color: var(--ok-yellow);
  font-family: ui-monospace, monospace;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 0.76rem;
  font-weight: 700;
}

/* =========== EMPTY / LOADING STATES =========== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state .empty-icon i { width: 28px; height: 28px; color: var(--text-muted); }
.empty-state h3 {
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  margin: 0 0 6px;
  text-transform: uppercase;
}
.empty-state p { margin: 0; font-size: 0.9rem; max-width: 360px; margin: 0 auto; }
.loading-row {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--ok-yellow);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========== AUTOLEAP SYNC BANNER =========== */
.sync-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
  color: #fff;
  padding: 20px 24px;
  border-radius: var(--radius);
  margin-bottom: 22px;
}
.sync-banner .sync-icon {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  background: rgba(254,218,8,.15);
  color: var(--ok-yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sync-banner .sync-icon i { width: 24px; height: 24px; }
.sync-banner .sync-text { flex: 1; min-width: 0; }
.sync-banner .sync-text h4 {
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 3px;
  text-transform: uppercase;
}
.sync-banner .sync-text p {
  margin: 0;
  font-size: 0.86rem;
  color: #b8b8b8;
}
.sync-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.sync-status-pill.pending {
  background: rgba(217,138,0,.2);
  color: #ffb938;
}
.sync-status-pill.pending::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* =========== MODAL =========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: loginSlide .3s ease;
}
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.modal-head h3 {
  font-family: var(--f-head);
  font-weight: 700;
  text-transform: uppercase;
  margin: 0;
  font-size: 1.1rem;
}
.modal-close {
  margin-left: auto;
  color: var(--text-muted);
  padding: 4px;
}
.modal-close:hover { color: var(--ok-black); }
.modal-close i { width: 20px; height: 20px; }
.modal-body { padding: 24px; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.detail-row {
  display: flex;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  width: 130px;
  flex-shrink: 0;
  font-family: var(--f-head);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 2px;
}
.detail-value { flex: 1; font-size: 0.92rem; }

/* =========== ROW ACTIONS =========== */
.row-actions {
  display: flex;
  gap: 6px;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all .15s ease;
}
.icon-btn:hover {
  border-color: var(--ok-black);
  color: var(--ok-black);
  background: var(--bg-alt);
}
.icon-btn i { width: 15px; height: 15px; }

/* =========== TOAST =========== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ok-black);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 500;
  transform: translateY(80px);
  opacity: 0;
  transition: all .3s ease;
  font-size: 0.9rem;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast i { width: 18px; height: 18px; color: var(--ok-yellow); }
.toast.error i { color: var(--red); }

/* =========== RESPONSIVE =========== */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-100%);
    width: 248px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .content { padding: 18px; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 35;
  }
  .sidebar-backdrop.show { display: block; }
}
@media (max-width: 560px) {
  .topbar { padding: 14px 18px; }
  .page-title { font-size: 1.15rem; }
  .stat-num { font-size: 1.6rem; }
  .login-card { padding: 30px 24px; }
}
