*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* First Quality Fire brand kit — locked tokens (v2 logo cleanup) */
  --ink: #2F2F31;
  --ink-2: #4a4a4d;
  --paper: #FAFAF7;
  --line: #e6e4dd;
  --fire: #E0582A;
  --mute: #8a8880;
  --dark-bg: #1a1a1c;
  --on-dark: #f1efe9;
  --on-dark-2: #bdbbb3;

  /* Legacy aliases so existing selectors keep working. */
  --brand: #2F2F31;
  --brand-hover: #1a1a1c;
  --brand-mid: #E0582A;
  --accent: #E0582A;
  --accent-hover: #C44A20;
  --accent-soft: #FDEBE2;
  --bg: #FAFAF7;
  --surface: #ffffff;
  --border: #e6e4dd;
  --border-soft: #f0ede8;
  --text: #2F2F31;
  --muted: #8a8880;
  --green-bg: #E8F5E9; --green-txt: #1a5c1a;
  --amber-bg: #FFF8E1; --amber-txt: #7a5100;
  --blue-bg:  #E3F2FD; --blue-txt:  #0a3d7a;
  --red-bg:   #FEECEC; --red-txt:   #8b1a1a;
  --purple-bg:#EDE7F6; --purple-txt:#4a0e8a;
  --radius: 10px;
  --sidebar-w: 210px;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Barlow Condensed', 'Oswald', 'Helvetica Neue', Arial, sans-serif;
}

body { font-family: var(--font-body); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* Display font for page titles, KPI labels, section headings, and the wordmark */
.page-title, .kpi-label, .card-title, .modal-title, .section-hdr, .type-title { font-family: var(--font-display); letter-spacing: 0.01em; }
.page-title { font-weight: 700; }
.kpi-label { font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.card-title { font-weight: 700; }
.modal-title { font-weight: 700; }

/* LOGIN */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--brand); }
.login-wrap { text-align: center; width: 100%; max-width: 380px; padding: 24px; }
.login-logo { font-size: 28px; font-weight: 700; color: #fff; letter-spacing: 0.04em; }
.login-sub { color: rgba(255,255,255,0.55); font-size: 13px; margin-bottom: 28px; }
.login-card { background: #fff; border-radius: var(--radius); padding: 28px; text-align: left; }
.error-msg { background: var(--red-bg); color: var(--red-txt); font-size: 13px; padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; }

/* LAYOUT */
#app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #2E2E2E; background: var(--brand); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar-logo { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.logo-text { color: #fff; font-size: 17px; font-weight: 700; letter-spacing: 0.04em; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 18px; color: var(--on-dark-2); cursor: pointer; font-size: 13.5px; font-weight: 500; transition: background 0.15s, color 0.15s; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--on-dark); }
.nav-item.active { background: rgba(225,88,42,0.18); color: var(--on-dark); border-left: 3px solid var(--fire); padding-left: 15px; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-footer { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-info { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.18); color: var(--on-dark); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.user-name { color: var(--on-dark); font-size: 13px; font-weight: 500; flex: 1; min-width: 0; }
.notif-bell { position: relative; background: transparent; border: none; color: rgba(255,255,255,0.65); cursor: pointer; padding: 4px; border-radius: 4px; }
.notif-bell:hover { color: #fff; background: rgba(255,255,255,0.08); }
.notif-badge { position: absolute; top: -2px; right: -2px; background: #e53935; color: #fff; font-size: 9px; font-weight: 700; border-radius: 9px; padding: 1px 5px; min-width: 14px; text-align: center; line-height: 1.2; }
.notif-dropdown { position: fixed; left: 12px; bottom: 70px; width: 320px; max-height: 420px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); z-index: 1100; display: flex; flex-direction: column; overflow: hidden; }
.notif-dropdown header { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.notif-dropdown header .h-title { font-size: 13px; font-weight: 700; }
.notif-dropdown .list { overflow-y: auto; flex: 1; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); cursor: pointer; font-size: 13px; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #fff9e6; }
.notif-item .title { font-weight: 600; margin-bottom: 2px; }
.notif-item .body { font-size: 12px; color: var(--muted); }
.notif-item .when { font-size: 11px; color: var(--muted); margin-top: 2px; }
.main-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }
.page { display: none; padding: 28px 30px; }
.page.active { display: block; }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* CARDS */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 14px; }

/* KPI GRID */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi-label { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-badge { display: inline-block; font-size: 11px; padding: 3px 8px; border-radius: 5px; margin-top: 8px; font-weight: 500; }

/* TABLES */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); background: #faf8f5; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #faf8f5; }
.job-num { font-weight: 700; color: var(--brand); }

/* STATUS PILLS */
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.pill-green  { background: var(--green-bg);  color: var(--green-txt); }
.pill-amber  { background: var(--amber-bg);  color: var(--amber-txt); }
.pill-blue   { background: var(--blue-bg);   color: var(--blue-txt); }
.pill-red    { background: var(--red-bg);    color: var(--red-txt); }
.pill-purple { background: var(--purple-bg); color: var(--purple-txt); }
.pill-gray   { background: #f0ede8; color: #666; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.05em; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text); outline: none; transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-mid); }
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* BUTTONS */
.btn-primary { background: var(--brand); color: #fff; border: none; border-radius: 7px; padding: 9px 18px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: opacity 0.15s; }
.btn-primary:hover { opacity: 0.88; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; transition: background 0.15s; }
.btn-outline:hover { background: var(--bg); }
.btn-ghost-sm { background: transparent; color: var(--on-dark-2); border: 1px solid rgba(255,255,255,0.18); border-radius: 6px; padding: 6px 12px; font-size: 12px; cursor: pointer; font-family: inherit; width: 100%; }
.btn-ghost-sm:hover { color: var(--on-dark); border-color: rgba(255,255,255,0.35); }
.btn-full { width: 100%; }
.btn-danger { background: var(--red-bg); color: var(--red-txt); border: 1px solid #fca5a5; border-radius: 7px; padding: 8px 16px; font-size: 13px; cursor: pointer; font-family: inherit; font-weight: 600; }
.btn-danger:hover { background: var(--red-txt); color: #fff; border-color: var(--red-txt); }
/* Round × button used on photo thumbnails, file rows, message bubbles. */
.btn-x { width: 28px; height: 28px; border-radius: 50%; border: none; background: var(--red-txt); color: #fff; font-size: 18px; line-height: 1; font-weight: 700; cursor: pointer; padding: 0; box-shadow: 0 2px 6px rgba(0,0,0,0.25); display: inline-flex; align-items: center; justify-content: center; }
.btn-x:hover { background: #6b0f0f; transform: scale(1.06); }
.btn-x.sm { width: 22px; height: 22px; font-size: 14px; }
.btn-qb { background: #2CA01C; color: #fff; border: none; border-radius: 7px; padding: 8px 14px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; }

/* SEARCH / FILTERS */
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: inherit; min-width: 200px; background: var(--surface); }
.filter-select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: inherit; background: var(--surface); cursor: pointer; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.42); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--surface); border-radius: var(--radius); padding: 24px 26px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }

/* TECH CARDS */
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tech-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.tech-avatar-lg { width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.tech-name-lg { font-size: 15px; font-weight: 600; }
.tech-role { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.tech-stat-row { display: flex; gap: 14px; margin-top: 10px; }
.tech-stat { text-align: center; }
.tech-stat-val { font-size: 20px; font-weight: 700; color: var(--text); }
.tech-stat-lbl { font-size: 10px; color: var(--muted); }

/* INV DETAIL */
.inv-detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.inv-items-table th, .inv-items-table td { padding: 8px 10px; }
.inv-total-row { font-weight: 700; font-size: 15px; }
.inv-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* DASHBOARD GRID */
.dash-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 20px; }

/* DASHBOARD — JOB TYPE SPLIT (colour-coded cards) */
.type-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; margin-bottom: 24px; }
.type-card { border-radius: var(--radius); padding: 18px 20px; border: 1px solid transparent; }
.type-card .type-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.type-card .type-big { font-size: 26px; font-weight: 700; line-height: 1; }
.type-card .type-sub { font-size: 12px; margin-top: 3px; opacity: 0.82; }
.type-card .type-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px solid currentColor; opacity: 0.9; }
.type-card .type-row strong { font-weight: 700; font-size: 14px; }
.type-card.type-new_construction  { background: #E3F2FD; color: #0a3d7a; border-color: #bfdbfe; }
.type-card.type-annual_inspection { background: #E8F5E9; color: #1a5c1a; border-color: #c8e6c9; }
.type-card.type-service_call      { background: #FFF8E1; color: #7a5100; border-color: #ffe0a3; }

@media (max-width: 900px) {
  .type-grid { grid-template-columns: 1fr; }
}

/* URGENCY DOT */
.dot-urgent { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #e53935; margin-right: 5px; vertical-align: middle; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state-icon { font-size: 36px; margin-bottom: 10px; }
.empty-state-msg { font-size: 14px; }

/* RESPONSIVE — phones + tablets.
   ≤900px gets a hamburger + slide-over sidebar (vs the desktop fixed rail).
   The previous top-bar layout was unusable with 10 nav items on a phone. */

/* Hamburger button — shown only on small screens. */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 10px; left: 10px; z-index: 110;
  width: 44px; height: 44px; border-radius: 8px;
  background: var(--brand); color: #fff; border: none;
  font-size: 22px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.mobile-menu-btn:active { transform: scale(0.96); }

/* Backdrop behind the slide-over sidebar. */
.mobile-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 99;
}
body.menu-open .mobile-backdrop { display: block; }

@media (max-width: 900px) {
  .mobile-menu-btn { display: block; }

  /* Sidebar becomes a left slide-over. Hidden by default, slides in when
     <body> gets the .menu-open class. */
  .sidebar {
    width: 260px;
    transform: translateX(-110%);
    transition: transform 0.22s ease-out;
    box-shadow: 4px 0 16px rgba(0,0,0,0.25);
  }
  body.menu-open .sidebar { transform: translateX(0); }

  /* Make room at the top of every page for the hamburger button. */
  .main-content { margin-left: 0; padding-top: 56px; }
  .page { padding: 14px; }
  .page-header { gap: 8px; }
  .page-header .page-title { font-size: 22px; }

  /* Grids: drop to 1–2 columns. */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 11px; }
  .dash-bottom { grid-template-columns: 1fr; gap: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .tech-grid { grid-template-columns: 1fr; }

  /* Modals fill more of the screen on phones, leave a thin gutter. */
  .modal-overlay { padding: 10px; align-items: flex-start; padding-top: 24px; }
  .modal-box { max-width: 100%; padding: 18px 18px; }

  /* Tables can't fit on phones — let them scroll. */
  .table-wrap { overflow-x: auto; }
  table { min-width: 560px; }

  /* Prevent iOS from zooming in on input focus by keeping font-size ≥ 16px. */
  input, select, textarea { font-size: 16px !important; }

  /* Filter bar wraps cleanly. */
  .filter-bar { gap: 6px; }
  .filter-bar .filter-select,
  .filter-bar .search-input { font-size: 14px; }
}

/* Tighter rules for true phones (≤500px). */
@media (max-width: 500px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  /* Login screen — make sure the card never overlaps the viewport edges. */
  .login-wrap { padding: 16px; }
  .login-card { padding: 22px 18px; }
  .login-logo-img { max-width: 220px !important; padding: 10px !important; }
}
