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

:root {
  /* Colours */
  --bg: #0f0f11;
  --bg2: #16161a;
  --bg3: #1e1e24;
  --border: #2a2a35;
  --accent: #d4a843;
  --accent2: #b8902e;
  --text: #e8e8ee;
  --text-muted: #7a7a8c;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;

  /* Spacing */
  --space-xs: 0.25rem; /* 4px  */
  --space-sm: 0.5rem; /* 8px  */
  --space-md: 1rem; /* 16px */
  --space-lg: 1.5rem; /* 24px */
  --space-xl: 2rem; /* 32px */
  --space-2xl: 2.5rem; /* 40px */

  /* Layout */
  --sidebar-w: 13.75rem; /* 220px */
  --radius: 0.625rem; /* 10px  */
  --radius-lg: 0.875rem; /* 14px  */

  /* Typography */
  --font-head: "DM Serif Display", serif;
  --font-body: "DM Sans", sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 100;
}

.sidebar-logo {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.logo-img-wrap {
  width: 100%;
  height: 8.125rem;
  overflow: hidden;
}

.logo-img {
  width: 70%;
  display: block;
  margin: 0 auto;
  object-fit: cover;
  object-position: top center;
}

.logo-text {
  font-family: var(--font-head);
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: -0.02rem;
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.844rem;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--bg3);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent);
  color: #111;
  font-weight: 600;
}

.nav-icon {
  font-size: 0.9375rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.6875rem;
}

.sidebar-company {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.sidebar-logout {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0;
  transition: color 0.15s;
}

.sidebar-logout:hover {
  color: var(--accent);
}

/* ── MAIN ─────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  padding: 1.5rem 2rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-family: var(--font-head);
  font-size: 1.5rem;
  color: var(--text);
  font-weight: 400;
}

.topbar-actions {
  display: flex;
  gap: 0.625rem;
  align-items: center;
}

.content-area {
  padding: 1.75rem 2rem;
  flex: 1;
}

/* ── ALERTS ───────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1.25rem;
  margin: 1rem 2rem;
  border-radius: var(--radius);
  font-size: 0.844rem;
  font-weight: 500;
}
.alert-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}
.alert-info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}
.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.alert-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5625rem 1.125rem;
  border-radius: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.844rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #111;
}
.btn-primary:hover {
  background: var(--accent2);
}

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.781rem;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.3;
}

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

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

.card-title {
  font-family: var(--font-head);
  font-size: 1.0625rem;
  font-weight: 400;
  color: var(--text);
}

/* ── STATS GRID ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0.125rem;
  background: var(--accent);
  opacity: 0.5;
}

.stat-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: var(--font-head);
  font-size: 1.75rem;
  color: var(--text);
  line-height: 1;
}

.stat-value.positive {
  color: var(--green);
}
.stat-value.negative {
  color: var(--red);
}

.stat-sub {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.844rem;
}

th {
  text-align: left;
  padding: 0.625rem 0.875rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid rgba(42, 42, 53, 0.6);
  color: var(--text);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}
tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.1875rem 0.625rem;
  border-radius: 1.25rem;
  font-size: 0.719rem;
  font-weight: 600;
}
.badge-scheduled {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}
.badge-in_progress {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}
.badge-completed {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}
.badge-cancelled {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}
.badge-active {
  background: rgba(200, 245, 66, 0.12);
  color: var(--accent);
}

/* ── FORMS ────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group.full {
  grid-column: 1 / -1;
}

label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05rem;
}

input,
select,
textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color 0.15s;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  min-height: 5.625rem;
  resize: vertical;
}

select option {
  background: var(--bg2);
}

.form-actions {
  display: flex;
  gap: 0.625rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

/* ── MATERIAL ROWS ────────────────────────────────────────── */
.material-row {
  display: grid;
  grid-template-columns: 1fr 7.5rem 2.5rem;
  gap: 0.625rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.remove-material {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 1.125rem;
  padding: 0.25rem;
  line-height: 1;
}

/* ── DISTANCE BOX ─────────────────────────────────────────── */
.distance-info {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  display: flex;
  gap: 1.5rem;
  font-size: 0.8125rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.distance-info span {
  color: var(--text-muted);
}
.distance-info strong {
  color: var(--accent);
}

/* ── GRIDS ────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

/* ── PROFIT INDICATOR ─────────────────────────────────────── */
.profit-positive {
  color: var(--green);
  font-weight: 600;
}
.profit-negative {
  color: var(--red);
  font-weight: 600;
}

/* ── CALENDAR ─────────────────────────────────────────────── */
#calendar {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 1rem;
}

.fc {
  font-family: var(--font-body);
}
.fc-toolbar-title {
  font-family: var(--font-head);
  font-size: 1.25rem !important;
  color: var(--text) !important;
}
.fc-button {
  background: var(--bg3) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-family: var(--font-body) !important;
}
.fc-button:hover {
  background: var(--border) !important;
}
.fc-button-active,
.fc-button-primary:not(:disabled).fc-button-active {
  background: var(--accent) !important;
  color: #111 !important;
  border-color: var(--accent) !important;
}
.fc-col-header-cell {
  background: var(--bg3);
}
.fc-col-header-cell-cushion {
  color: var(--text-muted) !important;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.031rem;
}
.fc-daygrid-day {
  background: var(--bg2);
}
.fc-daygrid-day:hover {
  background: var(--bg3);
}
.fc-daygrid-day-number {
  color: var(--text-muted) !important;
  font-size: 0.8125rem;
}
.fc-day-today {
  background: rgba(212, 168, 67, 0.08) !important;
}
.fc-day-today .fc-daygrid-day-number {
  color: var(--accent) !important;
  font-weight: 700;
}
.fc-col-header-cell.fc-day-today {
  background: rgba(212, 168, 67, 0.12) !important;
}
.fc .fc-scrollgrid-section-sticky .fc-col-header-cell.fc-day-today,
.fc .fc-scroller-harness .fc-col-header-cell.fc-day-today {
  background: var(--bg3) !important;
  border-bottom: 2px solid var(--accent) !important;
}
.fc-col-header-cell.fc-day-today .fc-col-header-cell-cushion {
  color: var(--accent) !important;
  font-weight: 700;
}
.fc-timegrid-col.fc-day-today {
  background: rgba(212, 168, 67, 0.05) !important;
}
.fc-timegrid-axis {
  background: var(--bg3) !important;
}
.fc-event {
  border-radius: 0.375rem !important;
  border: none !important;
  padding: 0.125rem 0.375rem !important;
  font-size: 0.75rem !important;
}
.fc-event-title {
  font-weight: 500 !important;
}
.fc-timegrid-slot-label {
  color: var(--text-muted) !important;
  font-size: 0.75rem !important;
}
.fc-scrollgrid {
  border-color: var(--border) !important;
}
.fc-scrollgrid td,
.fc-scrollgrid th {
  border-color: var(--border) !important;
}

/* List view */
.fc-list {
  border-color: var(--border) !important;
}
.fc-list-day-cushion,
.fc-list-day th {
  background: var(--bg3) !important;
}
.fc-list-day-text,
.fc-list-day-side-text {
  color: var(--text-muted) !important;
  text-decoration: none !important;
}
.fc-list-event td {
  background: var(--bg2) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
.fc-list-event:hover td {
  background: var(--bg3) !important;
}
.fc-list-event-title a {
  color: var(--text) !important;
  text-decoration: none !important;
}
.fc-list-empty {
  background: var(--bg2) !important;
  color: var(--text-muted) !important;
}

/* TimeGrid view */
.fc-timegrid-slot {
  border-color: var(--border) !important;
}
.fc-timegrid-col {
  background: var(--bg2) !important;
}
.fc-timegrid-now-indicator-line {
  border-color: var(--accent) !important;
}
.fc-timegrid-now-indicator-arrow {
  border-top-color: var(--accent) !important;
}

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  width: 30rem;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-hidden {
  display: none;
}

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

.modal-title {
  font-family: var(--font-head);
  font-size: 1.1875rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  font-size: 0.844rem;
}

.modal-notes {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.modal-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

/* ── REPORT SECTIONS ──────────────────────────────────────── */
.report-section {
  margin-bottom: 1.75rem;
}
.report-section h3 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ── MISC ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.75rem 1.25rem;
  color: var(--text-muted);
}
.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}
.empty-state p {
  font-size: 0.9375rem;
  margin-bottom: 1rem;
}

.pill {
  display: inline-block;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 0.1875rem 0.625rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── INVOICE TABLE ────────────────────────────────────────── */
.invoice-header-actions {
  display: flex;
  gap: 0.5rem;
}

.col-check {
  width: 2rem;
}

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

.invoice-status-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.invoice-status-cell .btn-xs {
  white-space: nowrap;
}

.form-inline {
  display: inline;
}


tr.row-warning td {
  background: rgba(239, 68, 68, 0.05);
}
tr.row-detail td {
  padding-top: 0;
  border-top: none;
}
.job-detail-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
}

.job-invoiced {
  text-decoration: line-through;
  opacity: 0.55;
}

/* ── INVOICE PREVIEW MODAL ───────────────────────────────── */
.invoice-preview-modal {
  max-width: 43.75rem;
  width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.invoice-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.modal-close-btn:hover { color: var(--text); background: var(--bg3); }

.preview-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.preview-intro {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-style: italic;
}

.preview-table {
  width: 100%;
}

.preview-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.preview-desc {
  font-size: 0.875rem;
  white-space: pre-line;
}

.preview-qty,
.preview-unit,
.preview-price,
.preview-total {
  text-align: right;
  font-size: 0.875rem;
  white-space: nowrap;
}

.preview-remark {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── COLOUR UTILS ─────────────────────────────────────────── */
.link-strong {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.link-strong:hover { text-decoration: underline; }
.text-muted {
  color: var(--text-muted);
}
.text-accent {
  color: var(--accent);
}
.text-green {
  color: var(--green);
}
.text-red {
  color: var(--red);
}
.text-yellow {
  color: var(--yellow);
}

/* ── SPACING UTILS ────────────────────────────────────────── */
.mb-4 {
  margin-bottom: 1rem;
}
.mb-5 {
  margin-bottom: 1.25rem;
}
.mb-6 {
  margin-bottom: 1.5rem;
}
.mt-4 {
  margin-top: 1rem;
}
.mt-5 {
  margin-top: 1.25rem;
}

/* ── LAYOUT UTILS ─────────────────────────────────────────── */
.flex {
  display: flex;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.gap-2 {
  gap: 0.5rem;
}

/* ── CHART ────────────────────────────────────────────────── */
.chart-box {
  position: relative;
  height: 12.5rem;
}

/* ── MONTH SELECTOR ───────────────────────────────────────── */
.month-selector {
  display: flex;
  gap: 0.625rem;
  margin-bottom: 1.5rem;
  align-items: center;
}
.month-selector select {
  width: auto;
  padding: 0.5rem 0.75rem;
}

/* ── FILTER TABS ──────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.844rem;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--bg2);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
  cursor: pointer;
}

.filter-tab:hover {
  color: var(--text);
  border-color: #3a3a45;
}

.filter-tab.active {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 600;
}

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 0.625rem;
  font-size: 0.6875rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
}

.filter-tab.active .filter-count {
  background: rgba(0, 0, 0, 0.15);
}

/* ── AUTH PAGES ───────────────────────────────────────────── */
.auth-page {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-md);
}

.auth-container {
  width: 100%;
  max-width: 27.5rem;
}
.auth-container-wide {
  width: 100%;
  max-width: 31.25rem;
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.auth-logo-img {
  width: 10rem;
  height: 10rem;
  object-fit: cover;
  object-position: top center;
  transform: scale(1.1);
  transform-origin: top center;
  display: block;
  margin: 0 auto var(--space-md);
}

.auth-logo h1 {
  font-family: var(--font-head);
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--text);
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: var(--space-xs);
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-card h2 {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 400;
  margin-bottom: var(--space-sm);
  color: var(--text);
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.auth-card p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: var(--space-md);
  line-height: 1.6;
}

.auth-footer,
.auth-back {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-footer a,
.auth-back a {
  color: var(--accent);
  text-decoration: none;
}

.auth-footer a:hover,
.auth-back a:hover {
  text-decoration: underline;
}

.auth-link-block {
  display: block;
  margin-bottom: 0.625rem;
}

.section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
  margin-bottom: var(--space-sm);
  margin-top: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.info-box {
  background: rgba(212, 168, 67, 0.06);
  border: 1px solid rgba(212, 168, 67, 0.2);
  border-radius: var(--radius);
  padding: 0.75rem var(--space-md);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.info-box strong {
  color: var(--accent);
}

.pw-strength {
  height: 0.1875rem;
  border-radius: 0.125rem;
  margin-top: var(--space-xs);
  background: var(--border);
  overflow: hidden;
}

.pw-strength-bar {
  height: 100%;
  width: 0;
  transition: all 0.3s;
  border-radius: 0.125rem;
}

.btn-auth {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: var(--radius);
  padding: 0.8125rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}

.btn-auth:hover {
  background: var(--accent2);
}

/* ── PAGE WIDTH WRAPPERS ──────────────────────────────────── */
.page-narrow {
  max-width: 31.25rem;
}
.page-medium {
  max-width: 43.75rem;
}
.page-wide {
  max-width: 51.25rem;
}
.page-max {
  max-width: 56.25rem;
}
.page-settings {
  max-width: 50rem;
}

.settings-panel {
  display: none;
  max-width: 50rem;
}

.settings-panel.active {
  display: block;
}

/* ── TYPOGRAPHY UTILS ─────────────────────────────────────── */
.text-sm {
  font-size: 0.75rem;
}
.table-sm {
  font-size: 0.8125rem;
}

/* ── FIELD META LABEL ─────────────────────────────────────── */
.field-meta {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  margin-bottom: 0.1875rem;
  color: var(--text-muted);
}

/* ── INFO GRID ────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
  font-size: 0.844rem;
}

/* ── NOTES BOX ────────────────────────────────────────────── */
.notes-box {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
  font-size: 0.844rem;
  color: var(--text-muted);
}

/* ── STATUS BUTTONS ───────────────────────────────────────── */
.status-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── RECURRENCE INFO ──────────────────────────────────────── */
.recurrence-info {
  margin-top: 0.875rem;
  padding: 0.625rem 0.875rem;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 0.5rem;
  font-size: 0.8125rem;
}

/* ── DELETE SECTION ───────────────────────────────────────── */
.delete-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.delete-children-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  cursor: pointer;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
}

/* ── FINANCIAL LIST ───────────────────────────────────────── */
.fin-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  font-size: 0.844rem;
}

.fin-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.fin-row-total {
  display: flex;
  justify-content: space-between;
  padding: 0.625rem 0;
  margin-top: 0.25rem;
}

.fin-label-lg {
  font-size: 0.9375rem;
}
.fin-value-lg {
  font-size: 1.125rem;
}

/* ── RECURRENCE SECTION ───────────────────────────────────── */
.recurrence-box {
  margin-top: 1.25rem;
  padding: 1.125rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 0.625rem;
}

.recurrence-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.875rem;
}

.recurrence-header h3 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 400;
}

.recurrence-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── SECTION BOX ──────────────────────────────────────────── */
.section-box {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.section-box h3 {
  font-family: var(--font-head);
  font-weight: 400;
  font-size: 1.0625rem;
}

/* ── INFO PANEL ───────────────────────────────────────────── */
.info-panel {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg3);
  border-radius: 0.5rem;
  font-size: 0.781rem;
  color: var(--text-muted);
}

.info-panel a {
  color: var(--accent);
}

/* ── RADIO GROUP ──────────────────────────────────────────── */
.radio-group {
  display: flex;
  gap: 1.5rem;
  padding: 0.5rem 0;
}
.radio-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-weight: 500;
}
.radio-option input[type="radio"] {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

/* ── CALENDAR LEGEND ──────────────────────────────────────── */
.cal-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8125rem;
}

.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.cal-legend-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 0.1875rem;
  display: inline-block;
  flex-shrink: 0;
}

.cal-legend-dot--blue {
  background: var(--blue);
}
.cal-legend-dot--amber {
  background: var(--yellow);
}
.cal-legend-dot--green {
  background: var(--green);
}
.cal-legend-dot--red {
  background: var(--red);
}

/* ── ROW & BUTTON UTILS ───────────────────────────────────── */
.row-inactive {
  opacity: 0.55;
}
.btn-group {
  display: flex;
  gap: 0.375rem;
}
.input-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── FIRM INFO ────────────────────────────────────────────── */
.firm-info {
  display: grid;
  gap: 0.75rem;
  font-size: 0.844rem;
}
.firm-stats {
  display: flex;
  gap: 1rem;
}

/* ── INVITE SECTION ───────────────────────────────────────── */
.invite-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.invite-section h3 {
  font-family: var(--font-head);
  font-size: 0.9375rem;
  font-weight: 400;
  margin-bottom: 0.875rem;
}

.invite-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin-bottom: 0.625rem;
}

/* ── STAT VALUE SMALL ─────────────────────────────────────── */
.stat-value-sm {
  font-family: var(--font-head);
  font-size: 1.375rem;
  line-height: 1;
}

/* ── MONTH TITLE ──────────────────────────────────────────── */
.month-title {
  font-size: 0.9375rem;
  font-family: var(--font-head);
  color: var(--text-muted);
}

/* ── QUICK LINK CARD ──────────────────────────────────────── */
.quick-link-card {
  text-decoration: none;
  display: block;
  text-align: center;
}

.quick-link-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.quick-link-card .stat-value {
  font-size: 2.25rem;
}
.quick-link-card .stat-label {
  text-align: center;
  margin-top: 0.25rem;
}

/* ── HAMBURGER BUTTON ─────────────────────────────────────── */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.125rem;
  cursor: pointer;
  padding: 0.375rem;
  margin-right: 0.625rem;
  line-height: 1;
}

.topbar-left {
  display: flex;
  align-items: center;
}

/* ── SIDEBAR OVERLAY ──────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 299;
  backdrop-filter: blur(2px);
}

/* ── MOBILE BREAKPOINT ────────────────────────────────────── */
@media (max-width: 768px) {

  /* Show hamburger */
  .menu-toggle {
    display: block;
  }

  /* Sidebar: hidden off-screen, slides in */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 300;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0.5rem 0 2rem rgba(0, 0, 0, 0.4);
  }
  body.menu-open {
    overflow: hidden;
  }

  /* Overlay */
  .sidebar-overlay.open {
    display: block;
  }

  /* Main content full width */
  .main-content {
    margin-left: 0;
  }

  /* Topbar */
  .topbar {
    padding: 0.875rem 1rem;
  }

  .page-title {
    font-size: 1.125rem;
  }

  /* Content area */
  .content-area {
    padding: 1rem;
  }

  /* Alerts */
  .alert {
    margin: 0.75rem 1rem;
  }

  /* Stats grid: 2 columns on mobile */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
  }

  /* All other grids: single column */
  .two-col,
  .three-col,
  .form-grid,
  .info-grid,
  .invite-grid,
  .modal-grid {
    grid-template-columns: 1fr;
  }

  /* Page width wrappers: full width */
  .page-narrow,
  .page-medium,
  .page-wide,
  .page-max,
  .page-settings {
    max-width: 100%;
  }

  /* Modal: full width */
  .modal {
    width: calc(100vw - 2rem);
    max-height: 90vh;
    margin: 1rem;
  }

  /* Material row: tighter */
  .material-row {
    grid-template-columns: 1fr 5.5rem 2.5rem;
  }

  /* Month selector: stack */
  .month-selector {
    flex-wrap: wrap;
  }

  /* Filter tabs: scroll horizontally */
  .filter-tabs {
    overflow-x: auto;
    padding-bottom: 0.25rem;
    flex-wrap: nowrap;
  }

  /* Form actions: stack buttons */
  .form-actions {
    flex-wrap: wrap;
  }

  /* Status buttons: wrap */
  .status-buttons {
    flex-wrap: wrap;
  }

  /* Table: allow horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Calendar */
  #calendar {
    padding: 0.5rem;
  }

  .fc-toolbar.fc-header-toolbar {
    flex-direction: column;
    gap: 0.5rem;
  }

  /* Quick link cards: 3-col stays but smaller */
  .quick-link-card .stat-value {
    font-size: 1.5rem;
  }

  /* Firm stats wrap */
  .firm-stats {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* ── SMALL PHONES ─────────────────────────────────────────── */
@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .three-col {
    grid-template-columns: 1fr;
  }

  .topbar-actions .btn {
    font-size: 0.75rem;
    padding: 0.4375rem 0.75rem;
  }
}

/* ── COLUMN VISIBILITY ────────────────────────────────────── */
@media (max-width: 768px) {
  .col-hide-mobile {
    display: none;
  }

  .invoice-status-cell .btn-xs {
    display: none;
  }

  /* Lock page width — only .table-wrap scrolls internally */
  body,
  .main-content,
  .content-area {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* table-wrap becomes the scroll container, contained within card */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── GEOCODE ROW ──────────────────────────────────────────── */
.geocode-row {
  display: flex;
  gap: 0.5rem;
}

.geocode-row input {
  flex: 1;
}

.geocode-row .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.geocode-status {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  min-height: 1rem;
}

.geocode-ok {
  color: var(--green);
}

.geocode-err {
  color: var(--red);
}

/* ── QUICK STATUS BUTTONS ─────────────────────────────────── */
.status-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.status-quick-btns {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.btn-status {
  padding: 0.375rem 0.875rem;
  border-radius: 1.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--s-color);
  background: transparent;
  color: var(--s-color);
  transition: all 0.15s ease;
  font-family: var(--font-body);
}

.btn-status:hover {
  background: var(--s-color);
  color: #111;
}

.btn-status--active {
  background: var(--s-color);
  color: #111;
}

.btn-status:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status-feedback {
  font-size: 0.75rem;
  margin-top: 0.375rem;
  min-height: 1rem;
}

.status-feedback--ok  { color: var(--green); }
.status-feedback--err { color: var(--red); }

/* ── STATUS BADGE PICKER ──────────────────────────────────── */
.badge-clickable {
  cursor: pointer;
  user-select: none;
}
.badge-clickable:hover {
  opacity: 0.85;
}

.status-picker {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.375rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.375rem;
  width: 9rem;
}

.status-pick-btn {
  background: none;
  border: none;
  text-align: left;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-family: var(--font-body);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s;
}
.status-pick-btn:hover {
  background: var(--border);
  color: var(--text);
}
.status-pick-btn--active {
  color: var(--accent);
  font-weight: 600;
}

/* ── CUSTOM CONFIRM MODAL ─────────────────────────────────── */
.confirm-modal {
  max-width: 22rem;
  text-align: center;
  padding: 2rem 1.75rem;
}

.confirm-icon {
  font-size: 2.25rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.confirm-title {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 400;
  margin-bottom: 0.625rem;
  color: var(--text);
}

.confirm-message {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.confirm-actions {
  display: flex;
  gap: 0.625rem;
  justify-content: center;
}
