: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); }

/* ---------- 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; }
}

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