/* Art direction: Architecture firm billing tool → professional, structured, efficient
   Palette: Deep navy/charcoal sidebar, warm white surfaces, Tomasetti red (#d42427)
   Typography: DM Sans (body) + Inter (data/numbers) — productivity tool, Linear/Stripe aesthetic
   Density: Balanced — clean but efficient */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root, [data-theme="light"] {
  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;
  --font-data: 'Inter', 'DM Sans', sans-serif;

  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);

  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Surfaces */
  --color-bg:              #f5f5f3;
  --color-surface:         #ffffff;
  --color-surface-2:       #fafaf8;
  --color-surface-offset:  #eeede9;
  --color-surface-offset-2:#e5e4e0;
  --color-surface-dynamic: #dddcd8;
  --color-divider:         #d5d4d0;
  --color-border:          #c8c7c3;

  /* Text */
  --color-text:            #1a1a1a;
  --color-text-muted:      #6b6b6b;
  --color-text-faint:      #a0a0a0;
  --color-text-inverse:    #ffffff;

  /* Sidebar */
  --color-sidebar:         #1c2536;
  --color-sidebar-hover:   #253043;
  --color-sidebar-active:  #2d3a50;
  --color-sidebar-text:    #c8d0dc;
  --color-sidebar-text-active: #ffffff;
  --color-sidebar-text-muted: #7a8599;
  --sidebar-width: 240px;

  /* Primary — Tomasetti red */
  --color-primary:         #d42427;
  --color-primary-hover:   #b81f22;
  --color-primary-active:  #9c1a1c;
  --color-primary-highlight: #fde8e8;

  /* Semantic */
  --color-success:         #1a7a3a;
  --color-success-highlight:#e8f5ec;
  --color-warning:         #b45309;
  --color-warning-highlight:#fef3c7;
  --color-error:           #c52a2a;
  --color-error-highlight: #fde8e8;

  /* Status badges */
  --color-draft:           #6b7280;
  --color-draft-bg:        #f3f4f6;
  --color-sent:            #2563eb;
  --color-sent-bg:         #eff6ff;
  --color-paid:            #16a34a;
  --color-paid-bg:         #f0fdf4;
  --color-overdue:         #dc2626;
  --color-overdue-bg:      #fef2f2;
  --color-active-status:   #d42427;
  --color-active-status-bg:#fde8e8;
  --color-hold:            #b45309;
  --color-hold-bg:         #fef3c7;
  --color-completed:       #16a34a;
  --color-completed-bg:    #f0fdf4;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
}

/* DARK MODE */
[data-theme="dark"] {
  --color-bg:              #111318;
  --color-surface:         #181a20;
  --color-surface-2:       #1e2028;
  --color-surface-offset:  #1c1e26;
  --color-surface-offset-2:#242630;
  --color-surface-dynamic: #2c2e38;
  --color-divider:         #2a2c36;
  --color-border:          #383a44;
  --color-text:            #e0e0e0;
  --color-text-muted:      #8a8a94;
  --color-text-faint:      #5a5a64;
  --color-text-inverse:    #181a20;

  --color-sidebar:         #0d0f14;
  --color-sidebar-hover:   #181a22;
  --color-sidebar-active:  #1e2030;
  --color-sidebar-text:    #b0b8c8;
  --color-sidebar-text-active: #ffffff;
  --color-sidebar-text-muted: #606878;

  --color-primary:         #e85356;
  --color-primary-hover:   #d42427;
  --color-primary-active:  #b81f22;
  --color-primary-highlight: #2e1a1a;

  --color-success:         #34d058;
  --color-success-highlight:#122918;
  --color-warning:         #f59e0b;
  --color-warning-highlight:#2a2010;
  --color-error:           #f87171;
  --color-error-highlight: #2a1212;

  --color-draft:           #9ca3af;
  --color-draft-bg:        #1f2937;
  --color-sent:            #60a5fa;
  --color-sent-bg:         #172554;
  --color-paid:            #4ade80;
  --color-paid-bg:         #14352a;
  --color-overdue:         #f87171;
  --color-overdue-bg:      #3b1212;
  --color-active-status:   #3ba0a8;
  --color-active-status-bg:#1a2e30;
  --color-hold:            #f59e0b;
  --color-hold-bg:         #2a2010;
  --color-completed:       #4ade80;
  --color-completed-bg:    #14352a;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

/* ============================================================
   LAYOUT — Full-viewport dashboard, no body scroll
   ============================================================ */

html, body { height: 100%; overflow: hidden; margin: 0; }

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 1fr;
  height: 100dvh;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  grid-row: 1 / -1;
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 30;
}

.sidebar-header {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-3);
}

.sidebar-logo-img {
  width: 180px;
  height: auto;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-sidebar-text);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--color-sidebar-hover); color: var(--color-sidebar-text-active); }
.nav-item.active { background: var(--color-sidebar-active); color: var(--color-sidebar-text-active); }

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-sidebar-text-muted);
  padding: var(--space-2) 0;
  width: 100%;
  cursor: pointer;
}
.theme-toggle-btn:hover { color: var(--color-sidebar-text); }

.sidebar-attribution {
  margin-top: var(--space-2);
}
.sidebar-attribution a {
  font-size: 11px;
  color: var(--color-sidebar-text-muted);
  text-decoration: none;
  opacity: 0.6;
}
.sidebar-attribution a:hover { opacity: 1; text-decoration: underline; }

/* ============================================================
   MOBILE HEADER
   ============================================================ */

.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  padding: var(--space-3) var(--space-4);
  align-items: center;
  gap: var(--space-3);
}

.hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1);
}

.mobile-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
}
.mobile-title svg { display: block; width: 20px; height: 20px; }

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

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main-content {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-8);
  background: var(--color-bg);
}

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

.page-title {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.2;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ============================================================
   KPI CARDS
   ============================================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.kpi-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: var(--text-xl);
  font-weight: 600;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums lining-nums;
  margin-top: var(--space-1);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition-interactive);
  border: none;
  white-space: nowrap;
  line-height: 1.5;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--color-primary); color: var(--color-text-inverse); }
.btn-primary:hover { background: var(--color-primary-hover); }

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

.btn-ghost { background: transparent; color: var(--color-primary); padding: var(--space-2) var(--space-3); }
.btn-ghost:hover { background: var(--color-primary-highlight); }

.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-danger-ghost { color: var(--color-error); }
.btn-danger-ghost:hover { background: var(--color-error-highlight); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }

.btn-icon {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--color-surface-offset); }

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  font-family: var(--font-data);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge-draft    { background: var(--color-draft-bg);    color: var(--color-draft); }
.badge-sent     { background: var(--color-sent-bg);     color: var(--color-sent); }
.badge-paid     { background: var(--color-paid-bg);     color: var(--color-paid); }
.badge-overdue  { background: var(--color-overdue-bg);  color: var(--color-overdue); }
.badge-active   { background: var(--color-active-status-bg); color: var(--color-active-status); }
.badge-on-hold  { background: var(--color-hold-bg);     color: var(--color-hold); }
.badge-completed{ background: var(--color-completed-bg); color: var(--color-completed); }

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

.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-data);
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.data-table td {
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
}

.data-table tbody tr:hover td { background: var(--color-surface-offset); }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .num {
  font-variant-numeric: tabular-nums lining-nums;
  text-align: right;
}

.table-empty {
  text-align: center;
  padding: var(--space-10);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.clickable-row { cursor: pointer; }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

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

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.3;
}

.card-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.form-input, .form-select, .form-textarea {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-body);
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
  border-color: var(--color-primary);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--color-text-faint); }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: var(--space-8);
}

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

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

.form-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-divider);
}

.form-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-top: var(--space-4);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
}

.form-helper {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}
.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-10) var(--space-4);
  overflow-y: auto;
}
.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-divider);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}
.modal-close:hover { background: var(--color-surface-offset); color: var(--color-text); }

.modal-body {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ============================================================
   SECTION
   ============================================================ */

.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
}

.section-title {
  font-size: var(--text-base);
  font-weight: 600;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */

.progress-bar {
  height: 6px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  transition: width 0.3s ease;
}

/* ============================================================
   PROJECT DETAIL
   ============================================================ */

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

.detail-item { font-size: var(--text-sm); }
.detail-label { color: var(--color-text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; }
.detail-value { font-weight: 500; margin-top: 2px; }

.phase-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.phase-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}

.phase-name { font-size: var(--text-sm); font-weight: 500; }
.phase-budget {
  font-size: var(--text-sm);
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text-muted);
  min-width: 100px;
}
.phase-progress { flex: 1; }
.phase-billed {
  font-size: var(--text-xs);
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text-muted);
  text-align: right;
  min-width: 100px;
}

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

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-divider);
  margin-bottom: var(--space-5);
}

.tab-btn {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ============================================================
   INVOICE PREVIEW / PRINT
   ============================================================ */

.invoice-preview {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  max-width: 800px;
}

.invoice-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-8);
}

.invoice-brand {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.invoice-brand-text { display: flex; flex-direction: column; }
.invoice-brand-name { font-size: var(--text-lg); font-weight: 700; }
.invoice-brand-addr { font-size: var(--text-xs); color: var(--color-text-muted); line-height: 1.5; }

.invoice-title {
  text-align: right;
}
.invoice-title h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}
.invoice-meta-grid {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: grid;
  grid-template-columns: auto auto;
  gap: var(--space-1) var(--space-3);
  justify-content: flex-end;
}
.invoice-meta-grid .label { text-align: right; }
.invoice-meta-grid .value { font-weight: 600; color: var(--color-text); font-family: var(--font-data); }

.invoice-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
}

.invoice-party-label { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); margin-bottom: var(--space-2); }
.invoice-party-name { font-size: var(--text-sm); font-weight: 600; }
.invoice-party-detail { font-size: var(--text-xs); color: var(--color-text-muted); line-height: 1.6; }

.invoice-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-6);
}
.invoice-items-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--color-divider);
}
.invoice-items-table td {
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  font-family: var(--font-data);
}
.invoice-items-table .text-right { text-align: right; }
.invoice-items-table .num { font-variant-numeric: tabular-nums lining-nums; }

.invoice-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.invoice-total-row {
  display: flex;
  gap: var(--space-10);
  font-size: var(--text-sm);
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums lining-nums;
}
.invoice-total-row .label { color: var(--color-text-muted); min-width: 140px; text-align: right; }
.invoice-total-row .value { font-weight: 500; min-width: 100px; text-align: right; }
.invoice-total-row.grand { font-size: var(--text-base); font-weight: 700; border-top: 2px solid var(--color-text); padding-top: var(--space-2); }

.invoice-footer {
  border-top: 1px solid var(--color-divider);
  padding-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
}

.invoice-actions {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

/* ============================================================
   STATEMENT
   ============================================================ */

.statement-header {
  margin-bottom: var(--space-6);
}

.statement-client {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.statement-summary {
  display: flex;
  gap: var(--space-8);
  margin-bottom: var(--space-6);
}

.statement-metric { font-size: var(--text-sm); }
.statement-metric .metric-label { color: var(--color-text-muted); font-size: var(--text-xs); }
.statement-metric .metric-value {
  font-size: var(--text-lg);
  font-weight: 600;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums lining-nums;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--color-text-muted);
}
.empty-state svg { margin: 0 auto var(--space-4); opacity: 0.3; }
.empty-state p { font-size: var(--text-sm); }

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

.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }
.font-data { font-family: var(--font-data); font-variant-numeric: tabular-nums lining-nums; }
.font-semibold { font-weight: 600; }
.gap-sm { gap: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.inline-flex { display: inline-flex; align-items: center; gap: var(--space-2); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    width: 260px;
    transition: left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 30;
  }
  .sidebar.open { left: 0; }

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

  .mobile-header {
    display: flex;
  }

  .main-content {
    padding: var(--space-4);
  }

  .page-header { flex-direction: column; align-items: flex-start; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .invoice-header-row { flex-direction: column; gap: var(--space-4); }
  .invoice-title { text-align: left; }
  .invoice-meta-grid { justify-content: flex-start; }
  .invoice-parties { grid-template-columns: 1fr; gap: var(--space-4); }
  .phase-item { flex-wrap: wrap; }
  .phase-name-wrap { min-width: auto; width: 100%; }
  .phase-desc-text { max-width: 100%; }
  .statement-summary { flex-direction: column; gap: var(--space-4); }
}

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

/* ============================================================
   AIA TABLE & ADDITIONAL SERVICES STYLES
   ============================================================ */

.aia-table th,
.aia-table td { white-space: nowrap; }
.aia-table .desc-col { width: 35%; white-space: normal; }
.aia-table .num-col { width: 16%; }
.aia-table .pct-col { width: 10%; }

.addl-table .desc-col { width: 40%; white-space: normal; }
.addl-table .num-col { width: 20%; }

.invoice-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: var(--space-4) 0 var(--space-2) 0;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

.subtotal-row td {
  border-top: 2px solid var(--color-border) !important;
  padding-top: var(--space-2) !important;
}

.form-input-sm {
  padding: var(--space-1) var(--space-2) !important;
  font-size: var(--text-sm) !important;
  height: auto !important;
  min-height: 32px;
}

.form-table {
  border-collapse: collapse;
}
.form-table th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: var(--space-1) var(--space-2);
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
}
.form-table td {
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
  body { background: white !important; margin: 0; padding: 0; }
  .app-layout,
  .sidebar,
  .mobile-header,
  .modal-overlay,
  .sidebar-overlay,
  .invoice-actions { display: none !important; }

  .print-invoice {
    display: block !important;
    padding: 0;
    margin: 0;
    color: #1a1a1a !important;
    background: #fff !important;
    font-family: 'DM Sans', 'Helvetica Neue', sans-serif;
    font-size: 10px;
    line-height: 1.4;
  }

  .print-invoice * {
    color: #1a1a1a !important;
    background: transparent !important;
    border-color: #ccc !important;
    box-shadow: none !important;
  }

  .print-invoice .badge {
    border: 1px solid currentColor !important;
    font-size: 8px !important;
    padding: 1px 5px !important;
  }

  .print-invoice .invoice-preview {
    border: none !important;
    padding: 0 !important;
    max-width: none !important;
  }

  .print-invoice .invoice-brand svg {
    display: block !important;
  }

  /* --- Compact print layout for 8.5x11 --- */
  .print-invoice .invoice-header-row {
    margin-bottom: 10px;
  }

  .print-invoice .invoice-brand svg {
    width: 28px !important;
    height: 28px !important;
  }

  .print-invoice .invoice-brand-addr {
    font-size: 8px !important;
    line-height: 1.3 !important;
  }

  .print-invoice .invoice-title h1 {
    font-size: 18px !important;
    margin-bottom: 4px !important;
  }

  .print-invoice .invoice-meta-grid {
    font-size: 8.5px !important;
    gap: 1px 6px !important;
  }

  .print-invoice .invoice-parties {
    margin-bottom: 10px;
    gap: 12px !important;
  }

  .print-invoice .invoice-party-label {
    font-size: 7.5px !important;
    margin-bottom: 2px !important;
  }

  .print-invoice .invoice-party-name {
    font-size: 9.5px !important;
  }

  .print-invoice .invoice-party-detail {
    font-size: 8.5px !important;
    line-height: 1.3 !important;
  }

  .print-invoice .invoice-items-table {
    margin-bottom: 8px;
  }

  .print-invoice .invoice-items-table th {
    font-size: 7.5px !important;
    padding: 4px 6px !important;
    letter-spacing: 0.05em;
  }

  .print-invoice .invoice-items-table td {
    font-size: 9px !important;
    padding: 3px 4px !important;
  }

  .print-invoice .aia-table th,
  .print-invoice .aia-table td {
    font-size: 8px !important;
    padding: 2px 3px !important;
  }

  .print-invoice .addl-table th,
  .print-invoice .addl-table td {
    font-size: 8px !important;
    padding: 2px 4px !important;
  }

  .print-invoice .invoice-section-label {
    font-size: 7px !important;
    margin: 6px 0 2px 0 !important;
    padding-top: 4px !important;
  }

  .print-invoice .subtotal-row td {
    border-top: 1.5px solid #333 !important;
    font-size: 8px !important;
  }

  .print-invoice .invoice-totals {
    margin-bottom: 8px;
    gap: 2px !important;
  }

  .print-invoice .invoice-total-row {
    font-size: 9px !important;
    gap: 12px !important;
  }

  .print-invoice .invoice-total-row .label {
    min-width: 100px !important;
  }

  .print-invoice .invoice-total-row .value {
    min-width: 70px !important;
  }

  .print-invoice .invoice-total-row.grand {
    font-size: 10.5px !important;
    padding-top: 3px !important;
  }

  .print-invoice .invoice-footer {
    padding-top: 8px;
    font-size: 8px !important;
  }

  .print-invoice .invoice-footer div {
    margin-bottom: 3px !important;
  }

  .print-invoice .invoice-notes {
    font-size: 8px !important;
    margin-bottom: 6px !important;
  }

  .print-invoice .invoice-paid-stamp {
    font-size: 8px !important;
    margin-bottom: 6px !important;
  }

  /* --- Page break logic for long invoices --- */
  .print-invoice .invoice-items-table tr {
    page-break-inside: avoid;
  }

  .print-invoice .invoice-page-break {
    page-break-before: always;
    padding-top: 12px;
  }

  .print-invoice .invoice-page-break::before {
    content: '';
    display: block;
  }

  .print-invoice .invoice-totals,
  .print-invoice .invoice-footer {
    page-break-inside: avoid;
  }

  @page {
    margin: 0.5in;
    size: letter;
  }
}

.print-invoice { display: none; }

/* ============================================================
   BACK LINK
   ============================================================ */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  margin-bottom: var(--space-4);
  cursor: pointer;
}
.back-link:hover { color: var(--color-primary); }

/* ============================================================
   AGREEMENT
   ============================================================ */

.agreement-section { }

.agreement-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-interactive);
}
.agreement-upload-zone:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}

.agreement-upload-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.agreement-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.agreement-file-selected {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text);
  padding: var(--space-2) 0;
}

.agreement-file-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.agreement-terms-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-4);
}

.agreement-terms-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-3);
}

.agreement-terms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
}

.agreement-term-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.agreement-term-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.agreement-term-value {
  font-size: var(--text-base);
  font-weight: 600;
}

.agreement-phase-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-4);
  font-family: var(--font-data);
}

.agreement-phase-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}

.agreement-phase-table td {
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}

.agreement-phase-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}

.agreement-phase-desc {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agreement-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
}
.agreement-empty p {
  font-size: var(--text-sm);
  margin: 0;
}

.phase-name-wrap {
  display: flex;
  flex-direction: column;
  min-width: 200px;
}

.phase-desc-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
  line-height: 1.3;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sub-header info bar */
.info-bar {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}
.info-item { font-size: var(--text-sm); }
.info-item .info-label { font-size: var(--text-xs); color: var(--color-text-muted); display: block; }
.info-item .info-value { font-weight: 500; }

/* Select client dropdown for statements */
.select-wrap {
  max-width: 400px;
  margin-bottom: var(--space-6);
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: var(--color-bg);
  padding: var(--space-4);
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-10) var(--space-8);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.login-logo-img {
  max-width: 260px;
  height: auto;
  display: block;
}

.login-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
}

.login-field {
  text-align: left;
  margin-bottom: var(--space-4);
}

.login-field .form-label {
  margin-bottom: var(--space-1);
  display: block;
}

.password-wrap {
  position: relative;
}

.password-wrap .form-input {
  padding-right: var(--space-10);
}

.password-toggle {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  padding: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.password-toggle:hover {
  color: var(--color-text);
}

.login-error {
  color: var(--color-error);
  font-size: var(--text-sm);
  min-height: 1.5em;
  margin-bottom: var(--space-2);
}

.login-btn {
  width: 100%;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
  margin-top: var(--space-2);
}

.forgot-password-link {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-1) 0;
  transition: color 0.15s ease;
}
.forgot-password-link:hover {
  color: var(--color-accent);
}

.forgot-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
  text-align: left;
  line-height: 1.5;
}

.login-success {
  color: var(--color-success, #10b981);
  font-size: var(--text-sm);
  min-height: 1.5em;
  margin-bottom: var(--space-2);
}

/* Monthly Progress Page */
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-3);
}
.progress-header h1 {
  font-size: var(--text-xl);
  font-weight: 700;
}
.progress-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
}
.progress-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-2);
}
.progress-card-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}
.progress-card-header .contract-badge {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-accent-light, rgba(1,105,111,0.1));
  color: var(--color-accent);
}
.progress-phase-grid {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  font-size: var(--text-sm);
}
.progress-phase-grid .phase-label {
  font-weight: 500;
}
.progress-phase-grid .phase-fee {
  color: var(--color-text-muted);
  font-family: 'Inter', sans-serif;
  text-align: right;
}
.progress-phase-grid .phase-input {
  width: 72px;
  text-align: center;
}
.progress-phase-grid .phase-billed {
  font-family: 'Inter', sans-serif;
  text-align: right;
  min-width: 80px;
  color: var(--color-text-muted);
}
.progress-notes {
  margin-top: var(--space-4);
}
.progress-notes textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
}
.progress-notes label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: var(--space-1);
  color: var(--color-text-muted);
}
.progress-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}
.progress-summary .total-label {
  font-weight: 600;
}
.progress-summary .total-amount {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: var(--text-base);
}
.progress-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.progress-empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--color-text-muted);
}
.progress-sending {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.progress-sending svg {
  animation: spin 1s linear infinite;
}

/* ============================================================
   SCHEDULE OF VALUES TABLE (Monthly Progress)
   ============================================================ */

.sov-table-wrap {
  overflow-x: auto;
  margin: 0 calc(-1 * var(--space-2));
  padding: 0 var(--space-2);
}
.sov-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
  font-family: var(--font-data);
}
.sov-table thead {
  background: var(--color-sidebar);
  color: #fff;
}
.sov-table th {
  padding: var(--space-2) var(--space-3);
  text-align: right;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.sov-table th.sov-phase {
  text-align: left;
}
.sov-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}
.sov-table td.sov-phase {
  text-align: left;
  font-weight: 500;
  font-family: var(--font-body);
}
.sov-table td.sov-num {
  text-align: right;
  white-space: nowrap;
}
.sov-table td.sov-pct {
  text-align: center;
}
.sov-table td.sov-pct input {
  width: 60px;
  text-align: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}
.sov-table tfoot {
  border-top: 2px solid var(--color-sidebar);
}
.sov-table tfoot td {
  padding: var(--space-2) var(--space-3);
  border-bottom: none;
}
.sov-total td {
  font-weight: 600;
}

/* Payment summary bar */
.payment-summary-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-4);
}
.pay-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pay-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 500;
}
.pay-stat-value {
  font-family: var(--font-data);
  font-size: var(--text-sm);
  font-weight: 600;
}
@media (max-width: 768px) {
  .payment-summary-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Payment modal balance header */
.payment-balance-header {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-family: var(--font-data);
  font-size: var(--text-sm);
}
.pay-bal-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-1) 0;
}
.pay-bal-due {
  border-top: 1px solid var(--color-divider);
  margin-top: var(--space-1);
  padding-top: var(--space-2);
  font-size: var(--text-base);
  color: var(--color-primary);
}

/* Payment history in modal */
.payment-history-section {
  margin-bottom: var(--space-4);
}
.payment-history-section h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text-muted);
}

/* Check upload zone */
.check-upload-zone {
  position: relative;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  transition: border-color 0.2s, background 0.2s;
}
.check-upload-zone:hover {
  border-color: var(--color-primary);
  background: rgba(212, 36, 39, 0.03);
}
.check-upload-zone span {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.check-upload-zone .file-upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Payment balance footer on invoice detail */
.payment-balance-footer {
  display: flex;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-sm);
  font-family: var(--font-data);
}

.login-theme-toggle {
  margin-top: var(--space-6);
  display: flex;
  justify-content: center;
}

.login-theme-toggle .theme-toggle-btn {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  display: inline-flex;
  width: auto;
}

/* ============================================================
   SIDEBAR USER INFO
   ============================================================ */

.sidebar-user {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-sidebar-text);
}

.sidebar-user:empty {
  display: none;
}

.user-display-name {
  font-weight: 500;
  color: var(--color-sidebar-text-active);
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-badge-admin {
  background: rgba(59, 160, 168, 0.2);
  color: var(--color-primary);
}

.role-badge-client {
  background: rgba(107, 114, 128, 0.2);
  color: var(--color-sidebar-text);
}

/* ============================================================
   LOGOUT BUTTON
   ============================================================ */

.logout-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-sidebar-text-muted);
  padding: var(--space-2) 0;
  width: 100%;
  cursor: pointer;
  margin-bottom: var(--space-2);
}
.logout-btn:hover {
  color: var(--color-error);
}

/* ============================================================
   FILE UPLOAD / PROJECT FILES
   ============================================================ */

.file-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-interactive);
}
.file-upload-zone:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}
.file-upload-zone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}

.file-upload-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.file-upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-data);
  text-transform: uppercase;
  flex-shrink: 0;
}

.file-type-pdf {
  background: var(--color-error-highlight);
  color: var(--color-error);
}

.file-type-img {
  background: var(--color-sent-bg);
  color: var(--color-sent);
}

.file-type-doc {
  background: var(--color-active-status-bg);
  color: var(--color-active-status);
}

.file-type-other {
  background: var(--color-draft-bg);
  color: var(--color-draft);
}

/* ============================================================
   PDF REVIEW MODAL
   ============================================================ */

.review-terms-intro {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  line-height: 1.5;
}

.review-term-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  margin-bottom: var(--space-2);
}

.review-term-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.review-term-label {
  flex: 1;
  font-size: var(--text-sm);
}

.review-term-label strong {
  font-weight: 600;
}

.review-term-current {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.review-excerpts {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-primary);
}

.review-excerpts-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}

.review-excerpt {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-style: italic;
  line-height: 1.5;
  margin-bottom: var(--space-1);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  max-width: 360px;
  animation: toast-in 0.3s ease-out;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

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

.toast-close {
  flex-shrink: 0;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 2px;
}
.toast-close:hover { color: var(--color-text); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-surface-offset);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   CLIENT PORTAL WELCOME
   ============================================================ */

.welcome-banner {
  background: var(--color-primary-highlight);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
}

.welcome-banner h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.welcome-banner p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ============================================================
   RESPONSIVE ADDITIONS
   ============================================================ */

@media (max-width: 768px) {
  .login-card {
    padding: var(--space-8) var(--space-5);
  }
}

@media print {
  .login-screen { display: none !important; }
  .toast-container { display: none !important; }
}
