/* ============================================================
   Electrical Invoice Assistant — Main Stylesheet
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #0f2444;
  --navy-mid:   #1a4480;
  --navy-light: #e8f0fe;
  --orange:     #f97316;
  --orange-lt:  #fff7ed;
  --blue:       #3b82f6;
  --blue-lt:    #eff6ff;
  --bg:         #f1f5f9;
  --card:       #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --muted:      #64748b;
  --green:      #16a34a;
  --green-lt:   #dcfce7;
  --red:        #dc2626;
  --red-lt:     #fee2e2;
  --yellow:     #d97706;
  --yellow-lt:  #fef3c7;
  --purple:     #7c3aed;
  --purple-lt:  #ede9fe;
  --sidebar-w:  240px;
  --topbar-h:   58px;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.1);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.sidebar-logo { color: var(--orange); flex-shrink: 0; }

.sidebar-title { flex: 1; }
.sidebar-app  { display: block; font-size: 1rem; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-sub  { display: block; font-size: 0.7rem; color: rgba(255,255,255,0.5); }

.sidebar-close {
  display: none;
  background: none; border: none; color: rgba(255,255,255,0.7);
  font-size: 1.1rem; cursor: pointer; padding: 4px;
}

.nav-links {
  list-style: none;
  padding: 10px 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.75);
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.08); text-decoration: none; }
.nav-link.active { color: #fff; border-left-color: var(--orange); background: rgba(249,115,22,0.1); }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 8px 16px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--orange);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.875rem;
  flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name { font-size: 0.8rem; font-weight: 600; color: #fff; truncate: ellipsis; overflow: hidden; white-space: nowrap; }
.user-role { font-size: 0.7rem; color: rgba(255,255,255,0.5); }

.btn-logout {
  background: none; border: none;
  color: rgba(255,255,255,0.5);
  padding: 6px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: color 0.15s;
  display: flex;
  text-decoration: none;
}
.btn-logout:hover { color: #fff; background: rgba(255,255,255,0.08); text-decoration: none; }
.btn-logout svg { width: 18px; height: 18px; }

/* ---------- Main layout ---------- */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  z-index: 100;
  box-shadow: var(--shadow);
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none; border: none;
  cursor: pointer; padding: 4px;
}
.hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--text); border-radius: 2px;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1280px;
}

/* ---------- Overlay (mobile) ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  font-size: 0.875rem; font-weight: 600;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn:active { transform: translateY(1px); }

.btn-primary  { background: var(--orange); color: #fff; }
.btn-secondary{ background: var(--navy); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-warn     { background: var(--yellow); color: #fff; }
.btn-danger   { background: var(--red); color: #fff; }
.btn-block    { width: 100%; }
.btn-sm       { padding: 6px 12px; font-size: 0.8rem; }

.btn-icon {
  background: none; border: none;
  color: var(--muted); font-size: 1rem;
  cursor: pointer; padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon-danger:hover { color: var(--red); background: var(--red-lt); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.card-title { font-size: 0.9rem; font-weight: 700; flex: 1; }
.card-body  { padding: 16px 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); background: #fafbfc; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.table-sm th, .table-sm td { padding: 7px 10px; }

.row-flagged { background: #fffbeb !important; }
.row-confirmed { background: #f0fdf4 !important; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  font-size: 0.7rem; font-weight: 700;
  border-radius: 20px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-outline   { border: 1px solid var(--border); color: var(--muted); }
.badge-success   { background: var(--green-lt); color: var(--green); }
.badge-danger    { background: var(--red-lt); color: var(--red); }
.badge-warn      { background: var(--yellow-lt); color: var(--yellow); }
.badge-blue      { background: var(--blue-lt); color: var(--blue); }

/* Job status badges */
.badge-draft     { background: #f1f5f9; color: var(--muted); }
.badge-reviewing { background: var(--yellow-lt); color: var(--yellow); }
.badge-confirmed { background: var(--blue-lt); color: var(--blue); }
.badge-invoiced  { background: var(--green-lt); color: var(--green); }

/* Category badges */
.badge-cat-labour    { background: #e0e7ff; color: #4338ca; }
.badge-cat-material  { background: #d1fae5; color: #059669; }
.badge-cat-equipment { background: #fce7f3; color: #be185d; }
.badge-cat-other     { background: #f3f4f6; color: #4b5563; }

/* Confidence badge */
.conf-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.75rem; font-weight: 700;
}
.conf-high { background: var(--green-lt); color: var(--green); }
.conf-low  { background: var(--yellow-lt); color: var(--yellow); }

/* ---------- Flash messages ---------- */
.flash-container { margin-bottom: 1rem; }

.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 6px;
}
.flash-success { background: var(--green-lt); color: var(--green); }
.flash-danger  { background: var(--red-lt); color: var(--red); }
.flash-warning { background: var(--yellow-lt); color: var(--yellow); }
.flash-info    { background: var(--blue-lt); color: var(--blue); }

.flash-close {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: 0.6; font-size: 0.875rem; padding: 0 4px;
}

/* ---------- Forms ---------- */
.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  max-width: 860px;
}

.form-section-title {
  font-size: 0.9rem; font-weight: 700;
  color: var(--navy);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.form-row {
  display: flex; gap: 1rem; flex-wrap: wrap;
}
.form-row-tight { gap: 0.5rem; }
.form-group { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 4px; }

.form-label { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.form-hint  { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

.form-input, .form-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  font-family: inherit;
}
textarea.form-input { resize: vertical; }
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-input-sm { padding: 6px 10px; font-size: 0.8rem; }
.form-select-sm { padding: 6px 10px; font-size: 0.8rem; }

.input-group {
  display: flex; align-items: stretch;
}
.input-group .form-input {
  border-radius: 0;
  flex: 1;
}
.input-prefix, .input-suffix {
  padding: 8px 10px;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  display: flex; align-items: center;
  white-space: nowrap;
}
.input-prefix { border-right: none; border-radius: 6px 0 0 6px; }
.input-suffix { border-left: none; border-radius: 0 6px 6px 0; }
.input-suffix.btn-style { cursor: pointer; }
button.input-suffix {
  cursor: pointer;
  border-left: none;
  border-radius: 0 6px 6px 0;
  border: 1.5px solid var(--border);
  background: #f8fafc;
  font-size: 0.8rem;
  color: var(--muted);
}
button.input-suffix:hover { background: var(--bg); color: var(--text); }

.form-actions {
  display: flex; gap: 10px; align-items: center;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.875rem; cursor: pointer;
}

/* ---------- Dashboard: stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-blue   { background: var(--blue-lt);   color: var(--blue); }
.stat-green  { background: var(--green-lt);  color: var(--green); }
.stat-orange { background: var(--orange-lt); color: var(--orange); }
.stat-purple { background: var(--purple-lt); color: var(--purple); }

.stat-value  { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-label  { font-size: 0.75rem; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; }

/* ---------- Attention cards ---------- */
.attention-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.attention-card {
  flex: 1; min-width: 180px;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  text-decoration: none; border: 2px solid transparent;
}
.attention-card:hover { text-decoration: none; opacity: 0.9; transform: translateY(-1px); }
.attention-warn { background: var(--yellow-lt); border-color: var(--yellow); color: var(--yellow); }
.attention-info { background: var(--blue-lt); border-color: var(--blue); color: var(--blue); }
.attention-num { font-size: 2rem; font-weight: 800; line-height: 1; }
.attention-label { font-size: 0.875rem; font-weight: 600; }

/* ---------- Section headers ---------- */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.75rem;
}
.section-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.section-link  { font-size: 0.875rem; color: var(--blue); }

/* ---------- Job detail layout ---------- */
.job-status-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

.status-steps {
  display: flex; gap: 0; align-items: center;
}
.status-step {
  padding: 5px 14px;
  font-size: 0.75rem; font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  background: #f8fafc;
  border-right: none;
}
.status-step:first-child { border-radius: 6px 0 0 6px; }
.status-step:last-child  { border-radius: 0 6px 6px 0; border-right: 1px solid var(--border); }
.status-step.active { background: var(--orange); color: #fff; border-color: var(--orange); }
.status-step.done   { background: var(--green-lt); color: var(--green); border-color: var(--green); }

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

.detail-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* Info grid */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}
.info-full { grid-column: 1 / -1; }
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-label { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.info-value { font-size: 0.875rem; color: var(--text); }

/* Document list */
.doc-list { list-style: none; margin-bottom: 1rem; }
.doc-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.doc-item:last-child { border-bottom: none; }
.doc-icon { font-size: 1.2rem; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 0.8rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: 0.72rem; color: var(--muted); }

/* Upload form */
.upload-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.upload-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.upload-label { cursor: pointer; }

/* Totals bar */
.totals-bar {
  padding: 12px 16px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}
.totals-admin { color: var(--muted); }
.totals-billed { font-size: 0.9rem; color: var(--text); }

/* Row actions */
.row-actions { display: flex; gap: 2px; }

/* Add item form */
.add-item-details { font-size: 0.875rem; }
.add-item-form { margin-top: 0.75rem; }

/* Audit log */
.audit-log { list-style: none; }
.audit-item {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.audit-item:last-child { border-bottom: none; }
.audit-type { font-weight: 600; color: var(--navy); text-transform: capitalize; }
.audit-desc { color: var(--muted); }
.audit-time { color: var(--muted); white-space: nowrap; }

/* ---------- Review page ---------- */
.review-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap; gap: 1rem;
}
.review-header h2 { font-size: 1.2rem; }

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1rem;
}

.review-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--yellow);
}

.review-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.review-flagged-badge { font-size: 0.75rem; font-weight: 700; color: var(--yellow); }

.review-reason {
  background: var(--yellow-lt);
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: #92400e;
  margin-bottom: 1rem;
  line-height: 1.4;
}

.review-item-preview {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.review-action-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 0.5rem; }

.divider { border: none; border-top: 1px solid var(--border); margin: 0.75rem 0; }

.review-edit-details { font-size: 0.875rem; }
.review-edit-form { margin-top: 0.75rem; }

/* ---------- Invoice preview ---------- */
.invoice-wrap { max-width: 900px; }

.admin-banner {
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.invoice-doc {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
}

.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 3px solid var(--navy);
}

.inv-company-name { font-size: 1.4rem; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.inv-company-addr, .inv-header > div > div { font-size: 0.85rem; color: var(--muted); line-height: 1.6; }

.inv-title-block { text-align: right; }
.inv-title { font-size: 2.2rem; font-weight: 900; color: var(--orange); letter-spacing: -1px; line-height: 1; }
.inv-meta { margin-top: 10px; }
.inv-meta-row { display: flex; justify-content: flex-end; gap: 12px; font-size: 0.875rem; color: var(--text); line-height: 1.8; }
.inv-meta-row span:first-child { color: var(--muted); }

.inv-bill-section { display: flex; gap: 2rem; margin-bottom: 2rem; }
.inv-bill-to, .inv-job-desc { flex: 1; }
.inv-section-label { font-size: 0.7rem; font-weight: 700; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 6px; }
.inv-customer-name { font-size: 1.1rem; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.inv-customer-addr, .inv-job-desc > div { font-size: 0.875rem; color: var(--text); line-height: 1.6; }

.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}
.inv-table thead tr { background: var(--navy); color: #fff; }
.inv-table thead th {
  padding: 10px 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.inv-table tbody tr:nth-child(even) { background: #f8fafc; }
.inv-table tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.inv-cat-row td {
  background: var(--navy-light) !important;
  color: var(--navy-mid);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
}

.inv-totals { display: flex; justify-content: flex-end; margin-bottom: 2rem; }
.inv-totals-table { width: 260px; }
.inv-total-row {
  display: flex; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.inv-total-final {
  font-size: 1.15rem; font-weight: 700; color: var(--navy);
  border-top: 2px solid var(--navy);
  border-bottom: 2px solid var(--navy);
  padding: 10px 0;
  margin-top: 2px;
}

.inv-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.7;
}
.inv-thank-you { font-size: 1rem; font-weight: 600; color: var(--navy); margin-top: 0.75rem; }

/* ---------- Settings ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.settings-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; gap: 1rem; align-items: flex-start;
  text-decoration: none; color: var(--text);
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.15s;
}
.settings-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.settings-icon { font-size: 1.75rem; width: 40px; flex-shrink: 0; }
.settings-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.settings-desc  { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }

/* ---------- Markup settings ---------- */
.markup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.markup-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.markup-cat { font-size: 0.8rem; font-weight: 700; color: var(--navy); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.5px; }
.markup-input-wrap { display: flex; align-items: center; gap: 4px; }
.markup-input { max-width: 90px; }
.markup-unit { font-size: 1rem; font-weight: 700; color: var(--muted); }
.markup-example { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }

/* ---------- Filters ---------- */
.filter-bar { margin-bottom: 1rem; }
.filter-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state svg { opacity: 0.3; margin-bottom: 1rem; }
.empty-state p { font-size: 0.95rem; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,36,68,0.6);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%; max-width: 580px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1rem; cursor: pointer; color: var(--muted); padding: 4px; }
.modal-body  { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid transparent;
}
.alert-warning { background: var(--yellow-lt); border-color: #fde68a; color: #92400e; }
.alert-link { color: inherit; font-weight: 700; text-decoration: underline; }

/* ---------- Login page ---------- */
.login-body { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrap { width: 100%; max-width: 380px; padding: 1rem; }
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; color: var(--orange); margin-bottom: 1rem; }
.login-logo-img { max-width: 240px; width: 100%; height: auto; }
.login-title { font-size: 1.5rem; font-weight: 700; text-align: center; color: var(--navy); margin-bottom: 4px; }
.login-sub   { font-size: 0.875rem; color: var(--muted); text-align: center; margin-bottom: 1.75rem; }

/* ---------- Utility ---------- */
.text-muted  { color: var(--muted); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { color: var(--blue); font-size: 0.875rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: block; }
  .sidebar-overlay.open { display: block; }

  .hamburger { display: flex; }
  .main-wrap { margin-left: 0; }
  .content { padding: 1rem; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .markup-grid { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; }
  .invoice-doc { padding: 1.25rem; }
  .inv-header { flex-direction: column; gap: 1rem; }
  .inv-title-block { text-align: left; }
  .inv-meta-row { justify-content: flex-start; }
  .review-grid { grid-template-columns: 1fr; }
  .audit-item { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .markup-grid { grid-template-columns: 1fr; }
  .status-steps { flex-wrap: wrap; gap: 4px; }
  .status-step:first-child { border-radius: 6px; }
  .status-step:last-child  { border-radius: 6px; border-right: 1px solid var(--border); }
  .status-step { border-radius: 6px; border: 1px solid var(--border) !important; }
}
