/* ═══ Finance Dashboard Pro — Combined Core CSS ═══ */
/* Flattened from @import chain for performance */


/* (Old top-nav CSS removed — replaced by sidebar) */

/* (Old donut/filter layout removed — now in scoped dashboard rules below) */

/* (Old button sizing removed — now in form-inputs.css) */

/* Responsive table cells and actions */
.summary-card table th,
.summary-card table td {
  padding: 0.45em 0.5em;
  font-size: 0.93em;
  word-break: break-word;
}

.summary-card .btn,
.summary-card button {
  margin: 0 2px;
}

@media (max-width: 1200px) {
  .summary-card table th,
  .summary-card table td {
    font-size: 0.85em;
    padding: 0.35em 0.3em;
  }
}

@media (max-width: 900px) {
  .summary-card table th,
  .summary-card table td {
    font-size: 0.78em;
    padding: 0.22em 0.15em;
  }
}
/* Center the calculator in its row */
.calculator-row-center {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 0 18px 0;
}
/* ── Compact Controls Bar ── */
.fd-controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 0;
}
.fd-ctrl-input,
.fd-ctrl-select,
.fd-ctrl-btn {
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 38px;
  border: 1px solid var(--fd-card-border);
  background: rgba(var(--fd-card-rgb), 0.4);
  color: var(--fd-text);
  margin: 0;
  box-shadow: none;
}
.fd-ctrl-input { text-align: center; min-width: 140px; }
.fd-ctrl-select { cursor: pointer; }
.fd-ctrl-btn {
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}
.fd-ctrl-btn:hover { background: rgba(255,255,255,0.08); }
.fd-ctrl-input:focus,
.fd-ctrl-select:focus,
.fd-ctrl-btn:focus {
  outline: 2px solid var(--fd-accent-strong);
  background: rgba(255,255,255,0.05);
}
.fd-controls-bar-summary-month {
  margin-top: 14px;
}
.fd-controls-label {
  font-size: 0.85rem;
  color: var(--fd-card-muted);
  font-weight: 600;
}
/* ── End Compact Controls Bar ── */
/* ==============================================
   Finance Dashboard Pro - Mobile-first approach
   Matching Filter Card size to other Summary Cards,
   2 donut charts side-by-side on larger screens
 ================================================ */

:root {
  --fd-card-alpha: 0.40;
  --fd-bg-alpha: 1;
  --font-size-base: 16px;
  --font-family-base: "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-family-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --radius: 12px;
}

/* Basic reset-ish */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* (Old .period-row styles removed — replaced by .fd-controls-bar) */

.table-container {
  contain: layout style paint;
}

/* ------------------ Base / Global Styles ------------------ */
html {
  font-size: 100%;
}
body {
  font-family: var(--font-family-base), sans-serif;
  font-size: var(--font-size-base);
  line-height: 1.4;
  color: var(--color-dark);
  min-height: 100vh;
  overflow-x: hidden; /* keep the page from sliding sideways */
  margin: 0;
}

.mono {
  font-family: var(--font-family-mono);
}

/* ==================================================
   Finance Dashboard themes (fd-app)
   ================================================== */
body.fd-app {
  --fd-bg-from: #020617;
  --fd-bg-via: #0f172a;
  --fd-bg-to: #020617;
  --fd-chrome-bg: #8b5e34;
  --fd-text: #ffffff;
  --fd-muted: rgba(226, 232, 240, 0.78);
  --fd-card-text: var(--fd-text);
  --fd-card-muted: var(--fd-muted);
  --fd-accent-text: #60a5fa;
  --fd-accent-strong: #3b82f6;
  --fd-total-number: #34d399;
  --fd-bg-alpha-clamped: clamp(0.01, var(--fd-bg-alpha), 1);
  --fd-chart-text: var(--fd-card-text);
  --fd-chart-grid: rgba(255, 255, 255, 0.10);
  --fd-chart-axis: rgba(255, 255, 255, 0.22);
  --fd-card-rgb: 30 41 59;
  --fd-card-border: rgba(71, 85, 105, 0.3);
  --fd-surface-alpha: 0.10;
  --fd-surface-hover-alpha: 0.14;
  --fd-surface-subtle-alpha: 0.08;
  --fd-surface-soft-alpha: 0.06;
  --fd-card-alpha-effective: 1;
  --fd-card-alpha-hover: 1;
  --fd-card-shadow: none;
  --fd-card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.2);
  --fd-input-bg: rgba(15, 23, 42, 0.8);
  --fd-input-border: rgba(71, 85, 105, 0.4);
  --fd-input-text: #ffffff;
  --fd-table-th-bg: rgba(30, 41, 59, 0.6);
  --fd-table-th-border: rgba(71, 85, 105, 0.5);
  --fd-table-td-border: rgba(71, 85, 105, 0.35);
  --fd-table-row-hover: rgba(255, 255, 255, 0.04);

  --color-primary: var(--fd-text);
  --color-dark: var(--fd-text);

  background-color: var(--fd-bg-to);
  color: var(--fd-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
  position: relative;
  z-index: 0;
  isolation: isolate;
}

body.fd-app::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--fd-bg-from), var(--fd-bg-via), var(--fd-bg-to));
  opacity: var(--fd-bg-alpha-clamped);
  pointer-events: none;
  z-index: -1;
}


/* (Old top-nav CSS removed — replaced by sidebar) */

/* Card surfaces: unified premium appearance across all cards */
body.fd-app .summary-card,
body.fd-app .insight-card,
body.fd-app .chart-canvas-container,
body.fd-app .branch-management,
body.fd-app section.management-section,
body.fd-app .management-section > section,
body.fd-app .ts-card,
body.fd-app.employer-page .emp-shift,
body.fd-app.employer-page .emp-request-panel,
body.fd-app.employer-page .emp-empty-inner,
body.fd-app.inventory-page .card,
body.fd-app.inventory-page .drawer__panel,
body.fd-app.inventory-page .modal__panel {
  background: rgb(var(--fd-card-rgb) / var(--fd-surface-alpha));
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  box-shadow: none;
  transition: background 0.15s;
  color: var(--fd-card-text);
}
body.fd-app .summary-card:hover,
body.fd-app .insight-card:hover,
body.fd-app .chart-canvas-container:hover,
body.fd-app .branch-management:hover,
body.fd-app section.management-section:hover,
body.fd-app .management-section > section:hover,
body.fd-app .ts-card:hover,
body.fd-app.employer-page .emp-shift:hover,
body.fd-app.employer-page .emp-request-panel:hover,
body.fd-app.inventory-page .card:hover {
  background: rgb(var(--fd-card-rgb) / var(--fd-surface-alpha));
  box-shadow: none;
}

body.fd-app .summary-card .muted,
body.fd-app .insight-card .muted,
body.fd-app .chart-canvas-container .muted,
body.fd-app .branch-management .muted,
body.fd-app section.management-section .muted,
body.fd-app .management-section > section .muted,
body.fd-app .ts-card .muted,
body.fd-app.employer-page .emp-shift .muted,
body.fd-app.employer-page .emp-request-panel .muted,
body.fd-app.employer-page .emp-empty-inner .muted,
body.fd-app.inventory-page .card .muted,
body.fd-app.inventory-page .drawer__panel .muted,
body.fd-app.inventory-page .modal__panel .muted {
  color: var(--fd-card-muted);
}

body.fd-app .summary-card {
  padding: 14px 16px;
}
body.fd-app .insight-card {
  padding: 14px 16px;
}
body.fd-app .chart-canvas-container {
  padding: 12px;
}


.timesheet-page .main-wrapper {
  width: 100%;
  margin: 0;
  padding: 0;
  max-width: none;
  box-sizing: border-box;
}
.timesheet-page .ts-shell,
.timesheet-page .ts-card {
  width: 100%;
  box-sizing: border-box;
}

/* ------------------ Container ------------------ */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: none;
  border-radius: 0;
  box-shadow: none;
  will-change: auto;
}

@media (min-width: 769px) {
  .container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 16px 18px;
  }
}

.container > * {
  width: 100%;
}

/* Timesheet page: same as all others now */
.timesheet-page .container {
  width: 100%;
  max-width: 100%;
  align-items: center;
}

@media (min-width: 769px) {
  .timesheet-page .container {
    width: 100%;
    max-width: 100%;
  }
}

.timesheet-page .container > * {
  width: 100%;
}


/* Utility classes */
.centered { text-align: center; }
.small-label { font-size: 0.8rem; }
.hidden { display: none; }
.noscript-warning {
  padding: 1rem;
  background: #fee;
  border: 1px solid #f99;
  margin: 1rem;
  border-radius: var(--radius);
}

/* Global error banner used when initial load fails */
.global-error-banner {
  padding: 12px 14px;
  border-radius: 10px;
  margin: 10px 0 14px 0;
  background: linear-gradient(180deg,#fff3f0,#fff7f5);
  border: 1px solid rgba(220,60,80,0.12);
  color: #3b2b2b;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(0,0,0,0.04);
}

/* (Old .filter-card-centered removed — replaced by .fd-controls-bar) */
.card-gap { margin-bottom: 1rem; }
.spaced-block { margin-bottom: 10px; }
.full-width-input { width: 100%; }
.month-input { min-width: 140px; }

/* ------------------ Grid & Forms (Mobile-first) ------------------ */
.grid.full-width {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
  justify-items: stretch;
  width: 100%;
}
.grid.full-width.management-sections-two {
  align-items: stretch;
  grid-auto-rows: auto;
}
.grid.full-width.management-sections-two > section {
  height: 100%;
}

form {
  display: grid;
  gap: 1rem;
  padding: 0;
  margin-bottom: 1rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#incomeForm > *,
#expenseForm > *,
#bankDepositForm > *,
#bankWithdrawalForm > * {
  min-width: 0;
  box-sizing: border-box;
}

.bank-deposit-quick {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--fd-card-border);
  border-radius: 12px;
  background: rgb(var(--fd-card-rgb) / 0.08);
}

.bank-deposit-title {
  margin: 0 0 4px;
  font-size: 0.92rem;
}

.bank-deposit-hint {
  margin: 0 0 8px;
  font-size: 0.78rem;
}

.bank-deposit-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 0;
}

.bank-deposit-submit {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(0.68rem, 1.15vw, 0.95rem);
  line-height: 1.15;
  padding: 10px 8px;
}

@media (max-width: 1200px) {
  .bank-deposit-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

/* ------------------ Filter and Upload Bars ------------------ */
.expense-search-container,
.time-overview-container,
.income-filter-bar,
.expense-filter-bar,
.expense-upload-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  row-gap: 10px;
}
@media (max-width: 640px) {
  .expense-search-container,
  .time-overview-container,
  .income-filter-bar,
  .expense-filter-bar,
  .expense-upload-bar {
    gap: 6px;
    padding: 6px;
    margin-top: 6px;
  }
}
@media (min-width: 1100px) {
  /* Keep Income/Expense filter bars on one line on wide desktop only */
  .management-sections-two .income-filter-bar,
  .management-sections-two .expense-filter-bar {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }
  .management-sections-two .income-filter-bar label,
  .management-sections-two .expense-filter-bar label {
    white-space: nowrap;
  }
  .management-sections-two .income-filter-bar .month-input,
  .management-sections-two .expense-filter-bar .month-input {
    flex: 0 0 160px;
  }
  .management-sections-two .income-filter-bar button,
  .management-sections-two .expense-filter-bar button {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

.search-input,
.expense-search-container input,
.time-overview-container input,
.income-filter-bar input,
.expense-filter-bar input,
.expense-upload-bar input {
  font-size: 0.9rem;
  padding: 0.5rem 0.7rem;
  margin: 0;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  min-height: 40px;
  box-sizing: border-box;
}
@media (max-width: 640px) {
  .search-input,
  .expense-search-container input,
  .time-overview-container input,
  .income-filter-bar input,
  .expense-filter-bar input,
  .expense-upload-bar input {
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
    min-height: 38px;
  }
}

.expense-search-container button,
.time-overview-container button,
.income-filter-bar button,
.expense-filter-bar button,
.expense-upload-bar button {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  min-height: 40px;
}
@media (max-width: 640px) {
  .expense-search-container button,
  .time-overview-container button,
  .income-filter-bar button,
  .expense-filter-bar button,
  .expense-upload-bar button {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    min-height: 38px;
  }
}

@media (min-width: 1100px) {
  /* Prevent the export button from wrapping on wide desktop */
  .expense-search-container { flex-wrap: nowrap; }
}

/* Allow inputs and selects to shrink so the button can stay on the same line */
.expense-search-container input,
.expense-search-container select {
  flex: 1 1 auto;
  min-width: 0;
}

/* Make the button stay its intrinsic size */
.expense-search-container button {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Hide file input visually */
#billFileInput { display: none; }
#cameraContainer { display: none; }
#cameraPreview {
  width: 200px;
  height: 150px;
  border: 1px solid #ccc;
}

/* Upload label button */
.upload-label {
  font-size: 0.8rem;
  background-color: var(--fd-accent-strong);
  color: #fff;
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid #ddd;
}
.upload-label:hover { background-color: var(--fd-accent-strong); }

/* ------------------ Table Container & Data-Tables ------------------ */
.table-container {
  background: none;
  border-radius: 0;
  box-shadow: none;
  border: none;
  max-height: 520px;
  width: 100%;
  overflow-x: auto !important;
  overflow-y: auto;
  /* Allow page scroll to continue when table reaches top/bottom. */
  overscroll-behavior-y: auto;
  /* Keep horizontal scroll behavior contained inside wide tables. */
  overscroll-behavior-x: contain;
  padding-bottom: 6px; /* keep horizontal scrollbar from covering last row */
  margin-bottom: 1rem;
}

/* Tablets/mobile: allow tables to exceed the card width and scroll horizontally. */
@media (max-width: 1024px) {
  body.fd-app .table-container > table {
    width: max-content;
    min-width: 100%;
  }
  body.fd-app .table-container > table.data-table {
    table-layout: auto;
  }
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
.data-table caption {
  text-align: left;
  padding: 0 0 10px 0;
  font-weight: 800;
}
.data-table th,
.data-table td {
  text-align: left;
  white-space: nowrap;
  min-width: 0;
  padding: 5px 4px;
  font-size: clamp(6px, 0.75vw + 4px, 13px);
}
.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  will-change: transform;
  background: rgba(59, 130, 246, 0.12);
}
.data-table thead th {
  text-align: left !important;
  font-weight: 700;
  color: #60a5fa;
  border-bottom: 2px solid rgba(59, 130, 246, 0.25);
  padding: 6px 4px;
}
.data-table tbody tr:hover { background: var(--fd-table-row-hover); }
.numeric { text-align: left !important; white-space: nowrap; }
th.numeric { text-align: left !important; }

/* Table buttons: always compact, never wrap */
.data-table .btn-danger,
.data-table button.btn-danger,
.data-table button {
  height: 24px !important;
  min-height: 24px !important;
  padding: 0 6px !important;
  font-size: clamp(6px, 0.6vw + 3px, 11px) !important;
  line-height: 24px !important;
  white-space: nowrap !important;
}

/* Expenses overview: show full text for company/reference/comments */
#expenseOverviewTable td:nth-child(3),
#expenseOverviewTable td:nth-child(7),
#expenseOverviewTable td:nth-child(8) {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#expenseOverviewTable td.expense-overview-bulk-editable {
  cursor: text;
  outline: 1px dashed rgba(96, 165, 250, 0.38);
  outline-offset: -2px;
}

#expenseOverviewTable td.expense-overview-bulk-editable:hover {
  background: rgba(59, 130, 246, 0.16);
}

#expenseOverviewTable .expense-overview-bulk-input {
  width: 100%;
  min-width: 0;
  min-height: 28px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.92);
  color: var(--fd-text);
  padding: 0.25rem 0.45rem;
  font-size: 0.78rem;
}
/* total-row highlight */
.total-row {
  background: rgb(var(--fd-card-rgb)) !important;
  font-weight: 800;
  position: sticky;
  bottom: 0;
  z-index: 11;
  will-change: transform; /* GPU-promote sticky total row */
}
.total-row td {
  border-top: 2px solid var(--fd-card-border) !important;
  text-align: left !important;
}
.total-row td.numeric {
  color: var(--fd-total-number) !important;
}
.ellipsis { margin: 0 4px; color: var(--fd-muted); }

/* --------------- Autocomplete -------------- */
.autocomplete-container {
  position: relative;
  display: inline-block;
  width: 100%;
}
.autocomplete-input { width: 100%; }
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  border: 1px solid var(--fd-card-border);
  border-top: none;
  max-height: 220px;
  overflow-y: auto;
  width: 100%;
  background: rgb(var(--fd-card-rgb));
  z-index: 5000;
  display: none;
  box-shadow: var(--fd-card-shadow-hover);
  border-radius: 8px;
  color: var(--fd-text);
  /* GPU-promote so box-shadow + overflow scroll don't repaint on main thread */
  will-change: transform;
  transform: translateZ(0);
}
.autocomplete-dropdown div {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.autocomplete-dropdown div:hover {
  background: rgba(59, 130, 246, 0.25);
  color: var(--fd-text);
}
.autocomplete-dropdown .selected {
  background: rgba(59, 130, 246, 0.35);
  color: var(--fd-text);
}

/* Remove the small top accent bar for management cards only */
.management-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  display: block !important;
}

.management-card { position: relative; overflow: hidden; }

/* Tighten employee loan table */
#employeeLoanContainer .data-table {
  table-layout: fixed;
}
#employeeLoanContainer .data-table th,
#employeeLoanContainer .data-table td {
  padding: 4px 3px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#employeeLoanContainer .data-table .col-actions {
  width: 140px;
  white-space: nowrap;
}
/* Reset History button */
.btn-secondary {
  height: 24px !important;
  min-height: 24px !important;
  padding: 0 8px !important;
  font-size: clamp(6px, 0.6vw + 3px, 11px) !important;
  line-height: 24px !important;
  background: rgba(59,130,246,0.15) !important;
  border: 1px solid rgba(59,130,246,0.3) !important;
  color: #60a5fa !important;
  border-radius: 6px !important;
  white-space: nowrap !important;
  cursor: pointer;
}
.btn-secondary:hover {
  background: rgba(59,130,246,0.25) !important;
}

/* Additional container for dynamic loan summary or custom charts */
.loan-summary {
  padding: 16px 18px;
  margin: 0.75rem 0 1.25rem 0;
  width: 100%;
  box-sizing: border-box;
}

.loan-summary .loan-filter-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 0;
  width: 100%;
}

.loan-summary .loan-filter-bar label {
  text-align: center;
  font-size: 1rem;
  color: var(--fd-text);
  font-weight: 500;
  width: 100%;
}

.loan-summary .loan-filter-bar .month-input {
  width: 100%;
  max-width: 280px;
  padding: 10px 12px;
  border: 1px solid var(--fd-card-border);
  border-radius: 6px;
  background: rgb(var(--fd-card-rgb));
  color: var(--fd-text);
  font-size: 1rem;
  min-height: 40px;
  box-sizing: border-box;
}

.loan-summary .loan-filter-bar .month-input:focus {
  outline: none;
  border-color: var(--fd-accent-strong);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#summaryCardsContainer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
  width: 100%;
}

/* Summary cards base styling */
#summaryCardsContainer .summary-card {
  width: 100%;
  padding: 14px 16px !important;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 140px;
}

#summaryCardsContainer .summary-card h2 {
  font-size: 1.3rem;
  margin: 0 0 10px 0;
  color: var(--fd-text);
  font-weight: 700;
  word-wrap: break-word;
}

#summaryCardsContainer .summary-card h3 {
  font-size: 1rem;
  margin: 8px 0 10px 0;
  color: var(--fd-accent-strong);
  font-weight: 600;
}

/* Responsive summary card sizing */
@media (max-width: 1399px) and (min-width: 1100px) {
  #summaryCardsContainer .summary-card {
    padding: 12px 14px !important;
    min-height: 120px;
  }
  #summaryCardsContainer .summary-card h2 {
    font-size: 1.15rem;
    margin-bottom: 8px;
  }
  #summaryCardsContainer .summary-card h3 {
    font-size: 0.95rem;
    margin: 6px 0 8px 0;
  }
}

@media (max-width: 1099px) and (min-width: 900px) {
  #summaryCardsContainer .summary-card {
    padding: 12px 14px !important;
    min-height: 120px;
  }
  #summaryCardsContainer .summary-card h2 {
    font-size: 1.1rem;
    margin-bottom: 8px;
  }
  #summaryCardsContainer .summary-card h3 {
    font-size: 0.9rem;
    margin: 6px 0 8px 0;
  }
}

@media (max-width: 899px) and (min-width: 600px) {
  #summaryCardsContainer .summary-card {
    padding: 12px 14px !important;
    min-height: 110px;
  }
  #summaryCardsContainer .summary-card h2 {
    font-size: 1rem;
    margin-bottom: 6px;
  }
  #summaryCardsContainer .summary-card h3 {
    font-size: 0.85rem;
    margin: 4px 0 6px 0;
  }
}

@media (max-width: 599px) {
  #summaryCardsContainer .summary-card {
    padding: 12px 14px !important;
    min-height: 130px;
  }
  #summaryCardsContainer .summary-card h2 {
    font-size: 0.95rem;
    margin-bottom: 6px;
  }
  #summaryCardsContainer .summary-card h3 {
    font-size: 0.8rem;
    margin: 4px 0 6px 0;
  }
}

/* Responsive table sizing for loan summary */
#summaryCardsContainer .table-container {
  background: none;
  border-radius: 0;
  box-shadow: none;
  border: none;
  max-height: 450px;
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-bottom: 6px;
  background-color: transparent;
}

#summaryCardsContainer .data-table {
  width: 100%;
  font-size: 0.9rem;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 100%;
}

#summaryCardsContainer .data-table th,
#summaryCardsContainer .data-table td {
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  min-width: auto;
}

#summaryCardsContainer .data-table thead th {
  font-weight: 600;
  background: transparent;
  color: var(--fd-text);
}

#summaryCardsContainer .data-table tbody tr:hover {
  background: rgb(var(--fd-card-rgb) / 0.08);
}

#summaryCardsContainer .total-row {
  background: rgb(var(--fd-card-rgb)) !important;
  font-weight: 800;
}

#summaryCardsContainer .total-row td {
  border-top: 2px solid var(--fd-card-border) !important;
  padding: 10px;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .loan-summary {
    padding: 12px 14px;
  }

  .loan-summary .loan-filter-bar {
    align-items: stretch;
    gap: 8px;
    margin-bottom: 12px;
  }

  .loan-summary .loan-filter-bar label {
    font-size: 0.95rem;
    text-align: left;
  }

  .loan-summary .loan-filter-bar .month-input {
    width: 100%;
    max-width: none;
    padding: 10px;
    font-size: 16px;
    min-height: 44px;
  }

  #summaryCardsContainer {
    gap: 10px;
    margin-top: 10px;
  }

  /* Mobile card sizing handled by responsive rules above */

  #summaryCardsContainer .data-table {
    font-size: 0.8rem;
    width: max-content;
    min-width: 100%;
  }

  #summaryCardsContainer .data-table th,
  #summaryCardsContainer .data-table td {
    padding: 6px 8px;
  }

  #summaryCardsContainer .table-container {
    max-height: 350px;
    margin-bottom: 8px;
    width: 100%;
    overflow-x: auto !important;
  }
}

@media (max-width: 768px) {
  .loan-summary {
    padding: 14px 16px;
  }

  .loan-summary .loan-filter-bar {
    align-items: stretch;
  }

  .loan-summary .loan-filter-bar label {
    text-align: left;
  }

  .loan-summary .loan-filter-bar .month-input {
    max-width: none;
  }

  #summaryCardsContainer {
    gap: 14px;
  }

  #summaryCardsContainer .table-container {
    max-height: 400px;
    overflow-x: auto !important;
    width: 100%;
  }

  #summaryCardsContainer .data-table {
    font-size: 0.85rem;
    width: max-content;
    min-width: 100%;
  }

  #summaryCardsContainer .data-table th,
  #summaryCardsContainer .data-table td {
    padding: 7px 9px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  /* iPad portrait/landscape optimization */
  .loan-summary {
    padding: 16px 20px;
    margin: 1rem 0 1.5rem 0;
  }

  .loan-summary .loan-filter-bar {
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .loan-summary .loan-filter-bar label {
    font-size: 1.05rem;
    flex: 0 1 100%;
  }

  .loan-summary .loan-filter-bar .month-input {
    width: 100%;
    max-width: 350px;
    padding: 12px 14px;
    font-size: 1.05rem;
    min-height: 48px;
  }

  #summaryCardsContainer {
    gap: 16px;
    margin-top: 18px;
  }

  #summaryCardsContainer .summary-card {
    padding: 16px 18px !important;
    border-radius: 14px;
  }

  #summaryCardsContainer .summary-card h2 {
    font-size: 1.4rem;
    margin-bottom: 14px;
    font-weight: 700;
  }

  #summaryCardsContainer .summary-card h3 {
    font-size: 1.05rem;
    margin: 14px 0 14px 0;
    font-weight: 600;
  }

  #summaryCardsContainer .table-container {
    max-height: 520px;
    overflow-x: auto !important;
    overflow-y: auto;
    margin-bottom: 14px;
    padding-bottom: 8px;
    width: 100%;
  }

  #summaryCardsContainer .data-table {
    width: max-content;
    min-width: 100%;
    font-size: 0.95rem;
  }

  #summaryCardsContainer .data-table th {
    padding: 10px 12px;
    min-height: 44px;
    font-weight: 600;
  }

  #summaryCardsContainer .data-table td {
    padding: 10px 12px;
    min-height: 40px;
  }

  #summaryCardsContainer .total-row td {
    padding: 12px;
    font-weight: 800;
  }
}

@media (min-width: 1024px) {
  /* Large tablets & desktops */
  .loan-summary {
    padding: 18px 22px;
    margin: 1rem 0 1.5rem 0;
  }

  .loan-summary .loan-filter-bar {
    gap: 14px;
    margin-bottom: 20px;
  }

  .loan-summary .loan-filter-bar label {
    font-size: 1.1rem;
  }

  .loan-summary .loan-filter-bar .month-input {
    width: 100%;
    max-width: 300px;
    padding: 12px 14px;
    font-size: 1rem;
    min-height: 44px;
  }

  #summaryCardsContainer {
    gap: 18px;
    margin-top: 20px;
  }

  #summaryCardsContainer .summary-card {
    padding: 16px 20px !important;
    border-radius: 14px;
  }

  #summaryCardsContainer .summary-card h2 {
    font-size: 1.45rem;
    margin-bottom: 14px;
  }

  #summaryCardsContainer .summary-card h3 {
    font-size: 1.08rem;
    margin: 14px 0 14px 0;
  }

  #summaryCardsContainer .table-container {
    max-height: 580px;
    overflow-x: auto !important;
    overflow-y: auto;
    margin-bottom: 14px;
  }

  #summaryCardsContainer .data-table {
    width: max-content;
    min-width: 100%;
    font-size: 0.95rem;
  }

  #summaryCardsContainer .data-table th {
    padding: 11px 13px;
    min-height: 44px;
    font-weight: 600;
  }

  #summaryCardsContainer .data-table td {
    padding: 10px 13px;
    min-height: 40px;
  }

  #summaryCardsContainer .total-row td {
    padding: 12px;
  }
}

/* iPad Landscape optimization (orientation) */
@media (min-width: 768px) and (max-height: 600px) and (orientation: landscape) {
  .loan-summary {
    padding: 12px 16px;
    margin: 0.75rem 0 1rem 0;
  }

  .loan-summary .loan-filter-bar {
    gap: 10px;
    margin-bottom: 12px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .loan-summary .loan-filter-bar label {
    font-size: 1rem;
    flex: 0 0 auto;
  }

  .loan-summary .loan-filter-bar .month-input {
    width: 280px;
    max-width: 100%;
    padding: 10px 12px;
    font-size: 1rem;
    min-height: 42px;
  }

  #summaryCardsContainer {
    gap: 12px;
    margin-top: 12px;
  }

  #summaryCardsContainer .summary-card {
    padding: 12px 16px !important;
  }

  #summaryCardsContainer .summary-card h2 {
    font-size: 1.2rem;
    margin-bottom: 10px;
  }

  #summaryCardsContainer .summary-card h3 {
    font-size: 0.95rem;
    margin: 8px 0 8px 0;
  }

  #summaryCardsContainer .table-container {
    max-height: 320px;
    margin-bottom: 8px;
  }

  #summaryCardsContainer .data-table {
    font-size: 0.85rem;
  }

  #summaryCardsContainer .data-table th,
  #summaryCardsContainer .data-table td {
    padding: 6px 8px;
  }
}



/* KPI summary layout — responsive rules in responsive.css */
section.summary-cards {
  margin: 0.75rem 0 1.25rem 0;
  width: 100%;
  box-sizing: border-box;
}

section.summary-cards > .kpi-legend {
  grid-column: 1 / -1;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--fd-card-border);
  background: rgb(var(--fd-card-rgb) / 0.08);
  font-size: 0.76rem;
  line-height: 1.3;
}

/* KPI card typography + spacing (top summary row) */
section.summary-cards > .summary-card {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: min-content;
  gap: 5px;
  padding: 12px 14px;
  min-height: 194px;
  border-radius: 14px;
}
section.summary-cards > .summary-card .icon {
  font-size: 0.82rem;
  opacity: 0.95;
  line-height: 1;
  margin-bottom: 2px;
}
section.summary-cards > .summary-card h3 {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.15;
  font-weight: 700;
  color: rgb(173 205 247);
  letter-spacing: 0.01em;
}
section.summary-cards > .summary-card > p {
  margin: 0;
  font-size: clamp(1.05rem, 1.25vw, 1.55rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
section.summary-cards > .summary-card .details {
  display: flex;
  align-items: baseline;
  gap: 2px 6px;
  flex-wrap: wrap;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  font-size: 0.76rem;
  line-height: 1.22;
  color: var(--fd-card-muted);
  margin-bottom: 2px;
}
section.summary-cards > .summary-card .details > span {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
section.summary-cards > .summary-card .details > span:not(.label) {
  margin-right: 8px;
}
section.summary-cards > .summary-card .details .label {
  white-space: nowrap;
  font-weight: 700;
  color: rgb(195 216 247);
}
section.summary-cards > .summary-card .kpi-helper {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.24;
}
section.summary-cards > .summary-card .inner-summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 2px;
}
section.summary-cards > .summary-card .inner-summary-table th,
section.summary-cards > .summary-card .inner-summary-table td {
  padding: 4px 0;
  font-size: 0.76rem;
  line-height: 1.18;
  border-bottom: 1px solid rgb(var(--fd-card-rgb) / 0.32);
  white-space: nowrap;
}
section.summary-cards > .summary-card .inner-summary-table th {
  text-align: left;
  font-weight: 700;
  color: rgb(221 233 250);
}
section.summary-cards > .summary-card .inner-summary-table td {
  text-align: right;
  font-weight: 700;
  color: rgb(231 241 255);
}
section.summary-cards > .summary-card .trend {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
section.summary-cards > .summary-card .trend svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}
section.summary-cards > .summary-card .trend.up {
  color: #22c55e;
}
section.summary-cards > .summary-card .trend.down {
  color: #fb7185;
}
section.summary-cards > .summary-card .summary-branch-list {
  margin: 2px 0 0;
  gap: 3px;
  max-height: 82px;
}
section.summary-cards > .summary-card .summary-branch-list li {
  font-size: 0.75rem;
  line-height: 1.18;
}
section.summary-cards > .summary-card .summary-branch-list .rank {
  width: 16px;
  height: 16px;
  line-height: 16px;
  font-size: 0.72rem;
}
section.summary-cards > .summary-card .summary-branch-list .label,
section.summary-cards > .summary-card .summary-branch-list .value {
  white-space: nowrap;
}

/* ------------------ Heading Toggles ------------------ */
.toggle-heading {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: transparent;
  color: var(--fd-text);
  padding: 6px 10px;
  margin: 0 auto 1rem auto;
  border: 1px solid var(--fd-card-border);
  border-radius: 10px;
  font-size: 0.85rem;
  width: 100%;
  min-height: 34px;
  line-height: 1.1;
  transition: background 0.1s ease, border-color 0.1s ease, transform 0.1s ease;
}
.toggle-heading:hover {
  background: rgb(var(--fd-card-rgb) / 0.12);
}
.toggle-heading::after {
  content: "▼";
  font-size: 0.85rem;
  margin-left: 5px;
  transition: transform 0.3s ease;
}
.toggle-heading.open::after { transform: rotate(180deg); }

/* ------------------ Branch Management ------------------ */
.branch-management {
  margin: 0.75rem 0 0.5rem 0;
  padding: 16px 18px;
}
.branch-form {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}
#monthlyLoanField {
  display: none;
  margin-bottom: 10px;
}
#loanPerWeekField { display: none; }
#loanPerHourWeekend { margin-bottom: 6px; }

/* --------------- Multi-Checkbox Branch Dropdown -------------- */
.branch-multiselect { display: inline-block; position: relative; margin-left: 10px; }
.branch-selectBox {
  display: inline-block;
  cursor: pointer;
  border: 1px solid var(--fd-card-border);
  border-radius: 4px;
  background: rgb(var(--fd-card-rgb) / 0.12);
  padding: 5px;
  min-width: 140px;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  color: var(--fd-text);
}
.branch-selectBox::after {
  content: "▼";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--fd-muted);
}
.branch-checkboxes {
  display: none;
  position: absolute;
  background: rgb(var(--fd-card-rgb));
  border: 1px solid var(--fd-card-border);
  border-radius: 4px;
  padding: 8px;
  z-index: 999;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
  box-shadow: var(--fd-card-shadow-hover);
  color: var(--fd-text);
}
.branch-checkboxes label {
  display: block;
  margin-bottom: 4px;
  cursor: pointer;
}
.branch-checkboxes input { margin-right: 6px; }

/* --------------- Additional Filter Card (General) -------------- */
.filter-label { font-size: 0.9rem; white-space: nowrap; }

/* --------------- Donut Charts & Two-Charts Layout -------------- */
.two-charts-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  margin-top: 1rem;
}
.two-charts-container.full-width { width: 100%; }
.two-charts-container > div {
  flex: 1 1 300px;
  max-width: 600px;
  margin: auto;
  min-height: 300px;
}
.chart-canvas-large { 
  height: clamp(250px, 60vh, 400px);
  min-height: 250px;
}

/* Dashboard branch/insight lists (scoped to overview page) */

body.fd-app.dashboard-overview-page .insight-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  max-height: 210px;
  overflow-y: auto;
  overflow-x: hidden;
}

body.fd-app.dashboard-overview-page .insight-list li {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  line-height: 1.2;
  min-height: 20px;
}

body.fd-app.dashboard-overview-page .insight-list .rank {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.16);
  color: var(--fd-card-text);
  text-align: center;
  font-size: 0.78rem;
  line-height: 18px;
  font-weight: 700;
  border: 1px solid rgba(59, 130, 246, 0.26);
}

body.fd-app.dashboard-overview-page .insight-list .key,
body.fd-app.dashboard-overview-page .insight-list .label { font-weight: 600; color: var(--fd-card-text); }
body.fd-app.dashboard-overview-page .insight-list .val,
body.fd-app.dashboard-overview-page .insight-list .value { color: var(--fd-card-muted); font-size: 0.86rem; white-space: nowrap; display: inline-flex; align-items: center; }
body.fd-app.dashboard-overview-page .insight-list .pct { color: var(--fd-card-muted); font-size: 0.8rem; margin-left: 6px; }
body.fd-app.dashboard-overview-page .insight-list .muted { color: var(--fd-card-muted); font-size: 0.9rem; grid-template-columns: 1fr; }

body.fd-app.dashboard-overview-page .ops-card .ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

body.fd-app.dashboard-overview-page .ops-card .ops-grid.split-highlights {
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.65fr);
  gap: 12px;
}

body.fd-app.dashboard-overview-page .ops-card .mini-block {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 6px 0;
  border-bottom: 1px solid rgb(var(--fd-card-rgb) / var(--fd-surface-soft-alpha));
  min-width: 0;
}

body.fd-app.dashboard-overview-page .ops-card .mini-block:nth-last-child(-n + 2) {
  border-bottom: 0;
}

body.fd-app.dashboard-overview-page .ops-card .ops-grid.split-highlights .mini-block {
  border-bottom: 0;
}

body.fd-app.dashboard-overview-page .ops-card .ops-grid.split-highlights .stats-block {
  border-left: 1px solid rgb(var(--fd-card-rgb) / var(--fd-surface-soft-alpha));
  padding-left: 12px;
}

body.fd-app.dashboard-overview-page .ops-card .mini-title {
  font-weight: 600;
  color: var(--fd-card-muted);
  margin-bottom: 4px;
}

body.fd-app.dashboard-overview-page .ops-card .insight-list.compact {
  max-height: 176px;
  gap: 4px;
}

body.fd-app.dashboard-overview-page .ops-card .stats-block {
  display: grid;
  gap: 6px;
}

body.fd-app.dashboard-overview-page .ops-card .stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--fd-card-muted);
}

body.fd-app.dashboard-overview-page .ops-card .stat-row strong { font-size: 0.93rem; color: var(--fd-accent-text); }

body.fd-app.dashboard-overview-page .ops-card .stats-block[data-branch][data-mode]::before {
  content: attr(data-mode) " | " attr(data-branch);
  display: block;
  margin-bottom: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--fd-card-muted);
}

body.fd-app.dashboard-overview-page #insightBranchList li[data-branch],
body.fd-app.dashboard-overview-page #insightBranchBalanceList li[data-branch],
body.fd-app.dashboard-overview-page #cashBalanceBranchList li[data-branch] {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  border-radius: 8px;
  padding: 4px 6px;
}

body.fd-app.dashboard-overview-page #insightBranchList li[data-branch]:hover,
body.fd-app.dashboard-overview-page #insightBranchBalanceList li[data-branch]:hover,
body.fd-app.dashboard-overview-page #cashBalanceBranchList li[data-branch]:hover {
  background: rgba(46, 109, 246, 0.08);
}

body.fd-app.dashboard-overview-page #insightBranchList li[data-branch].active,
body.fd-app.dashboard-overview-page #insightBranchBalanceList li[data-branch].active,
body.fd-app.dashboard-overview-page #cashBalanceBranchList li[data-branch].active {
  background: rgba(46, 109, 246, 0.12);
  box-shadow: 0 0 0 1px rgba(46, 109, 246, 0.35) inset;
}

body.fd-app.dashboard-overview-page .branch-cats .bc-card-hdr.active {
  box-shadow: 0 0 0 2px rgba(46, 109, 246, 0.25) inset;
  border-radius: 10px;
}

body.fd-app.dashboard-overview-page .ai-insight { font-size: 0.86rem; line-height: 1.34; }
body.fd-app.dashboard-overview-page .ai-list {
  list-style: none;
  margin: 0;
  padding: 0;
  column-count: 2;
  column-gap: 14px;
  counter-reset: ai-step;
}
body.fd-app.dashboard-overview-page .ai-list li {
  display: block;
  break-inside: avoid;
  position: relative;
  font-size: 0.79rem;
  color: var(--fd-card-text);
  border: 0;
  border-bottom: 1px solid rgb(var(--fd-card-rgb) / var(--fd-surface-soft-alpha));
  border-radius: 0;
  padding: 5px 0 5px 28px;
  margin: 0 0 5px;
  line-height: 1.34;
  box-shadow: none;
}
body.fd-app.dashboard-overview-page .ai-list li::before {
  counter-increment: ai-step;
  content: counter(ai-step);
  position: absolute;
  left: 0;
  top: 5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(59, 130, 246, 0.28);
  background: rgba(59, 130, 246, 0.14);
  color: var(--fd-card-text);
  text-align: center;
  line-height: 18px;
  font-size: 0.72rem;
  font-weight: 700;
}
body.fd-app.dashboard-overview-page .ai-list li:last-child { border-bottom: 0; }
body.fd-app.dashboard-overview-page .ai-list strong { color: var(--fd-accent-text); }

@media (max-width: 900px) {
  body.fd-app.dashboard-overview-page .ai-list {
    column-count: 1;
  }
}

@media (max-width: 600px) {
  body.fd-app.dashboard-overview-page .ops-card .ops-grid,
  body.fd-app.dashboard-overview-page .ops-card .ops-grid.split-highlights { grid-template-columns: 1fr; }

  body.fd-app.dashboard-overview-page .ops-card .ops-grid.split-highlights .stats-block {
    border-left: 0;
    border-top: 1px solid rgb(var(--fd-card-rgb) / var(--fd-surface-soft-alpha));
    padding-left: 0;
    padding-top: 10px;
  }
}

/* ── Premium Branch Category Cards ── */
.branch-categories-section {
  margin-top: 14px;
  padding: 0;
}
.branch-categories-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fd-card-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--fd-card-border);
}
.branch-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.bc-card {
  background: rgb(var(--fd-card-rgb) / var(--fd-surface-alpha));
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.bc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 14px 14px 0 0;
}
.bc-blue::before  { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.bc-green::before { background: linear-gradient(90deg, #10b981, #34d399); }
.bc-purple::before{ background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.bc-amber::before { background: linear-gradient(90deg, #d97706, #fbbf24); }
.bc-teal::before  { background: linear-gradient(90deg, #0d9488, #2dd4bf); }
.bc-coral::before { background: linear-gradient(90deg, #dc2626, #f87171); }

.bc-card-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  cursor: pointer;
}
.bc-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.04em;
}
.bc-blue .bc-tag  { background: rgba(59,130,246,0.12);  color: #60a5fa; }
.bc-green .bc-tag { background: rgba(16,185,129,0.12);  color: #34d399; }
.bc-purple .bc-tag{ background: rgba(139,92,246,0.12);  color: #a78bfa; }
.bc-amber .bc-tag { background: rgba(217,119,6,0.12);   color: #fbbf24; }
.bc-teal .bc-tag  { background: rgba(13,148,136,0.12);  color: #2dd4bf; }
.bc-coral .bc-tag { background: rgba(220,38,38,0.12);   color: #f87171; }

.bc-total {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--fd-card-text);
  letter-spacing: -0.02em;
}
.bc-cat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  max-height: 155px;
}
.bc-cat-list::-webkit-scrollbar { width: 4px; }
.bc-cat-list::-webkit-scrollbar-track { background: transparent; }
.bc-cat-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.bc-cat-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
.bc-cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.bc-cat-row:last-child { margin-bottom: 0; }
.bc-cat-num {
  font-size: 0.68rem;
  color: var(--fd-card-muted);
  font-weight: 600;
  width: 14px;
  text-align: right;
  flex-shrink: 0;
}
.bc-cat-body { flex: 1; min-width: 0; }
.bc-cat-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
  gap: 8px;
}
.bc-cat-nm {
  font-size: 0.82rem;
  color: var(--fd-card-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.bc-cat-am {
  font-size: 0.76rem;
  color: var(--fd-card-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.bc-cat-am b {
  color: var(--fd-card-text);
  font-weight: 600;
}
.bc-cat-bar {
  width: 100%;
  height: 4px;
  background: rgb(var(--fd-card-rgb) / 0.06);
  border-radius: 2px;
  overflow: hidden;
}
.bc-cat-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(.4,0,.2,1);
}
.bc-blue .bc-cat-bar-fill  { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.bc-green .bc-cat-bar-fill { background: linear-gradient(90deg, #10b981, #34d399); }
.bc-purple .bc-cat-bar-fill{ background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.bc-amber .bc-cat-bar-fill { background: linear-gradient(90deg, #d97706, #fbbf24); }
.bc-teal .bc-cat-bar-fill  { background: linear-gradient(90deg, #0d9488, #2dd4bf); }
.bc-coral .bc-cat-bar-fill { background: linear-gradient(90deg, #dc2626, #f87171); }

.bc-card-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgb(var(--fd-card-rgb) / 0.06);
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--fd-card-muted);
}
.bc-card-footer span:last-child { font-weight: 600; }

@media (max-width: 600px) {
  .branch-cats { grid-template-columns: 1fr; }
}
/* ── End Premium Branch Category Cards ── */

/* ── Notice Status Badge ── */
.notice-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.notice-status-badge.pending {
  background: rgba(251,191,36,0.12);
  color: #fbbf24;
}
.notice-status-badge.held {
  background: rgba(34,197,94,0.12);
  color: #22c55e;
}
.notice-status-badge.missed {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
}
.insights-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.stat-card {
  background: rgb(var(--fd-card-rgb) / var(--fd-surface-subtle-alpha));
  border: 1px solid var(--fd-card-border);
  border-radius: 8px;
  padding: 10px;
  box-shadow: none;
  display: grid;
  gap: 4px;
}
.stat-label { font-size: 0.85rem; color: var(--fd-card-muted); }
.stat-value { font-size: 1.05rem; font-weight: 700; color: var(--fd-card-text); }

/* ===============================
   MAKE THE DONUT CHARTS FIXED
   SIDE-BY-SIDE ON DESKTOP
================================= */
@media (min-width: 601px) {
  .two-charts-container {
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
  }
  .two-charts-container > div {
    max-width: 400px;
    margin: 0;
  }
}


/* ------------------ Bills / Notices / PDF / Time Tracking Sections ------------------ */
#billsCardDetails,
#noticesCardDetails,
#pdfCardDetails,
#timeTrackingCardDetails,
#inventoryCardDetails {
  
  border: 1px solid #ddd;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 20px;
  padding: 1rem;
}
#billsCardDetails .data-table,
#noticesCardDetails .data-table,
#pdfCardDetails .data-table,
#timeTrackingCardDetails .data-table,
#inventoryCardDetails .data-table {
  font-size: 0.8rem !important;
}

/* --------------- Time Tracking --------------- */
#timeTrackingStatus { margin-top: 0.5rem; color: green; font-size: 0.9rem; }
#timeTrackingTbody td { white-space: nowrap; }

/* ------------------ Footer ------------------ */
.footer {
  background: rgb(var(--fd-card-rgb) / 0.10);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--fd-card-muted);
  text-align: center;
  padding: 14px 12px;
  margin: 20px auto 0;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.footer-copy {
  width: 100%;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  min-height: 1.2em;
  line-height: 1.35;
  font-size: 0.82rem;
  color: var(--fd-card-muted);
}

body.fd-app.fd-theme-modal-open {
  overflow: hidden;
}

body.fd-app.fd-chart-preview-open {
  overflow: hidden;
}

.chart-preview-trigger {
  border: 1px solid var(--fd-card-border);
  background: rgba(var(--fd-card-rgb), 0.4);
  color: var(--fd-text);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 38px;
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  white-space: nowrap;
  cursor: pointer;
}

.chart-preview-trigger:hover {
  background: rgba(255,255,255,0.08);
}

.fd-overview-preview[hidden] {
  display: none;
}

.fd-overview-preview {
  position: fixed;
  inset: 0;
  z-index: 10080;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.fd-overview-preview__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: 0;
  background: rgba(2, 6, 23, 0.78);
}

.fd-overview-preview__panel {
  position: relative;
  width: min(96vw, 1700px);
  height: min(88vh, 920px);
  background: rgb(var(--fd-card-rgb));
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  box-shadow: var(--fd-card-shadow-hover);
  color: var(--fd-text);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fd-overview-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.fd-overview-preview__header h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
}

.fd-overview-preview__close {
  min-width: 92px !important;
}

.fd-overview-preview__chart-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#overviewChartPreviewCanvas {
  width: 100% !important;
  height: 100% !important;
}

.fd-footer-theme-toggle {
  min-width: 220px;
}

body.fd-app .appearance-layout-panel[hidden] {
  display: none;
}

body.fd-app .appearance-layout-panel {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.fd-appearance-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: 0;
  background: rgba(2, 6, 23, 0.72);
}

.fd-appearance-window {
  position: relative;
  width: min(960px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  background: rgb(var(--fd-card-rgb));
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  box-shadow: var(--fd-card-shadow-hover);
  color: var(--fd-text);
  padding: 18px;
}

.fd-appearance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.fd-appearance-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

.fd-appearance-close {
  min-width: 92px;
}

.fd-appearance-subtitle {
  margin: 8px 0 14px;
  color: var(--fd-muted);
}

.fd-appearance-grid {
  display: block;
}

.fd-appearance-card {
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  padding: 12px;
  background: rgb(var(--fd-card-rgb) / 0.12);
}

.fd-appearance-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.fd-color-inline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.fd-color-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.fd-color-inline-label {
  font-weight: 700;
}

.fd-color-inline input[type="color"] {
  width: 56px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid var(--fd-card-border);
  background: rgb(var(--fd-card-rgb) / 0.35);
  cursor: pointer;
  padding: 5px;
}

.fd-color-value {
  font-family: var(--font-family-mono);
  font-size: 0.77rem;
  color: var(--fd-muted);
  min-width: 66px;
  text-align: left;
}

.fd-appearance-actions {
  margin-top: 10px;
}

.fd-appearance-actions button {
  width: auto;
}

@media (max-width: 640px) {
  .chart-preview-trigger {
    height: 34px;
    line-height: 34px;
    font-size: 0.72rem;
    padding: 0 12px;
  }

  .fd-overview-preview {
    padding: 8px;
  }

  .fd-overview-preview__panel {
    width: 100%;
    height: min(90vh, 760px);
    padding: 10px;
  }

  .fd-overview-preview__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .fd-overview-preview__close {
    width: 100%;
  }

  .fd-appearance-window {
    padding: 14px;
  }

  .fd-appearance-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .fd-appearance-close {
    width: 100%;
  }

  .fd-color-inline-list {
    flex-direction: column;
    gap: 10px;
  }

  .fd-color-inline {
    justify-content: space-between;
    width: 100%;
  }
}


.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgb(var(--fd-card-rgb));
  border: 1px solid var(--fd-card-border);
  border-radius: var(--radius);
  box-shadow: var(--fd-card-shadow-hover);
  padding: 2rem;
  width: 90%;
  max-width: 500px;
  z-index: 10000;
  display: none;
  color: var(--fd-text);
}
.modal h2 { margin-bottom: 1rem; }
.modal .close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  cursor: pointer;
  color: #ef4444;
  font-size: 1.2rem;
}

body.fd-app .fd-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10050;
  padding: 16px;
}
body.fd-app .fd-modal-panel {
  background: rgb(var(--fd-card-rgb));
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  box-shadow: var(--fd-card-shadow-hover);
  color: var(--fd-text);
  padding: 1rem 1.25rem;
  max-width: min(520px, 96vw);
  max-height: 70vh;
  overflow: auto;
}
body.fd-app .fd-modal-title {
  margin: 0 0 0.65rem 0;
  font-size: 1.1rem;
}
body.fd-app .fd-modal-body {
  white-space: pre-wrap;
  margin: 0;
}
body.fd-app .fd-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}
body.fd-app .fd-modal-actions.split > button {
  flex: 1;
}
body.fd-app .fd-date-modal-overlay {
  z-index: 10060;
}
body.fd-app .fd-date-modal-panel {
  width: min(420px, calc(100vw - 32px));
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
body.fd-app .fd-date-modal-title {
  margin: 0;
  color: var(--fd-text);
  font-size: 1rem;
  line-height: 1.45;
}
body.fd-app .fd-date-modal-input {
  width: 100%;
  min-height: 48px;
  color-scheme: dark;
  background: var(--fd-input-bg);
  color: var(--fd-text);
  border: 1px solid var(--fd-input-border);
  box-sizing: border-box;
}
body.fd-app .fd-date-modal-input::-webkit-calendar-picker-indicator {
  filter: invert(0.9);
  cursor: pointer;
}
body.fd-app .fd-date-modal-actions {
  margin-top: 0;
}
body.fd-app .fd-date-modal-actions .btn {
  min-width: 110px;
}
body.fd-app .fd-date-modal-actions .btn-ghost,
body.fd-app .fd-date-modal-actions button.btn-ghost,
body.fd-app .fd-date-modal-actions .btn.ghost,
body.fd-app .fd-date-modal-actions button.ghost {
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.34);
  color: var(--fd-text);
}
body.fd-app .fd-date-modal-actions .btn-ghost:hover,
body.fd-app .fd-date-modal-actions button.btn-ghost:hover,
body.fd-app .fd-date-modal-actions .btn.ghost:hover,
body.fd-app .fd-date-modal-actions button.ghost:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
  filter: brightness(1.06);
}

.ts-date-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 35, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10005;
}
.ts-date-picker-dialog {
  background: rgb(var(--fd-card-rgb));
  border: 1px solid var(--fd-card-border);
  padding: 18px 20px 16px;
  border-radius: 14px;
  box-shadow: var(--fd-card-shadow-hover);
  min-width: 280px;
  max-width: 360px;
  width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--fd-text);
}
.ts-date-picker-dialog h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--fd-text);
}
.ts-date-picker-input {
  width: 100%;
}
.ts-date-picker-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Laptop tuning */
@media (min-width: 1200px) and (max-width: 1499px) {
  .ops-card .mini-block { padding: 5px 7px; }
  .ops-card .mini-title { font-size: 0.74rem; }
  .insight-list li { font-size: 0.7rem; line-height: 1.1; min-height: 16px; }
  .insight-list .rank { width: 14px; height: 14px; line-height: 14px; font-size: 0.62rem; }
  .insight-list .val { font-size: 0.7rem; }
  .insight-list .pct { font-size: 0.62rem; }
  .ops-card .stat-row { font-size: 0.7rem; }
  .ops-card .stat-row span { white-space: nowrap; }
  .ops-card .stat-row strong { font-size: 0.76rem; }
  .ops-card .stats-block[data-branch][data-mode]::before { font-size: 0.64rem; }
  .ai-insight { font-size: 0.74rem; }
  .ai-list li { font-size: 0.7rem; }
  .bc-card { padding: 10px 12px; border-radius: 10px; }
  .bc-tag { font-size: 0.65rem; padding: 2px 7px; }
  .bc-total { font-size: 0.88rem; }
  .bc-cat-nm { font-size: 0.74rem; }
  .bc-cat-am { font-size: 0.68rem; }
  .bc-cat-num { font-size: 0.6rem; }
  .bc-card-footer { font-size: 0.6rem; }
}

/* ------------------------------------------------
   INPUT/FORM COMPACT ALIGNMENT (desktop only)
------------------------------------------------ */
@media (min-width: 1100px) {
  #incomeForm > *:not(label),
  #expenseForm > *:not(label) {
    min-width: 130px;
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 2px 0 !important;
    display: block;
  }

  #incomeForm,
  #expenseForm {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-content: start;
  }

  #incomeForm > *:not(label),
  #expenseForm > *:not(label),
  #incomeForm .autocomplete-container,
  #expenseForm .autocomplete-container {
    min-width: 0 !important;
    max-width: none !important;
    width: 100%;
  }

  #incomeForm button[type="submit"],
  #expenseForm button[type="submit"] {
    grid-column: 1 / -1;
    width: 140px;
    max-width: 100%;
    margin-top: 2px !important;
  }

  .management-sections-two .income-filter-bar,
  .management-sections-two .expense-filter-bar {
    min-height: 46px;
    align-items: center;
  }
}

#incomeForm input,
#incomeForm select,
#expenseForm input,
#expenseForm select {
  height: 32px;
  line-height: 32px;
  padding: 0 6px;
}
#incomeForm,
#expenseForm {
  grid-template-columns: repeat(auto-fit, 130px);
  gap: 8px;
}
@media (min-width: 601px) and (max-width: 1099px) {
  #incomeForm,
  #expenseForm {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

/* LEFT ALIGN in key tables */
#incomeList td,
#expenseList td,
#timeOverview td,
#expenseOverview td {
  text-align: left !important;
}

/* (Old grid.full-width responsive rules removed — now in responsive.css) */

/* Center dashboard headings */
/* Removed heavy :has selector for performance; use explicit classes if needed */

/* Center two forms side-by-side */
.flex-center-wrap {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  width: 100%;
}

/* ──────────────────────────────
   INVENTORY TABLE: SUPER COMPACT
────────────────────────────── */
@media (max-width: 900px) {
  .table-container { overflow-x: auto !important; }
}

/* --- Responsive: Time Tracking Table for Smartphones --- */
@media (max-width: 600px) {
  #timeTrackingCardDetails .data-table,
  #timeTrackingCardDetails table {
    width: 100%;
    border: 0;
    font-size: 0.88rem;
    box-shadow: none;
  }
  #timeTrackingCardDetails .data-table thead,
  #timeTrackingCardDetails table thead { display: none; }
  #timeTrackingCardDetails .data-table tbody tr,
  #timeTrackingCardDetails table tbody tr {
    display: block;
    margin-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
  }
  #timeTrackingCardDetails .data-table td,
  #timeTrackingCardDetails table td {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    border: none;
    border-bottom: 1px solid #eee;
    padding: 6px 8px;
    position: relative;
    font-size: 0.98em;
    min-width: 0;
  }
  #timeTrackingCardDetails .data-table td::before,
  #timeTrackingCardDetails table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #555;
    flex: 0 0 55%;
    min-width: 80px;
    padding-right: 12px;
    text-align: left;
    font-size: 0.95em;
  }
  #timeTrackingCardDetails .data-table td:last-child,
  #timeTrackingCardDetails table td:last-child { border-bottom: 0; }
}

/* ─── Fancy Blue Accent Palette ─── */
/* Chart Section spacing */
.chart-section {
  padding: 16px 18px;
  margin-bottom: 1.25rem;
  width: 100%;
  box-sizing: border-box;
  margin-left: 0;
  margin-right: 0;
}

/* Mobile: reduce chart section padding */
@media (max-width: 768px) {
  .chart-section {
    padding: 12px 0;
    margin: 10px 0;
  }
}

/* Income & Expense Management Section */
.grid.management-section {
  background: none;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  border: none;
  margin-bottom: 1.25rem;
  width: 100%;
  box-sizing: border-box;
}
section.management-section {
  padding: 16px 18px;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  section.management-section {
    padding: 12px 0;
    margin: 10px 0;
  }
}

.management-section > section {
  padding: 16px 18px;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .management-section > section {
    padding: 12px 0;
    margin: 10px 0;
  }
}

.management-section > section h2 {
  margin: 0 0 8px 0;
}
.management-section .income-filter-bar,
.management-section .expense-filter-bar {
  margin: 6px 0 8px 0;
  padding: 6px;
}
.management-section .table-container {
  margin-top: 0;
  margin-bottom: 0.75rem;
}
.management-section > section .table-container {
  flex: 1 1 auto;
}

/* Pagination static appearance */
.pagination {
  position: static;
  background: transparent;
  box-shadow: none;
  margin-top: 0.75rem;
  padding: 6px 0 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  width: 100%;
  z-index: 5;
}

/* Keep overview pagers visible under scrollable tables */
#timeOverviewTable + .pagination,
#expenseOverviewTable + .pagination,
#timeOverview + .pagination,
#expenseOverview + .pagination,
#pagination-incomeOverview,
#pagination-expenseOverview {
  position: sticky;
  bottom: 0;
  background: linear-gradient(0deg, rgb(var(--fd-card-rgb) / 0.9), rgb(var(--fd-card-rgb) / 0.35));
  padding: 6px 0 10px;
  z-index: 5;
}
body.fd-app .pagination button {
  padding: 6px 12px;
  margin: 0;
  font-size: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: transparent;
  color: var(--fd-text);
  cursor: pointer;
  border-radius: 8px;
}
body.fd-app .pagination button:hover { background: rgb(var(--fd-card-rgb) / 0.12); }
.pagination button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.grid.management-section {
  align-items: flex-start;
}
.grid.management-section > section {
  display: flex;
  flex-direction: column;
}
.grid.management-section > section .table-container {
  flex: 1 1 auto;
}
.grid.management-section > section .pagination {
  margin-top: 0.75rem;
}

/* Income/Expense management: keep the table viewport identical so both columns show the same number of rows */
.grid.management-section.management-sections-two > section .table-container {
  flex: none;
  height: clamp(280px, 50vh, 520px);
  max-height: none;
}
@media (max-width: 900px) {
  .grid.management-section.management-sections-two > section .table-container {
    height: auto;
    max-height: clamp(280px, 60vh, 520px);
  }
}
@media (max-width: 640px) {
  .grid.management-section.management-sections-two > section .table-container {
    max-height: clamp(200px, 40vh, 350px);
  }
}

/* Green accents for detail tables */
#billsCardDetails .data-table thead th,
#noticesCardDetails .data-table thead th,
#pdfCardDetails .data-table thead th,
#timeTrackingCardDetails .data-table thead th,
#inventoryCardDetails .data-table thead th {
  color: var(--fd-card-text);
  border-bottom: 2px solid var(--fd-card-border);
}
#billsCardDetails .data-table tbody tr:hover,
#noticesCardDetails .data-table tbody tr:hover,
#pdfCardDetails .data-table tbody tr:hover,
#timeTrackingCardDetails .data-table tbody tr:hover,
#inventoryCardDetails .data-table tbody tr:hover {
  background: var(--fd-table-row-hover);
  transition: background-color 0.2s ease;
}


#employeeLoanContainer .table-container { overflow-x: auto; }
#employeeLoanContainer .data-table { table-layout: auto; }
#employeeLoanContainer .data-table th,
#employeeLoanContainer .data-table td {
  padding: 6px 5px;
  font-size: 11.5px;
  white-space: nowrap;
}
#employeeLoanContainer .data-table td.actions-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  flex-wrap: nowrap;
}

/* Employer accounts table: keep role/job title same visual weight as name and align action buttons */
#employerAccountsBody td {
  padding: 8px 10px;
  font-size: 12.5px;
  vertical-align: middle;
  white-space: nowrap;
}
#employerAccountsBody td:nth-child(2) .ts-label {
  background: none;
  box-shadow: none;
  padding: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fd-muted);
  text-transform: none;
  letter-spacing: 0;
}
#employerAccountsBody td.col-actions .ts-actions-row {
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
#employerAccountsBody .ts-chip-btn {
  min-width: 70px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.2;
  box-shadow: none;
}
#employerAccountsBody .ts-chip-btn[data-action="save"] {
  background: linear-gradient(135deg, var(--fd-accent-strong), #2563eb);
  color: #fff;
  border: 1px solid #2563eb;
}
#employerAccountsBody .ts-chip-btn[data-action="delete"],
#employerAccountsBody .ts-chip-btn.danger {
  background: #e74c3c;
  color: #fff;
  border: 1px solid #c0392b;
}

/* Create employer access form: compact controls and labels */
#employerAccessForm {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr)) 120px;
  gap: 10px 12px;
  align-items: end;
}
#employerAccessForm .ts-field,
#employerAccessForm .ts-actions-row {
  margin: 0;
}
#employerAccessForm .ts-label {
  font-size: 0.88rem;
  padding: 4px 8px;
}
#employerAccessForm .perm-field {
  grid-column: auto;
  min-width: 220px;
}
#employerAccessForm .perm-dropdown {
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  background: transparent;
  padding: 4px 8px;
  box-shadow: none;
}
#employerAccessForm .perm-dropdown summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  font-size: 0.9rem;
  gap: 8px;
  padding: 4px 2px;
}
#employerAccessForm .perm-dropdown summary::-webkit-details-marker { display: none; }
#employerAccessForm .perm-hint {
  color: var(--fd-muted);
  font-size: 0.82rem;
}
#employerAccessForm .perm-options {
  margin-top: 8px;
  display: none;
  border-top: 1px solid var(--fd-card-border);
  padding-top: 6px;
}
#employerAccessForm .perm-dropdown[open] .perm-options { display: grid; gap: 6px; }
#employerAccessForm .perm-option {
  font-size: 0.82rem !important;
  text-transform: none;
  letter-spacing: 0;
  background: transparent;
  border: 1px solid var(--fd-card-border);
  border-radius: 10px;
  padding: 6px 8px;
  box-shadow: none;
}
#employerAccessForm .ts-control,
#employerAccessForm .ts-select {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 0.92rem;
}
#employerAccessForm .ts-label.ts-label-small {
  font-size: 0.84rem !important;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
#employerAccessForm input[type="checkbox"] {
  width: 14px;
  height: 14px;
}
#employerAccessForm .ts-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0;
}
#employerAccessForm .ts-chip-btn {
  width: 100%;
  min-width: 0;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  height: 40px;
  border-radius: 10px;
}
@media (max-width: 960px) {
  #employerAccessForm {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: start;
  }
  #employerAccessForm .perm-field,
  #employerAccessForm .ts-actions-row {
    grid-column: 1 / -1;
  }
}

/* Create employer access permissions dropdown (compact, select-like) */
#employerAccessForm .perm-field {
  grid-column: auto;
}
#employerAccessForm .perm-dropdown {
  width: 100%;
  border: 1.2px solid #b7c7e6;
  background: #f5f7ff;
  border-radius: 14px;
  padding: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
#employerAccessForm .perm-dropdown summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #0f2745;
  border-radius: 10px;
  min-height: 36px;
  padding: 4px 8px;
}
#employerAccessForm .perm-dropdown summary::-webkit-details-marker { display: none; }
#employerAccessForm .perm-dropdown summary::after {
  content: "▾";
  font-size: 0.9rem;
  color: var(--fd-muted);
}
#employerAccessForm .perm-dropdown .ts-label {
  background: none;
  box-shadow: none;
  padding: 0;
  font-size: 0.88rem;
  text-transform: none;
  letter-spacing: 0;
}
#employerAccessForm .perm-dropdown .perm-hint {
  font-size: 0.8rem;
  color: var(--fd-muted);
}
#employerAccessForm .perm-dropdown .perm-options {
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--fd-card-border);
  border-radius: 10px;
  background: transparent;
  display: grid;
  gap: 6px;
}
#employerAccessForm .perm-dropdown .perm-option {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--fd-card-border);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--fd-text);
  text-transform: none;
  letter-spacing: 0;
}
#employerAccessForm .perm-dropdown .perm-option input {
  width: 14px;
  height: 14px;
}

/* Crypto card gradients */
#cryptoSummaryCard .crypto-card-header {
  border-bottom: 3px solid rgba(255,255,255,0.6) !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
#cryptoSummaryCard .crypto-card { transition: box-shadow 0.1s ease; }
#cryptoSummaryCard .crypto-card:hover { box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); }
#cryptoSummaryCard .crypto-card::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
#cryptoSummaryCard .crypto-card:hover::after { opacity: 1; }

/* ---- Scroll-jank prevention ----
   While scrolling, kill transitions and hover repaints on table rows so the
   compositor can scroll without waiting for main-thread style recalc.
   pointer-events stays enabled so scrollbars and clicks still work. */
body.is-scrolling tr,
body.is-scrolling .summary-card,
body.is-scrolling .insight-card,
body.is-scrolling .fd-btn-primary,
body.is-scrolling .fd-btn-secondary {
  transition: none !important;
}
body.is-scrolling .data-table tbody tr:hover {
  background: inherit !important;
}

@media (prefers-reduced-motion: reduce) { tr.missed td { animation: none !important; } }


/* =========================================================
   PHONE-FRIENDLY TOOLBARS & SUMMARY CARDS (≤ 600px)
   (Mobile Fix Pack — desktop kept unchanged)
========================================================= */
@media (max-width: 600px) {

  /* Headings center, content left for readability */
  h1, h2, h3, h4, h5, h6 { text-align: center !important; }
  p, td, th, label, input, select, textarea, .data-table td, .data-table th {
    text-align: left !important;
  }

  /* Toolbars: wrap cleanly on small screens (no horizontal scroll) */
  .expense-search-container,
  .income-filter-bar,
  .expense-filter-bar,
  .time-overview-container {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    overflow-x: visible !important;
    padding: 8px 6px !important;
  }
  .expense-search-container > *,
  .income-filter-bar > *,
  .expense-filter-bar > *,
  .time-overview-container > * {
    flex: 1 1 48% !important;
    min-width: 0 !important;
  }
  .expense-search-container input[type="date"],
  .income-filter-bar input[type="month"],
  .expense-filter-bar input[type="month"] { min-width: 0 !important; }
  .expense-search-container button,
  .income-filter-bar button,
  .expense-filter-bar button { min-width: 0 !important; }

  /* Forms: full width, left-aligned controls */
  form {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 16px 0 !important;
    text-align: left !important;
  }
  form input,
  form select,
  form button,
  form textarea {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
  /* Tables: scrollable, readable */
  .table-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 16px 0 !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    max-height: min(520px, 55vh) !important;
  }
  table.data-table {
    width: 100% !important;
    min-width: 0 !important; /* avoid forcing wide tables on small screens */
    margin: 0 !important;
    font-size: 0.9rem;
  }

  /* Buttons: full width for easy tap (scope to page content, not top-nav/swatches) */
  form button,
  .expense-search-container button,
  .income-filter-bar button,
  .expense-filter-bar button,
  .time-overview-container button,
  .expense-upload-bar button {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 8px 0 !important;
  }

  body.fd-app.finance-dashboard-page .container > .chart-section,
  body.fd-app.finance-dashboard-page .container > .grid.full-width.management-section,
  body.fd-app.finance-dashboard-page .container > .grid.full-width.management-sections-two,
  body.fd-app.finance-dashboard-page .container > .branch-management,
  body.fd-app.finance-dashboard-page .container > section.management-section,
  body.fd-app.finance-dashboard-page .container > section.loan-summary,
  body.fd-app.finance-dashboard-page .container > section.summary-cards {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    box-sizing: border-box;
  }

  body.fd-app.finance-dashboard-page .chart-section,
  body.fd-app.finance-dashboard-page .branch-management,
  body.fd-app.finance-dashboard-page section.management-section,
  body.fd-app.finance-dashboard-page section.loan-summary,
  body.fd-app.finance-dashboard-page section.summary-cards,
  body.fd-app.finance-dashboard-page .grid.full-width.management-section > section,
  body.fd-app.finance-dashboard-page .grid.full-width.management-sections-two > section {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 12px !important;
    box-sizing: border-box;
    align-items: stretch !important;
  }

  body.fd-app.finance-dashboard-page .toggle-heading {
    width: 100% !important;
    margin: 0 0 12px !important;
    box-sizing: border-box;
  }

  /* (Management-section mobile stacking — now in responsive.css) */

  /* Canvas & charts fit */
  #overviewChart,
  #expenseCategoryChart,
  #expenseBranchChart {
    width: 100% !important;
    height: auto !important;
    display: block;
  }

  /* Loan & Notices content */
  #employeeLoanContent,
  #noticesContent {
    width: 100% !important;
    margin: 0 !important;
    display: block;
  }

  /* Card internals stay full width without changing every section on the page */
  .card,
  .ops-card,
  [class*="card"] {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Calculator: keep centered but fluid */
  .calculator-card {
    width: 100% !important;
    margin: 10px 0 !important;
    justify-content: space-between !important;
  }

  /* Footer */
  .footer {
    width: 100% !important;
    text-align: center !important;
    padding: 12px 0 !important;
  }
}

/* (Old management-sections-two responsive rules removed — now in responsive.css) */

@media (max-width: 900px) {
  .table-container { overflow-x: auto !important; }
  table.data-table { min-width: 0; }
}

/* ===== Center the "Toggle Employee Loans" button ===== */
#toggleEmployeeLoansBtn {
  display: block !important;
  margin: 12px auto !important;
  background: linear-gradient(135deg, #009cff, #005bb5) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 6px !important;
  padding: 8px 18px !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
  transition: all 0.25s ease-in-out !important;
}
#toggleEmployeeLoansBtn:hover {
  background: linear-gradient(135deg, #00b4ff, #0073c2) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25) !important;
}
/* Employee loan form layout */
#employeeLoanContent .flex-center-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(420px, 1fr));
  gap: 16px;
  align-items: stretch;
  width: 100%;
  margin-bottom: 24px;
}
#employeeLoanContent .flex-center-wrap > .summary-card {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 14px 16px;
  height: 100%;
}
#employeeLoanContent .flex-center-wrap > .summary-card h3.centered {
  margin-bottom: 10px;
}
.employer-access-section .employer-access-wrap {
  margin-top: 0;
}

.account-security-section #accountSecurityContent {
  display: grid;
  gap: 12px;
}

.account-security-section .account-security-card {
  padding: 12px 14px;
}

.account-security-section .account-security-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.account-security-section .account-security-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0;
}

.account-security-section .account-security-msg {
  margin-top: 8px;
  min-height: 1.2em;
  color: var(--fd-muted);
  font-size: 0.86rem;
}

.account-security-section .account-security-msg.error {
  color: #f87171;
}

.account-security-section .account-security-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--fd-card-border);
  border-radius: 10px;
  background: rgb(var(--fd-card-rgb) / 0.12);
}

.account-security-section .account-security-help {
  margin: 0;
  color: var(--fd-muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.account-security-section .account-security-qr-wrap {
  margin-top: 8px;
  padding: 8px;
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--fd-card-border);
  border-radius: 10px;
}

.account-security-section .account-security-qr-image {
  display: block;
  width: 210px;
  height: 210px;
  border-radius: 6px;
  background: #ffffff;
}

.account-security-section .account-security-uri {
  margin-top: 6px;
  word-break: break-all;
}

.account-security-section code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
}

/* ------------------------------------------------------------------
   Admin Page: compact, balanced branch + employer layout
------------------------------------------------------------------ */
body.fd-app.admin-page .container.main-surface {
  display: grid;
  gap: 12px;
}

body.fd-app.admin-page .branch-management {
  margin: 0;
  padding: 12px 14px;
}

body.fd-app.admin-page .branch-management h2 {
  margin: 0 0 10px;
}

body.fd-app.admin-page #branchManagementContent {
  display: grid;
  gap: 10px;
}

body.fd-app.admin-page .branch-admin-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

body.fd-app.admin-page .branch-admin-toolbar .branch-form {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--fd-card-border);
  border-radius: 12px;
  background: rgb(var(--fd-card-rgb) / 0.12);
  display: grid;
  gap: 8px;
  align-items: center;
}

body.fd-app.admin-page .branch-form-add {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

body.fd-app.admin-page .branch-form-delete {
  grid-template-columns: minmax(0, 1fr) auto;
}

body.fd-app.admin-page .branch-admin-toolbar .branch-form input,
body.fd-app.admin-page .branch-admin-toolbar .branch-form button {
  width: 100%;
  min-height: 42px;
}

body.fd-app.admin-page .branch-admin-toolbar .branch-form button {
  min-width: 140px;
}

body.fd-app.admin-page .branch-table-wrap {
  margin-top: 0;
  max-height: min(340px, 45vh);
}

body.fd-app.admin-page .branch-table-wrap .data-table caption {
  text-align: left;
  margin-bottom: 8px;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--fd-card-text);
}

body.fd-app.admin-page #employerAccessContent {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 12px;
  align-items: stretch;
}

body.fd-app.admin-page .employer-access-section .ts-card {
  margin: 0;
  height: 100%;
  padding: 12px 14px;
}

body.fd-app.admin-page .employer-access-section .ts-card h3 {
  margin: 0 0 4px;
}

body.fd-app.admin-page .employer-access-section .ts-subtle {
  margin: 0 0 10px;
}

body.fd-app.admin-page #employerAccessForm {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 10px;
  align-items: end;
}

body.fd-app.admin-page #employerAccessForm .perm-field {
  min-width: 0;
}

body.fd-app.admin-page #employerAccessForm .ts-actions-row {
  grid-column: auto;
  justify-content: stretch;
}

body.fd-app.admin-page #employerAccessForm .ts-chip-btn {
  min-height: 42px;
}

body.fd-app.admin-page #employerAccessForm .perm-dropdown {
  border: 1px solid var(--fd-card-border);
  background: rgb(var(--fd-card-rgb) / 0.12);
  border-radius: 12px;
  padding: 5px 8px;
  box-shadow: none;
}

body.fd-app.admin-page #employerAccessForm .perm-dropdown summary {
  color: var(--fd-card-text);
  min-height: 32px;
}

body.fd-app.admin-page #employerAccessForm .perm-dropdown .perm-options {
  border-top: 1px solid var(--fd-card-border);
  border-radius: 0;
  margin-top: 6px;
  padding: 6px 0 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  background: transparent;
}

body.fd-app.admin-page #employerAccessForm .perm-dropdown .perm-option {
  background: rgb(var(--fd-card-rgb) / 0.15);
  border: 1px solid var(--fd-card-border);
}

body.fd-app.admin-page .employer-manage-wrap .table-container {
  margin-top: 0;
  max-height: min(360px, 48vh);
}

body.fd-app.admin-page .branch-management .data-table th,
body.fd-app.admin-page .branch-management .data-table td {
  padding: 8px 10px;
}

@media (max-width: 1320px) {
  body.fd-app.admin-page #employerAccessContent {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1120px) {
  body.fd-app.admin-page .branch-admin-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  body.fd-app.admin-page .branch-form-add,
  body.fd-app.admin-page .branch-form-delete,
  body.fd-app.admin-page #employerAccessForm {
    grid-template-columns: 1fr;
  }

  body.fd-app.admin-page #employerAccessForm .ts-actions-row,
  body.fd-app.admin-page #employerAccessForm .perm-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 960px) {
  .account-security-section .account-security-row {
    grid-template-columns: 1fr;
  }

  .account-security-section .account-security-actions {
    width: 100%;
  }

  .account-security-section .account-security-actions .ts-chip-btn,
  .account-security-section .account-security-actions .btn {
    width: 100%;
  }
}

/* Grid layout inside Employee Loan forms */
#employeeLoanForm,
#repaymentForm {
  display: grid;
  gap: 8px;
  align-items: center;
  align-content: start;
}
#employeeLoanForm input,
#employeeLoanForm select,
#employeeLoanForm button,
#repaymentForm input,
#repaymentForm select,
#repaymentForm button {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
#employeeLoanForm input,
#employeeLoanForm select,
#repaymentForm input,
#repaymentForm select {
  min-height: 38px;
  padding: 0.38rem 0.62rem;
  font-size: 0.92rem;
}

#employeeLoanForm {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
#employeeLoanForm > label[for="loanStartDate"],
#employeeLoanForm > label[for="loanType"] {
  grid-column: 1 / -1;
  margin: 0;
  font-weight: 700;
}
#employeeLoanForm #loanStartDate,
#employeeLoanForm #employeeName,
#employeeLoanForm #employeeJobTitle,
#employeeLoanForm #loanType,
#employeeLoanForm #loanMode,
#employeeLoanForm #loanPerHour,
#employeeLoanForm #loanPerWeekField,
#employeeLoanForm #loanPerHourWeekend,
#employeeLoanForm #hoursPerWeek,
#employeeLoanForm #monthlyLoanField {
  width: 100%;
  min-width: 0;
  grid-column: span 1;
}
#employeeLoanForm .inline-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin: 0;
  min-height: 42px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.18);
  grid-column: span 1;
  font-size: 0.92rem;
  line-height: 1.2;
  cursor: pointer;
  overflow: visible;
}
#employeeLoanForm .inline-checkbox input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 18px;
  accent-color: #6ea8ff;
}
#employeeLoanForm .inline-checkbox span {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.15;
  font-size: max(0.64rem, calc(0.92rem - 5px));
}
#employeeLoanForm .inline-checkbox:hover {
  border-color: rgba(110, 168, 255, 0.45);
  background: rgba(30, 41, 59, 0.28);
}
#employeeLoanForm button[type="submit"] {
  grid-column: 1 / -1;
}

#repaymentForm {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
#repaymentForm #repaymentBranch,
#repaymentForm label[for="repaymentDate"],
#repaymentForm button[type="submit"] {
  grid-column: 1 / -1;
}
#repaymentForm #repaymentEmployeeName,
#repaymentForm #repaymentAmount,
#repaymentForm #repaymentDate,
#repaymentForm #repaymentPaymentMethod {
  grid-column: span 1;
  width: 100%;
  min-width: 0;
}
#repaymentForm label[for="repaymentDate"] {
  margin: 2px 0 0;
  font-weight: 700;
}

@media (max-width: 1100px) {
  #employeeLoanContent .flex-center-wrap {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  #employeeLoanForm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #employeeLoanForm .inline-checkbox {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  #employeeLoanForm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #employeeLoanForm #loanStartDate,
  #employeeLoanForm #employeeName,
  #employeeLoanForm #employeeJobTitle,
  #employeeLoanForm #loanType,
  #employeeLoanForm #loanMode,
  #employeeLoanForm #loanPerHour,
  #employeeLoanForm #loanPerWeekField,
  #employeeLoanForm #loanPerHourWeekend,
  #employeeLoanForm #hoursPerWeek,
  #employeeLoanForm #monthlyLoanField,
  #employeeLoanForm .inline-checkbox,
  #repaymentForm #repaymentBranch,
  #repaymentForm #repaymentEmployeeName,
  #repaymentForm #repaymentAmount,
  #repaymentForm #repaymentDate,
  #repaymentForm #repaymentPaymentMethod,
  #repaymentForm button[type="submit"] {
    grid-column: 1 / -1;
  }
}

/* ===============================================================
   Timesheet & Shift Planner Page
   Isolated class names to avoid touching existing dashboard styles
   =============================================================== */

.ts-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  color: var(--fd-text);
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.timesheet-page .ts-shell,
.timesheet-page .ts-card,
.timesheet-page .ts-card.ts-block,
.timesheet-page .ts-card.ts-card-margin,
.timesheet-page .ts-card.ts-timesheet-luxe {
  width: 100%;
  box-sizing: border-box;
}
.ts-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}


.ts-header h1 {
  margin: 6px 0 4px 0;
  color: var(--color-dark);
}
.ts-header .eyebrow {
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--fd-accent-strong);
  margin: 0;
}
.ts-header .muted {
  margin: 0;
  color: var(--fd-muted);
  font-size: 0.95rem;
}
.ts-btn { display: inline-block; text-decoration: none; }

.ts-card {
  padding: 12px;
  margin-bottom: 10px;
}
.timesheet-page .ts-card {
  color: var(--fd-text);
}
.timesheet-page .ts-shell {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}
.timesheet-page .ts-card.ts-block,
.timesheet-page .ts-card.ts-card-margin,
.timesheet-page .ts-card.ts-timesheet-luxe {
  width: 100%;
  overflow-x: hidden;
}
.timesheet-page .ts-block-row.ts-auto-row,
.timesheet-page .ts-block-row {
  padding: 6px;
  border-radius: 0;
}
.ts-card h2 {
  margin: 0 0 6px 0;
  font-size: 1.2rem;
  color: var(--color-dark);
}
.ts-card .muted { color: var(--fd-muted); }

.ts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  width: 100%;
}

.ts-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 12px;
  margin-top: 6px;
  align-items: start;
}
.ts-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ts-preference-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}
.ts-preference-select {
  flex: 1 1 180px;
  min-height: 96px;
  resize: vertical;
}
body.fd-app .ts-pref-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
body.fd-app .ts-pref-controls button {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.08);
  color: var(--fd-text);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
body.fd-app .ts-pref-controls button:hover {
  background: rgb(var(--fd-card-rgb) / 0.12);
  transform: translateY(-1px);
}
.ts-label {
  font-size: 0.85rem;
  letter-spacing: 0.2px;
  font-weight: 600;
  color: var(--fd-muted);
  background: transparent;
  padding: 0;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-transform: none;
}
.ts-control,
.ts-select {
  width: 100%;
  min-height: 44px;
}
.ts-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ts-chip-btn {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #ddd;
  background: #f7f9fb;
  color: var(--color-dark);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.ts-chip-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}
.ts-chip-btn.primary {
  background: var(--color-accent);
  color: #fff;
  border: 1px solid var(--color-accent-dark);
  font-weight: 700;
}
.ts-chip-btn.secondary {
  background: #e4e7ef;
  border-color: rgba(12,39,66,0.25);
  color: #0f2745;
  font-weight: 600;
}
.ts-chip-btn.secondary:hover {
  background: #d4dae5;
}

/* Responsive polish for inventory & timesheet (phones) */
@media (max-width: 768px) {
  .main-surface,
  .container,
  .ts-shell {
    width: 100%;
    max-width: 100%;
    padding: 10px;
    margin: 10px auto;
  }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .header-actions { width: 100%; flex-wrap: wrap; gap: 8px; }
  .filters.card,
  .card {
    padding: 10px;
  }
  .filters .field-row,
  .filters .field-group,
  .filters .field {
    flex-direction: column;
    width: 100%;
  }
  .table-container { overflow-x: auto !important; }
  .ai-intake, .intake-list { overflow-x: auto; }
}

/* Extra-tight phone layout (<= 480px) */
@media (max-width: 480px) {
  body { padding: 0; }
  
  /* Main surfaces and containers */
  .main-surface,
  .container,
  .ts-shell {
    padding: 0;
    margin: 0;
    box-shadow: none;
    width: 100%;
  }
  
  /* Cards on ultra-small screens */
  .ts-card,
  .card,
  .filters {
    padding: 8px;
    margin: 6px 0;
    border-radius: 8px;
  }
  
  .ts-header,
  .page-header { gap: 6px; }
  
  .ts-form-grid,
  #tsShiftBlocks .ts-block-row {
    grid-template-columns: 1fr !important;
  }
  
  #tsShiftBlocks .ts-block { padding: 6px !important; }
  .ts-actions-row button { width: 100% !important; }
}

.ts-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  color: var(--color-dark);
  font-size: 0.92rem;
}
.ts-table th,
.ts-table td {
  padding: 12px 10px;
  text-align: left;
}
.ts-table th {
  letter-spacing: 0.4px;
  font-size: 0.85rem;
  font-weight: 800;
}
.ts-table tbody tr {
  background: transparent;
  border-radius: 0;
  border-bottom: 1px solid var(--fd-card-border);
}
.ts-summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.ts-summary-card {
  border: 1px solid var(--fd-card-border);
  border-radius: 12px;
  padding: 12px;
  color: var(--fd-text);
}
.ts-summary-card .label { color: var(--fd-muted); font-size: 0.8rem; }
.ts-summary-card .value { font-size: 1.2rem; font-weight: 700; color: var(--fd-text); }
.ts-summary-card .value.positive { color: #10b981; }

.ts-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
}

.ts-dual-pane {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 14px;
  align-items: start;
}
.ts-pane-section {
  width: 100%;
}
.ts-workdays-panel {
  background: transparent;
  border: 1px solid var(--fd-card-border);
  border-radius: 12px;
  padding: 10px 12px 6px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}
.ts-loc-wrapper { position: relative; }
.ts-loc-dropdown { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 2px); background: rgb(var(--fd-card-rgb)); border: 1px solid var(--fd-card-border); border-radius: 8px; box-shadow: var(--fd-card-shadow-hover); max-height: 220px; overflow-y: auto; will-change: transform; transform: translateZ(0); }
.ts-loc-dropdown.hidden { display: none; }
.ts-loc-item { padding: 8px 10px; cursor: pointer; font-size: 14px; }
.ts-loc-item:hover { background: rgb(var(--fd-card-rgb) / 0.12); }
.ts-loc-item small { display: block; color: var(--fd-muted); font-size: 12px; margin-top: 2px; }

/* Shift blocks container: lay blocks side-by-side on wide screens */
#tsShiftBlocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  align-items: start;
  width: 100%;
  max-width: 100%;
}
/* Keep each shift block contained within the grid column */
.timesheet-page #tsShiftBlocks .ts-block {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
@media (max-width: 900px) {
  #tsShiftBlocks {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}
@media (max-width: 640px) {
  #tsShiftBlocks {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .timesheet-page #tsShiftBlocks .ts-block {
    padding: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  }
  .timesheet-page .ts-block-row,
  .timesheet-page .ts-block-row.ts-auto-row {
    grid-template-columns: 1fr !important;
    padding: 4px;
    background: transparent;
    box-shadow: none;
  }
  .ts-pane { padding: 10px; min-height: 0; }
}

.timesheet-page .ts-card.ts-block {
  max-width: 100%;
  overflow: hidden;
}
.timesheet-page .table-container {
  width: 100%;
  overflow-x: auto;
}
.timesheet-page .ts-table {
  min-width: 720px;
}
.timesheet-page .ts-dual-pane {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
@media (max-width: 768px) {
  .timesheet-page .ts-dual-pane {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
  .timesheet-page .ts-pane {
    padding: 10px;
  }
  .timesheet-page #tsEmployeeList {
    max-width: 100%;
    overflow-x: hidden;
  }
}
.ts-pane {
  padding: 14px;
  min-height: 220px;
  width: 100%;
}

/* ===== Modern refinements for the Create shift / Shift blocks UI ===== */

/* Layout: make the left side larger and give the right side a neat card column */
@media (min-width: 980px) {
  .ts-split { grid-template-columns: 1fr 420px; align-items: start; }
}

/* Employee list: pills with soft glass background */
#tsEmployeeList {
  min-height: 260px;
  max-height: 420px;
  overflow-y: auto;
  padding: 14px;
  border-radius: 12px;
  background: transparent;
  border: 1px dashed var(--fd-card-border);
  box-shadow: none;
}

.ts-employee-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 6px 8px 6px 0;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--fd-card-border);
  background: transparent;
  color: var(--fd-text);
  box-shadow: none;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}

.ts-employee-checkbox input[type="checkbox"] {
  margin: 0;
  width: 18px;
  height: 18px;
  accent-color: #3b82f6;
  transform: translateY(-1px);
}

.ts-employee-checkbox span { display: inline-block; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Individual workday block: clearer section and nice pill buttons */
.ts-workday-row { margin-top: 10px; padding: 12px; border-radius: 12px; border: 1px solid rgba(0,0,0,0.04); }
.ts-workday-row { border-color: var(--fd-card-border); }
.ts-workday-label { display: block; font-weight: 700; margin-bottom: 8px; color: var(--fd-muted); }
.ts-day {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: transparent;
  color: var(--fd-text);
  padding: 8px 12px;
  border-radius: 999px;
  transition: background 0.12s ease, transform 0.08s ease;
}
.ts-day.active {
  background: linear-gradient(90deg,#00a9ff,#1f7fff);
  border-color: rgba(20,110,220,0.95);
  color: #fff;
  font-weight: 700;
  transform: translateY(-2px);
}

/* Shift block: elevated, soft UI with header accent — ULTRA-COMPACT HORIZONTAL */
.ts-shift-block {
  border-radius: 12px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--fd-card-border);
  box-shadow: none;
  transition: background 0.12s ease;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}
.ts-shift-block:hover { background: rgb(var(--fd-card-rgb) / 0.08); }
.ts-shift-block .ts-block-row { 
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  align-items: end;
  width: 100%;
}
.ts-shift-block .ts-block-row > * { min-width: 0; }
.ts-shift-block .ts-field { min-width: 0; }
.ts-shift-block .ts-block-row.ts-auto-row {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
@media (max-width: 640px) {
  .ts-shift-block {
    flex-direction: column;
    gap: 6px;
    padding: 10px;
  }
  .ts-shift-block .ts-block-row,
  .ts-shift-block .ts-block-row.ts-auto-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

.ts-shift-block .ts-label { 
  font-size: 0.9rem; 
  color: var(--fd-muted);
  white-space: nowrap;
  display: block;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ts-shift-block input.ts-control, 
.ts-shift-block select.ts-select { 
  border-radius: 10px;
  height: 42px;
  min-width: 0;
  max-width: 100%;
}

/* Add shift-block prominent button */
#tsAddShiftBlock { background: linear-gradient(90deg,#00a6ff,#005fe6); border: none; color: #fff; padding: 12px 14px; border-radius: 14px; box-shadow: 0 8px 30px rgba(3,88,214,0.18); font-weight: 700; }

/* Manual assignment 'Add Single Shift' and Auto distribute - make them stand out */
#tsAddManualShift, #tsAutoDistribute { background: linear-gradient(90deg,#00b4a2,#00a1ff); border: none; color: #fff; padding: 10px 14px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,150,220,0.12); font-weight: 700; }

/* Small helpers */
.ts-subtle { color: var(--fd-muted); }
.ts-empty { color: var(--fd-muted); }

/* Ensure preference select scrollbar looks good */
.ts-preference-select::-webkit-scrollbar { width: 8px; }
.ts-preference-select::-webkit-scrollbar-thumb { background: linear-gradient(180deg,#c7def8,#94c5ff); border-radius: 6px; }

.ts-pane h3 {
  font-size: 1.05rem;
  letter-spacing: 0.2px;
  margin-top: 0;
  margin-bottom: 10px;
  color: var(--fd-text);
}
.ts-pane .ts-subtle {
  margin-bottom: 10px;
}
.ts-pane .ts-field + .ts-field {
  margin-top: 6px;
}
.ts-pane .ts-actions-row {
  margin-top: 6px;
}
.ts-subtle {
  color: var(--fd-muted);
  font-size: 0.9rem;
}

.ts-workdays {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 6px;
}
.ts-day {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: transparent;
  color: var(--fd-text);
  padding: 8px 11px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
}
.ts-day.active {
  background: linear-gradient(90deg,#00a9ff,#1f7fff);
  border-color: rgba(20,110,220,0.95);
  color: #fff;
  font-weight: 700;
  transform: translateY(-1px);
}

.ts-block {
  border: 1px solid var(--fd-card-border);
  background: transparent;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  color: var(--fd-text);
  box-shadow: none;
}
.ts-block h4 {
  margin: 0 0 6px 0;
  color: var(--color-dark);
}
.ts-block .ts-label {
  letter-spacing: 0.5px;
  text-transform: none;
  font-weight: 600;
}
.ts-block-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px;
}

/* Make non-shift block rows denser so up to 3 controls can sit on one line comfortably */
.ts-block:not(.ts-shift-block) .ts-block-row {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

@media (min-width: 1100px) {
  .ts-block:not(.ts-shift-block) .ts-block-row {
    grid-template-columns: repeat(2, minmax(300px, 1fr));
  }
}

/* Auto-schedule & manual assignment: keep fields compact in two-column grids on wide screens */
.ts-block-row.ts-auto-row {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
@media (min-width: 1100px) {
  .ts-block-row.ts-auto-row {
    grid-template-columns: repeat(3, minmax(260px, 1fr));
  }
}
.ts-gps-row {
  grid-template-columns: minmax(200px, 260px) 200px;
  align-items: end;
}
.ts-gps-row .ts-chip-btn {
  width: 100%;
  max-width: 200px;
  justify-self: start;
}

.ts-light-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}
.ts-light-grid .ts-card {
  margin: 0;
}

/* Upcoming schedule cards */
.ts-upcoming {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.ts-upcoming.single-column {
  flex-direction: column;
}
.ts-up-card {
  border: 1px solid var(--fd-card-border);
  box-shadow: none;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--fd-text);
}
.ts-up-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.ts-up-date { font-weight: 800; font-size: 1.05rem; color: var(--fd-text); }
.ts-up-sub { color: var(--fd-muted); font-size: 0.96rem; }
.ts-up-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ts-up-card-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}
.ts-up-card-actions .ts-chip-btn {
  flex: 0 0 auto; /* Prevent buttons from growing */
  border-radius: 10px;
  font-size: 0.85rem;
  padding: 8px 12px; /* Add some horizontal padding */
  text-transform: none;
}
.admin-hidden { display: none !important; }
.ts-pill {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.86rem;
  letter-spacing: 0.2px;
  border: 1px solid var(--fd-card-border);
  background: rgb(var(--fd-card-rgb) / 0.12);
  color: var(--fd-text);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.12s ease;
}
.ts-pill:hover { transform: translateY(-1px); filter: brightness(1.05); }
.ts-pill.muted {
  background: transparent;
  border-color: var(--fd-card-border);
  color: var(--fd-muted);
}
.ts-pill.primary {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), var(--fd-accent-strong));
  border: none;
  font-weight: 700;
  color: #fff;
  box-shadow: none;
}

/* === Timesheet & Export refinements === */
#tsTimesheetCard {
  overflow-x: visible;
}
#tsTimesheetCard .ts-form-grid {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 10px 8px;
  align-items: end;
}
#tsTimesheetCard .ts-field {
  margin-bottom: 0;
  display: grid;
  grid-template-rows: minmax(16px, auto) 44px;
  gap: 6px;
  align-content: end;
  min-width: 0;
}
#tsTimesheetCard .ts-field .ts-control,
#tsTimesheetCard .ts-field .ts-select,
#tsTimesheetCard .ts-field input,
#tsTimesheetCard .ts-field select {
  min-height: 44px;
  height: 44px;
}
#tsTimesheetCard .ts-field.save-days {
  align-self: stretch;
  min-width: 140px;
}
#tsTimesheetCard .ts-field.save-days::before {
  content: "";
  display: block;
}
#tsTimesheetCard .ts-field.save-days button {
  min-width: 120px;
  width: 100%;
  height: 44px;
  min-height: 44px;
  align-self: end;
}
#tsTimesheetCard .ts-field.actions-row {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  grid-template-rows: none;
}
#tsTimesheetCard .ts-field.actions-row .ts-actions-row { justify-content: flex-start; }
#tsTimesheetCard .ts-label {
  color: var(--fd-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  min-height: 16px;
  width: 100%;
  white-space: nowrap;
}
#tsTimesheetCard .ts-label .help-icon {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  padding: 0;
  line-height: 1;
  flex: 0 0 14px;
  font-size: 9px;
  border-radius: 999px;
}
#tsTimesheetCard .ts-actions-row { gap: 8px; }
#tsTimesheetCard .ts-actions-row .ts-chip-btn { min-width: 110px; }
#tsTimesheetCard .ts-control,
#tsTimesheetCard .ts-select {
  padding: 8px 10px;
  font-size: 13px;
}
@media (max-width: 1700px) {
  #tsTimesheetCard .ts-form-grid {
    grid-template-columns: repeat(6, minmax(150px, 1fr));
  }
}
@media (max-width: 1280px) {
  #tsTimesheetCard .ts-form-grid {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
  }
}
@media (max-width: 900px) {
  #tsTimesheetCard .ts-form-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}
@media (max-width: 560px) {
  #tsTimesheetCard .ts-form-grid {
    grid-template-columns: 1fr;
  }
  #tsTimesheetCard .ts-field.save-days {
    min-width: 0;
  }
}
#tsTimesheetCard .ts-table {
  min-width: 960px;
  border: 1px solid var(--fd-card-border);
  border-radius: 10px;
  overflow: hidden;
}
#tsTimesheetCard .ts-table th { text-transform: uppercase; }
#tsTimesheetCard .ts-table th, #tsTimesheetCard .ts-table td { padding: 12px 10px; }
#tsVacationDaysInput { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.45); }
#tsSickDaysInput { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.45); }
.vacation-day td { background: rgba(245, 158, 11, 0.14) !important; color: var(--fd-text); font-weight: 600; }
.sick-day td { background: rgba(239, 68, 68, 0.14) !important; color: var(--fd-text); font-weight: 600; }
.status-cell.vacation { color: #fbbf24; font-weight: 700; }
.status-cell.sick { color: #f87171; font-weight: 700; }

/* Tighten table for print/fit */
.ts-table.compact th,
.ts-table.compact td { padding: 6px 8px; font-size: 12px; }

/* Print tightening: fit on one page */
@media print {
  @page { size: A4 portrait; margin: 2mm; }
  body { background: #fff; }
  .ts-card, .ts-shell { box-shadow: none !important; border: none !important; }
  #tsTimesheetCard { transform: scale(0.78); transform-origin: top left; width: 128%; }
  #tsTimesheetCard .ts-table { font-size: 8px; }
  #tsTimesheetCard .ts-table th, #tsTimesheetCard .ts-table td { padding: 1.5px 2px; line-height: 1.05; }
  #tsTimesheetCard .ts-summary-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px,1fr)); gap: 4px; }
  #tsTimesheetCard .ts-summary-card { padding: 3px 4px; font-size: 8px; }
  #tsTimesheetCard .ts-summary-card .value { font-size: 10px; }
  #tsTimesheetCard h2 { margin-bottom: 2px; font-size: 12px; }
  #tsTimesheetCard p { margin-bottom: 2px; font-size: 9px; }
  .ts-actions-row { margin-bottom: 2px; }
  .ts-table, .ts-summary-row, .ts-summary-card { page-break-inside: avoid; }
}
.ts-pill.danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}
.ts-pill.presence { margin-left: 6px; }
.ts-pill.presence.ok { background:#d1fae5; color:#065f46; }
.ts-pill.presence.no { background:#fee2e2; color:#991b1b; }
.ts-pill.presence.unknown { background:#fef3c7; color:#92400e; }
.ts-shift-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 10px;
  align-items: stretch;
}
.ts-shift-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgb(var(--fd-card-rgb) / 0.12);
  border: 1px solid var(--fd-card-border);
  color: var(--fd-text);
  box-shadow: none;
}
.ts-shift-main { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ts-shift-name { font-weight: 700; color: var(--fd-text); font-size: 1rem; }
.ts-shift-time { color: var(--fd-muted); font-size: 0.92rem; }
.ts-shift-tag { color: var(--fd-muted); font-size: 0.82rem; }

#tsArchiveContent {
  margin-top: 12px;
  display: grid;
  gap: 14px;
}
#tsArchiveContent h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-dark);
}
#tsArchiveContent .ts-shift-list {
  gap: 10px;
}
#tsArchiveContent .ts-shift-row {
  background: rgb(var(--fd-card-rgb) / 0.12);
  border-color: var(--fd-card-border);
  color: var(--fd-text);
  box-shadow: none;
}
#tsArchiveContent .ts-shift-row .ts-shift-name,
#tsArchiveContent .ts-shift-row .ts-shift-time {
  color: inherit;
  font-size: 0.95rem;
}

@media (max-width: 720px) {
  .ts-upcoming {
    flex-direction: column;
  }
  .ts-shift-list {
    grid-template-columns: 1fr;
  }
}

/* Utility spacers for the timesheet page */
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.full-width { width: 100%; }
.ts-empty-pane { min-height: 260px; }

@media (max-width: 720px) {
  .ts-header { flex-direction: column; align-items: flex-start; }
  .ts-actions-row { width: 100%; }
}
/* On wide laptop/desktop viewports, force five columns with moderate gaps. */
@media (min-width: 1500px) {
  .ops-card .mini-block { padding: 5px 7px; }
  .ops-card .mini-title { font-size: 0.74rem; }
  .insight-list li { font-size: 0.7rem; line-height: 1.1; min-height: 16px; }
  .insight-list .rank { width: 14px; height: 14px; line-height: 14px; font-size: 0.62rem; }
  .insight-list .val { font-size: 0.7rem; }
  .insight-list .pct { font-size: 0.62rem; }
  .ops-card .stat-row { font-size: 0.7rem; }
  .ops-card .stat-row span { white-space: nowrap; }
  .ops-card .stat-row strong { font-size: 0.76rem; }
  .ops-card .stats-block[data-branch][data-mode]::before { font-size: 0.64rem; }
  .ai-insight { font-size: 0.74rem; }
  .ai-list li { font-size: 0.7rem; }
}


/* ===================== INDEX.HTML - EXTRACTED INLINE STYLES ===================== */
.insight-container-scrollable {
  max-height: 320px;
  overflow-y: auto;
  padding: 0;
}

.ts-label-small {
  font-size: 0.9rem !important;
  font-weight: 600;
}

.ts-table-center {
  text-align: center;
}

/* (Legacy unscoped dashboard chart-card block removed; see scoped dashboard-overview rules below.) */

/* Footer centering fix for pages where footer is outside container */
.fd-main-content > .footer {
  width: calc(100% - 36px);
  max-width: 100%;
  margin: 20px auto 0;
  box-sizing: border-box;
}
@media (max-width: 768px) {
  .fd-main-content > .footer {
    width: calc(100% - 20px);
    margin: 12px auto 0;
  }
}


/* Footer centering safety net */
.fd-main-content > .footer { width: calc(100% - 32px); max-width: 100%; margin: 20px auto 0; text-align: center; }

/* ------------------------------------------------------------------
   Dashboard Overview Page: clear section-first layout
------------------------------------------------------------------ */
body.fd-app.dashboard-overview-page .main-wrapper {
  width: 100%;
  margin: 0;
  padding: 0;
}

body.fd-app.dashboard-overview-page .container.main-surface {
  gap: 14px;
}

body.fd-app.dashboard-overview-page .dashboard-workspace {
  width: 100%;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 14px;
}

body.fd-app.dashboard-overview-page .dashboard-topbar {
  display: grid;
  grid-template-columns: minmax(300px, 1.2fr) minmax(360px, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  background: rgb(var(--fd-card-rgb) / 0.10);
}

body.fd-app.dashboard-overview-page .dashboard-headline h1 {
  margin: 0;
  font-size: clamp(1.1rem, 1.35vw, 1.45rem);
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--fd-card-text);
}

body.fd-app.dashboard-overview-page .dashboard-headline p {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--fd-card-muted);
}

body.fd-app.dashboard-overview-page .fd-controls-bar.dashboard-controls {
  justify-content: flex-end;
  margin: 0;
}

body.fd-app.dashboard-overview-page .dashboard-kpi-strip {
  margin: 0;
}

body.fd-app.dashboard-overview-page .dashboard-kpi-strip .summary-card {
  min-height: 206px;
}

body.fd-app.dashboard-overview-page .dashboard-kpi-strip .pagination {
  display: none;
}

body.fd-app.dashboard-overview-page .dashboard-block {
  padding: 14px 16px;
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  background: rgb(var(--fd-card-rgb) / var(--fd-surface-alpha));
  display: grid;
  gap: 10px;
}

body.fd-app.dashboard-overview-page .dashboard-highlights-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

body.fd-app.dashboard-overview-page .dashboard-highlights-row > .dashboard-block {
  height: 100%;
}

body.fd-app.dashboard-overview-page .dashboard-block-header {
  display: grid;
  gap: 4px;
}

body.fd-app.dashboard-overview-page .dashboard-block-header h4 {
  margin: 0;
  font-size: 0.96rem;
  letter-spacing: 0.02em;
  color: var(--fd-card-text);
}

body.fd-app.dashboard-overview-page .dashboard-block-header p {
  margin: 0;
  font-size: 0.78rem;
}

body.fd-app.dashboard-overview-page .dashboard-overview-block .charts-unified-row,
body.fd-app.dashboard-overview-page .dashboard-breakdown-block .donut-row {
  margin: 0;
}

body.fd-app.dashboard-overview-page .dashboard-overview-block .charts-unified-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
  width: 100%;
}

body.fd-app.dashboard-overview-page .dashboard-overview-block .main-chart-box,
body.fd-app.dashboard-overview-page .dashboard-breakdown-block .donut-box {
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  background: rgb(var(--fd-card-rgb) / var(--fd-surface-alpha));
  box-shadow: none;
}

body.fd-app.dashboard-overview-page .dashboard-overview-block .main-chart-box {
  flex: 1 1 auto;
  padding: 10px;
  min-height: 280px;
  max-height: 320px;
  overflow: hidden;
}

body.fd-app.dashboard-overview-page .dashboard-breakdown-block .donut-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

body.fd-app.dashboard-overview-page .dashboard-breakdown-block .donut-box {
  min-height: 220px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

body.fd-app.dashboard-overview-page .dashboard-overview-block canvas,
body.fd-app.dashboard-overview-page .dashboard-breakdown-block canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

body.fd-app.dashboard-overview-page .branch-categories-section {
  margin-top: 0;
}

body.fd-app.dashboard-overview-page .branch-categories-title-spaced {
  margin-top: 14px;
}

@media (max-width: 1150px) {
  body.fd-app.dashboard-overview-page .dashboard-topbar {
    grid-template-columns: 1fr;
  }

  body.fd-app.dashboard-overview-page .fd-controls-bar.dashboard-controls {
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  body.fd-app.dashboard-overview-page .dashboard-workspace {
    gap: 10px;
  }

  body.fd-app.dashboard-overview-page .dashboard-topbar,
  body.fd-app.dashboard-overview-page .dashboard-block {
    padding: 12px;
  }

  body.fd-app.dashboard-overview-page .dashboard-overview-block .main-chart-box {
    min-height: 220px;
    max-height: 260px;
  }
}

@media (max-width: 1200px) {
  body.fd-app.dashboard-overview-page .dashboard-highlights-row {
    grid-template-columns: 1fr;
  }
}
