/* ============================================================
   Attorney Billing System — Design System
   Corporate Navy / Warm Gold palette
   ============================================================ */

/* ── Custom properties ──────────────────────────────────────── */
:root {
  /* Brand — overridden per-user by inline <style> from settings */
  --color-primary:      #0F2044;
  --color-primary-700:  #1A3060;
  --color-primary-500:  #243B6E;
  --color-primary-300:  #3A568A;
  --color-accent:       #B8965A;
  --color-accent-light: #CCA96E;
  --color-accent-muted: rgba(184,150,90,.15);
  --color-bg:           #F4F2EE;

  /* Neutrals */
  --color-surface:      #FFFFFF;
  --color-surface-2:    #F9F8F6;
  --color-border:       #E2DDD6;
  --color-border-light: #EDE9E3;
  --color-text:         #1C1C2E;
  --color-text-muted:   #64687A;
  --color-text-light:   #9CA3AF;

  /* Semantic */
  --color-success:      #1A6B47;
  --color-success-bg:   #D1FAE5;
  --color-warning:      #92400E;
  --color-warning-bg:   #FEF3C7;
  --color-danger:       #9B1C1C;
  --color-danger-bg:    #FEE2E2;
  --color-info:         #1E3A8A;
  --color-info-bg:      #DBEAFE;

  /* Layout */
  --sidebar-width:      260px;
  --topbar-height:      60px;

  /* Tokens */
  --radius:    8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(15,32,68,.07);
  --shadow:    0 2px 8px rgba(15,32,68,.10);
  --shadow-lg: 0 8px 24px rgba(15,32,68,.15);
  --transition: 150ms ease;

  /* Typography */
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono:    'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: .9rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
svg { display: inline-block; vertical-align: middle; }

/* ── App shell ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform var(--transition);
}

.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar header ─────────────────────────────────────────── */
.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-logo { max-height: 48px; width: auto; object-fit: contain; }
.sidebar-firm-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  letter-spacing: .01em;
}

/* ── Nav list ───────────────────────────────────────────────── */
.nav-list {
  list-style: none;
  padding: 12px 0;
  flex: 1;
}
.nav-section {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 20px 20px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.72);
  font-size: .82rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.nav-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link.active {
  background: var(--color-accent-muted);
  color: var(--color-accent-light);
  border-left: 3px solid var(--color-accent);
  padding-left: 17px;
}

/* ── Sidebar footer ─────────────────────────────────────────── */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-primary);
  font-weight: 700;
  font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { font-size: .8rem; font-weight: 600; color: #fff; }
.user-role { font-size: .7rem; color: rgba(255,255,255,.45); }
.btn-logout {
  display: block;
  text-align: center;
  padding: 6px;
  font-size: .75rem;
  color: rgba(255,255,255,.5);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.btn-logout:hover { color: #fff; border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.05); text-decoration: none; }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary);
  flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px;
}
.sidebar-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

/* ── Page content ───────────────────────────────────────────── */
.page-content {
  padding: 28px;
  flex: 1;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
  flex-wrap: wrap;
}
.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
}
.card-body { padding: 24px; }
.card-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  font-size: .8rem;
  color: var(--color-text-muted);
}

/* ── Stat grid ──────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-sub { font-size: .75rem; color: var(--color-text-muted); }

/* ── Dashboard grid ─────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}
.dashboard-quick {}
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  background: var(--color-surface);
  color: var(--color-primary);
  font-size: .78rem;
  font-weight: 500;
  text-align: center;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.quick-action svg { width: 22px; height: 22px; fill: none; stroke: var(--color-accent); stroke-width: 1.8; }
.quick-action:hover { background: var(--color-accent-muted); text-decoration: none; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}
.table th {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  text-align: left;
}
.table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(184,150,90,.04); }
.table tfoot td {
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-surface-2);
  border-top: 2px solid var(--color-border);
}
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.cell-primary { font-weight: 500; color: var(--color-text); }
.cell-sub { font-size: .75rem; color: var(--color-text-muted); margin-top: 1px; }
.desc-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-row { text-align: center; color: var(--color-text-muted); padding: 32px !important; }
.mono { font-family: var(--font-mono); font-size: .8rem; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge-draft   { background: #F3F4F6; color: #6B7280; }
.badge-sent    { background: var(--color-info-bg); color: var(--color-info); }
.badge-paid    { background: var(--color-success-bg); color: var(--color-success); }
.badge-void    { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-open    { background: var(--color-info-bg); color: var(--color-info); }
.badge-closed  { background: #F3F4F6; color: #6B7280; }
.badge-running { background: var(--color-success-bg); color: var(--color-success); }
.badge-deposit { background: var(--color-success-bg); color: var(--color-success); }
.badge-disbursement { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-transfer { background: var(--color-info-bg); color: var(--color-info); }
.badge-adjustment { background: var(--color-warning-bg); color: var(--color-warning); }

/* Practice area badges */
.badge-corp     { background: #EDE9FE; color: #5B21B6; }
.badge-realty   { background: #D1FAE5; color: #065F46; }
.badge-finance  { background: #DBEAFE; color: #1E3A8A; }
.badge-general  { background: #F3F4F6; color: #374151; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }

.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-700); border-color: var(--color-primary-700); }

.btn-accent { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.btn-accent:hover { background: var(--color-accent-light); border-color: var(--color-accent-light); }

.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-border); }
.btn-outline:hover { background: var(--color-surface-2); }

.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { opacity: .88; }

.btn-success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.btn-success:hover { opacity: .88; }

.btn-sm { padding: 5px 12px; font-size: .78rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 11px 28px; font-size: .95rem; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled], .btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  letter-spacing: .02em;
}
.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: .87rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
}
.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-muted);
}
select.form-control,
select.form-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 34px;
}
textarea.form-control { resize: vertical; min-height: 90px; }
.form-control[readonly],
.form-select[readonly] { background: var(--color-surface-2); color: var(--color-text-muted); }

/* ── File upload inputs ─────────────────────────────────────── */
input[type=file].form-control {
  padding: 6px 10px;
  cursor: pointer;
  line-height: 1.6;
}
input[type=file].form-control::file-selector-button {
  padding: 5px 14px;
  margin-right: 12px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
  letter-spacing: .02em;
}
input[type=file].form-control::file-selector-button:hover { opacity: .88; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-hint { font-size: .73rem; color: var(--color-text-muted); margin-top: 4px; }
.form-error { font-size: .73rem; color: var(--color-danger); margin-top: 4px; }
.form-section-title {
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
  margin: 24px 0 16px;
}

/* Checkbox / toggle */
.checkbox-group { display: flex; align-items: center; gap: 8px; }
.checkbox-group input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--color-accent); cursor: pointer; }
.checkbox-group label { margin-bottom: 0; font-size: .85rem; cursor: pointer; }

.toggle-switch { display: flex; align-items: center; gap: 10px; }
.toggle-switch input[type=checkbox] { display: none; }
.toggle-track {
  width: 40px; height: 22px;
  background: var(--color-border);
  border-radius: 99px;
  cursor: pointer;
  position: relative;
  transition: background var(--transition);
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}
input[type=checkbox]:checked + .toggle-track { background: var(--color-accent); }
input[type=checkbox]:checked + .toggle-track::after { transform: translateX(18px); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 16px;
  border-left: 4px solid transparent;
}
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success); }
.alert-error   { background: var(--color-danger-bg);  color: var(--color-danger);  border-color: var(--color-danger); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: var(--color-warning); }
.alert-info    { background: var(--color-info-bg);    color: var(--color-info);    border-color: var(--color-info); }

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}
.filter-bar .form-control,
.filter-bar .form-select { width: auto; min-width: 140px; font-size: .82rem; padding: 7px 10px; padding-right: 30px; }
.search-input {
  display: block;
  min-width: 220px;
  padding: 7px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: .82rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}
.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-muted);
}
.form-control-sm,
.form-select-sm  { padding: 5px 9px; font-size: .8rem; }
select.form-select-sm { padding-right: 28px; background-size: 12px; background-position: right 8px center; }
.filter-bar-stacked { align-items: flex-start; }
.filter-bar-stacked .filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-bar-stacked .filter-group label { font-size: .72rem; color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; margin: 0; }
.filter-bar .btn { padding: 7px 14px; }

/* ── Breadcrumbs ────────────────────────────────────────────── */
.breadcrumbs { margin-bottom: 20px; }
.breadcrumbs ol { display: flex; list-style: none; gap: 4px; flex-wrap: wrap; }
.breadcrumbs li { font-size: .78rem; color: var(--color-text-muted); display: flex; align-items: center; }
.breadcrumbs li:not(:last-child)::after { content: '›'; margin-left: 4px; color: var(--color-text-light); }
.breadcrumbs li a { color: var(--color-accent); }
.breadcrumbs li.current { color: var(--color-text); font-weight: 500; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 24px;
  border-top: 1px solid var(--color-border);
  justify-content: flex-end;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  text-decoration: none;
  transition: all var(--transition);
}
.page-link:hover { border-color: var(--color-accent); color: var(--color-accent); text-decoration: none; }
.page-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.page-info { font-size: .78rem; color: var(--color-text-muted); margin-right: auto; }

/* ── Initials chip ──────────────────────────────────────────── */
.initials-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-accent);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .02em;
}

/* ── Section tabs ───────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab-link {
  padding: 10px 20px;
  font-size: .83rem;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  text-decoration: none;
}
.tab-link:hover { color: var(--color-primary); text-decoration: none; }
.tab-link.active { color: var(--color-accent); border-color: var(--color-accent); font-weight: 600; }

/* ── Text helpers ───────────────────────────────────────────── */
.text-muted   { color: var(--color-text-muted) !important; }
.text-danger  { color: var(--color-danger) !important; }
.text-success { color: var(--color-success) !important; }
.text-accent  { color: var(--color-accent) !important; }
.text-primary { color: var(--color-primary) !important; }
.fw-bold   { font-weight: 700 !important; }
.fw-600    { font-weight: 600 !important; }
.font-mono { font-family: var(--font-mono) !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.ml-auto { margin-left: auto; }

/* ── Timer widget (topbar) ──────────────────────────────────── */
#timerWidget .timer-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-success-bg);
  border: 1px solid var(--color-success);
  color: var(--color-success);
  border-radius: 99px;
  padding: 5px 14px;
  font-size: .8rem;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  text-decoration: none;
}
#timerWidget .timer-mini:hover { text-decoration: none; }
.timer-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* ── Timer page ─────────────────────────────────────────────── */
.timer-page { max-width: 680px; margin: 0 auto; }
.timer-clock {
  font-family: var(--font-mono);
  font-size: 4.5rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: .05em;
  text-align: center;
  padding: 36px 20px;
}
.timer-clock.running { color: var(--color-success); }
.timer-clock.paused  { color: var(--color-warning); }
.timer-controls { display: flex; justify-content: center; gap: 12px; margin-bottom: 28px; flex-wrap: wrap; }
.timer-btn {
  padding: 12px 32px;
  border-radius: 99px;
  font-size: .9rem;
  font-weight: 600;
  min-width: 120px;
  justify-content: center;
}

/* ── Login page ─────────────────────────────────────────────── */
body.login-page {
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-wrap {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo { max-height: 60px; margin: 0 auto 12px; }
.login-firm-name {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}
.login-tagline { font-size: .8rem; color: rgba(255,255,255,.5); letter-spacing: .04em; }
.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 40px;
  width: 100%;
}
.login-card h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--color-primary);
  margin-bottom: 22px;
}
.login-footer { color: rgba(255,255,255,.3); font-size: .72rem; margin-top: 20px; }

/* ── Color picker preview ───────────────────────────────────── */
.color-input-wrap { display: flex; align-items: center; gap: 10px; }
.color-input-wrap input[type=color] {
  width: 40px; height: 36px;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
}
.color-input-wrap input[type=text] { flex: 1; }

/* ── Invoice totals summary ─────────────────────────────────── */
.invoice-summary {
  margin-left: auto;
  width: 340px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: .88rem;
}
.invoice-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border-light);
}
.invoice-summary-row:last-child { border-bottom: none; }
.invoice-summary-row.total {
  font-weight: 700;
  font-size: 1rem;
  background: var(--color-primary);
  color: #fff;
}
.invoice-summary-row.balance-due {
  font-weight: 700;
  color: var(--color-danger);
  background: var(--color-danger-bg);
}
.invoice-summary-row.paid-off {
  font-weight: 700;
  color: var(--color-success);
  background: var(--color-success-bg);
}

/* ── Trust balance card ─────────────────────────────────────── */
.trust-balance-card {
  border-left: 4px solid var(--color-accent);
}
.trust-balance-amount {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  font-family: var(--font-mono);
}

/* ── Settings sections ──────────────────────────────────────── */
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: 28px; align-items: start; }
.settings-nav { position: sticky; top: 80px; }
.settings-nav-link {
  display: block;
  padding: 8px 12px;
  font-size: .82rem;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-decoration: none;
}
.settings-nav-link:hover { background: var(--color-surface-2); color: var(--color-primary); text-decoration: none; }
.settings-nav-link.active { background: var(--color-accent-muted); color: var(--color-accent); font-weight: 600; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
}

@media (max-width: 700px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .stat-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .timer-clock { font-size: 3rem; }
}

/* ── Page header: keep title and action button from abutting ─── */
.d-flex.justify-content-between.align-items-center {
  gap: 1rem;
}

/* ── Page header (title + action buttons row) ───────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-header-left { flex: 1; min-width: 0; }
.page-header-left .page-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}
.page-subtitle {
  font-size: .83rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding-top: 6px; /* align with multi-line titles */
}

/* ── Card header actions group ──────────────────────────────── */
.card-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.card-header-meta {
  font-size: .78rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ── Detail two-column layout ───────────────────────────────── */
.detail-layout { display: grid; gap: 24px; align-items: start; }
.detail-layout.two-col { grid-template-columns: 1fr 1fr; }
.detail-col {}

/* ── Detail grid (label/value pairs inside a card) ──────────── */
.detail-grid { display: flex; flex-direction: column; gap: 12px; }
.detail-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  align-items: baseline;
}
.detail-item-full { grid-template-columns: 1fr; gap: 4px; }
.detail-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.detail-value { font-size: .88rem; color: var(--color-text); }
.text-pre { white-space: pre-wrap; word-break: break-word; }

/* ── Empty states ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: .88rem;
}
.empty-state-sm {
  padding: 24px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: .85rem;
}

/* ── Table utilities ─────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.text-nowrap { white-space: nowrap !important; }
.text-mono, .font-mono { font-family: var(--font-mono) !important; font-size: .82rem; }
.table-total td { font-weight: 700; background: var(--color-surface-2); border-top: 2px solid var(--color-border); }
.table-grand-total td { font-weight: 700; background: var(--color-surface-2); border-top: 1px solid var(--color-border); color: var(--color-primary); }
.table-hover tbody tr:hover td { background: rgba(184,150,90,.04); }
.row-billed td { background: rgba(209,250,229,.25); }
.row-nc td { background: rgba(243,244,246,.5); color: var(--color-text-muted); }
.col-check { width: 36px; text-align: center !important; }
.actions-cell { white-space: nowrap; }
.truncate-200 { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.truncate-300 { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-primary { color: var(--color-primary); font-weight: 500; }
.link-primary:hover { color: var(--color-accent); }

/* ── Badge additions ─────────────────────────────────────────── */
.badge-neutral   { background: #F3F4F6; color: #4B5563; }
.badge-blue      { background: var(--color-info-bg); color: var(--color-info); }
.badge-purple    { background: #EDE9FE; color: #5B21B6; }
.badge-success   { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning   { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-info      { background: var(--color-info-bg); color: var(--color-info); }
.badge-secondary { background: #F3F4F6; color: #6B7280; }
.badge-accent    { background: var(--color-accent-muted); color: var(--color-accent); }

/* ── Form helpers ────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  letter-spacing: .02em;
}
.required { color: var(--color-danger); margin-left: 2px; }
.form-control-static {
  padding: 8px 0;
  font-size: .88rem;
  color: var(--color-text);
  min-height: 38px;
  display: flex;
  align-items: center;
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 500;
}
.checkbox-label input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--color-accent); cursor: pointer; }
.btn-inline-link {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  font-size: .75rem;
  font-weight: 600;
  padding: 0 4px;
  text-decoration: underline;
}
.btn-inline-link:hover { color: var(--color-accent-light); }
.input-prefix { position: relative; display: flex; align-items: stretch; }
.input-prefix .prefix-symbol {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: .88rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.input-prefix .form-control {
  border-radius: 0 var(--radius) var(--radius) 0;
}
.form-container { max-width: 900px; }
.form-container-narrow { max-width: 680px; }

/* ── Filter bar (stacked variant) ────────────────────────────── */
.filter-bar.filter-bar-stacked { flex-direction: column; align-items: stretch; padding: 16px 20px; }
.filter-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group-wide { flex: 1; min-width: 180px; }
.filter-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
}
.filter-actions { display: flex; gap: 6px; align-items: flex-end; padding-bottom: 1px; }
.filter-summary {
  font-size: .78rem;
  color: var(--color-text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--color-border-light);
  margin-top: 4px;
}

/* ── Bulk-action bar ─────────────────────────────────────────── */
.bulk-actions { display: flex; align-items: center; gap: 10px; }
.bulk-count { font-size: .8rem; font-weight: 600; color: var(--color-accent); }

/* ── Pagination (btn variant) ────────────────────────────────── */
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  text-decoration: none;
  transition: all var(--transition);
}
.pagination-btn:hover { border-color: var(--color-accent); color: var(--color-accent); text-decoration: none; }
.pagination-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination-info { font-size: .78rem; color: var(--color-text-muted); }

/* ── Spacing utilities ───────────────────────────────────────── */
.mt-1 { margin-top:  4px !important; }
.mt-2 { margin-top:  8px !important; }
.mt-3 { margin-top: 16px !important; }
.mt-4 { margin-top: 24px !important; }
.mb-1 { margin-bottom:  4px !important; }
.mb-2 { margin-bottom:  8px !important; }
.mb-3 { margin-bottom: 16px !important; }
.mb-4 { margin-bottom: 24px !important; }
.ml-1 { margin-left:  4px !important; }
.ml-2 { margin-left:  8px !important; }
.mr-1 { margin-right: 4px !important; }
.mr-2 { margin-right: 8px !important; }
.font-medium { font-weight: 500 !important; }
.text-warning { color: var(--color-warning) !important; }

/* ── Responsive additions ────────────────────────────────────── */
@media (max-width: 900px) {
  .detail-layout.two-col { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-actions { padding-top: 0; }
}

/* ── Print overrides (for non-invoice pages) ────────────────── */
@media print {
  .sidebar, .topbar, .btn, .filter-bar, .pagination { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}