@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');
/* Centered navigation bar for top nav */
.fd-center-nav {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  width: 100%;
}
.fd-nav-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.55rem, 1.1vw, 2.1rem);
  flex-wrap: nowrap;
  list-style: none;
  margin: 0;
  padding: 0;
}
.fd-nav-link {
  color: #fff;
  font-weight: 600;
  font-size: clamp(0.92rem, 1.02vw, 1.12rem);
  text-decoration: none;
  padding: clamp(0.28rem, 0.45vw, 0.44rem) clamp(0.62rem, 0.95vw, 1rem);
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.fd-nav-link:hover, .fd-nav-link.active {
  background: rgba(255,255,255,0.13);
  color: #b3e0ff;
}

@media (max-width: 900px) {
  .fd-center-nav {
    flex: 1 1 100%;
    justify-content: center;
  }
  .fd-nav-list {
    gap: 0.55rem;
    flex-wrap: wrap;
  }
  .fd-nav-link {
    font-size: 0.95rem;
    padding: 0.28rem 0.62rem;
  }
}
/* Restore horizontal row for main chart and donuts, with filter above donuts */
.charts-unified-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 32px;
  width: 100%;
  margin-bottom: 18px;
}

.donut-charts-with-filter {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-width: 320px;
}

.filter-above-donuts {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}

.donuts-row {
  display: flex;
  flex-direction: row;
  gap: 18px;
  width: 100%;
  justify-content: center;
}

@media (max-width: 1100px) {
  .charts-unified-row {
    flex-direction: column;
    gap: 18px;
    align-items: stretch;
  }
  .donuts-row {
    flex-direction: column;
    gap: 12px;
    align-items: center;
  }
}
/* Make all buttons small and responsive */
body.fd-app button,
body.fd-app .btn,
body.fd-app .fd-btn,
body.fd-app .ts-chip-btn,
body.fd-app .ts-btn {
  font-size: 0.85rem !important;
  padding: 0.35em 0.9em !important;
  min-width: 60px !important;
  min-height: 32px !important;
  border-radius: 8px !important;
  line-height: 1.1 !important;
}

/* Make delete buttons even smaller */
body.fd-app .btn-danger,
body.fd-app .fd-btn-danger,
body.fd-app button.btn-danger {
  font-size: 0.82rem !important;
  padding: 0.32em 0.7em !important;
  min-width: 48px !important;
  min-height: 28px !important;
}

/* 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;
  }
  body.fd-app button,
  body.fd-app .btn,
  body.fd-app .fd-btn {
    font-size: 0.8rem !important;
    min-width: 48px !important;
    min-height: 26px !important;
    padding: 0.28em 0.6em !important;
  }
}

@media (max-width: 900px) {
  .summary-card table th,
  .summary-card table td {
    font-size: 0.78em;
    padding: 0.22em 0.15em;
  }
  body.fd-app button,
  body.fd-app .btn,
  body.fd-app .fd-btn {
    font-size: 0.75rem !important;
    min-width: 38px !important;
    min-height: 22px !important;
    padding: 0.18em 0.4em !important;
  }
}
/* Center the calculator in its row */
.calculator-row-center {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 0 18px 0;
}
/* Donut charts column and filter above donuts */
.donut-charts-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  width: 100%;
}

.filter-above-donuts {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}

@media (min-width: 900px) {
  .donut-charts-column {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 32px;
  }
  .filter-above-donuts {
    flex-direction: column;
    align-items: center;
    margin-bottom: 0;
    margin-right: 0;
  }
  .donut-charts-column > .filter-above-donuts {
    width: 100%;
    margin-bottom: 12px;
  }
}
/* Centered period selector above chart */
.period-row-over-chart {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  margin-top: 0;
  padding: 0;
}
/* ==============================================
   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;
}

/* Extra row for period selector */
.period-row {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 18px;
  margin-top: 0;
  padding: 0;
}
.period-row select {
  font-size: 1rem;
  padding: 8px 18px;
  border-radius: 8px;
  background: rgb(var(--fd-card-rgb));
  color: var(--fd-text);
  border: 1px solid var(--fd-card-border);
  box-shadow: none;
  margin: 0;
}
.period-row input[type="date"] {
  font-size: 1rem;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgb(var(--fd-card-rgb));
  color: var(--fd-text);
  border: 1px solid var(--fd-card-border);
  margin-left: 8px;
}
.period-row select:focus,
.period-row input[type="date"]:focus {
  outline: 2px solid var(--fd-accent-strong);
  background: rgba(255,255,255,0.05);
}

.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-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;
}

/* Header / top bar (matches the React snippet: no extra card behind it) */
.fd-app .top-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--fd-chrome-bg);
  border: none;
  border-bottom: 1px solid rgba(71, 85, 105, 0.45);
  box-shadow: none;
  padding: 12px 12px 16px 12px;
  border-radius: 0;
  margin: -12px -12px 16px -12px;
  width: calc(100% + 24px);
  box-sizing: border-box;
}

.fd-app .top-nav__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  column-gap: clamp(8px, 1.05vw, 18px);
  row-gap: 8px;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

.fd-brand {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: clamp(8px, 0.9vw, 12px);
  min-width: 0;
  justify-self: start;
}
.fd-brand__title {
  font-size: clamp(27px, 1.7vw, 34px);
  font-weight: 900;
  letter-spacing: 0.2px;
  line-height: 1.05;
  color: #60a5fa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fd-brand__title span {
  display: inline;
  margin-left: 6px;
  color: inherit;
}
.fd-brand__sub {
  font-size: clamp(11px, 0.75vw, 14px);
  color: var(--fd-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.fd-actions {
  display: flex;
  gap: clamp(6px, 0.7vw, 10px);
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  justify-self: end;
  min-width: 0;
}
.fd-app .top-nav .fd-center-nav {
  justify-self: center;
}
.fd-date {
  color: var(--fd-muted);
  font-weight: 700;
  font-size: clamp(11px, 0.78vw, 14px);
  margin-right: 6px;
  white-space: nowrap;
}
body.fd-app .top-nav #logoutBtn {
  font-size: clamp(0.76rem, 0.76vw, 0.9rem) !important;
  padding: clamp(0.3rem, 0.42vw, 0.48rem) clamp(0.72rem, 0.9vw, 1.08rem) !important;
  min-height: 32px !important;
}

@media (max-width: 1560px) {
  .fd-brand__title {
    font-size: clamp(24px, 1.8vw, 30px);
  }
  .fd-brand__sub {
    max-width: clamp(190px, 24vw, 320px);
  }
  .fd-nav-list {
    gap: clamp(0.45rem, 0.85vw, 1rem);
  }
  .fd-nav-link {
    font-size: clamp(0.88rem, 0.88vw, 1rem);
    padding: 0.28rem clamp(0.5rem, 0.65vw, 0.85rem);
  }
}

@media (max-width: 1320px) {
  .fd-app .top-nav__inner {
    column-gap: 8px;
  }
  .fd-brand {
    gap: 8px;
  }
  .fd-brand__title {
    font-size: clamp(21px, 2vw, 26px);
  }
  .fd-brand__sub {
    display: none;
  }
  .fd-nav-list {
    gap: 0.45rem;
  }
  .fd-nav-link {
    font-size: 0.88rem;
    padding: 0.28rem 0.56rem;
  }
  .fd-actions {
    gap: 6px;
  }
  .fd-date {
    font-size: 11px;
    margin-right: 2px;
  }
  body.fd-app .top-nav #logoutBtn {
    padding: 0.3rem 0.75rem !important;
    min-height: 30px !important;
    font-size: 0.78rem !important;
  }
}

.fd-app .top-nav__links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
  justify-self: center;
}
.fd-app .top-nav__links .top-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  text-decoration: none;
  white-space: nowrap;
}
.fd-app .top-nav__links .top-nav__link[aria-current="page"] {
  border-color: rgba(59, 130, 246, 0.95);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
.fd-app .top-nav__links .nav-text-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--fd-muted);
  white-space: nowrap;
}
.fd-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}
.fd-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.fd-btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
}
.fd-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}
.fd-btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}
.fd-btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

@media (max-width: 1180px) {
  .fd-app .top-nav__inner {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .fd-brand { flex-direction: column; align-items: center; gap: 4px; }
  .fd-brand__title {
    white-space: normal;
    text-align: center;
  }
  .fd-brand__sub {
    display: block;
    white-space: normal;
    text-align: center;
  }
  .fd-nav-list { flex-wrap: wrap; }
  .fd-actions { justify-content: center; justify-self: center; }
}

/* Add padding back for larger screens only */
@media (min-width: 769px) {
  body.fd-app { padding: 12px; }
}

@media (max-width: 768px) {
  body.fd-app { padding: 0; }
  .fd-app .top-nav {
    width: 100%;
    margin: 0 0 12px 0;
    padding: 8px 0 12px 0;
    box-sizing: border-box;
  }
}

@media (max-width: 480px) {
  body.fd-app { padding: 0; }
  .fd-app .top-nav {
    width: 100%;
    margin: 0 0 12px 0;
    padding: 6px 0 10px 0;
    box-sizing: border-box;
  }
  .fd-brand__title { font-size: 24px; }
  .fd-brand__sub { font-size: 12px; }
}

/* Dashboard mobile: keep month + period controls perfectly centered */
@media (max-width: 768px) {
  body.fd-app.finance-dashboard-page .chart-section > .filter-row.filter-row-over-donuts,
  body.fd-app.finance-dashboard-page .chart-section > .period-row.period-row-over-chart {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
  }

  body.fd-app.finance-dashboard-page .chart-section > .filter-row.filter-row-over-donuts {
    margin: 8px 0 10px;
  }

  body.fd-app.finance-dashboard-page .chart-section .filter-card.filter-card-centered.compact {
    margin: 0 auto 10px !important;
    width: fit-content !important;
    max-width: 220px;
    min-height: auto;
    padding: 8px 10px !important;
  }

  body.fd-app.finance-dashboard-page #filterMonth {
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    margin: 0 auto;
    text-align: center !important;
  }

  body.fd-app.finance-dashboard-page .period-row.period-row-over-chart {
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 12px;
  }

  body.fd-app.finance-dashboard-page #overviewPeriod,
  body.fd-app.finance-dashboard-page #overviewGranularity,
  body.fd-app.finance-dashboard-page #overviewStart,
  body.fd-app.finance-dashboard-page #overviewEnd,
  body.fd-app.finance-dashboard-page #overviewChartPreviewBtn {
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    margin: 0 !important;
    text-align: center !important;
  }
}

/* Mobile navbar behavior:
   keep logout pinned to top-right and center the date line */
@media (max-width: 768px) {
  body.fd-app .top-nav {
    padding: 6px 0 8px 0;
  }

  body.fd-app .top-nav__inner {
    position: relative;
    row-gap: 6px;
    padding-inline: 74px;
  }

  body.fd-app .top-nav .fd-brand {
    display: none !important;
  }

  body.fd-app .top-nav .fd-center-nav {
    width: 100%;
    justify-self: center;
  }

  body.fd-app .top-nav .fd-nav-list {
    justify-content: center;
    row-gap: 6px;
  }

  body.fd-app .top-nav .fd-actions {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0;
    min-height: 24px;
  }

  body.fd-app .top-nav .fd-date {
    width: 100%;
    margin: 0;
    text-align: center;
  }

  body.fd-app .top-nav__inner #logoutBtn {
    position: absolute;
    top: 6px;
    right: 8px;
    margin: 0;
    z-index: 4;
  }
}

@media (max-width: 480px) {
  body.fd-app .top-nav__inner {
    padding-inline: 62px;
  }
}

:focus {
  outline: 3px solid var(--fd-accent-strong);
  outline-offset: 2px;
}

/* Shared component styling (buttons, inputs, tables) */
body.fd-app button,
body.fd-app .btn,
body.fd-app .fd-btn,
body.fd-app .ts-chip-btn,
body.fd-app .ts-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fd-text);
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
body.fd-app button:disabled,
body.fd-app .btn:disabled,
body.fd-app .fd-btn:disabled,
body.fd-app .ts-chip-btn:disabled,
body.fd-app .ts-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

body.fd-app .btn.btn-primary,
body.fd-app .btn.primary,
body.fd-app button.btn-primary,
body.fd-app button.primary,
body.fd-app .fd-btn-primary,
body.fd-app .ts-chip-btn.primary,
body.fd-app .ts-btn.primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
}
body.fd-app .btn.btn-primary:hover,
body.fd-app .btn.primary:hover,
body.fd-app button.btn-primary:hover,
body.fd-app button.primary:hover,
body.fd-app .fd-btn-primary:hover,
body.fd-app .ts-chip-btn.primary:hover,
body.fd-app .ts-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}
body.fd-app .btn.btn-success,
body.fd-app .btn.success,
body.fd-app button.btn-success,
body.fd-app button.success,
body.fd-app .ts-chip-btn.success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}
body.fd-app .btn.btn-success:hover,
body.fd-app .btn.success:hover,
body.fd-app button.btn-success:hover,
body.fd-app button.success:hover,
body.fd-app .ts-chip-btn.success:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}
body.fd-app .btn.btn-danger,
body.fd-app .btn.danger,
body.fd-app button.btn-danger,
body.fd-app button.danger,
body.fd-app .fd-btn-danger,
body.fd-app .ts-chip-btn.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}
body.fd-app .btn.btn-danger:hover,
body.fd-app .btn.danger:hover,
body.fd-app button.btn-danger:hover,
body.fd-app button.danger:hover,
body.fd-app .fd-btn-danger:hover,
body.fd-app .ts-chip-btn.danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}
body.fd-app .btn-ghost,
body.fd-app .btn.ghost,
body.fd-app button.btn-ghost,
body.fd-app button.ghost {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--fd-text);
}

body.fd-app input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
body.fd-app select,
body.fd-app textarea,
body.fd-app .input {
  background: var(--fd-input-bg);
  border: 1px solid var(--fd-input-border);
  padding: 0.5rem 0.875rem;
  border-radius: 6px;
  color: var(--fd-input-text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 44px;
  box-sizing: border-box;
}
body.fd-app textarea {
  resize: vertical;
}
body.fd-app input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
body.fd-app select:focus,
body.fd-app textarea:focus,
body.fd-app .input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

body.fd-app table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
/* Keep dashboard data tables on fixed layout even inside fd-app */
body.fd-app table.data-table {
  table-layout: fixed;
}
body.fd-app th {
  background: var(--fd-table-th-bg);
  padding: 0.75rem 0.5rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  border-bottom: 2px solid var(--fd-table-th-border);
  white-space: nowrap;
}
body.fd-app td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--fd-table-td-border);
  font-size: 0.8rem;
}
body.fd-app tr:hover {
  background: var(--fd-table-row-hover);
}
body.fd-app th.text-right,
body.fd-app td.text-right {
  text-align: right;
}
body.fd-app th.text-center,
body.fd-app td.text-center {
  text-align: center;
}

/* Action columns: keep buttons flush to the right edge (avoid unused space after action buttons). */
body.fd-app table th.col-actions,
body.fd-app table td.col-actions {
  text-align: right;
  white-space: nowrap;
}
@supports (min-width: max-content) {
  body.fd-app table:not(.data-table) th.col-actions,
  body.fd-app table:not(.data-table) td.col-actions {
    width: 1%;
    min-width: max-content;
  }
}
body.fd-app table td.col-actions .ts-actions-row {
  justify-content: flex-end;
}

body.fd-app ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
body.fd-app ::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.3);
}
body.fd-app ::-webkit-scrollbar-thumb {
  background: rgba(71, 85, 105, 0.55);
  border-radius: 3px;
}

@media (max-width: 640px) {
  body.fd-app button,
  body.fd-app .btn,
  body.fd-app .fd-btn,
  body.fd-app .ts-chip-btn,
  body.fd-app .ts-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    min-height: 40px;
  }
  body.fd-app input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  body.fd-app select,
  body.fd-app textarea,
  body.fd-app .input {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    min-height: 40px;
  }
}

/* Card surfaces: keep exactly one visual surface per feature/card */
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-card-alpha-effective));
  border: 1px solid var(--fd-card-border);
  border-radius: 12px;
  box-shadow: var(--fd-card-shadow);
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
  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-card-alpha-hover));
  box-shadow: var(--fd-card-shadow-hover);
}

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: 12px;
}
body.fd-app .insight-card {
  padding: 16px 18px;
}
body.fd-app .chart-canvas-container {
  padding: 12px;
}

/* Auth pages (login/reset) */
body.fd-app.auth-page {
  align-items: center;
  justify-content: center;
  padding: 20px;
}
body.fd-app.auth-page .login-shell,
body.fd-app.auth-page .shell {
  width: 100%;
  background: rgb(var(--fd-card-rgb) / var(--fd-card-alpha-effective));
  border: 1px solid var(--fd-card-border);
  border-radius: 16px;
  box-shadow: var(--fd-card-shadow-hover);
  padding: 22px 22px 26px;
}
body.fd-app.auth-page .login-shell { max-width: 420px; }
body.fd-app.auth-page .shell { max-width: 520px; }
body.fd-app.auth-page .login-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 18px;
}
body.fd-app.auth-page .tab-btn {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: transparent;
  color: var(--fd-muted);
  padding: 10px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
body.fd-app.auth-page .tab-btn.active {
  background: rgb(var(--fd-card-rgb) / var(--fd-card-alpha-hover));
  color: var(--fd-text);
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}
body.fd-app.auth-page h2 {
  margin: 0 0 4px;
  text-align: center;
  letter-spacing: 0.3px;
}
body.fd-app.auth-page .subtitle {
  text-align: center;
  color: var(--fd-muted);
  margin-bottom: 16px;
  font-size: 0.95rem;
}
body.fd-app.auth-page .field-label {
  margin: 12px 0 6px;
  font-weight: 700;
  color: var(--fd-text);
  letter-spacing: 0.2px;
}
body.fd-app.auth-page .input-wrap {
  position: relative;
}
body.fd-app.auth-page .toggle-pass {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: #60a5fa;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
body.fd-app.auth-page .remember-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--fd-muted);
  margin: 12px 0 14px;
  font-size: 0.9rem;
}
body.fd-app.auth-page .remember-row label { cursor: pointer; }
body.fd-app.auth-page .small-link,
body.fd-app.auth-page .link {
  color: #60a5fa;
  text-decoration: none;
  font-size: 0.9rem;
}
body.fd-app.auth-page .error {
  color: #f87171;
  text-align: center;
  margin-top: 10px;
  min-height: 1em;
}
body.fd-app.auth-page .msg {
  margin-top: 12px;
  min-height: 1em;
  text-align: center;
  color: var(--fd-muted);
  word-break: break-word;
}
body.fd-app.auth-page .msg.error { color: #f87171; }
body.fd-app.auth-page .row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}
body.fd-app.auth-page .auth-secondary-row {
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
}
body.fd-app.auth-page .auth-secondary-row .btn {
  min-width: 180px;
}
body.fd-app.auth-page .auth-security-panel {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--fd-card-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}
body.fd-app.auth-page .auth-security-panel .row {
  justify-content: flex-start;
}
body.fd-app.auth-page .auth-otpauth-wrap {
  margin-top: 8px;
  word-break: break-all;
}
body.fd-app.auth-page .auth-row-spacer {
  margin-top: 16px;
}
body.fd-app.auth-page .card-divider {
  height: 1px;
  background: rgba(71, 85, 105, 0.35);
  margin: 18px 0;
}
body.fd-app.auth-page code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
}
body.fd-app.auth-page .tiny {
  font-size: 0.85rem;
  color: var(--fd-muted);
  margin-top: 10px;
}
.main-wrapper {
  flex: 1;
  width: 100%;
}

.main-surface {
  background: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  width: 100%;
  max-width: 100%;
  margin: 0 auto 0;
}

@media (min-width: 769px) {
  .main-surface {
    width: 96%;
    max-width: 1800px;
    margin: 0 auto 20px;
  }
}

.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: 96%;
    max-width: 1800px;
    margin: 12px auto 24px auto;
    padding: 16px 18px;
  }
}

.container > * {
  width: 100%;
}

/* Timesheet page: stretch container like inventory, no centering squeeze */
.timesheet-page .container {
  width: 100%;
  max-width: 100%;
  align-items: center;
}

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

.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);
}

.filter-card-centered {
  margin: 22px auto 16px;
  text-align: center;
  max-width: 200px;
}
.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 > * {
  min-width: 0;
  box-sizing: border-box;
}

/* ------------------ 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: fixed;
}
.data-table caption {
  text-align: left;
  padding: 0 0 10px 0;
  font-weight: 800;
}
.data-table th,
.data-table td {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  will-change: transform; /* GPU-promote sticky header to avoid repaint on scroll */
}
.data-table thead th {
  text-align: left !important;
  font-weight: 600;
}
.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; }

/* 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;
}
/* 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 padding only there */
#employeeLoanContainer .data-table td {
  padding: 6px 8px;
}

/* 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 {
    gap: 8px;
    margin-bottom: 12px;
  }

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

  .loan-summary .loan-filter-bar .month-input {
    width: 100%;
    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;
  }

  #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 - FULLY RESPONSIVE */
section.summary-cards {
  margin: 0.75rem 0 1.25rem 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
}

/* Desktop: 5 columns (no change) */
@media (min-width: 1400px) {
  section.summary-cards {
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
  }
}

/* Large tablet: 4 columns */
@media (max-width: 1399px) and (min-width: 1100px) {
  section.summary-cards {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
}

/* iPad landscape: 3 columns */
@media (max-width: 1099px) and (min-width: 900px) {
  section.summary-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

/* Tablet portrait: 2 columns */
@media (max-width: 899px) and (min-width: 600px) {
  section.summary-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* Mobile: 1 column with horizontal scroll option */
@media (max-width: 599px) {
  section.summary-cards {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    padding-bottom: 8px;
  }
}

/* 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 .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;
}

/* Insights under charts */
.insights-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  grid-auto-rows: auto;
  gap: 10px;
  margin-top: 10px;
  align-items: start;
}

@media (max-width: 1100px) {
  .insights-panel { grid-template-columns: repeat(2, minmax(220px, 1fr)); grid-auto-rows: auto; }
}
@media (max-width: 768px) {
  .insights-panel { grid-template-columns: 1fr; grid-auto-rows: auto; }
}
.insight-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  max-height: 210px;
  overflow-y: auto;
  overflow-x: hidden;
}
.insight-list li {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  line-height: 1.2;
  min-height: 20px;
}
.insight-list .rank {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.18);
  color: var(--fd-card-text);
  text-align: center;
  font-size: 0.8rem;
  line-height: 18px;
  font-weight: 700;
  border: 1px solid rgba(59, 130, 246, 0.28);
}
.insight-list .key { font-weight: 600; color: var(--fd-card-text); }
.insight-list .val {
  color: var(--fd-card-muted);
  font-size: 0.9rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
.insight-list .pct {
  color: var(--fd-card-muted);
  font-size: 0.82rem;
  margin-left: 6px;
}
.insight-list .muted { color: var(--fd-card-muted); font-size: 0.9rem; grid-template-columns: 1fr; }
.ai-insight { font-size: 0.86rem; line-height: 1.3; }
.ai-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; }
.ai-list li { font-size: 0.78rem; color: var(--fd-card-text); background: rgb(var(--fd-card-rgb) / 0.12); border: 1px solid var(--fd-card-border); border-radius: 7px; padding: 5px 7px; box-shadow: none; }
.ai-list strong { color: var(--fd-accent-text); }

.branch-cats .branch-card {
  background: rgb(var(--fd-card-rgb) / 0.10);
  border: 1px solid var(--fd-card-border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  box-shadow: none;
}
.branch-cats .branch-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-weight: 600;
}
.branch-cats .branch-name { color: var(--fd-card-text); }
.branch-cats .branch-total { color: var(--fd-card-text); font-weight: 700; font-size: 0.95rem; }
.branch-cats .insight-list.compact { max-height: none; gap: 3px; }
.branch-cats .insight-list.compact li { margin: 2px 0; }
.insight-list.compact .rank { background: rgba(59, 130, 246, 0.12); }

/* Ops card layout */
.ops-card .ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.ops-card .mini-block {
  background: rgb(var(--fd-card-rgb) / 0.10);
  border: 1px solid var(--fd-card-border);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}
.ops-card .mini-title {
  font-weight: 600;
  color: var(--fd-card-muted);
  margin-bottom: 4px;
}
.ops-card .insight-list.compact {
  max-height: 128px;
  gap: 4px;
}
.ops-card .stats-block {
  display: grid;
  gap: 6px;
}
.ops-card .stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--fd-card-muted);
}
.ops-card .stat-row strong { font-size: 0.95rem; color: var(--fd-accent-text); }

@media (max-width: 600px) {
  .ops-card .ops-grid { grid-template-columns: 1fr; }
}

/* Branch Overview stats: make branch selection discoverable */
.ops-card .stats-block[data-branch][data-mode]::before {
  content: attr(data-mode) " \\00B7 " attr(data-branch);
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--fd-card-muted);
}

#insightBranchList li[data-branch],
#insightBranchBalanceList li[data-branch],
#cashBalanceBranchList li[data-branch] {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  border-radius: 8px;
  padding: 4px 6px;
}
#insightBranchList li[data-branch]:hover,
#insightBranchBalanceList li[data-branch]:hover,
#cashBalanceBranchList li[data-branch]:hover {
  background: rgba(46, 109, 246, 0.08);
}
#insightBranchList li[data-branch].active,
#insightBranchBalanceList li[data-branch].active,
#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;
}
.branch-cats .branch-card__header.active {
  box-shadow: 0 0 0 2px rgba(46, 109, 246, 0.25) inset;
  border-radius: 10px;
}

.branch-card__header { display: flex; justify-content: space-between; align-items: center; }
.insight-list.compact.collapsed { max-height: none; }
.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) / 0.10);
  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: var(--fd-chrome-bg);
  color: rgba(255,255,255,0.80);
  text-align: center;
  padding: 14px 12px;
  margin-top: 20px;
  border-top: 1px solid rgba(71, 85, 105, 0.45);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.footer-actions,
.footer-copy {
  width: 100%;
  display: flex;
  justify-content: center;
}

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: rgb(var(--fd-card-rgb) / 0.35);
  color: var(--fd-text);
  font-size: 0.82rem !important;
  font-weight: 700;
  line-height: 1.1;
  padding: 0.34rem 0.78rem !important;
  min-height: 30px !important;
  min-width: 110px !important;
}

.chart-preview-trigger:hover {
  background: rgb(var(--fd-card-rgb) / 0.58);
}

.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: 12px;
  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 {
    min-width: 100px !important;
    font-size: 0.78rem !important;
  }

  .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: 12px;
  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;
}

.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: 12px;
  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; }
  .branch-cats .branch-name { font-size: 0.78rem; }
  .branch-cats .branch-total { font-size: 0.78rem; }
  .branch-cats .branch-card { padding: 6px 8px; margin-bottom: 6px; border-radius: 10px; }
  .branch-cats .branch-card__header { margin-bottom: 4px; font-size: 0.74rem; }
  .branch-cats .insight-list.compact { gap: 2px; }
  .branch-cats .insight-list.compact li { margin: 1px 0; }
}

/* ------------------------------------------------
   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 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;
}

/* Desktop: Income & Expense tables two columns */
@media (min-width: 601px) {
  .grid.full-width {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)) !important;
    align-items: start !important;
    gap: 20px !important;
  }
}

/* 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: 12px;
  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: 12px;
  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;
  }

  /* Sections spacing */
  .chart-section,
  .management-section,
  .branch-management {
    width: 100% !important;
    margin: 10px 0 !important;
    padding: 12px !important;
    align-items: stretch !important;
  }

  /* 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;
  }

  /* Cards and sections on mobile: reduced padding */
  .card,
  .ops-card,
  [class*="card"],
  section {
    width: 100% !important;
    margin: 8px 0 !important;
    padding: 12px !important;
  }

  /* 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;
  }
}

/* === Place Income/Expense Management side-by-side on desktop via flex === */
.grid.full-width.management-section{
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 24px !important;
  justify-content: space-between !important;
  align-items: stretch !important;
}
.grid.full-width.management-section > section{
  flex: 1 1 620px !important;
  max-width: calc(50% - 12px) !important;
  min-width: 0 !important;
  display: flex;
  flex-direction: column;
}

/* Tablet/phone: stack columns */
@media (max-width: 1199px){
  .grid.full-width.management-section{
    justify-content: center !important;
  }
  .grid.full-width.management-section > section{
    max-width: 100% !important;
    flex: 1 1 100% !important;
  }
}

@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;
}

@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: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-height: 34px;
  white-space: nowrap;
  grid-column: span 1;
  font-size: 0.92rem;
}
#employeeLoanForm .inline-checkbox input {
  width: auto;
}
#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;
  }
}

@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; }
  .branch-cats .branch-name { font-size: 0.78rem; }
  .branch-cats .branch-total { font-size: 0.78rem; }
  .branch-cats .branch-card { padding: 6px 8px; margin-bottom: 6px; border-radius: 10px; }
  .branch-cats .branch-card__header { margin-bottom: 4px; font-size: 0.74rem; }
  .branch-cats .insight-list.compact { gap: 2px; }
  .branch-cats .insight-list.compact li { margin: 1px 0; }
}

/* =================================================
   Employer / Published shifts page styles
   Unified with dashboard theme for readability
   ================================================= */
.employer-shell {
  max-width: 960px;
  margin: 36px auto;
  padding: 0 16px;
}
.emp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 0 0 16px 0;
  background: transparent;
  border-bottom: 1px solid rgba(71, 85, 105, 0.45);
}
.emp-title { font-size: 1.5rem; font-weight: 800; color: var(--fd-text); margin: 0; }
.emp-sub { color: var(--fd-muted); font-size: 0.92rem; margin-top: 6px; }
.emp-card { padding: 0; border: none; box-shadow: none; border-radius: 0; }

/* Date swap modal (styled via shared theme; no JS-injected CSS) */
body.fd-app.employer-page .emp-date-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10050;
  padding: 12px;
}
body.fd-app.employer-page .emp-date-modal {
  background: rgb(var(--fd-card-rgb));
  border: 1px solid var(--fd-card-border);
  border-radius: 14px;
  width: min(420px, 92vw);
  box-shadow: var(--fd-card-shadow-hover);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--fd-text);
}
body.fd-app.employer-page .emp-date-modal h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--fd-text);
}
body.fd-app.employer-page .emp-date-modal input[type="date"] {
  width: 100%;
}
body.fd-app.employer-page .emp-date-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
body.fd-app.employer-page .emp-date-modal-actions button {
  min-width: 92px;
}
.emp-grid {
  /* responsive card grid: 1 column on small, 2-3 on larger screens */
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
}

.emp-shift {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  padding: 52px 16px 16px;
  transition: transform 0.18s ease;
  text-align: center;
}
.emp-shift:hover { transform: translateY(-6px); }
.emp-shift .left { 
  min-width: 92px; 
  font-weight: 700; 
  color: var(--fd-muted);
  display:flex; 
  flex-direction:column; 
  gap:4px; 
  align-items:flex-start; 
  position:absolute;
  top:12px;
  left:12px;
  width:auto;
}

/* avatar + date block */
.emp-shift .left .avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
  box-shadow: inset 0 -6px 12px rgba(255,255,255,0.06), 0 8px 18px rgba(8,20,40,0.06);
  font-size: 0.82rem;
  align-self: flex-start; /* keep the avatar to the left while centering other content */
}

.emp-shift .left .date { font-size: 0.9rem; color: var(--fd-text); font-weight: 800; letter-spacing: 0.01em; }
.emp-shift .right {
  flex:1;
  display:flex;
  flex-direction:column;
  gap:6px;
  align-items:stretch;
  margin: 0;
  width: 100%;
  padding: 40px 12px 10px 80px;
  box-sizing: border-box;
}
.emp-shift-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 40px;
  padding: 8px 10px 0 10px;
  box-sizing: border-box;
  flex-wrap: nowrap;
}
.emp-shift-actions .ts-chip-btn {
  flex: 1 1 0;
  min-width: 0;
  max-width: 50%;
  padding: 8px 10px;
  font-size: 12px;
  text-align: center;
  white-space: normal;
  line-height: 1.2;
}
.emp-shift-actions .ts-chip-btn:last-child {
  margin-left: 0;
}
.emp-meta { color: var(--fd-muted); font-size: 0.92rem; }
.emp-presence { display:inline-block; padding:2px 8px; border-radius:999px; font-size:0.78rem; font-weight:700; margin-left:6px; }
.emp-presence.ok { background:#d1fae5; color:#065f46; }
.emp-presence.no { background:#fee2e2; color:#991b1b; }
.emp-presence.unknown { background:#fef3c7; color:#92400e; }
.emp-badge { display:inline-block; padding:6px 10px; border-radius:999px; background:linear-gradient(90deg,var(--color-accent-light),var(--color-accent)); color:#071026; font-weight:700; font-size:0.85rem; border:1px solid rgba(0,0,0,0.04); }
.emp-empty { text-align: center; padding: 30px; color: var(--fd-muted); }

/* Nice compact employee name and meta layout */
.emp-shift .right { flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: center; width: 100%; }
.emp-shift .right .emp-meta { color: var(--fd-muted); font-size: 0.92rem; }
.emp-shift .right .emp-title {
  font-weight: 900;
  color: var(--fd-text);
  font-size: 1.08rem;
  letter-spacing: 0.01em;
  display: block;
  text-align: center;
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  margin: 0;
}
.emp-shift .right .meta-row { display:flex; gap:10px; align-items:center; justify-content:center; color: var(--fd-muted); font-size:0.95rem; flex-wrap:wrap; font-weight:700; width: 100%; }
.emp-shift .right .meta-row .location { display:inline-block; background: rgba(59, 130, 246, 0.18); color: #60a5fa; padding: 6px 10px; border-radius: 999px; border:1px solid rgba(59, 130, 246, 0.3); }

/* subtle visual badge for presence or status */
.emp-presence { font-size: 0.78rem; font-weight:700; margin-left:6px; box-shadow: 0 6px 18px rgba(8,20,40,0.04); padding:4px 8px; }

@media (max-width:680px){
  .employer-shell { padding: 12px; }
  .emp-header { flex-direction:column; align-items:flex-start; }
  .emp-shift { flex-direction:column; align-items:stretch; padding: 52px 12px 16px; position: relative; }
  .emp-shift .left { min-width:auto; text-align:center; position: static; width: 100%; align-items: center; margin-bottom: 6px; }
  .emp-shift .left .date { text-align: center; width: 100%; }
  .emp-shift .left .avatar { width: 38px; height: 38px; font-size: 0.76rem; }
  .emp-shift .right { padding: 40px 6px 10px; align-items: center; }
  .emp-shift .right .emp-title {
    position: absolute;
    top: 12px;
    left: 16px;
    right: 16px;
    margin: 0;
    text-align: center;
  }
  .emp-shift .right .meta-row { justify-content: center; }
  .emp-shift-actions { flex-wrap: wrap; justify-content: center; margin-top: 16px; gap: 8px; }
  .emp-shift-actions .ts-chip-btn { max-width: 100%; flex: 1 1 45%; }
}

/* Centered mobile layout for employer page */
@media (max-width:540px){
  .employer-shell {
    max-width: 520px;
    padding: 12px 10px;
    position: relative;
  }
  .emp-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
  }
  .emp-header-avatar-container {
    width: 100%;
    justify-content: center;
  }
  .emp-controls-flex {
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 10px;
  }
  .emp-search-flex {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  .emp-search-input {
    width: 100%;
    max-width: none;
    text-align: center;
  }
  .emp-header-buttons {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  /* Keep logout easy to reach on small screens (employer surface only) */
.employer-shell #logoutBtn {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 5;
}
}

/* Employer mobile overrides: keep content centered and place logout as a normal button */
.employer-shell #logoutBtn {
  position: static;
  top: auto;
  right: auto;
  align-self: flex-end;
  margin-left: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

@media (max-width: 680px) {
  .emp-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
  }
  .emp-controls-flex,
  .emp-search-flex,
  .emp-header-buttons {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 10px;
  }
  .employer-shell #logoutBtn {
    align-self: flex-end;
  }
}

@media (max-width: 540px) {
  .emp-search-input {
    max-width: 100%;
    text-align: center;
  }
  .employer-shell #logoutBtn {
    position: static;
    top: auto;
    right: auto;
    margin-left: auto;
  }
  .emp-header {
    gap: 8px;
  }
}

/* ===================== EMPLOYER PAGE - EXTRACTED INLINE STYLES ===================== */
.emp-header-avatar-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.emp-header-avatar-box {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  flex-shrink: 0;
}

.emp-controls-flex {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.emp-search-flex {
  display: flex;
  align-items: center;
  gap: 8px;
}

.emp-search-input {
  min-width: 220px;
}

.emp-search-input::placeholder {
  color: var(--fd-muted);
}

.emp-header-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}
.emp-ribbon {
  width: 100%;
  height: 10px;
  background: linear-gradient(90deg, #008cff, #0052d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f4f8ff;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px rgba(0,82,212,0.25);
}
.emp-ribbon span { display:block; font-size: 0.7rem; }
.ts-fairness-body { margin-top: 8px; }
.ts-fairness-row { display:flex; align-items:center; gap:10px; margin:6px 0; font-size:0.92rem; }
.ts-fairness-name { min-width: 120px; font-weight:800; color: var(--fd-text); }
.ts-fairness-bar { flex:1; height:10px; background: rgba(148, 163, 184, 0.25); border-radius:999px; overflow:hidden; }
.ts-fairness-bar span { display:block; height:100%; background: linear-gradient(90deg,#4fa3ff,#1c64f2); }
.ts-fairness-meta { color: var(--fd-muted); font-size:0.85rem; white-space:nowrap; }
.ts-gps-routes { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.ts-gps-row { padding: 8px 10px; border: 1px solid var(--fd-card-border); border-radius: 10px; background: transparent; }
.ts-gps-row strong { color: var(--fd-text); }
.ts-gps-meta { color: var(--fd-muted); font-size: 0.88rem; }
.ts-req-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.ts-req-list { display: flex; flex-direction: column; gap: 6px; padding-bottom: 6px; }
.ts-req-pagination {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  padding: 8px 0 2px;
  border-top: 1px solid var(--fd-card-border);
}
.ts-req-page-info { color: var(--fd-muted); font-size: 0.85rem; }
.ts-req-page-btn { min-width: 44px; }
.ts-gps-save-btn { margin-top: 24px; }
body.fd-app .help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.08);
  color: var(--fd-text);
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
body.fd-app .help-icon:hover { background: rgb(var(--fd-card-rgb) / 0.12); border-color: rgba(59, 130, 246, 0.55); }
.help-pop {
  position: absolute;
  max-width: 240px;
  padding: 8px 10px;
  background: #0f2545;
  color: #f5f9ff;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(5,20,50,0.25);
  font-size: 0.85rem;
  z-index: 9999;
}
.help-pop::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 16px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #0f2545;
}

.emp-empty-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 22px;
}

.emp-empty-svg {
  display: block;
  margin: 0 auto 12px auto;
}

.emp-empty-heading {
  font-size: 1.15rem;
  margin-bottom: 6px;
  color: var(--fd-text);
  font-weight: 700;
}

.emp-empty-text {
  color: var(--fd-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

.emp-request-panel {
  margin-top: 20px;
  padding: 16px;
}
.emp-request-panel h2 {
  margin: 0 0 10px 0;
  font-size: 1.1rem;
  color: var(--fd-text);
}
.emp-request-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.emp-request-card {
  padding: 12px 0;
  border-top: 1px solid var(--fd-card-border);
  font-size: 0.9rem;
  color: var(--fd-text);
}
.emp-request-card:first-child {
  border-top: none;
  padding-top: 0;
}
.emp-request-card small {
  color: var(--fd-muted);
  display: block;
  margin-top: 4px;
}
.emp-request-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  flex-wrap: wrap;
  align-items: center;
}
.emp-request-flag {
  margin: 6px 0 0 0;
  padding: 6px 10px;
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.emp-shift-history {
  margin: 6px 0 0 0;
  padding: 6px 10px;
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.emp-request-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

/* ===================== 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;
}

/* ===================== TIMESHEET.HTML - EXTRACTED INLINE STYLES ===================== */
.ts-toggle-heading {
  cursor: pointer;
}

.ts-toggle-hidden {
  display: none;
}

.ts-card-margin {
  margin-bottom: 12px;
}

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

.ts-heading-no-margin {
  margin: 0;
}

.ts-publish-all-btn {
  display: none;
  padding: 8px 10px;
}

.ts-employee-list {
  min-height: 60px;
  overflow-y: auto;
  background: transparent;
}

.ts-draft-preview-row {
  background-color: rgba(245, 158, 11, 0.14);
  text-align: center;
  font-weight: bold;
}

.insight-loading {
  padding: 10px;
}

.emp-empty-hidden {
  display: none;
}

.ts-shift-requests-admin { max-height: 480px; overflow: auto; }

/* =======================================================
   Unified Single-Row Charts Layout 
   (Comparison Chart | Date Filter | Donut 1 | Donut 2)
   ======================================================= */
.charts-unified-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  margin: 0 0 20px 0;
  box-sizing: border-box;
}

/* 1. Comparison Chart (40%) */
.charts-unified-row .main-chart-box {
  flex: 2;
  background: rgb(var(--fd-card-rgb));
  border: 1px solid var(--fd-card-border);
  border-radius: 12px;
  padding: 10px;
  min-height: 220px;
  max-height: 220px; /* Reduced height */
  position: relative;
  overflow: hidden;
}

/* 2. Middle Filter Box */
.charts-unified-row .filter-box-middle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
}

.charts-unified-row .filter-card.compact {
  width: 100%;
  padding: 8px 10px !important;
  margin: 0;
  min-height: auto;
  background: rgb(var(--fd-card-rgb));
  border: 1px solid var(--fd-card-border);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.charts-unified-row .month-input {
  width: 100%;
  max-width: 140px;
  height: 38px;
  min-height: 38px;
  font-size: 0.9rem;
  padding: 4px 8px;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--fd-text);
  margin: 0;
}
.charts-unified-row .month-input:focus {
  outline: none;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
}

/* 3 & 4. Donut Boxes (20% each) */
.charts-unified-row .donut-box {
  flex: 1;
  background: rgb(var(--fd-card-rgb));
  border: 1px solid var(--fd-card-border);
  border-radius: 12px;
  padding: 8px;
  min-height: 220px;
  max-height: 220px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Canvas styling */
.charts-unified-row canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

/* Responsive: stack on smaller screens */
@media (max-width: 1200px) {
  .charts-unified-row {
    flex-wrap: wrap;
    gap: 10px;
  }
  .charts-unified-row .main-chart-box {
    flex: 1 1 100%;
    order: 1;
    margin-bottom: 8px;
  }
  .charts-unified-row .filter-box-middle {
    flex: 1 1 100%;
    order: 2;
    margin-bottom: 8px;
  }
  .charts-unified-row .donut-box {
    flex: 1 1 48%;
    order: 3;
  }
}

@media (max-width: 600px) {
  .charts-unified-row .donut-box {
    flex: 1 1 100%;
    order: 3;
  }
}
