/*
  GLOBAL THEME + LAYOUT
  - Defines base colors, typography, and layout scaffolding.
  - Individual sections below style the header, views, tables, etc.
*/
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #ef4444;
  --radius-md: 12px;
  --radius: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --font-sans: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  
  --sidebar-bg: #0f172a;
  --sidebar-text: #f8fafc;
  --sidebar-hover: #1e293b;
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* Shell: branding bar + app (fills viewport) */
.app-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-brand-bar {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.site-brand-bar-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
}

.site-brand-bar-text a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.site-brand-bar-text a:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

/* APP LAYOUT - GRID */
.app-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: minmax(0, 1fr);
  background: var(--bg);
}

/* SIDEBAR NAVIGATION */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: stretch;
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

.sidebar-header {
  padding: 32px 24px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  background: var(--primary);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.app-title-clickable {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.5px;
  transition: opacity 0.2s;
}

.app-title-clickable:hover {
  opacity: 0.8;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-nav-separator {
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
  margin: 6px 0 8px;
  width: 100%;
  flex-shrink: 0;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  color: #94a3b8; /* slate-400 */
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.nav-btn svg {
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.nav-btn:hover {
  color: var(--sidebar-text);
  background: var(--sidebar-hover);
}

.nav-btn.active {
  color: var(--primary);
  background: #e0e7ff; /* indigo-100 */
  font-weight: 600;
}

.nav-btn.active svg {
  opacity: 1;
}

/* FOOTER / SETTINGS */
.sidebar-footer {
  padding: 16px;
}

.sidebar-settings-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  width: 100%;
  font-size: 15px;
  font-weight: 500;
  color: #94a3b8;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.sidebar-settings-btn:hover {
  color: var(--sidebar-text);
  background: var(--sidebar-hover);
}

/* Main content */
.main-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 32px 48px;
  overflow-y: auto;
  background: var(--bg);
  position: relative;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
}

.toolbar h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sort-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.invoices-sort {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.invoices-client-search {
  width: 240px;
  min-width: 180px;
}

.clients-search {
  width: 240px;
  min-width: 180px;
}

/* Responsive toolbar layout (prevents overlap on narrow widths) */
@media (max-width: 860px) {
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .invoices-client-search,
  .clients-search {
    width: 100%;
    min-width: 0;
  }
}

/* Automatic backups section (Settings → Data Backup) */
#auto-backup-location {
  flex: 1;
  min-width: 220px;
}

/* HOME SUMMARY DASHBOARD */
.home-summary {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.home-current-month {
  flex: 1;
  min-width: 250px;
}

.home-current-month h3 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.home-total {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.home-total-label {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.home-items-sold-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.home-items-sold-label {
  font-weight: 500;
  color: var(--text);
}

.home-items-sold-qty {
  font-variant-numeric: tabular-nums;
}

.home-items-sold-empty {
  font-style: italic;
  color: var(--text-muted);
}

.home-balance-due h3,
.home-bank-account h3 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.home-balance-due .home-months-table {
  max-width: 360px;
}

.home-balance-invoices {
  list-style: none;
  margin: 6px 0 0 0;
  padding-left: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.home-balance-invoices li + li {
  margin-top: 2px;
}

.link-button {
  border: none;
  padding: 0;
  background: none;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.link-button:hover {
  color: var(--primary-hover);
}

.home-empty {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.home-months-table {
  width: 100%;
  max-width: 400px;
  border-collapse: collapse;
  font-size: 14px;
}

.home-months-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.home-months-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.home-months-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: #f8fafc;
  box-shadow: var(--shadow);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  padding: 8px 12px;
  font-size: 13px;
  box-shadow: none;
}

.btn-danger:hover {
  background: #fef2f2;
}

/* Home Chart Row */
.home-top-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.home-chart-panel {
  flex: 2;
  min-width: 350px;
  display: flex;
  flex-direction: column;
}

.home-sales-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 4px;
  flex: 1;
  min-height: 120px;
  padding-top: 10px;
}

.chart-bar-wrap {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  flex: 1;
  height: 100%;
}

.chart-bar {
  width: 100%;
  max-width: 20px;
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
}

.chart-bar:hover {
  opacity: 0.8;
}

.chart-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
}

/* PANELS (generic card container used throughout app) */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.panel:hover {
  box-shadow: var(--shadow);
}

.panel h3 {
  margin: 0 0 16px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel-header h3 {
  margin: 0;
}

/* Form fields */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  margin-bottom: 20px;
}

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

.field-row {
  margin-bottom: 14px;
}

.field-row:last-child {
  margin-bottom: 0;
}

.field-required-hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
}

.field-row .input-readonly,
.field-row input.input-readonly {
  background: var(--bg);
  color: var(--text-muted);
  cursor: default;
}

.field-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.field-row input,
.field-row select,
.field-row textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  transition: all 0.2s ease;
}

.field-row input:focus,
.field-row select:focus,
.field-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.field-row.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* LINE ITEMS TABLE (invoice editor) */
.line-items-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.line-items-actions .btn {
  white-space: nowrap;
}

.line-items-panel .table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
}

.line-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.line-items-table th {
  text-align: left;
  padding: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
}

.line-items-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.line-items-table input,
.line-items-table select {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  transition: all 0.2s ease;
}

.line-items-table input:hover,
.line-items-table select:hover {
  background: var(--bg);
}

.line-items-table input:focus,
.line-items-table select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.line-items-table .col-inventory {
  min-width: 140px;
}

.line-items-table .col-inventory select {
  width: 100%;
  min-width: 120px;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.line-items-empty-msg {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.line-items-table input.item-name {
  background: var(--bg);
  color: var(--text);
  cursor: default;
  font-weight: 500;
}

.line-items-table input.qty { width: 70px; }
.line-items-table input.unit-cost { width: 90px; }
.line-items-table .line-total {
  font-variant-numeric: tabular-nums;
  min-width: 80px;
}

.line-items-table .remove-cell {
  width: 40px;
  padding-left: 0;
}

/* INVOICE TOTALS (subtotal, tax, grand total) */
.totals {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  max-width: 280px;
  margin-left: auto;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-variant-numeric: tabular-nums;
}

.totals-row.total-final {
  font-size: 16px;
  font-weight: 600;
  padding-top: 12px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

/* INVOICES LIST (cards on the Invoices view) */
.invoices-list,
.goals-list,
.expenses-list,
.time-entries-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Goals */
.badge-overdue {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.goal-steps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.goal-step-row {
  display: grid;
  grid-template-columns: 180px 1fr 120px 100px;
  gap: 10px;
  align-items: center;
}

.goal-step-row input[type="date"] {
  width: 100%;
}

.goal-step-row input[type="text"] {
  width: 100%;
}

.goal-step-actions {
  display: flex;
  justify-content: flex-end;
}

.goal-step-completed {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

/* TIME TRACKER */
.time-tracker-filters {
  margin-bottom: 14px;
}

.time-tracker-summary {
  margin: 0 0 14px 0;
  color: var(--text-muted);
}

.invoice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.invoice-card:hover {
  border-color: #c4b5fd;
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.invoice-card-info h4 {
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 600;
}

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

.invoice-card-client {
  font-weight: 500;
  color: var(--text);
}

.invoice-card-totals {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.invoice-card-totals span + span {
  margin-left: 12px;
}

.invoice-card-balance .balance-due {
  color: var(--primary);
  font-weight: 500;
}

.invoice-card-balance .balance-paid {
  color: #059669;
  font-weight: 500;
}

.invoice-card-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.invoice-card-amount {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.invoice-card-actions {
  display: flex;
  gap: 8px;
  margin-left: 16px;
}

/* Inventory list */
.inventory-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.inventory-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.inventory-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: #cbd5e1;
}

.inventory-card h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
}

.inventory-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.inventory-card-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.field-row-checkbox {
  margin-bottom: 0;
}

.radio-toggle-row {
  display: flex;
  gap: 18px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 400;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

/* CLIENTS LIST (cards on the Clients view) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-prospect {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.badge-converted {
  background: #dcfce7;
  color: #059669;
  border: 1px solid #a7f3d0;
}

/* One card per row, full width of main content (same idea as .invoices-list) */
.clients-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.client-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: #cbd5e1;
}

.client-card h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
}

.client-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.client-card-totals {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.client-total-sold {
  font-variant-numeric: tabular-nums;
}

.client-balance-due {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text);
}

.client-card-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.client-more-actions {
  margin-left: auto;
}

.client-more-actions summary {
  list-style: none;
}

.client-more-actions summary::-webkit-details-marker {
  display: none;
}

.client-more-actions-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
}

.client-more-actions[open] .client-more-actions-body {
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* GENERIC MODAL DIALOGS */
.modal {
  border: none;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  max-width: 480px;
  width: 90%;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal::backdrop {
  background: rgba(0,0,0,0.4);
}

.modal-wide {
  max-width: 560px;
}

/* Home calendar: Edit/Delete chooser has no <form>, so it misses .modal form padding */
#calendar-item-actions-modal {
  padding: 24px;
  box-sizing: border-box;
}

#calendar-item-actions-modal .modal-body {
  margin-bottom: 0;
}

#calendar-item-actions-modal h3 {
  margin: 0 0 10px 0;
}

#calendar-item-actions-modal .modal-hint {
  margin: 0 0 18px 0;
  font-size: 13px;
  line-height: 1.5;
}

#calendar-item-actions-modal .modal-actions {
  margin-top: 4px;
}

.client-invoices-modal-content {
  padding: 24px;
}

.client-invoices-modal-content h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
}

.client-notes-modal-content {
  padding: 24px;
}

.client-notes-modal-content h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
}

.client-notes-list {
  max-height: min(60vh, 480px);
  overflow-y: auto;
  margin: 16px 0 20px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.client-notes-empty {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.client-note-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--bg);
}

.client-note-meta {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.client-note-body {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.private-notes-panel textarea {
  min-height: 100px;
  resize: vertical;
}

.client-invoices-totals {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.client-invoices-totals-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.client-invoices-totals-row strong {
  font-size: 16px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.client-invoices-totals-row strong.balance-zero {
  color: #059669;
}

.client-invoices-list {
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.client-invoices-empty {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.client-invoices-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.client-invoices-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}

.client-invoices-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

/* CALENDAR (first block on home view; spacing below before summary) */
.home-calendar-panel {
  margin-top: 0;
  margin-bottom: 24px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}

.calendar-view-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--text-muted);
}

.calendar-view-toolbar label {
  font-weight: 500;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.calendar-weekdays--week {
  align-items: start;
}

.calendar-weekday-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 4px;
  line-height: 1.2;
}

.calendar-weekday-date {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Week view: one row, tall columns for readable entries */
.calendar-grid--week {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: minmax(380px, 1fr);
  align-items: stretch;
}

.calendar-day--week {
  min-height: 380px;
  min-width: 0;
}

.calendar-day--week .calendar-events {
  overflow-y: auto;
  min-height: 0;
}

.calendar-day--week .calendar-event {
  white-space: normal;
  word-break: break-word;
}

.calendar-day--week .calendar-task {
  white-space: normal;
  word-break: break-word;
}

/* Year view: 12 mini months */
.calendar-grid--year {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}

@media (max-width: 1100px) {
  .calendar-grid--year {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.calendar-year-month {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 10px 10px 12px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.calendar-year-month-title {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.calendar-mini-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.calendar-mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.calendar-mini-grid .calendar-day--mini {
  min-height: 52px;
  padding: 4px;
  font-size: 10px;
}

.calendar-mini-grid .calendar-day-number {
  font-size: 10px;
  margin-bottom: 2px;
}

.calendar-mini-grid .calendar-event {
  font-size: 9px;
  padding: 3px 4px;
}

.calendar-mini-grid .calendar-task {
  font-size: 9px;
  padding: 2px 3px;
}

.calendar-day {
  background: var(--surface);
  min-height: 120px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  transition: background 0.2s ease;
}

.calendar-day:hover {
  background: #f8fafc;
}

.calendar-day.empty {
  background: #f1f5f9;
}

.calendar-day.today .calendar-day-number {
  background: var(--primary);
  color: white;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-left: -2px;
  margin-top: -2px;
  margin-bottom: 4px;
}

.calendar-day-number {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.calendar-events {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.calendar-event {
  background: #e0e7ff;
  color: #3730a3;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.2s;
}

.calendar-event:hover {
  background: #c7d2fe;
  transform: translateY(-1px);
}

.calendar-event strong {
  font-weight: 600;
  display: block;
}

.client-invoices-table td {
  font-variant-numeric: tabular-nums;
}

.client-invoices-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.client-invoices-actions .btn-sm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.payment-invoice-info {
  font-size: 13px;
  color: var(--text-muted);
  margin: -8px 0 16px 0;
}

.modal-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -4px 0 16px 0;
}

.company-backup-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.company-backup-section h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.company-backup-section .modal-hint {
  margin-bottom: 12px;
}

.backup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.company-inventory-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.company-inventory-section h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.company-inventory-section .modal-hint {
  margin-bottom: 12px;
}

.company-tax-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.company-tax-section h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.company-tax-section .modal-hint {
  margin-bottom: 12px;
}

.company-modal-inventory-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 12px;
}

/* On the dedicated Products & Services page, prefer browser-page scrolling. */
#view-products-services #company-modal-inventory-list {
  max-height: none;
  overflow-y: visible;
}

.company-modal-inventory-card {
  padding: 10px 12px;
}

.company-modal-inventory-card h4 {
  margin: 0 0 4px 0;
  font-size: 13px;
  text-transform: none;
  color: var(--text);
}

.company-modal-inventory-card p {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.company-modal-inventory-card .inventory-card-actions {
  margin-top: 8px;
  padding-top: 8px;
}

.company-logo-hint {
  margin-top: 4px !important;
  margin-bottom: 8px !important;
}

.company-logo-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.company-logo-preview {
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  flex-shrink: 0;
}

.company-logo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.company-logo-actions input[type="file"] {
  font-size: 13px;
  max-width: 100%;
}

.company-reports-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.company-reports-section h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Reporting page */
.reporting-intro {
  max-width: 640px;
  margin-bottom: 16px;
}

.reporting-date-range {
  margin-bottom: 16px;
}

.reporting-date-fields {
  max-width: 420px;
}

.reporting-balances-hint {
  max-width: 640px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid var(--border);
}

.reporting-extra {
  margin-bottom: 16px;
}

.reporting-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.reporting-section {
  margin: 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.reporting-section legend {
  padding: 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.reporting-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.reporting-option-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
}

.reporting-option-label input {
  margin-top: 3px;
  flex-shrink: 0;
}

.reporting-run-footer {
  display: flex;
  justify-content: flex-end;
  padding: 16px 18px;
  margin-top: 8px;
}

.modal form {
  padding: 24px;
}

.modal h3 {
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  margin-bottom: 20px;
}

.modal-body .field-row {
  margin-bottom: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* EMPTY STATE MESSAGES */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
}

.actions {
  display: flex;
  gap: 10px;
}

/* TASKS */
.task-completed {
  opacity: 0.6;
}
.task-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  color: white;
}
.task-priority-high {
  background: var(--danger);
}
.task-priority-medium {
  background: var(--primary);
}
.task-priority-low {
  background: #10b981;
}

.calendar-task {
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 4px;
  margin-top: 2px;
  cursor: pointer;
  background-color: #ffedd5;
  color: #1c1917;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calendar-task:hover {
  opacity: 0.8;
  background-color: #fed7aa;
}
.calendar-task.completed {
  text-decoration: line-through;
  opacity: 0.6;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

/* HELP (wiki + search) */
#view-help.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.help-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.help-header h2 {
  margin: 0 0 16px;
}

.help-search-row {
  max-width: 560px;
}

.help-search-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.help-search-input {
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.help-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(79 70 229 / 0.15);
}

.help-search-hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.help-body {
  display: grid;
  grid-template-columns: minmax(200px, 240px) 1fr;
  gap: 28px 32px;
  align-items: start;
  flex: 1;
  min-height: 0;
}

@media (max-width: 900px) {
  .help-body {
    grid-template-columns: 1fr;
  }
}

.help-toc {
  position: sticky;
  top: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.help-toc-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.help-toc a {
  color: var(--primary);
  text-decoration: none;
  line-height: 1.35;
}

.help-toc a:hover {
  text-decoration: underline;
}

.help-toc a.help-toc-muted {
  opacity: 0.45;
  pointer-events: none;
}

.help-wiki {
  min-width: 0;
}

.help-wiki .help-block {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.help-wiki .help-block:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.help-wiki h3 {
  margin: 0 0 12px;
  font-size: 1.15rem;
  scroll-margin-top: 16px;
}

.help-wiki p {
  margin: 0 0 12px;
}

.help-wiki ul {
  margin: 0 0 12px;
  padding-left: 1.25rem;
}

.help-wiki li {
  margin-bottom: 6px;
}

.help-wiki code {
  font-size: 0.9em;
  padding: 2px 6px;
  background: #f1f5f9;
  border-radius: 4px;
}

.help-no-results {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-top: 8px;
}

/* INVOICE: Payments & Terms panel */
.invoice-inline-payment {
  margin: 10px 0 6px;
}

.invoice-payments-panel .invoice-payments-summary {
  margin-bottom: 14px;
}

.invoice-terms-controls {
  margin-bottom: 16px;
}

#invoice-terms-custom-row {
  margin-top: 10px;
}

.invoice-payments-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 13px;
}

.invoice-payments-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
}

.invoice-payments-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.invoice-payments-table .num {
  text-align: right;
  white-space: nowrap;
}

.invoice-payments-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
}
