:root {
  --primary: #1a365d;
  --primary-light: #2a5298;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 8px;
  --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { overflow-x: hidden; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ═══ Header ═══ */
.header {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-inverse);
  text-decoration: none;
}

.header-brand span { color: var(--accent); }

.header-subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: 0.75rem;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
}

.btn-link:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ═══ Login ═══ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 72px);
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card h2 { color: var(--text-inverse); margin-bottom: 0.25rem; }
.login-card .text-muted { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* ═══ Tabs ═══ */
.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  margin-top: 1.5rem;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.tab-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-inverse);
}

/* ═══ Forms ═══ */
.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text); margin-bottom: 0.35rem; }

.form-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}

.form-input:focus { border-color: var(--accent); }
textarea.form-input { resize: vertical; font-family: inherit; }
select.form-input { cursor: pointer; }

.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-row-3 .form-group:nth-child(2),
.form-row-3 .form-group:nth-child(3) { flex: 0 0 80px; }

/* ═══ Buttons ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: var(--text-inverse); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.3); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; border-radius: 4px; }
.btn-block { width: 100%; margin-top: 0.5rem; }

/* ═══ Tables ═══ */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.data-table th {
  background: rgba(51, 65, 85, 0.5);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(51, 65, 85, 0.3); }

.text-right { text-align: right; }
.text-small { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.loading-cell { text-align: center; color: var(--text-muted); padding: 2rem !important; }
.error-cell { text-align: center; color: var(--danger); padding: 2rem !important; }
.row-inactive { opacity: 0.5; }

.action-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ═══ Status Badges ═══ */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-owner { background: rgba(59, 130, 246, 0.2); color: var(--accent); }
.status-accountant { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.status-viewer { background: rgba(148, 163, 184, 0.2); color: var(--text-muted); }
.status-draft { background: rgba(148, 163, 184, 0.2); color: var(--text-muted); }
.status-sent { background: rgba(59, 130, 246, 0.2); color: var(--accent); }
.status-paid { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.status-partial { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-overdue { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.status-cancelled { background: rgba(100, 116, 139, 0.2); color: #64748b; }
.status-individual { background: rgba(59, 130, 246, 0.2); color: var(--accent); }
.status-business { background: rgba(168, 85, 247, 0.2); color: #a855f7; }

/* ═══ Filters ═══ */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-input {
  width: auto;
  min-width: 140px;
  max-width: 200px;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}

.date-presets {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ═══ Modals ═══ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  overflow-y: auto;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-wide { max-width: 600px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-header h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-inverse); }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* ═══ Messages ═══ */
.error-msg {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.success-msg {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* ═══ Dashboard ═══ */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--text-inverse); }
.stat-positive { color: var(--success); }
.stat-negative { color: var(--danger); }

.stat-card-sm { padding: 0.85rem; border-style: dashed; }
.stat-card-sm .stat-label { font-size: 0.7rem; margin-bottom: 0.3rem; }
.stat-card-sm .stat-value { font-size: 1.1rem; }

.dash-header { margin-bottom: 1.5rem; }
.dash-header .stat-cards { margin-bottom: 1rem; }
#recordTransactionBtn { margin-bottom: 0.5rem; }
.dashboard-columns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }
.dash-col h3 { font-size: 1rem; font-weight: 600; color: var(--text-inverse); margin-bottom: 0.75rem; }
.dash-list { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.dash-item {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  gap: 0.75rem;
}

.dash-item:last-child { border-bottom: none; }
.dash-amount { font-weight: 600; white-space: nowrap; }
.view-all-link { display: block; text-align: center; margin-top: 0.5rem; font-size: 0.82rem; }

/* ═══ Invoice Line Items ═══ */
.line-items-header,
.line-item-row {
  display: grid;
  grid-template-columns: 1fr 70px 100px 90px 40px;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.line-items-header {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.line-item-row .form-input { padding: 0.4rem 0.5rem; font-size: 0.85rem; }
.line-item-row .li-amount { font-size: 0.85rem; text-align: right; font-weight: 500; }
.line-item-row .li-remove { padding: 0.2rem 0.5rem; }

.invoice-totals {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  font-size: 0.9rem;
}

.total-row-bold { font-weight: 700; font-size: 1rem; color: var(--text-inverse); }

/* ═══ Reports ═══ */
.report-nav {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.report-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.report-btn:hover { color: var(--text); border-color: var(--text-muted); }
.report-btn.active { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); }

.report-output { margin-top: 1rem; }
.report-title { font-size: 1.2rem; font-weight: 700; color: var(--text-inverse); margin-bottom: 0.25rem; }
.report-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.25rem; }

.report-section { margin-bottom: 1.5rem; }
.report-section h4 { font-size: 0.95rem; font-weight: 600; color: var(--text-inverse); margin-bottom: 0.5rem; }

.report-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}

.report-table th,
.report-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.report-table th {
  background: rgba(51, 65, 85, 0.5);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.report-table tr:last-child td { border-bottom: none; }

.report-total td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  color: var(--text-inverse);
}

.report-grand-total td {
  font-weight: 700;
  font-size: 1rem;
  border-top: 3px double var(--text-muted);
  color: var(--text-inverse);
  padding: 0.75rem;
}

/* AR Aging */
.aging-summary {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.aging-bucket {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  text-align: center;
  flex: 1;
  min-width: 100px;
}

.aging-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.aging-amount { font-size: 1.1rem; font-weight: 700; color: var(--text-inverse); margin-top: 0.25rem; }
.aging-bucket.days_90_plus .aging-amount { color: var(--danger); }
.aging-bucket.aging-total { border-color: var(--accent); }

/* ═══ Chart of Accounts ═══ */
.acct-group { margin-bottom: 1rem; }

.acct-group-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-inverse);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.acct-group-header:hover { background: rgba(30, 41, 59, 0.8); }

.acct-group-body {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.acct-group-body.collapsed { display: none; }

.chevron {
  font-size: 0.7rem;
  transition: transform var(--transition);
  display: inline-block;
}

.chevron.rotated { transform: rotate(-90deg); }

/* ═══ Receipt icon ═══ */
.receipt-icon {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #fff;
  font-size: 0.85rem;
}

.receipt-icon:hover { opacity: 0.7; }
.receipt-icon svg { vertical-align: middle; }

/* ═══ Voided Entries ═══ */
.voided-row { opacity: 0.6; }
.voided-row s { color: var(--text-muted); }

.void-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.void-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--danger);
  text-transform: uppercase;
}

.void-reason {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
}

.void-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.void-toggle input { cursor: pointer; }

/* ═══ Audit Log ═══ */
.audit-type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.audit-type-expense { background: #fef3c7; color: #92400e; }
.audit-type-transaction { background: #dbeafe; color: #1e40af; }
.audit-type-invoice { background: #ede9fe; color: #5b21b6; }

.btn-inline-edit {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 0.25rem;
  text-decoration: underline;
}
.btn-inline-edit:hover { color: var(--primary-dark); }

.inline-edit { display: flex; flex-direction: column; gap: 0.35rem; }
.inline-edit-input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.inline-edit-input:focus { outline: none; border-color: var(--primary); }
.inline-edit-actions { display: flex; gap: 0.35rem; }

.audit-reason-cell { min-width: 180px; }

/* ═══ Vehicle Tab ═══ */
.vehicle-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.vehicle-profile-info h3 { margin: 0 0 0.25rem; }
.vehicle-details {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.vehicle-setup {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.vehicle-setup p { margin-bottom: 1rem; }

.vehicle-sub-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
}
.vehicle-sub-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.vehicle-sub-btn:hover { color: var(--text); }
.vehicle-sub-btn.active {
  color: var(--text-inverse);
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  border-bottom-color: var(--primary);
}

.mileage-total {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--primary);
  margin-left: auto;
}

/* Year Summary */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}
.summary-card h4 { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--text); }
.summary-stat {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.summary-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.summary-winner {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}
.summary-biz-pct {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  color: var(--text);
}
.summary-biz-pct strong { color: var(--accent, var(--primary)); font-size: 1.1rem; }

.summary-recommendation {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .summary-grid { grid-template-columns: 1fr; }
  .vehicle-details { flex-direction: column; gap: 0.25rem; }
}

/* ═══ Business Use Calculator ═══ */
.biz-use-calc {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 1rem;
}
.biz-use-calc-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}
.biz-use-pct-display {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  padding: 6px 0;
}
.biz-use-calc-result {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--text);
}
.biz-use-calc-result strong {
  font-size: 1.05rem;
  color: var(--success);
}

/* ═══ Upload Progress ═══ */
.upload-progress {
  margin-bottom: 0.75rem;
}

.upload-progress-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.upload-progress-bar {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  width: 0%;
  transition: width 0.2s ease;
}

/* ═══ Receipt List (edit form) ═══ */
.receipt-list {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
}

.receipt-list-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.receipt-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.receipt-list-item:last-child { border-bottom: none; }

.receipt-list-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 0.5rem;
}

.receipt-list-delete {
  flex-shrink: 0;
  padding: 0.1rem 0.4rem !important;
  font-size: 0.85rem !important;
  line-height: 1;
}

/* ═══ Footer ═══ */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 3rem;
}

.footer a { color: var(--accent); text-decoration: none; }

/* ═══ Mobile-only elements (hidden by default) ═══ */
.show-mobile-only { display: none !important; }

/* ═══ Row Action Menu (vertical ellipsis) ═══ */
.row-menu-wrap { position: relative; }
.row-menu-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; line-height: 1; padding: 0.25rem 0.5rem;
  color: var(--text); border-radius: var(--radius);
}
.row-menu-btn:hover { background: var(--bg-input); }
.row-menu-dropdown {
  position: fixed; z-index: 200;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); min-width: 160px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  overflow: hidden;
}
.row-menu-info {
  display: flex; gap: 0.5rem; padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.row-menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  padding: 0.6rem 0.75rem; font-size: 0.85rem;
  color: var(--text);
}
.row-menu-item:hover { background: var(--bg-input); }
.row-menu-danger { color: var(--danger); }

/* ═══ Hamburger Menu ═══ */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.6rem;
  flex-shrink: 0;
}
.hamburger-btn span {
  display: block;
  width: 24px;
  height: 3px;
  background: var(--text-inverse);
  margin: 4px 0;
  transition: all 0.3s ease;
  border-radius: 2px;
}
.hamburger-btn.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; }
.hamburger-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

/* ═══ Mobile Nav Drawer ═══ */
.mobile-nav-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.mobile-nav-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.mobile-nav-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  z-index: 160;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.mobile-nav-drawer.open { transform: translateX(0); }
.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.mobile-nav-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-inverse);
}
.mobile-nav-item {
  display: flex;
  align-items: center;
  padding: 0.85rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}
.mobile-nav-item:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--text);
}
.mobile-nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
  .container { padding: 0 1rem; }
  .hamburger-btn { display: block; }
  .tab-nav { display: none; }
  .tab-btn { padding: 0.65rem 0.75rem; font-size: 0.8rem; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .dashboard-columns { grid-template-columns: 1fr; }
  .dash-header { text-align: center; }
  .form-row { flex-direction: column; gap: 0; }
  .form-row-3 { flex-direction: row; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-input { min-width: 0; max-width: none; width: 100%; }
  .line-items-header, .line-item-row {
    grid-template-columns: 1fr 50px 80px 70px 35px;
    gap: 0.25rem;
  }
  .tab-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
  .aging-summary { flex-direction: column; }
  .hide-mobile { display: none !important; }
  .show-mobile-only { display: table-cell !important; }

  /* Compact tables */
  .data-table th, .data-table td { padding: 0.45rem 0.5rem; font-size: 0.8rem; }
  .data-table th { font-size: 0.68rem; }
  .action-btns { gap: 0.25rem; }
  .action-btns .btn-sm { padding: 0.2rem 0.4rem; font-size: 0.72rem; }

  /* Touch-friendly inputs */
  .form-input { min-height: 44px; font-size: 16px; }
  select.form-input { min-height: 44px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* Header compact — hide everything except Desktop Mode toggle */
  .header-inner { gap: 0.75rem; }
  .header-brand { font-size: 1.1rem; }
  .header-user { font-size: 0.78rem; gap: 0.5rem; margin-left: auto; }
  .header-user #headerDisplayName,
  .header-user #headerAccountsBtn,
  .header-user #headerAccountsDivider,
  .header-user #headerUsersBtn,
  .header-user #headerUsersDivider,
  .header-user #headerSettingsBtn,
  .header-user #headerSettingsDivider,
  .header-user #quickGuideBtn,
  .header-user #logoutBtn,
  .header-user .header-divider { display: none !important; }
  .header-user #modeToggleBtn { display: inline; }

  /* Sub-navigation scroll */
  .vehicle-sub-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .vehicle-sub-btn { padding: 0.5rem 0.85rem; font-size: 0.82rem; white-space: nowrap; }

  /* Date presets scroll */
  .date-presets { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .date-presets .btn { flex-shrink: 0; white-space: nowrap; }

  /* Report nav wrap */
  .report-nav { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .line-items-header, .line-item-row {
    grid-template-columns: 1fr 40px 65px 55px 30px;
    gap: 0.2rem;
  }
  .line-item-row .form-input { padding: 0.3rem; font-size: 0.78rem; }
  .line-items-header { font-size: 0.65rem; }
  .form-row-3 { flex-wrap: wrap; }
  .form-row-3 .form-group:first-child { flex: 1 1 100%; }
  .form-row-3 .form-group:nth-child(2),
  .form-row-3 .form-group:nth-child(3) { flex: 1; }
  .modal { padding: 1.25rem; }
  .modal-wide { max-width: 100%; }
  .modal-overlay { padding: 0.5rem; }
}

@media (max-width: 400px) {
  .stat-cards { grid-template-columns: 1fr; }
}

/* ═══ PWA Safe Area Insets ═══ */
@supports (padding: env(safe-area-inset-top)) {
  .header { padding-top: env(safe-area-inset-top); }
  .mobile-nav-drawer { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ═══ Transaction Form ═══ */
.tx-type-hint {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Header divider */
.header-divider {
  color: var(--text-muted);
  opacity: 0.4;
  margin: 0 0.15rem;
}

/* Guide modal */
.modal-guide {
  max-width: 800px;
  width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.guide-search {
  padding: 0 1.5rem 1rem;
}

.guide-search .form-input {
  font-size: 1rem;
  padding: 0.75rem 1rem;
}

.guide-content {
  overflow-y: auto;
  padding: 0 1.5rem 1.5rem;
  flex: 1;
}

.guide-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.guide-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
  background: var(--bg-input);
  transition: background var(--transition);
  user-select: none;
}

.guide-section-header:hover {
  background: var(--primary-light);
}

.guide-section-icon {
  font-size: 1.25rem;
  width: 1.5rem;
  text-align: center;
}

.guide-section-title {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
}

.guide-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.guide-section-body {
  padding: 1rem 1.25rem 1.25rem;
  line-height: 1.7;
  font-size: 0.9rem;
}

.guide-section-body h4 {
  margin: 1.25rem 0 0.5rem;
  color: var(--accent);
  font-size: 0.95rem;
}

.guide-section-body h4:first-child {
  margin-top: 0;
}

.guide-section-body h5 {
  margin: 1rem 0 0.35rem;
  font-size: 0.9rem;
}

.guide-section-body p {
  margin-bottom: 0.5rem;
}

.guide-section-body ol,
.guide-section-body ul {
  margin: 0.35rem 0 0.75rem 1.5rem;
}

.guide-section-body li {
  margin-bottom: 0.3rem;
}

.guide-section-body ul ul {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.guide-tip {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin: 1rem 0 0.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.85rem;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem;
  font-size: 0.85rem;
}

.guide-table td {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  vertical-align: top;
}

.guide-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

@media (max-width: 600px) {
  .modal-guide {
    max-height: 90vh;
  }
  .guide-section-body {
    padding: 0.75rem;
  }
}

/* ═══ Receipt Viewer ═══ */
.receipt-viewer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 95vw;
  max-width: 900px;
  height: 90vh;
  display: flex;
  flex-direction: column;
}

.receipt-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#receiptPrev, #receiptNext {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  line-height: 1;
}

.receipt-viewer-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-inverse);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.receipt-viewer-controls {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}

.receipt-viewer-body {
  flex: 1;
  overflow: auto;
  position: relative;
  cursor: grab;
  background: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
}

.receipt-viewer-body.dragging { cursor: grabbing; }

.receipt-viewer-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.15s ease;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
}

.receipt-viewer-img.zoomed {
  max-width: none;
  max-height: none;
  cursor: grab;
}

.receipt-viewer-img.zoomed.dragging { cursor: grabbing; }

.receipt-viewer-pdf {
  width: 100%;
  height: 100%;
  border: none;
}

@media (max-width: 600px) {
  .receipt-viewer { width: 100vw; height: 100vh; border-radius: 0; }
  .receipt-viewer-controls { gap: 0.25rem; }
  .receipt-viewer-controls .btn { padding: 0.2rem 0.4rem; font-size: 0.7rem; }
}

/* ═══ Mobile Mode ═══ */
body.mobile-mode #appMain { display: none !important; }
/* hamburger stays visible in mobile mode */
body:not(.mobile-mode) #mobileMain { display: none !important; }
body.mobile-mode.desktop-override #appMain { display: block !important; }
body.mobile-mode.desktop-override #mobileMain { display: none !important; }

.mob-active-trip {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  animation: mob-pulse 2s ease-in-out infinite;
}
@keyframes mob-pulse {
  0%, 100% { border-color: var(--accent); }
  50% { border-color: var(--success); }
}
.mob-active-trip-label { font-weight: 600; color: var(--accent); font-size: 0.9rem; }
.mob-active-trip-detail { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }

.mob-summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0;
}
.mob-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.5rem;
  text-align: center;
}
.mob-summary-value { font-size: 1.2rem; font-weight: 700; color: var(--text-inverse); }
.mob-summary-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 0.2rem;
}

.mob-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.mob-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.25rem 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 90px;
}
.mob-action-btn:active { transform: scale(0.97); background: var(--bg-input); }
.mob-action-icon { font-size: 1.75rem; }
.mob-action-text { font-size: 0.82rem; font-weight: 600; }
.mob-action-trip { border-color: var(--accent); }
.mob-action-trip .mob-action-text { color: var(--accent); }
.mob-action-expense { border-color: var(--success); }
.mob-action-expense .mob-action-text { color: var(--success); }

.mob-screen { padding-top: 1rem; }
.mob-screen-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.mob-screen-header h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-inverse); margin: 0; }
.mob-back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.35rem 0;
}

.mob-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.mob-hint { font-size: 0.82rem; margin-bottom: 1rem; }
.mob-calculated-miles {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--success);
}

.mob-quick-cats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.mob-cat-btn {
  padding: 0.6rem 0.4rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 44px;
}
.mob-cat-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

#mobileMain .form-group { max-width: 100%; overflow: hidden; }
#mobileMain input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.mob-amount-input {
  font-size: 1.5rem !important;
  font-weight: 700;
  text-align: center;
  padding: 0.85rem !important;
}

.mob-receipt-section { margin-bottom: 1rem; }
.mob-receipt-section > label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}
.mob-receipt-actions { display: flex; gap: 0.5rem; }
.mob-camera-btn, .mob-file-btn {
  flex: 1;
  text-align: center;
  cursor: pointer;
  min-height: 44px;
}
.mob-receipt-thumbs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.mob-receipt-thumb {
  width: 60px;
  height: 60px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.mob-receipt-preview { margin-top: 0.75rem; text-align: center; }
.mob-receipt-preview-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}
.mob-receipt-preview-actions { display: flex; gap: 0.5rem; justify-content: center; }

.mob-post-save-msg {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
}

.mob-section { margin-bottom: 1.5rem; }
.mob-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-inverse);
  margin-bottom: 0.75rem;
}
.mob-recent-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.mob-recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  gap: 0.5rem;
}
.mob-recent-item:last-child { border-bottom: none; }
.mob-recent-type {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  flex-shrink: 0;
}
.mob-recent-type-expense { background: #fef3c7; color: #92400e; }
.mob-recent-type-trip { background: #dbeafe; color: #1e40af; }
.mob-recent-detail {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mob-recent-amount { font-weight: 600; white-space: nowrap; }

body.mobile-mode .form-input { min-height: 48px; font-size: 16px; }
body.mobile-mode .btn { min-height: 48px; }
body.mobile-mode .btn-block { margin-top: 0.75rem; }

/* Notifications */
.notification-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; margin-bottom: 0.5rem; border-radius: var(--radius); border-left: 4px solid; background: var(--bg-card); }
.notification-info { border-left-color: var(--accent); }
.notification-warning { border-left-color: var(--warning, #f59e0b); }
.notification-danger { border-left-color: var(--danger, #ef4444); }
.notification-msg { color: var(--text-inverse); font-size: 0.9rem; }
.notification-actions { display: flex; gap: 0.5rem; align-items: center; }

/* Dashboard chart */
.dash-chart-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem; }
.dash-chart-legend { display: flex; gap: 1.5rem; margin-bottom: 0.75rem; font-size: 0.82rem; color: var(--text-muted); }
.dash-legend-item { display: flex; align-items: center; gap: 0.35rem; }
.dash-legend-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.dash-col-title { font-size: 1rem; font-weight: 600; color: var(--text-inverse); margin: 0 0 0.75rem 0; }

/* Report filter checkbox */
.filter-checkbox { display: flex; align-items: center; gap: 0.4rem; color: var(--text); font-size: 0.85rem; white-space: nowrap; cursor: pointer; }

/* Settings tab */
.settings-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.settings-section h3 { color: var(--text-inverse); margin: 0 0 1rem 0; font-size: 1.1rem; }
.settings-section h4 { color: var(--text); margin: 1rem 0 0.75rem 0; font-size: 0.95rem; }
.settings-export-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.settings-year-row { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--border); color: var(--text-inverse); }
.settings-year-row:last-child { border-bottom: none; }

/* ═══ Mortgage Payment Modal ═══ */
.mortgage-trigger-row { border-bottom: 1px solid var(--border); padding-bottom: 0.75rem; margin-bottom: 0.75rem; }
.mortgage-trigger-btn { border: 1px dashed var(--border); color: var(--text-muted); display: inline-flex; align-items: center; background: transparent; }
.mortgage-trigger-btn:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
.mortgage-back-row { margin-bottom: 1rem; }
.mortgage-section { border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 1rem; }
.mortgage-section-info { border-color: var(--border); }
.mortgage-section-header h4 { margin: 0 0 0.75rem 0; font-size: 0.95rem; color: var(--text-inverse); }
.mortgage-total { text-align: right; font-size: 1rem; color: var(--text); padding: 0.75rem 0; margin-bottom: 0.5rem; border-top: 1px solid var(--border); }
.mortgage-total strong { color: var(--success); font-size: 1.1rem; }
.modal-mortgage-wide { max-width: 650px; }

/* ── Projects & Documents ──────────────────────────────────────────────────── */

.modal-lg { max-width: 700px; }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.project-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

.project-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.35rem; }
.project-card-name { font-size: 1rem; font-weight: 600; color: var(--text-inverse); margin: 0; }
.project-card-client { font-size: 0.85rem; color: var(--text); margin-bottom: 0.35rem; }
.project-card-desc { font-size: 0.82rem; color: var(--text); margin-bottom: 0.5rem; line-height: 1.4; }

.project-card-stats { display: flex; align-items: center; gap: 1rem; font-size: 0.8rem; color: var(--text); }
.project-card-stats span { display: flex; align-items: center; gap: 0.3rem; }
.project-card-stats svg { opacity: 0.6; }

.project-progress { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; min-width: 50px; }
.project-progress-bar { height: 100%; background: var(--success); border-radius: 2px; transition: width 0.3s; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.project-status-active { background: rgba(34,197,94,0.15); color: #22c55e; }
.project-status-on_hold { background: rgba(251,191,36,0.15); color: #fbbf24; }
.project-status-completed { background: rgba(59,130,246,0.15); color: #3b82f6; }
.project-status-archived { background: rgba(107,114,128,0.15); color: #6b7280; }

.project-detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.project-section { margin-top: 1.25rem; }
.project-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.35rem; }
.project-section-header h4 { margin: 0; font-size: 0.95rem; color: var(--text-inverse); }

.empty-state { text-align: center; color: var(--text); padding: 2rem; font-size: 0.9rem; }
.empty-state-sm { text-align: center; color: var(--text); padding: 1rem; font-size: 0.85rem; }

/* Tasks */
.tasks-list { display: flex; flex-direction: column; gap: 0.25rem; }

.task-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 0.5rem;
}
.task-item.task-done { opacity: 0.55; }
.task-item.task-done .task-title { text-decoration: line-through; }

.task-item-left { display: flex; align-items: flex-start; gap: 0.5rem; flex: 1; min-width: 0; }
.task-item-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.task-check { background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 0; line-height: 1; color: var(--text); }
.task-title { font-size: 0.88rem; font-weight: 500; color: var(--text-inverse); }
.task-desc { font-size: 0.78rem; }
.task-due { font-size: 0.78rem; color: var(--text); }
.task-due.overdue { color: var(--danger); font-weight: 600; }
.task-due.due-soon { color: #fbbf24; font-weight: 500; }
.task-assignee { font-size: 0.78rem; }

.priority-low { background: rgba(107,114,128,0.15); color: #6b7280; }
.priority-normal { background: rgba(59,130,246,0.15); color: #3b82f6; }
.priority-high { background: rgba(251,146,60,0.15); color: #fb923c; }
.priority-urgent { background: rgba(239,68,68,0.15); color: #ef4444; }

.btn-icon { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0.15rem 0.3rem; color: var(--text); border-radius: 4px; text-decoration: none; }
.btn-icon:hover { background: var(--border); color: var(--text-inverse); }
.btn-icon-danger:hover { background: rgba(239,68,68,0.15); color: var(--danger); }

/* Documents */
.doc-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.doc-item:last-child { border-bottom: none; }
.doc-icon { font-size: 1.3rem; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-weight: 500; color: var(--accent); text-decoration: none; }
.doc-name:hover { text-decoration: underline; }
.doc-actions { display: flex; gap: 0.3rem; }

.doc-table-icon { margin-right: 0.4rem; }
.doc-table-name { font-weight: 500; color: var(--accent); text-decoration: none; }
.doc-table-name:hover { text-decoration: underline; }

.doc-detail-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }

.versions-list { display: flex; flex-direction: column; gap: 0.25rem; }
.version-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.version-info { font-size: 0.85rem; color: var(--text); }
.version-info strong { color: var(--text-inverse); }

.category-item { font-size: 0.9rem; color: var(--text-inverse); }

.btn-danger { background: var(--danger); color: white; border: none; padding: 0.3rem 0.6rem; border-radius: var(--radius); cursor: pointer; font-size: 0.82rem; }
.btn-danger:hover { opacity: 0.85; }

@media (max-width: 768px) {
  .projects-grid { grid-template-columns: 1fr; }
  .task-item { flex-direction: column; align-items: flex-start; }
  .task-item-right { width: 100%; justify-content: flex-end; }
  .modal-lg { max-width: 100%; }
  .project-detail-header { flex-direction: column; gap: 0.5rem; }
}

@media print {
  .header, .tab-nav, .filter-bar, .footer, .action-btns, .btn, .report-nav, .date-presets { display: none !important; }
  #mobileMain { display: none !important; }
  body { background: white; color: black; }
  .report-table, .data-table { background: white; }
  .report-table td, .report-table th { border-color: #ccc; color: black; }
  .stat-card { border-color: #ccc; background: white; }
  .stat-value, .stat-label, .report-title { color: black; }
}

/* Subscriptions Overview */
.subs-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.subs-stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
}

.subs-stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-inverse);
  line-height: 1;
}

.subs-stat-label {
  font-size: 0.75rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.35rem;
}

.subs-source {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.subs-fees { color: #ef4444 !important; }
.subs-net { color: #22c55e !important; }

.badge-success { background: rgba(34,197,94,0.15); color: #22c55e; }
.badge-warning { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-muted { background: rgba(107,114,128,0.15); color: #6b7280; }
