/* Cali Current - Tesla-inspired dark theme with red accent */
:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --ink: #171a21;
    --muted: #6b7280;
    --line: #e5e7eb;
    --dark: #171a21;
    --dark2: #23262f;
    --red: #cc0000;
    --red-dark: #a30000;
    --green: #0e7a3d;
    --amber: #b45309;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.45;
}

/* ---------- top bar ---------- */
.topbar {
    background: var(--dark);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-bolt { color: var(--red); font-size: 22px; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.brand-tag { font-size: 12px; color: #9ca3af; }
.userbox { display: flex; align-items: center; gap: 12px; }
.username { font-size: 13px; color: #d1d5db; }
.logout {
    color: #fff; text-decoration: none; font-size: 13px;
    border: 1px solid #4b5563; padding: 6px 12px; border-radius: 6px;
}
.logout:hover { background: var(--dark2); }

/* ---------- nav ---------- */
.subnav {
    background: var(--dark2);
    display: flex; flex-wrap: wrap; gap: 2px;
    padding: 0 10px;
    position: sticky; top: 57px; z-index: 40;
}
.subnav a {
    color: #d1d5db; text-decoration: none; font-size: 14px;
    padding: 10px 14px; border-bottom: 3px solid transparent;
}
.subnav a:hover { color: #fff; }
.subnav a.active { color: #fff; border-bottom-color: var(--red); font-weight: 600; }

/* ---------- layout ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card h2, .card h3 { margin: 0 0 12px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { margin: 0; font-size: 24px; }

/* ---------- buttons ---------- */
.btn {
    display: inline-block; background: var(--red); color: #fff;
    border: none; border-radius: 8px; padding: 10px 18px;
    font-size: 15px; cursor: pointer; text-decoration: none; font-weight: 600;
}
.btn:hover { background: var(--red-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f3f4f6; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.dark { background: var(--dark); }
.btn.dark:hover { background: var(--dark2); }
.btn.green { background: var(--green); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 14px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 10px 12px; font-size: 15px;
    border: 1px solid #d1d5db; border-radius: 8px; background: #fff;
}
.field textarea { min-height: 80px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th { background: #f9fafb; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
table.data tr:hover td { background: #fafafa; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- status pills ---------- */
.pill {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
}
.pill.open { background: #fef3c7; color: #92400e; }
.pill.in-progress { background: #dbeafe; color: #1e40af; }
.pill.waiting-parts { background: #f3e8ff; color: #6b21a8; }
.pill.completed { background: #d1fae5; color: #065f46; }
.pill.cancelled { background: #f3f4f6; color: #6b7280; }
.pill.scheduled { background: #dbeafe; color: #1e40af; }
.pill.done { background: #d1fae5; color: #065f46; }
.pill.no-show { background: #fee2e2; color: #991b1b; }

/* ---------- dashboard stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; text-align: center;
}
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 4px; }
.stat.alert .n { color: var(--red); }

/* ---------- alerts ---------- */
.alert {
    border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; font-size: 14px;
}
.alert.warn { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.alert.ok { background: #d1fae5; border: 1px solid #6ee7b7; color: #065f46; }
.alert.err { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }

/* ---------- login ---------- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark2) 100%);
    padding: 20px;
}
.login-card {
    background: #fff; border-radius: 14px; padding: 36px 32px;
    width: 100%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.login-card .brand-bolt { font-size: 34px; }
.login-card h1 { margin: 8px 0 4px; font-size: 26px; }
.login-card p.sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; padding: 12px; }

/* ---------- invoice ---------- */
.invoice { max-width: 800px; margin: 0 auto; background: #fff; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--red); padding-bottom: 14px; margin-bottom: 18px; }
.inv-brand { font-size: 26px; font-weight: 800; }
.inv-brand .bolt { color: var(--red); }
.inv-meta { text-align: right; font-size: 13px; color: var(--muted); }
.inv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.inv-box h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; color: var(--muted); }
.inv-total-row { display: flex; justify-content: flex-end; }
.inv-totals { width: 280px; }
.inv-totals .row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.inv-totals .grand { font-size: 18px; font-weight: 800; border-bottom: none; padding-top: 10px; }
.inv-foot { margin-top: 26px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }

.no-print { }
@media print {
    .no-print, .topbar, .subnav, .site-footer { display: none !important; }
    body { background: #fff; }
    .wrap { max-width: none; padding: 0; }
    .card { box-shadow: none; border: none; }
    @page { margin: 12mm; }
}

/* ---------- detail lists ---------- */
dl.detail { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
dl.detail dt { font-weight: 600; color: var(--muted); }
dl.detail dd { margin: 0; }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 16px; }
.filterbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filterbar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
    .stats { grid-template-columns: 1fr 1fr; }
    .field-row, .field-row3 { grid-template-columns: 1fr; }
    .inv-cols { grid-template-columns: 1fr; }
    .brand-tag { display: none; }
    .subnav { top: 53px; overflow-x: auto; flex-wrap: nowrap; }
    .subnav a { white-space: nowrap; }
    dl.detail { grid-template-columns: 1fr; }
    dl.detail dt { margin-top: 8px; }
    .page-head h1 { font-size: 20px; }
}

/* ---------- JAS Dealer additions ---------- */
.big-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 20px 0; }
.big-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 28px 16px; background: var(--brand, #1e3a5f); color: #fff; border-radius: 12px; text-decoration: none; font-size: 19px; font-weight: 700; text-align: center; box-shadow: var(--shadow); }
.big-btn small { font-size: 13px; font-weight: 400; opacity: .85; }
.big-btn:hover { background: var(--brand-dark, #152a45); }
.big-btn.alt { background: #fff; color: var(--brand, #1e3a5f); border: 2px solid var(--brand, #1e3a5f); }
.big-btn.alt:hover { background: #eef2f7; }
.big-btn.admin { background: #334155; }
.owed-total { font-size: 34px; font-weight: 800; color: var(--brand, #1e3a5f); }
.owed-buckets { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 8px; }
.owed-buckets div span { display: block; font-size: 13px; color: var(--muted, #64748b); }
.owed-buckets div strong { font-size: 19px; }
.alert-flag { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 10px; padding: 12px 16px; margin: 14px 0; font-weight: 600; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line, #e2e8f0); text-align: left; vertical-align: top; }
table.data th { color: var(--muted, #64748b); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
.searchbar { display: flex; gap: 10px; margin: 14px 0; }
.searchbar input[type=text] { flex: 1; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.checkline input { width: auto; }
.footer { text-align: center; color: var(--muted, #64748b); font-size: 12px; padding: 18px 0 28px; }

/* ---------- phone tuning ---------- */
@media (max-width: 720px) {
  input, select, textarea { font-size: 16px !important; }
  .big-buttons { grid-template-columns: 1fr; gap: 12px; }
  .big-btn { padding: 22px 14px; font-size: 18px; min-height: 64px; }
  .btn { min-height: 44px; display: inline-flex; align-items: center; }
  .btn.small { min-height: 36px; }
  .owed-total { font-size: 28px; }
  .searchbar { flex-wrap: wrap; }
  .searchbar .btn { flex: 1; justify-content: center; }
  .page-head { flex-wrap: wrap; gap: 10px; }
}

/* ---------- customer / vehicle form additions ---------- */
.warn-red { display: block; background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; font-weight: 700; border-radius: 8px; padding: 10px 12px; margin-top: 8px; }
div.warn-red { margin: 0 0 14px; }
.thumb { width: 72px; height: auto; border-radius: 6px; display: block; }
.vin-input { text-transform: uppercase; }
input[type="text"]:not(.vin-input), textarea { text-transform: capitalize; }
input[type="email"], input[type="password"] { text-transform: none; }
.ref-block { padding: 10px 0; border-bottom: 1px solid var(--line, #e2e8f0); line-height: 1.45; }
.ref-block:last-child { border-bottom: none; }
.btn.danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn.small.danger { background: #fff; color: #dc2626; border: 1px solid #fca5a5; }
