/* TradeDesk — Core Design System */
/* All component styles reference these variables. Never hardcode hex values. */

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

/* ── CSS Custom Properties ──────────────────────────────────────────────── */
:root {
  /* Brand */
  --color-brand:        #1B4FD8;
  --color-brand-light:  #DBEAFE;
  --color-brand-dark:   #1E3A8A;
  --color-brand-50:     #EFF6FF;
  --color-brand-200:    #BFDBFE;

  /* Semantic */
  --color-success:       #16A34A;
  --color-success-light: #DCFCE7;
  --color-warning:       #F59E0B;
  --color-warning-light: #FEF3C7;
  --color-danger:        #DC2626;
  --color-danger-light:  #FEE2E2;

  /* Neutrals */
  --color-slate:        #1A2332;
  --color-text:         #0F172A;
  --color-text-muted:   #64748B;
  --color-text-hint:    #94A3B8;
  --color-bg:           #F8FAFC;
  --color-surface:      #FFFFFF;
  --color-border:       #E2E8F0;
  --color-border-strong:#94A3B8;

  /* Pipeline stages */
  --stage-enquiry-bg:    #DBEAFE;
  --stage-enquiry-text:  #1E40AF;
  --stage-visit-bg:      #FEF3C7;
  --stage-visit-text:    #B45309;
  --stage-quote-bg:      #F3E8FF;
  --stage-quote-text:    #6B21A8;
  --stage-quoted-bg:     #CCFBF1;
  --stage-quoted-text:   #0F766E;
  --stage-progress-bg:   #DCFCE7;
  --stage-progress-text: #15803D;
  --stage-done-bg:       #F1F5F9;
  --stage-done-text:     #475569;

  /* Typography */
  --font-sans:   'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'JetBrains Mono', 'Courier New', Courier, monospace;
  --font-serif:  Georgia, 'Times New Roman', serif;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-6:  24px;
  --space-8:  32px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-card:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-focus: 0 0 0 3px rgba(27,79,216,0.12);

  /* Transitions */
  --transition: 150ms ease;

  /* Layout */
  --nav-width:      240px;
  --nav-width-icon: 56px;
  --content-max:    1200px;
}

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

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

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

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

img, svg { display: block; max-width: 100%; }

button { cursor: pointer; font-family: var(--font-sans); }

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

/* ── App Shell ───────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar Navigation ──────────────────────────────────────────────────── */
.app-nav {
  width: var(--nav-width);
  min-height: 100vh;
  background: var(--color-slate);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.app-nav__logo {
  height: 56px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-decoration: none;
}

.app-nav__logomark {
  width: 32px;
  height: 32px;
  background: var(--color-brand);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 14px;
}

.app-nav__name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.01em;
}

.app-nav__tagline {
  display: none;
}

.app-nav__links {
  flex: 1;
  padding: var(--space-3) 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  margin: 1px var(--space-2);
  border-radius: var(--radius-md);
  color: #9CA3AF;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #F9FAFB;
  text-decoration: none;
}

.nav-item.active {
  background: #111827;
  color: #F9FAFB;
  border-left: 3px solid var(--color-brand);
  padding-left: calc(var(--space-4) - 3px);
}

.nav-item .ti {
  font-size: 18px;
  color: #6B7280;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.nav-item.active .ti,
.nav-item:hover .ti {
  color: #60A5FA;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4B5563;
  padding: var(--space-3) var(--space-4) var(--space-1);
  margin-top: var(--space-2);
}

.app-nav__bottom {
  padding: var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.nav-user__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.nav-user__info { min-width: 0; }

.nav-user__name {
  font-size: 13px;
  font-weight: 500;
  color: #F9FAFB;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-user__role {
  font-size: 11px;
  color: #6B7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Main Content ────────────────────────────────────────────────────────── */
.app-content {
  margin-left: var(--nav-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-8);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.page-header__mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 22px;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.02em;
  flex: 1;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.page-body {
  padding: var(--space-6) var(--space-8);
  flex: 1;
}

/* ── Trial Banner ────────────────────────────────────────────────────────── */
.trial-banner {
  background: var(--color-brand);
  color: #fff;
  text-align: center;
  padding: 8px var(--space-6);
  font-size: 13px;
  font-weight: 500;
}

.trial-banner a {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  min-height: 40px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity var(--transition), transform var(--transition), background var(--transition), box-shadow var(--transition);
  outline: none;
}

.btn:focus-visible { box-shadow: var(--shadow-focus); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--color-brand);
  color: #FFFFFF;
}
.btn-primary:hover { opacity: 0.88; text-decoration: none; color: #fff; }

.btn-secondary {
  background: transparent;
  color: var(--color-brand);
  border: 1.5px solid var(--color-brand);
}
.btn-secondary:hover { background: var(--color-brand-50); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 0.5px solid var(--color-border);
}
.btn-ghost:hover { background: var(--color-bg); text-decoration: none; color: var(--color-text); }

.btn-danger {
  background: var(--color-danger);
  color: #FFFFFF;
}
.btn-danger:hover { opacity: 0.88; text-decoration: none; color: #fff; }

.btn-success {
  background: var(--color-success);
  color: #FFFFFF;
}
.btn-success:hover { opacity: 0.88; text-decoration: none; color: #fff; }

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  min-height: 32px;
}

.btn-icon {
  padding: 8px;
  min-height: 36px;
  width: 36px;
  justify-content: center;
}

/* ── Form Components ─────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.form-control {
  background: var(--color-bg);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  height: 40px;
  font-size: 14px;
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-control::placeholder { color: var(--color-text-hint); }

.form-control:focus {
  outline: none;
  border: 1.5px solid var(--color-brand);
  box-shadow: var(--shadow-focus);
}

.form-control.error { border: 1.5px solid var(--color-danger); }

.form-error {
  font-size: 11px;
  color: var(--color-danger);
  margin-top: 2px;
}

textarea.form-control {
  height: auto;
  min-height: 80px;
  resize: vertical;
}

select.form-control { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
}

.card-raised {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  box-shadow: var(--shadow-card);
}

.card-surface {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

/* ── Stat Cards ──────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.15;
  font-family: var(--font-mono);
}

.stat-value.money::before { content: '£'; font-size: 16px; font-weight: 500; vertical-align: top; margin-top: 4px; display: inline-block; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--color-border);
  background: var(--color-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--color-bg);
}

th {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}

td {
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--color-text);
  border-bottom: 0.5px solid var(--color-border);
}

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

tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--color-bg); }

.td-mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ── Badges / Status Pills ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  line-height: 1.4;
  white-space: nowrap;
}

/* Pipeline stages */
.stage-enquiry   { background: var(--stage-enquiry-bg);   color: var(--stage-enquiry-text); }
.stage-site-visit{ background: var(--stage-visit-bg);     color: var(--stage-visit-text); }
.stage-to-quote  { background: var(--stage-quote-bg);     color: var(--stage-quote-text); }
.stage-quoted    { background: var(--stage-quoted-bg);    color: var(--stage-quoted-text); }
.stage-in-progress { background: var(--stage-progress-bg); color: var(--stage-progress-text); }
.stage-done      { background: var(--stage-done-bg);      color: var(--stage-done-text); }

/* Invoice / quote statuses */
.badge-unpaid   { background: #FEE2E2; color: #B91C1C; }
.badge-partial  { background: #FEF3C7; color: #B45309; }
.badge-paid     { background: #DCFCE7; color: #15803D; }
.badge-overdue  { background: var(--color-danger); color: #FFFFFF; }
.badge-draft    { background: #F1F5F9; color: #475569; }
.badge-sent     { background: #DBEAFE; color: #1E40AF; }
.badge-accepted { background: #DCFCE7; color: #15803D; }
.badge-declined { background: #FEE2E2; color: #B91C1C; }

/* ── Search Bar ──────────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search-wrap .ti-search {
  position: absolute;
  left: 10px;
  color: var(--color-text-hint);
  font-size: 16px;
  pointer-events: none;
}

.search-input {
  padding-left: 34px;
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  height: 38px;
  width: 280px;
  font-size: 13.5px;
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input::placeholder { color: var(--color-text-hint); }
.search-input:focus {
  outline: none;
  border: 1.5px solid var(--color-brand);
  box-shadow: var(--shadow-focus);
}

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  text-align: center;
  gap: var(--space-4);
}

.empty-state .ti {
  font-size: 40px;
  color: var(--color-text-hint);
}

.empty-state__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.empty-state__body {
  font-size: 13.5px;
  color: var(--color-text-hint);
  max-width: 320px;
}

/* ── Slide-Out Panel ─────────────────────────────────────────────────────── */
.panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.35);
  z-index: 200;
  backdrop-filter: blur(2px);
}

.panel-overlay.open { display: block; }

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 100%;
  background: var(--color-surface);
  border-left: 0.5px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 201;
  transform: translateX(100%);
  transition: transform 200ms ease;
  box-shadow: -8px 0 32px rgba(0,0,0,0.08);
}

.panel.open { transform: translateX(0); }

.panel__header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 0.5px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.panel__close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 20px;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
}
.panel__close:hover { color: var(--color-text); background: var(--color-bg); }

.panel__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.panel__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 0.5px solid var(--color-border);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  backdrop-filter: blur(2px);
}

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

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  border: 0.5px solid var(--color-border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal__header {
  padding: var(--space-6);
  border-bottom: 0.5px solid var(--color-border);
}

.modal__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
}

.modal__body { padding: var(--space-6); }

.modal__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 0.5px solid var(--color-border);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ── Toast Notifications ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  background: var(--color-slate);
  color: #F9FAFB;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 200ms ease, opacity 200ms ease;
  max-width: 320px;
}

.toast.show { transform: translateX(0); opacity: 1; }

.toast.toast-success { border-left: 3px solid var(--color-success); }
.toast.toast-error   { border-left: 3px solid var(--color-danger); }
.toast.toast-info    { border-left: 3px solid var(--color-brand); }

/* ── Dashboard Grid ──────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

/* ── Kanban Board ────────────────────────────────────────────────────────── */
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: var(--space-4);
  align-items: start;
  overflow-x: auto;
  padding-bottom: var(--space-4);
}

.kanban-col {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--color-border);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.kanban-col.drag-over {
  border-color: var(--color-brand);
  background: var(--color-brand-50);
}

.kanban-col__header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 0.5px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.kanban-col__title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex: 1;
}

.kanban-col__count {
  font-size: 11px;
  font-weight: 600;
  background: var(--color-border);
  color: var(--color-text-muted);
  padding: 1px 7px;
  border-radius: 10px;
}

.kanban-col__cards {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  min-height: 100px;
}

.kanban-col__total {
  padding: var(--space-2) var(--space-4);
  border-top: 0.5px solid var(--color-border);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  text-align: right;
}

.job-card {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-3) var(--space-3) calc(var(--space-3) + 3px);
  cursor: grab;
  text-decoration: none;
  display: block;
  transition: border-color var(--transition);
  border-left: 3px solid transparent;
}

.job-card:hover { border-color: var(--color-border-strong); text-decoration: none; }
.job-card:active { cursor: grabbing; }

.job-card.stage-enquiry    { border-left-color: var(--stage-enquiry-text); }
.job-card.stage-site-visit { border-left-color: var(--stage-visit-text); }
.job-card.stage-to-quote   { border-left-color: var(--stage-quote-text); }
.job-card.stage-quoted     { border-left-color: var(--stage-quoted-text); }
.job-card.stage-in-progress{ border-left-color: var(--stage-progress-text); }
.job-card.stage-done       { border-left-color: var(--stage-done-text); }

.job-card__customer {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.job-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  line-height: 1.3;
}

.job-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.job-card__date {
  font-size: 11px;
  color: var(--color-text-hint);
}

.job-card__price {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
}

/* ── Calendar ────────────────────────────────────────────────────────────── */
.calendar-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.calendar-grid {
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
}

.calendar-day-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--color-bg);
  border-bottom: 0.5px solid var(--color-border);
}

.calendar-day-header {
  padding: var(--space-2) var(--space-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  text-align: center;
}

.calendar-weeks {
  display: flex;
  flex-direction: column;
}

.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 0.5px solid var(--color-border);
}

.calendar-week:last-child { border-bottom: none; }

.calendar-day {
  min-height: 100px;
  padding: var(--space-2) var(--space-3);
  border-right: 0.5px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition);
}

.calendar-day:last-child { border-right: none; }
.calendar-day:hover { background: var(--color-bg); }
.calendar-day.today { background: var(--color-brand-50); }
.calendar-day.other-month .day-num { color: var(--color-text-hint); }

.day-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

.calendar-day.today .day-num {
  background: var(--color-brand);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.cal-job-pill {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  display: block;
}

/* ── Materials Table (job detail) ────────────────────────────────────────── */
.materials-table td:nth-child(2),
.materials-table td:nth-child(3),
.materials-table td:nth-child(4) {
  font-family: var(--font-mono);
  font-size: 13px;
}

.materials-table .editable {
  border: none;
  background: transparent;
  font: inherit;
  width: 100%;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

.materials-table .editable:focus {
  outline: 1.5px solid var(--color-brand);
  background: var(--color-surface);
}

/* ── Photos Grid ─────────────────────────────────────────────────────────── */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 0.5px solid var(--color-border);
  position: relative;
  background: var(--color-bg);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Notes Timeline ──────────────────────────────────────────────────────── */
.notes-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.note-item {
  display: flex;
  gap: var(--space-3);
}

.note-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-brand);
  margin-top: 5px;
  flex-shrink: 0;
}

.note-content { flex: 1; }
.note-text { font-size: 13.5px; line-height: 1.6; color: var(--color-text); }
.note-meta { font-size: 11px; color: var(--color-text-hint); margin-top: 2px; }

/* ── Quote Builder ───────────────────────────────────────────────────────── */
.quote-line-items {
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.quote-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) 0;
}

.quote-total-row {
  display: flex;
  gap: var(--space-6);
  align-items: center;
  font-size: 13.5px;
}

.quote-total-row span:first-child { color: var(--color-text-muted); width: 120px; text-align: right; }
.quote-total-row span:last-child  { font-family: var(--font-mono); width: 100px; text-align: right; }

.quote-total-row.grand-total {
  font-size: 16px;
  font-weight: 700;
  padding-top: var(--space-3);
  border-top: 1.5px solid var(--color-text);
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-6);
}

.tab {
  padding: 10px var(--space-4);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  margin-bottom: -1px;
}

.tab:hover { color: var(--color-text); }
.tab.active { color: var(--color-brand); border-bottom-color: var(--color-brand); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Misc Utilities ──────────────────────────────────────────────────────── */
.text-muted   { color: var(--color-text-muted); }
.text-hint    { color: var(--color-text-hint); }
.text-danger  { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-brand   { color: var(--color-brand); }

.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 600; }

.text-right  { text-align: right; }
.text-center { text-align: center; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.divider {
  height: 0;
  border: none;
  border-top: 0.5px solid var(--color-border);
  margin: var(--space-4) 0;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

/* ── Hamburger / Mobile nav ──────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .app-nav {
    transform: translateX(-100%);
  }
  .app-nav.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.2);
  }
  .app-content { margin-left: 0; }
  .page-header__mobile-toggle { display: flex; }
  .page-body { padding: var(--space-4) var(--space-4); }
  .page-header { padding: var(--space-3) var(--space-4); }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .stats-grid { grid-template-columns: 1fr; }
  .pipeline-board {
    grid-template-columns: repeat(6, 80vw);
    scroll-snap-type: x mandatory;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .kanban-col { scroll-snap-align: start; }
  .panel { width: 100%; }
  .search-input { width: 100%; }

  /* Tables to card-list on mobile */
  .table-responsive thead { display: none; }
  .table-responsive tr {
    display: block;
    padding: var(--space-3) var(--space-4);
    border-bottom: 0.5px solid var(--color-border);
  }
  .table-responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border: none;
    font-size: 13px;
  }
  .table-responsive td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
}

/* ── Nav mobile overlay ──────────────────────────────────────────────────── */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 99;
}
.nav-overlay.open { display: block; }
