:root {
  --red: #E53949;
  --dark: #2B0003;
  --black: #111111;
  --gray: #595959;
  --light-gray: #f4f4f4;
  --border: #e2c3c5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--black);
  background: #fafafa;
}

/* ---------- top bar ---------- */
.topbar {
  background: #fff;
  border-bottom: 4px solid var(--red);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { height: 42px; width: auto; }
.brandname { font-weight: bold; font-size: 15px; line-height: 1.2; }
.brandsub { font-size: 11px; color: var(--gray); }
.userbox { font-size: 13px; color: var(--gray); white-space: nowrap; }
.userbox a { color: var(--red); text-decoration: none; font-weight: bold; }

/* ---------- nav ---------- */
.mainnav {
  background: var(--dark);
  display: flex;
  flex-wrap: wrap;
  overflow-x: auto;
}
.mainnav a {
  color: #fff;
  text-decoration: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: bold;
  white-space: nowrap;
}
.mainnav a:hover { background: var(--red); }

/* ---------- layout ---------- */
.content { max-width: 1100px; margin: 0 auto; padding: 16px; }
.footer { text-align: center; color: var(--red); font-weight: bold; font-size: 11px; padding: 20px 0 30px; }

h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 20px 0 10px; color: var(--red); border-bottom: 2px solid var(--red); padding-bottom: 4px;}
.muted { color: var(--gray); font-size: 13px; }

/* ---------- flash ---------- */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.flash-ok { background: #e7f6e9; color: #226b2c; border: 1px solid #b7e0bd; }
.flash-err { background: #fdeaea; color: #a3202c; border: 1px solid #f3b8bd; }

/* ---------- cards / KPIs ---------- */
.kpi-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.kpi {
  flex: 1 1 150px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: 6px;
  padding: 12px 14px;
}
.kpi .label { font-size: 12px; color: var(--gray); text-transform: uppercase; }
.kpi .value { font-size: 20px; font-weight: bold; margin-top: 2px; }
.kpi.negative .value { color: var(--red); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th {
  background: var(--red);
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid var(--light-gray); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fff7f7; }

/* ---------- forms ---------- */
form { max-width: 640px; }
.field { margin-bottom: 12px; display: flex; flex-direction: column; }
.field label { font-size: 12px; font-weight: bold; color: var(--gray); margin-bottom: 4px; }
input, select, textarea {
  padding: 9px 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1 1 160px; }

.line-items-table th, .line-items-table td { font-size: 13px; }
.line-items-table input { padding: 6px; }

.labor-picker { display: inline-flex; align-items: center; gap: 8px; margin-left: 8px; }
.labor-hour-select { padding: 6px 8px; border: 1px solid #ccc; border-radius: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 5px;
  border: none;
  font-size: 14px;
  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
  margin-right: 6px;
  margin-bottom: 6px;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #c72e3c; }
.btn-secondary { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn-secondary:hover { background: #fff0f0; }
.btn-dark { background: var(--dark); color: #fff; }
.btn-danger { background: #a3202c; color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.actions { margin: 14px 0; }
.share-block {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
}
.share-block h3 { margin: 0 0 8px 0; font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: #666; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 11px; font-weight: bold; color: #fff; white-space: nowrap;}
.badge-waiting-for-parts { background: #b98900; }
.badge-in-progress { background: #2064a3; }
.badge-ready-for-pickup { background: #6a2ea3; }
.badge-completed { background: #226b2c; }
.badge-pending { background: #b98900; }
.badge-accepted { background: #226b2c; }
.badge-declined { background: #a3202c; }
.badge-expired { background: var(--gray); }
.badge-good { background: #226b2c; }
.badge-service-recommended { background: #b98900; }
.badge-service-mandatory { background: var(--red); }
.badge-confirmed { background: #226b2c; }
.badge-cancelled { background: var(--gray); }
.badge-mandatory { background: var(--red); }
.badge-recommended { background: #b98900; }
.badge-optional { background: var(--gray); }
.badge-per-testing { background: #2064a3; }

.nav-badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: bold;
  margin-left: 4px;
}

/* ---------- login ---------- */
.login-body { background: var(--dark); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.loginbox { background: #fff; padding: 30px; border-radius: 10px; width: 90%; max-width: 340px; text-align: center; }
.loginlogo { height: 70px; margin-bottom: 6px; }
.loginbox h1 { font-size: 16px; }
.loginbox form { text-align: left; max-width: none; }

/* ---------- recurring grid ---------- */
.grid-table th, .grid-table td { text-align: center; }
.grid-table td input { width: 90px; text-align: right; padding: 5px; }
.grid-table td:first-child, .grid-table th:first-child { text-align: left; }

/* ---------- print (invoice/estimate) ---------- */
.doc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.doc-header img { height: 70px; }
.doc-title { font-size: 30px; font-weight: bold; margin: 6px 0 16px; }
.doc-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; margin-bottom: 16px; }
.terms-list { color: var(--gray); font-size: 12px; padding-left: 18px; }
.terms-list li { margin-bottom: 4px; }
.inspection-status-grid .field { width: auto; min-width: 160px; }
.doc-totals { max-width: 320px; margin-left: auto; margin-top: 10px; }
.doc-totals td { padding: 4px 6px; }
.doc-totals .grand { font-weight: bold; color: var(--red); border-top: 2px solid var(--red); }
@media print {
  .topbar, .mainnav, .actions, .footer, .no-print { display: none !important; }
  body { background: #fff; }
}

.photo-gallery { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0; }
.photo-thumb { width: 140px; text-align: center; }
.photo-thumb img { width: 140px; height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid #ddd; }
.photo-thumb form { margin-top: 4px; }

/* ---------- home page ---------- */
.home-body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(20,0,1,0.55) 0%, rgba(20,0,1,0.75) 45%, rgba(10,0,0,0.92) 100%),
    url("/static/hero-mechanic.jpg");
  background-size: cover;
  background-position: center 55%;
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.home-staff-link {
  position: fixed;
  top: 18px;
  right: 20px;
  color: #fff;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: bold;
  text-decoration: none;
  letter-spacing: 0.3px;
  backdrop-filter: blur(4px);
  z-index: 10;
}
.home-staff-link:hover { background: rgba(255,255,255,0.18); }

.home-hero {
  position: relative;
  max-width: 780px;
  width: 100%;
  text-align: center;
  padding: 40px 20px 60px;
}
.home-logo { height: 90px; margin-bottom: 18px; filter: drop-shadow(0 6px 18px rgba(0,0,0,0.5)); }
.home-title {
  color: #fff;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.5px;
  margin: 0 0 6px;
  text-transform: uppercase;
}
.home-tagline {
  color: var(--red);
  font-weight: bold;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 13px;
  margin: 0 0 40px;
}

.home-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  text-align: left;
}
.home-card {
  background: rgba(20,0,2,0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 16px;
  padding: 28px 24px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.home-card:hover { transform: translateY(-3px); background: rgba(20,0,2,0.7); border-color: var(--red); }
.home-card-icon {
  width: 46px;
  height: 46px;
  color: var(--red);
  background: rgba(229,57,73,0.15);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  margin-bottom: 6px;
}
.home-card-icon svg { width: 100%; height: 100%; }
.home-card-title { color: #fff; font-size: 18px; font-weight: bold; }
.home-card-sub { color: rgba(255,255,255,0.65); font-size: 13px; margin-bottom: 10px; }
.home-card-form input[type="tel"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.25);
  color: #fff;
  font-size: 14px;
  margin-bottom: 10px;
}
.home-card-form input[type="tel"]::placeholder { color: rgba(255,255,255,0.45); }

@media (max-width: 640px) {
  .home-actions { grid-template-columns: 1fr; }
  .home-staff-link { top: 12px; right: 12px; padding: 6px 12px; font-size: 12px; }
  .home-title { font-size: 24px; }
}

/* ---------- customer portal ---------- */
.portal-date-group { margin-bottom: 22px; }
.portal-date-group h3 {
  font-size: 14px;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.portal-event {
  background: var(--light-gray);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 14px;
}
.portal-event-type {
  display: inline-block;
  background: var(--dark);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 6px;
  margin-right: 8px;
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .brand .logo { height: 34px; }
  form { max-width: 100%; }
  .content { padding: 10px; }
}
