/* ============================================================
   REFURB MANAGER — STYLESHEET
   Clean, professional, high-contrast. Built for daily use.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --navy:       #0f1b2d;
  --navy-mid:   #1a2d47;
  --navy-light: #243d5c;
  --slate:      #4a6380;
  --mid:        #8fa8c0;
  --pale:       #d4e2ef;
  --off-white:  #f0f5fa;
  --white:      #ffffff;

  --amber:      #e8942a;
  --amber-light:#fdf3e3;
  --green:      #1a8a5a;
  --green-light:#e6f6ee;
  --red:        #c0392b;
  --red-light:  #fdecea;
  --blue:       #1a6aaf;
  --blue-light: #e8f2fb;
  --purple:     #6b3fa0;
  --purple-light:#f0eaf8;

  --status-awaiting-bg:  #fff8e6;
  --status-awaiting-col: #996600;
  --status-0-bg:         #f5f5f5;
  --status-0-col:        #555;
  --status-1-bg:         #e8f2fb;
  --status-1-col:        #1a5a96;
  --status-2-bg:         #e8f0fb;
  --status-2-col:        #1a3d96;
  --status-charged-bg:   #e6f6ee;
  --status-charged-col:  #1a6a4a;
  --status-rent-bg:      #f0eaf8;
  --status-rent-col:     #5a2a88;
  --status-upfront-bg:   #fff0e6;
  --status-upfront-col:  #8a4000;

  --sidebar-w: 240px;
  --radius:    6px;
  --shadow:    0 2px 8px rgba(15,27,45,0.10);
  --shadow-lg: 0 4px 20px rgba(15,27,45,0.15);

  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--off-white);
  color: var(--navy);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ============================================================
   LAYOUT
   ============================================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: var(--pale);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--navy-light);
}

.sidebar-brand h1 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--white);
  letter-spacing: 0.01em;
}

.sidebar-brand p {
  font-size: 0.72rem;
  color: var(--mid);
  margin-top: 0.15rem;
  font-weight: 300;
}

.sidebar-region {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--amber);
  background: rgba(232,148,42,0.12);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-top: 0.4rem;
  display: inline-block;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.sidebar-nav-section {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--slate);
  text-transform: uppercase;
  padding: 0.75rem 1.25rem 0.35rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.25rem;
  color: var(--pale);
  font-size: 0.875rem;
  font-weight: 400;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: var(--navy-light);
  color: var(--white);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--navy-mid);
  border-left-color: var(--amber);
  color: var(--white);
  font-weight: 500;
}

.sidebar-nav a .nav-icon {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.7;
  flex-shrink: 0;
  width: 1.5rem;
  min-width: 1.5rem;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--navy-light);
  font-size: 0.8rem;
}

.sidebar-footer .user-name { color: var(--white); font-weight: 500; }
.sidebar-footer .user-role { color: var(--mid); font-size: 0.72rem; text-transform: capitalize; }

.sidebar-footer a {
  color: var(--mid);
  font-size: 0.75rem;
  display: inline-block;
  margin-top: 0.5rem;
}
.sidebar-footer a:hover { color: var(--pale); }
.logout-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--mid);
  font-size: 0.75rem;
  display: inline-block;
  margin-top: 0.5rem;
  font-family: inherit;
}
.logout-btn:hover { color: var(--pale); }

/* ---- Main Content ---- */

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: calc(100vw - var(--sidebar-w));
}

.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--pale);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: nowrap;
}

.page-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy);
  /* Allow long addresses to truncate rather than forcing buttons onto a new row */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.page-header .header-meta {
  font-size: 0.8rem;
  color: var(--slate);
  margin-top: 0.1rem;
}

.page-body {
  padding: 1.75rem 2rem;
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  width: 100%;
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--pale);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 0.85rem 1.25rem;
  background: var(--off-white);
  border-top: 1px solid var(--pale);
  font-size: 0.8rem;
  color: var(--slate);
}

/* ============================================================
   STATUS BADGES
   ============================================================ */

.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.status-awaiting { background: var(--status-awaiting-bg); color: var(--status-awaiting-col); }
.status-0        { background: var(--status-0-bg);        color: var(--status-0-col); }
.status-1        { background: var(--status-1-bg);        color: var(--status-1-col); }
.status-2        { background: var(--status-2-bg);        color: var(--status-2-col); }
.status-charged  { background: var(--status-charged-bg);  color: var(--status-charged-col); }
.status-rent     { background: var(--status-rent-bg);     color: var(--status-rent-col); }
.status-upfront  { background: var(--status-upfront-bg);  color: var(--status-upfront-col); }

/* ============================================================
   TABLES
   ============================================================ */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 0;
}

/* Wrap tables in this to allow horizontal scroll without breaking layout */
.table-scroll, .table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table th {
  background: var(--off-white);
  color: var(--slate);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--pale);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--pale);
  vertical-align: middle;
  /* No truncation on desktop — let content wrap or scroll naturally */
}
.data-table td.nowrap      { white-space: nowrap; max-width: none; }
.data-table td.status-col  { max-width: none; overflow: visible; white-space: nowrap; }

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: #f7fafd; }

.data-table .amount {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  text-align: right;
  white-space: nowrap;
}

.data-table .totals-row td {
  font-weight: 600;
  background: var(--off-white);
  border-top: 2px solid var(--pale);
}

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
  margin-bottom: 1.1rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.35rem;
  letter-spacing: 0.01em;
}

.form-label .required { color: var(--red); margin-left: 0.15rem; }

.form-control {
  display: block;
  width: 100%;
  padding: 0.55rem 0.8rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: var(--navy);
  background: var(--white);
  border: 1.5px solid var(--pale);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,106,175,0.12);
}

.form-control.is-invalid { border-color: var(--red); }

.form-hint {
  font-size: 0.75rem;
  color: var(--slate);
  margin-top: 0.3rem;
}

.form-error {
  font-size: 0.75rem;
  color: var(--red);
  margin-top: 0.3rem;
}

.form-row {
  display: grid;
  gap: 1rem;
}
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* Extras/deductions tab — always stacked vertically */
.extras-stack { display: flex; flex-direction: column; gap: 0; }

select.form-control { cursor: pointer; }
textarea.form-control { min-height: 80px; resize: vertical; }

.form-section {
  border-top: 1px solid var(--pale);
  padding-top: 1.25rem;
  margin-top: 1.25rem;
}
.form-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-family: var(--font-body);
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
  position: relative;
}
.btn:hover { opacity: 0.9; text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--navy);  color: var(--white); }
.btn-secondary { background: var(--pale);  color: var(--navy); }
.btn-success   { background: var(--green); color: var(--white); }
.btn-danger    { background: var(--red);   color: var(--white); }
.btn-amber     { background: var(--amber); color: var(--white); }
.btn-sm        { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-xs        { padding: 0.2rem 0.5rem; font-size: 0.72rem; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ============================================================
   ALERTS / FLASH MESSAGES
   ============================================================ */

.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.4rem;
  line-height: 1.6;
}
.alert-success { background: var(--green-light); color: #145a3d; border-left: 4px solid var(--green); }
.alert-error   { background: var(--red-light);   color: #8b1a12; border-left: 4px solid var(--red); }
.alert-info    { background: var(--blue-light);  color: #0f3f6f; border-left: 4px solid var(--blue); }
.alert-warning { background: var(--amber-light); color: #7a4400; border-left: 4px solid var(--amber); }

/* ============================================================
   JOB CARDS (dashboard grid)
   ============================================================ */

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

.job-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--pale);
  padding: 1.1rem 1.25rem;
  transition: box-shadow 0.15s, transform 0.15s;
  text-decoration: none;
  display: block;
  color: var(--navy);
}
.job-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--navy);
}

.job-card.status-awaiting { border-left-color: var(--status-awaiting-col); }
.job-card.status-0        { border-left-color: var(--mid); }
.job-card.status-1        { border-left-color: var(--blue); }
.job-card.status-2        { border-left-color: var(--purple); }
.job-card.status-charged  { border-left-color: var(--green); }
.job-card.status-rent     { border-left-color: var(--purple); }

.job-card-address {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.2rem;
}

.job-card-meta {
  font-size: 0.78rem;
  color: var(--slate);
  margin-bottom: 0.6rem;
}

.job-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
}

.job-card-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--navy);
}

/* ============================================================
   FINANCE SUMMARY BLOCK
   ============================================================ */

.finance-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--pale);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.finance-panel {
  background: var(--white);
  padding: 1.25rem;
}

.finance-panel-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--slate);
  margin-bottom: 0.85rem;
}

.finance-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.875rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--off-white);
}

.finance-row:last-child { border-bottom: none; }

.finance-row.total {
  font-weight: 600;
  font-size: 0.95rem;
  border-top: 2px solid var(--pale);
  padding-top: 0.6rem;
  margin-top: 0.3rem;
}

.finance-row .label { color: var(--slate); }
.finance-row .value { font-family: var(--font-mono); }

.profit-figure {
  font-size: 1.5rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--green);
  margin-top: 0.25rem;
}
.profit-figure.negative { color: var(--red); }

.profit-percent {
  font-size: 0.85rem;
  color: var(--slate);
  margin-top: 0.15rem;
}

/* ============================================================
   QUOTE ITEMS BUILDER
   ============================================================ */

.quote-item-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.quote-total-bar {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.75rem 0;
  border-top: 2px solid var(--pale);
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--slate);
}

.quote-total-bar .total-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
}

/* ============================================================
   TABS
   ============================================================ */

.tabs {
  display: flex;
  border-bottom: 2px solid var(--pale);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 0;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE */
  /* Prevent tab bar from clipping on narrow content areas */
  width: 100%;
  box-sizing: border-box;
}
.tabs::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.tabs-wrapper {
  position: relative;
  /* Wrapper must NOT scroll — only inner .tabs scrolls.
     overflow visible here ensures the tab bar is never clipped. */
  overflow: visible;
}
.tabs-wrapper::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 2px;
  width: 48px;
  background: linear-gradient(to right, transparent, var(--white));
  pointer-events: none;
  z-index: 1;
}


.tab {
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--slate);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--navy); text-decoration: none; }
.tab.active { color: var(--navy); border-bottom-color: var(--amber); font-weight: 600; }

/* ============================================================
   NOTES / COMMENTS
   ============================================================ */

.note-item {
  padding: 0.85rem 1rem;
  background: var(--off-white);
  border-radius: var(--radius);
  border-left: 3px solid var(--pale);
  margin-bottom: 0.6rem;
  font-size: 0.875rem;
}

.note-item.type-general       { border-left-color: var(--mid); }
.note-item.type-payment       { border-left-color: var(--amber); }
.note-item.type-recommendation{ border-left-color: var(--purple); }
.note-item.type-contractor_ref{ border-left-color: var(--blue); }
.note-item.type-extra         { border-left-color: var(--green); }
.note-item.type-whatsapp_summary { border-left-color: #25d366; }
.note-item.type-email_summary   { border-left-color: var(--amber); }

.note-meta {
  font-size: 0.72rem;
  color: var(--slate);
  margin-bottom: 0.35rem;
}

.note-content { white-space: pre-wrap; line-height: 1.4; color: var(--navy); font-size: 0.875rem; }

/* Note edit history */
.note-history {
  margin-top: 0.6rem;
  border-top: 1px dashed var(--pale);
  padding-top: 0.5rem;
}
.note-history-entry {
  background: #f7fafd;
  border-left: 2px solid var(--pale);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
}
.note-history-meta {
  font-size: 0.7rem;
  color: var(--slate);
  margin-bottom: 0.2rem;
}
.note-history-content {
  color: var(--navy);
  white-space: pre-wrap;
  opacity: 0.75;
}
.note-history-toggle { margin-top: 0.4rem; }

/* Activity log */
.activity-log { padding: 0 0.25rem; }
.activity-entry {
  display: flex;
  gap: 0.85rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--pale);
  align-items: flex-start;
}
.activity-entry:last-child { border-bottom: none; }
.activity-icon {
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
  padding-top: 0.05rem;
}
.activity-body { flex: 1; min-width: 0; }
.activity-action {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--navy);
  margin-bottom: 0.15rem;
}
.activity-meta { font-size: 0.75rem; color: var(--slate); }
.activity-detail {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--slate);
  font-style: italic;
}
.activity-value-old { color: var(--navy); opacity: 0.6; }

/* ============================================================
   PAYMENT STAGES
   ============================================================ */

.payment-stages {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--pale);
  border-radius: var(--radius);
  overflow: hidden;
}

.payment-stage {
  background: var(--white);
  padding: 1rem;
  text-align: center;
}

.payment-stage-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate);
  margin-bottom: 0.3rem;
}

.payment-stage-amount {
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--navy);
}

.payment-stage-percent {
  font-size: 0.75rem;
  color: var(--mid);
}

.payment-stage.received { background: var(--green-light); }
.payment-stage.received .payment-stage-label { color: var(--green); }
.payment-stage.requested { background: var(--amber-light); }
.payment-stage.requested .payment-stage-label { color: #7a4400; }

/* ============================================================
   STATS / SUMMARY BOXES
   ============================================================ */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  width: 100%;
  box-sizing: border-box;
}

.stat-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
}

.stat-box-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--slate);
  margin-bottom: 0.35rem;
}

.stat-box-value {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--navy);
  font-family: var(--font-mono);
  line-height: 1.2;
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: normal;
  overflow: visible;
  hyphens: none;
}

.stat-box-sub {
  font-size: 0.75rem;
  color: var(--slate);
  margin-top: 0.2rem;
}

.stat-box-link {
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  color: inherit;
}
.stat-box-link:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
  text-decoration: none;
}

.stat-box-alert {
  border-left: 3px solid var(--amber);
  background: var(--amber-light);
}
.stat-box-alert .stat-box-value { color: #7a4400; }
.stat-box-alert .stat-box-label { color: #7a4400; }

/* ============================================================
   FILTERS & SEARCH
   ============================================================ */

.filter-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1.25rem;
}

.filter-bar input,
.filter-bar select {
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 0.45rem 0.8rem;
  border: 1.5px solid var(--pale);
  border-radius: var(--radius);
  color: var(--navy);
  background: var(--white);
  outline: none;
}

.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--blue);
}

.filter-bar input[type="search"] { min-width: 220px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-box {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--navy);
}

.login-logo p {
  font-size: 0.8rem;
  color: var(--slate);
  margin-top: 0.25rem;
}


/* ============================================================
   ARCHIVED BADGE
   ============================================================ */
.archived-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate);
  background: var(--off-white);
  border: 1px solid var(--pale);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  margin-left: 0.4rem;
  vertical-align: middle;
}


/* ============================================================
   MAINTENANCE — JOB BANNER (notes tab)
   ============================================================ */
.maint-job-banner {
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
}
.maint-job-banner-address {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.maint-job-banner-meta {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Full-width button on mobile -------------------------------- */
@media (max-width: 768px) {
  .btn-full-mobile {
    width: 100%;
    justify-content: center;
    padding: 0.85rem;
    font-size: 1rem;
  }
  .maint-note-input {
    font-size: 1rem;
    min-height: 120px;
    resize: none;
    overflow: hidden;
  }
  /* Notes form comes first on mobile — Add Note card floats to top */
  .notes-mobile-swap {
    display: flex !important;
    flex-direction: column-reverse;
    gap: 1rem;
  }
  /* On mobile, truncate data-table cells and allow tap-to-reveal tooltip */
  .data-table td {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .data-table td.status-col { max-width: none; overflow: visible; white-space: nowrap; }
  .data-table td.nowrap      { max-width: none; white-space: nowrap; }
}

/* ============================================================
   MOBILE OVERRIDES (maintenance staff view)
   ============================================================ */

/* ============================================================
   MOBILE HAMBURGER TOGGLE
   ============================================================ */

.mobile-header {
  display: none;
  background: var(--navy);
  padding: 0.85rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
}

.mobile-header-title {
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  align-items: center;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: all 0.25s;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 149;
}

.sidebar-overlay.active { display: block; }

.show-mobile      { display: none; }
/* hide-narrow-show: hidden on desktop, revealed when landlord col is hidden */
.hide-narrow-show { display: none; }

/* ============================================================
   JOBS INDEX TABLE
   Priority cascade — columns drop one at a time as screen narrows:
     >1100px  : Status · Address · Plan · Landlord · Quote · Ref  (all 6)
     900-1100px: Ref drops   → Status · Address · Plan · Landlord · Quote
     700-900px : Landlord drops → Status · Address · Plan · Quote
     <700px   : Plan drops  → Status · Address · Quote  (core 3)
   Widths recalculate at each breakpoint so no dead space is left.
   ============================================================ */

.jobs-index-table { table-layout: fixed; width: 100%; }

/* All cells: clip rather than overflow — except Status and Plan (see below) */
.jobs-index-table th,
.jobs-index-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status and Plan badges must never be clipped by their cell —
   fixed px width guarantees the space, overflow:visible lets the badge breathe */
.jobs-index-table th.col-status,
.jobs-index-table td.col-status,
.jobs-index-table th.col-plan,
.jobs-index-table td.col-plan {
  overflow: visible;
}

/* --- Full desktop widths (all 6 columns) ---
   Status, Plan, Quote: fixed px — never clip.
   Ref, Landlord, Address: percentage — scale proportionally as screen shrinks. --- */
.jobs-index-table th.col-status,
.jobs-index-table td.col-status   { width: 88px; white-space: nowrap; }

.jobs-index-table th.col-plan,
.jobs-index-table td.col-plan     { width: 72px; white-space: nowrap; text-align: center; }

.jobs-index-table th.col-quote,
.jobs-index-table td.col-quote    { width: 110px; white-space: nowrap; text-align: right; }

.jobs-index-table th.col-ref,
.jobs-index-table td.col-ref      { width: 10%; }

.jobs-index-table th.col-landlord,
.jobs-index-table td.col-landlord { width: 18%; }

.jobs-index-table th.col-address,
.jobs-index-table td.col-address  { width: 30%; white-space: normal; }

/* Address link — truncates, hover tooltip shows full address */
.jobs-index-table td.col-address a {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Postcode/region sub-line stays on one line too */
.jobs-index-table td.col-address > div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Landlord — truncates with tooltip */
.jobs-index-table td.col-landlord span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

/* Status and Plan: never clip — fixed px width guarantees space */
.jobs-index-table td.col-status { overflow: visible; }
.jobs-index-table td.col-plan   { overflow: visible; }

/* --- Step 1: Ref drops at 1300px — 5 columns remain ---
   Quote and Plan get fixed px so they never clip.
   Address and Landlord share the remaining space. --- */
@media (max-width: 1300px) {
  .col-ref { display: none !important; }
  .jobs-index-table th.col-landlord,
  .jobs-index-table td.col-landlord { width: 22%; }
  .jobs-index-table th.col-address,
  .jobs-index-table td.col-address  { width: 36%; }
}

/* --- Step 2: Landlord drops at 1100px — 4 columns remain --- */
@media (max-width: 1100px) {
  .col-landlord { display: none !important; }
  .hide-narrow-show { display: block !important; }
  .jobs-index-table th.col-address,
  .jobs-index-table td.col-address  { width: 55%; }
}

/* --- Step 3: Plan drops at 900px — 3 core columns remain ---
   Address fills the middle as a percentage so there's no dead space. --- */
@media (max-width: 900px) {
  .col-plan { display: none !important; }
  .jobs-index-table th.col-address,
  .jobs-index-table td.col-address  { width: 70%; }
}

@media (max-width: 768px) {

  /* --- Layout --- */
  .app-layout { flex-direction: column; }
  .main-content { margin-left: 0; max-width: 100vw; }

  /* --- Mobile header bar --- */
  .mobile-header { display: flex; }

  /* --- Sidebar becomes a slide-in drawer --- */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100%;
    z-index: 150;
    transition: left 0.25s ease;
    overflow-y: auto;
  }

  .sidebar.open { left: 0; }

  /* --- Page spacing --- */
  .page-body   { padding: 0.85rem; }
  .page-header {
    padding: 0.85rem 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }
  .page-header h2 {
    font-size: 1.1rem;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
  }

  /* --- Buttons --- */
  .btn-group { flex-wrap: wrap; }
  .page-header .btn-group { width: 100%; }

  /* --- Two col layouts all collapse to one --- */
  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4  { grid-template-columns: 1fr; }

  /* Overview tab two-col card layout */
  .form-row[style*="align-items:start"],
  .form-row[style*="align-items: start"] { grid-template-columns: 1fr; }

  /* Extras tab — single column always (stacks list above form) */
  .extras-stack { display: block; }

  /* --- Finance & payment grids --- */
  .finance-summary  { grid-template-columns: 1fr; }
  .payment-stages   { grid-template-columns: 1fr !important; }

  /* --- Job cards & stats --- */
  .jobs-grid  { grid-template-columns: 1fr; }
  .stats-row  { grid-template-columns: 1fr 1fr; }

  /* --- Tables --- */
  .data-table          { font-size: 0.8rem; }
  .data-table th,
  .data-table td        { padding: 0.45rem 0.5rem; }
  .hide-mobile          { display: none !important; }
  .show-mobile          { display: block !important; }

  /* --- Status badges — keep nowrap, labels are now short enough --- */
  .status-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }

  /* --- Tabs scroll horizontally --- */
  .tabs { overflow-x: auto; }
  .tab  { padding: 0.75rem 1rem; font-size: 0.82rem; min-height: 44px; display: inline-flex; align-items: center; white-space: nowrap; }

  /* --- Page header — prevent job title truncation on mobile --- */
  .page-header h2 {
    font-size: 1rem;
    white-space: normal;      /* allow wrapping rather than truncating */
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
  }

  /* --- Header action buttons — wrap cleanly rather than overflowing --- */
  .page-header { align-items: flex-start; }
  .page-header > div:first-child { min-width: 0; flex: 1; }
  .page-header .btn-group {
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
  }
  .page-header .btn-group .btn { flex: 1 1 auto; min-width: 80px; font-size: 0.78rem; padding: 0.4rem 0.6rem; }

  /* --- Jobs list — make Quote column visible on mobile by allowing table scroll --- */
  .jobs-table-wrap { overflow-x: hidden; }

  /* --- Payment stage cards — stack to single column and prevent clipping --- */
  .payment-stages {
    grid-template-columns: 1fr !important;
    overflow: visible;
  }
  .payment-card { min-width: 0; width: 100%; box-sizing: border-box; }

  /* --- Filter bar stacks --- */
  .filter-bar form { flex-direction: column; align-items: stretch; }
  .filter-bar input[type="search"],
  .filter-bar select { width: 100%; min-width: 0; }
  /* Larger touch targets for filter buttons on mobile */
  .filter-bar .btn { min-height: 44px; padding: 0.65rem 1rem; font-size: 0.9rem; }

  /* --- Cards full width --- */
  .card { border-radius: var(--radius); }

  /* --- Quote item rows stack --- */
  .quote-item-row { grid-template-columns: 1fr auto; }

  /* --- Login box full width on small screens --- */
  .login-box { padding: 1.5rem; }

  /* --- Modals full width --- */
  .modal-box { margin: 0.5rem; max-width: calc(100vw - 1rem); }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--slate); }
.text-small  { font-size: 0.8rem; }
.text-mono   { font-family: var(--font-mono); }
.text-success{ color: var(--green); }
.text-danger { color: var(--red); }
.text-amber  { color: var(--amber); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex   { display: flex; }
.gap-1    { gap: 0.5rem; }
.gap-2    { gap: 1rem; }
.flex-wrap{ flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--slate);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

.divider { height: 1px; background: var(--pale); margin: 1.25rem 0; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: var(--pale);
  color: var(--slate);
}

/* VAT note highlight */
.vat-note {
  background: var(--amber-light);
  border: 1px solid #e8c070;
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  font-size: 0.8rem;
  color: #6b4400;
}

/* Route labels */
.route-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.route-1 { background: #e8f4ff; color: #0a4a8a; }
.route-2 { background: #fff3e8; color: #7a3a00; }

/* ============================================================
   QUICK-ADD POPUP MODAL
   ============================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,27,45,0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  margin: 1rem;
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--pale);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--slate);
  padding: 0.25rem;
  line-height: 1;
}

.modal-close:hover { color: var(--navy); }

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--pale);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ================================================================
   SEARCHABLE SELECT WIDGET
   ================================================================ */
.searchable-select {
  position: relative;
}

.searchable-select .ss-input {
  width: 100%;
}

.ss-dropdown {
  display: none;
  position: absolute;
  z-index: 200;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg, #fff);
  border: 1px solid var(--pale);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}

.searchable-select.ss-open .ss-dropdown {
  display: block;
}

.ss-option {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--body);
}

.ss-option:hover,
.ss-option.ss-focused {
  background: var(--pale);
}

.ss-option.ss-hidden {
  display: none;
}

.ss-add-new {
  color: var(--amber);
  font-weight: 600;
  border-top: 1px solid var(--pale);
}

.ss-add-new:hover {
  background: color-mix(in srgb, var(--amber) 10%, transparent);
}

.ss-no-results {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--slate);
  font-style: italic;
}

/* ================================================================
   DESCRIPTION AUTOCOMPLETE WIDGET
   ================================================================ */
.desc-autocomplete {
  position: relative;
}

.desc-dropdown {
  display: none;
  position: absolute;
  z-index: 300;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg, #fff);
  border: 1px solid var(--pale);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  max-height: 200px;
  overflow-y: auto;
}

.desc-dropdown.open {
  display: block;
}

.desc-option {
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.desc-option:hover {
  background: var(--pale);
}

.desc-save-row {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  border-top: 1px solid var(--pale);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.desc-save-row span {
  color: var(--slate);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.desc-save-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--amber);
  color: var(--amber);
  border-radius: var(--radius);
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.desc-save-btn:hover {
  background: var(--amber);
  color: #fff;
}

/* ============================================================
   OUTSTANDING PAYMENTS PAGE
   ============================================================ */

.outstanding-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.summary-stat {
  background: #fff;
  border: 1px solid var(--pale);
  border-radius: var(--radius);
  padding: 0.85rem 1.25rem;
  min-width: 140px;
  box-shadow: var(--shadow);
}

.summary-stat.summary-alert {
  border-color: #f5c6cb;
  background: #fff5f5;
}

.summary-val {
  font-size: 1.5rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--navy);
}

.summary-alert .summary-val { color: var(--red); }

.summary-lbl {
  font-size: 0.72rem;
  color: var(--slate);
  margin-top: 0.1rem;
}

.card-header-alert {
  border-bottom-color: #f5c6cb;
  background: #fff5f5;
}

.card-header-alert h3 { color: var(--red); }

.card-body-note {
  padding: 0.6rem 1.25rem;
  font-size: 0.8rem;
  color: var(--slate);
  background: var(--off-white);
  border-bottom: 1px solid var(--pale);
}

/* Urgency row colouring */
tr.overdue-high td:first-child { border-left: 3px solid var(--red); }
tr.overdue-mid  td:first-child { border-left: 3px solid var(--amber); }
tr.overdue-low  td:first-child { border-left: 3px solid var(--green); }

.days-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-family: var(--font-mono);
}
.days-high { background: #fdecea; color: var(--red); }
.days-mid  { background: var(--amber-light); color: #7a4400; }
.days-low  { background: var(--green-light); color: var(--green); }

.stage-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: var(--off-white);
  color: var(--slate);
  border: 1px solid var(--pale);
  white-space: nowrap;
}

.stage-pill.stage-1 { background: var(--blue-light); color: var(--blue); border-color: var(--blue-light); }
.stage-pill.stage-2 { background: var(--purple-light); color: var(--purple); border-color: var(--purple-light); }
.stage-pill.stage-3 { background: var(--green-light); color: var(--green); border-color: var(--green-light); }

.job-link { font-weight: 500; color: var(--navy); }
.job-link:hover { color: var(--blue); text-decoration: underline; }

.row-meta { font-size: 0.72rem; color: var(--slate); margin-top: 0.1rem; }

.text-muted { color: var(--mid); }

.actions-cell { white-space: nowrap; }

.badge-red    { background: #fdecea; color: var(--red); }
.badge-amber  { background: var(--amber-light); color: #7a4400; }
.badge-slate  { background: var(--off-white); color: var(--slate); }

/* Invoice link button on job view */
.btn-invoice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* ============================================================
   REPORTS
   ============================================================ */

.reports-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
  min-width: 0;
}
/* reports-main must have min-width:0 — grid items default to min-width:auto
   which allows them to grow beyond their column, pushing Export CSV off-screen */
.reports-main {
  min-width: 0;
  overflow: hidden;
}

/* Reports layout stacks on smaller screens */
@media (max-width: 900px) {
  .reports-layout {
    grid-template-columns: 1fr;
  }
}

/* Column cascade breakpoints are now handled in the JOBS INDEX TABLE
   section above. Each column drops individually at its own breakpoint. */

.reports-nav {
  background: #fff;
  border: 1px solid var(--pale);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: sticky;
  top: 1rem;
}

.report-nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--slate);
  text-decoration: none;
  border-bottom: 1px solid var(--pale);
  transition: background 0.1s;
}
.report-nav-item:last-child { border-bottom: none; }
.report-nav-item:hover { background: var(--off-white); color: var(--navy); text-decoration: none; }
.report-nav-item.active { background: var(--navy); color: #fff; }
.report-nav-item.active:hover { background: var(--navy); }
.report-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(0,0,0,0.06);
  border-radius: 3px;
  font-family: var(--font-mono);
  line-height: 1;
}
.report-nav-item.active .report-nav-icon {
  background: rgba(255,255,255,0.15);
}
.report-nav-label { line-height: 1.3; }

.reports-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
  /* Prevent the Export CSV button being pushed off-screen by filter overflow */
  flex-wrap: nowrap;
}
.reports-header-left {
  flex: 1;
  min-width: 0;
}
.reports-header-actions {
  flex-shrink: 0; /* Never shrink — always visible */
}
.reports-title { font-size: 1.15rem; font-weight: 600; color: var(--navy); margin-bottom: 0.2rem; }
.reports-desc  { font-size: 0.8rem; color: var(--slate); }

.reports-filters {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
}
.filter-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-row .form-group {
  margin: 0;
  flex: 1;
  min-width: 140px;
}

/* Summary bar */
.report-summary-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.rsb-stat {
  background: #fff;
  border: 1px solid var(--pale);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  min-width: 110px;
  box-shadow: var(--shadow);
}
.rsb-val { font-size: 1.2rem; font-weight: 600; font-family: var(--font-mono); color: var(--navy); }
.rsb-lbl { font-size: 0.7rem; color: var(--slate); margin-top: 0.1rem; }
.rsb-positive { border-color: var(--green-light); }
.rsb-positive .rsb-val { color: var(--green); }
.rsb-negative { border-color: var(--red-light); }
.rsb-negative .rsb-val { color: var(--red); }
.rsb-alert { border-color: #f5c6cb; background: #fff5f5; }
.rsb-alert .rsb-val { color: var(--red); }
.rsb-note {
  flex: 1;
  min-width: 200px;
  background: #fffbf0;
  border-color: #ffe4a8;
}
.rsb-note .rsb-lbl { color: #7a5a00; font-size: 0.75rem; line-height: 1.4; }

/* Report table */
.report-table th { white-space: nowrap; }
.text-success { color: var(--green) !important; }
.text-danger  { color: var(--red)   !important; }

/* ============================================================
   MAINTENANCE PREVIEW MODE
   ============================================================ */

.preview-banner {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--amber);
  color: #1a1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.preview-banner-text {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.preview-banner-exit {
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(0,0,0,0.25);
  color: #1a1000;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.preview-banner-exit:hover {
  background: rgba(0,0,0,0.28);
}

/* Sidebar toggle button */
.btn-preview-toggle {
  display: block;
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.75);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  margin-bottom: 0.4rem;
}
.btn-preview-toggle:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}
.btn-preview-exit {
  background: rgba(232,148,42,0.25);
  border-color: rgba(232,148,42,0.4);
  color: var(--amber);
}
.btn-preview-exit:hover {
  background: rgba(232,148,42,0.35);
  color: #ffd080;
}

/* Role badge shown in sidebar footer during preview */
.preview-role-badge {
  display: inline-block;
  margin-left: 0.4rem;
  background: var(--amber);
  color: #1a1000;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}


/* ============================================================
   INSPECTIONS MODULE
   ============================================================ */

.rating-good       { background: #0d4a1f; color: #4ade80; border: 1px solid #166534; }
.rating-attention  { background: #4a3000; color: #fbbf24; border: 1px solid #92400e; }
.rating-work       { background: #4a0d0d; color: #f87171; border: 1px solid #991b1b; }
.rating-na         { background: var(--surface); color: var(--slate); border: 1px solid var(--border); }

.rating-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.capture-rating-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.capture-rating-btn {
  display: block;
  width: 100%;
  padding: 0.75rem 0.5rem;
  border-radius: 6px;
  border: 2px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  background: var(--surface);
  color: var(--text);
}

.capture-rating-btn.selected-good            { background: #0d4a1f; color: #4ade80; border-color: #166534; }
.capture-rating-btn.selected-needs_attention { background: #4a3000; color: #fbbf24; border-color: #92400e; }
.capture-rating-btn.selected-requires_work   { background: #4a0d0d; color: #f87171; border-color: #991b1b; }
.capture-rating-btn.selected-na              { background: #3a3f4d; color: #9ca3af; border-color: #4b5563; }

.insp-pre-works { background: #0f2744; color: #60a5fa; border: 1px solid #1e3a5f; }
.insp-mid-works { background: #1e3a1e; color: #86efac; border: 1px solid #166534; }
.insp-snagging  { background: #4a3000; color: #fbbf24; border: 1px solid #92400e; }
.insp-sign-off  { background: #1a3d1a; color: #4ade80; border: 1px solid #166534; }

.insp-type-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.capture-progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.capture-progress-fill {
  height: 100%;
  background: var(--amber);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.area-list-item {
  display: flex;
  align-items: center;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}
.area-list-item.completed { opacity: 0.65; }

.area-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
}
.area-status-dot.done    { background: #4ade80; }
.area-status-dot.partial { background: #fbbf24; }
.area-status-dot.pending { background: var(--border); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.photo-grid-item {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
}
.photo-grid-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   TRUNCATED CELL TOOLTIP (mobile tap / desktop hover)
   ============================================================ */
.td-tooltip {
  position: fixed;
  background: var(--navy);
  color: #fff;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: min(340px, 90vw);
  white-space: normal;
  word-break: break-word;
  z-index: 9000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.td-tooltip.visible { opacity: 1; }
