/* Final responsive safety layer. Loaded after app.css so page styles cannot undo these breakpoints. */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

.app-shell,
.main-area,
.content,
.hr-workspace,
.agency-workspace,
.agency-module-page,
.agency-home,
.agency-dashboard,
.dashboard-page {
  min-width: 0;
  max-width: 100%;
}

.content :where(.panel,.card,.widget,.table-panel,.agency-card,.agency-module-card,.agency-hr-widget,.leave-widget,.chart-card,.chart-panel,.agency-sidebar,.agency-hr-main,.agency-hr-sidebar),
.content :where(.panel,.card,.widget,.table-panel,.agency-card,.agency-module-card,.agency-hr-widget,.leave-widget,.chart-card,.chart-panel,.agency-sidebar,.agency-hr-main,.agency-hr-sidebar) > * {
  min-width: 0;
}

.content :where(img,svg,canvas,video) {
  max-width: 100%;
}

.content :where(.table-scroll,.pm-table-wrap,.activity-table-scroll,.table-responsive,.agency-table-wrap,.leave-table-wrap,.po-items-scroll,.invoice-items-scroll,.hr-trash-table-scroll,.ui-table-scroll) {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.content :where(.table-scroll,.pm-table-wrap,.activity-table-scroll,.table-responsive,.agency-table-wrap,.leave-table-wrap,.po-items-scroll,.invoice-items-scroll,.hr-trash-table-scroll,.ui-table-scroll) > table {
  max-width: none;
}

.content :where(.table-scroll,.pm-table-wrap,.activity-table-scroll,.table-responsive,.agency-table-wrap,.leave-table-wrap,.agency-hr-main .table-scroll,.agency-attendance-main .table-scroll,.hr-trash-table-scroll) table {
  min-width: 720px;
}

.content :where(.dashboard-grid,.two-col,.agency-project-layout,.agency-task-layout,.agency-client-layout,.agency-contact-layout,.agency-module-layout,.agency-workspace-layout,.agency-hr-layout,.agency-attendance-layout,.agency-attendance-overview,.leave-layout,.agency-invoice-layout,.agency-invoice-grid,.agency-quotation-layout,.expense-layout,.agency-po-layout,.procurement-layout,.contract-layout,.settings-grid,.analytics-grid,.chart-grid) > * {
  min-width: 0;
}

.content :where(.chart,.chart-wrap,.chart-container,.chart-canvas-wrap,.ui-chart-plot,.agency-growth-chart,.agency-attendance-chart,.agency-po-chart,.hr-dashboard-chart,.hr-chart-area) {
  min-width: 0;
  max-width: 100%;
}

.content :where(.chart,.chart-wrap,.chart-container,.chart-canvas-wrap,.ui-chart-plot,.agency-growth-chart,.agency-attendance-chart,.agency-po-chart,.hr-dashboard-chart,.hr-chart-area) canvas,
.content :where(.chart,.chart-wrap,.chart-container,.chart-canvas-wrap,.ui-chart-plot,.agency-growth-chart,.agency-attendance-chart,.agency-po-chart,.hr-dashboard-chart,.hr-chart-area) svg {
  display: block;
  max-width: 100%;
}

@media (max-width: 1200px) {
  .content :where(.agency-hr-layout,.agency-attendance-layout.agency-attendance-table-layout,.agency-attendance-overview,.leave-layout,.agency-invoice-grid,.agency-invoice-layout,.agency-quotation-layout,.agency-module-layout,.agency-workspace-layout,.agency-client-layout,.agency-contact-layout,.agency-project-layout,.agency-task-layout,.expense-layout,.agency-po-layout,.procurement-layout,.contract-layout) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .content :where(.agency-hr-sidebar,.agency-attendance-sidebar,.leave-sidebar,.agency-invoice-sidebar,.agency-quotation-sidebar) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content :where(.agency-hr-sidebar,.agency-attendance-sidebar,.leave-sidebar,.agency-invoice-sidebar,.agency-quotation-sidebar) > * {
    grid-column: auto;
  }

  .content :where(.agency-attendance-overview,.agency-dashboard-grid,.hr-dashboard-grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .content :where(.dashboard-grid,.two-col,.agency-home-grid,.agency-dashboard-grid,.hr-dashboard-grid,.analytics-grid,.chart-grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content :where(.dashboard-grid,.two-col,.agency-home-grid,.agency-dashboard-grid,.hr-dashboard-grid,.analytics-grid,.chart-grid) > * {
    grid-column: auto;
  }

  .content :where(.dashboard-grid,.agency-home-grid,.agency-dashboard-grid,.hr-dashboard-grid) > .full-width,
  .content :where(.dashboard-grid,.agency-home-grid,.agency-dashboard-grid,.hr-dashboard-grid) > [class*="span-all"] {
    grid-column: 1 / -1;
  }

  .content :where(.stats-grid,.agency-kpis,.agency-invoice-kpis,.agency-hr-kpis,.agency-attendance-kpis,.leave-kpis,.hr-trash-stats,.media-stats,.activity-stats) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content :where(.agency-hr-layout,.agency-attendance-layout,.leave-layout,.agency-invoice-grid,.agency-quotation-layout) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .content :where(.agency-hr-sidebar,.agency-attendance-sidebar,.leave-sidebar,.agency-invoice-sidebar,.agency-quotation-sidebar) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content :where(.agency-hr-sidebar,.agency-attendance-sidebar,.leave-sidebar,.agency-invoice-sidebar,.agency-quotation-sidebar) > * {
    grid-column: auto;
  }

  .content :where(.page-heading,.agency-module-heading,.agency-hr-heading,.agency-attendance-heading,.leave-page-heading,.media-heading,.agency-projects-heading,.agency-tasks-heading,.agency-quotation-heading,.agency-invoice-heading) {
    min-width: 0;
    flex-wrap: wrap;
  }

  .content :where(.agency-hr-toolbar,.agency-attendance-toolbar,.leave-toolbar,.agency-project-toolbar,.agency-task-toolbar,.agency-expense-toolbar,.agency-invoice-toolbar,.agency-quotation-toolbar,.media-toolbar,.workspace-toolbar) {
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  .topbar {
    min-width: 0;
    max-width: 100%;
  }

  .content :where(.stats-grid,.agency-kpis,.agency-invoice-kpis,.agency-hr-kpis,.agency-attendance-kpis,.leave-kpis,.hr-trash-stats,.media-stats,.activity-stats) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .content :where(.agency-hr-sidebar,.agency-attendance-sidebar,.leave-sidebar,.agency-invoice-sidebar,.agency-quotation-sidebar) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content :where(.agency-hr-sidebar,.agency-attendance-sidebar,.leave-sidebar,.agency-invoice-sidebar,.agency-quotation-sidebar) > * {
    grid-column: auto;
  }

  .content :where(.filter-row,.filter-bar,.filters-row,.agency-client-toolbar,.agency-contact-toolbar,.agency-hr-toolbar,.agency-attendance-toolbar,.agency-task-toolbar,.agency-project-toolbar,.media-toolbar,.leave-toolbar,.workspace-toolbar,.agency-expense-toolbar,.agency-invoice-toolbar,.agency-quotation-toolbar) {
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
  }

  .content :where(.filter-row,.filter-bar,.filters-row,.agency-hr-toolbar,.agency-attendance-toolbar,.leave-toolbar,.agency-project-toolbar,.agency-task-toolbar,.media-toolbar,.workspace-toolbar,.agency-expense-toolbar,.agency-invoice-toolbar,.agency-quotation-toolbar) > * {
    min-width: 0;
    max-width: 100%;
  }

  .content :where(.filter-row,.filter-bar,.filters-row) select,
  .content :where(.filter-row,.filter-bar,.filters-row) input:not([type=checkbox]):not([type=radio]) {
    flex: 1 1 calc(50% - 8px);
    width: auto;
  }

  .content :where(.filter-row,.filter-bar,.filters-row) input[type=search],
  .content :where(.filter-row,.filter-bar,.filters-row) .table-search {
    flex-basis: 100%;
  }

  .content :where(.panel,.card,.widget,.table-panel,.agency-card,.agency-module-card,.agency-hr-widget,.leave-widget,.chart-card,.chart-panel) {
    max-width: 100%;
  }

  .content :where(.ui-chart-legend,.agency-attendance-chart-legend,.agency-po-chart-legend,.agency-hr-legend) {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .content :where(.agency-hr-pages,.leave-pagination,.agency-hr-pagination,.agency-pagination) {
    max-width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 600px) {
  body:not([data-mobile-view="compact"]) .topbar {
    display: flex;
    flex-wrap: wrap;
    height: auto;
    min-height: 58px;
    padding-block: 7px;
  }

  body:not([data-mobile-view="compact"]) .topbar > .mobile-menu {
    flex: 0 0 36px;
  }

  body:not([data-mobile-view="compact"]) .topbar > .global-search {
    flex: 1 1 calc(100% - 48px);
    min-width: 0;
    max-width: none;
  }

  body:not([data-mobile-view="compact"]) .topbar-period,
  body:not([data-mobile-view="compact"]) .topbar-clock {
    display: none !important;
  }

  body:not([data-mobile-view="compact"]) .topbar > .top-actions {
    flex: 1 1 100%;
    justify-content: flex-end;
    min-width: 0;
  }

  body:not([data-mobile-view="compact"]) .topbar-user-copy {
    display: none;
  }

  .content :where(.stats-grid,.agency-kpis,.agency-invoice-kpis,.agency-hr-kpis,.agency-attendance-kpis,.leave-kpis,.hr-trash-stats,.media-stats,.activity-stats) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content :where(.agency-hr-sidebar,.agency-attendance-sidebar,.leave-sidebar,.agency-invoice-sidebar,.agency-quotation-sidebar,.agency-home-bottom,.agency-bottom-row) {
    grid-template-columns: minmax(0, 1fr);
  }

  .content :where(.agency-hr-sidebar,.agency-attendance-sidebar,.leave-sidebar,.agency-invoice-sidebar,.agency-quotation-sidebar,.agency-home-bottom,.agency-bottom-row) > * {
    grid-column: auto !important;
  }

  .content :where(.form-grid,.settings-grid,.form-row,.agency-form-grid,.agency-fields,.invoice-create-grid,.invoice-bottom-grid,.leave-form-grid,.pm-project-field-grid) {
    grid-template-columns: minmax(0, 1fr);
  }

  .content :where(.panel,.card,.widget,.table-panel,.agency-card,.agency-module-card,.agency-hr-widget,.leave-widget,.chart-card,.chart-panel) {
    padding: 12px;
  }

  .content :where(.panel-title,.ui-card-heading,.ui-chart-heading,.agency-hr-widget-title,.agency-attendance-panel-heading,.leave-table-heading) {
    flex-wrap: wrap;
  }
}

@media (max-width: 380px) {
  .content {
    padding-inline: 8px !important;
  }

  .content :where(.stats-grid,.agency-kpis,.agency-invoice-kpis,.agency-hr-kpis,.agency-attendance-kpis,.leave-kpis,.hr-trash-stats,.media-stats,.activity-stats) {
    grid-template-columns: minmax(0, 1fr);
  }

  body:not([data-mobile-view="compact"]) .topbar > .top-actions {
    gap: 4px;
  }
}

/* Leave Management: retain a real scroll viewport for its wide request table,
   while allowing its filters, KPI cards, and summaries to reflow independently. */
body[data-page="human-resources"] .hr-workspace > .leave-page {
  width: 100%;
  min-width: 0;
}

body[data-page="human-resources"] .leave-page .leave-layout {
  min-width: 0;
}

body[data-page="human-resources"] .leave-page .leave-main-column,
body[data-page="human-resources"] .leave-page .leave-table-panel {
  min-width: 0;
  max-width: 100%;
}

body[data-page="human-resources"] .leave-page .leave-table-panel > .table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

body[data-page="human-resources"] .leave-page .leave-table {
  width: 100%;
  min-width: 980px;
  table-layout: fixed;
}

body[data-page="human-resources"] .leave-page .leave-toolbar > * {
  min-width: 0;
  max-width: 100%;
}

body[data-page="human-resources"] .leave-page .leave-date-range {
  flex-wrap: nowrap;
}

body[data-page="human-resources"] .leave-page .leave-date-range input {
  flex: 1 1 0;
  width: 1%;
  min-width: 0;
}

/* Notes cards use explicit page-specific columns because the legacy app rules
   otherwise keep four cards at tablet widths. */
body[data-page="notes"] .note-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  min-width: 0;
}

body[data-page="notes"] .note-card,
body[data-page="notes"] .note-card p,
body[data-page="notes"] .note-card h3 {
  min-width: 0;
  max-width: 100%;
}

body[data-page="notes"] .note-card p {
  overflow-wrap: anywhere;
  line-height: 1.5;
}

body[data-page="notes"] .note-tabs {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

body[data-page="notes"] .note-tabs .tab {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Let Notes use the same full content width as the other workspace pages. */
body[data-page="notes"] .main-area > .content {
  width: 100%;
  max-width: none;
  margin-inline: 0;
  padding-inline: clamp(12px, 1.5vw, 28px);
}

/* Invoice overview filters and side charts must give the records panel the
   available width; the table itself scrolls inside its own viewport. */
body:has(.agency-invoice-dashboard) .agency-invoice-dashboard,
body:has(.agency-invoice-dashboard) .agency-invoice-grid,
body:has(.agency-invoice-dashboard) .agency-invoice-list,
body:has(.agency-invoice-dashboard) .agency-invoice-sidebar {
  min-width: 0;
  max-width: 100%;
}

body:has(.agency-invoice-dashboard) .agency-invoice-table {
  min-width: 1100px;
}

body:has(.agency-invoice-dashboard) .agency-invoice-filter-row,
body:has(.agency-invoice-dashboard) .agency-invoice-filters {
  min-width: 0;
}

/* Password Manager overview has high-specificity desktop columns. */
body[data-page="overview"] .overview-insights-grid {
  min-width: 0;
}

body[data-page="overview"] .overview-insights-grid > *,
body[data-page="overview"] .overview-summary-grid > * {
  min-width: 0;
  max-width: 100%;
}

body[data-page="overview"] .overview-tools-panel {
  grid-column: 1 / -1;
}

body[data-page="overview"] :is(.chart-panel,.score-panel,.category-panel,.favorites-panel,.list-panel) {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 1100px) {
  body[data-page="human-resources"] .leave-page .leave-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body[data-page="human-resources"] .leave-page .leave-sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body[data-page="notes"] .note-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body:has(.agency-invoice-dashboard) .agency-invoice-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body:has(.agency-invoice-dashboard) .agency-invoice-sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body[data-page="overview"] .overview-insights-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body[data-page="overview"] .overview-activity-stack {
    grid-column: 1 / -1;
  }

  body[data-page="overview"] .overview-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 760px) {
  body[data-page="human-resources"] .leave-page .leave-sidebar,
  body:has(.agency-invoice-dashboard) .agency-invoice-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-page="overview"] .overview-insights-grid,
  body[data-page="overview"] .overview-summary-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body[data-page="overview"] .overview-activity-stack {
    grid-column: auto;
  }

  body[data-page="overview"] .overview-tools-panel {
    grid-column: auto;
  }

  body[data-page="overview"] .overview-column-stack:first-child > .chart-panel,
  body[data-page="overview"] .overview-column-stack:nth-child(2) > .score-panel {
    height: auto;
    min-height: 230px;
  }
}

@media (max-width: 600px) {
  body[data-page="notes"] .note-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px;
  }

  body[data-page="notes"] .filter-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body[data-page="notes"] .filter-row .table-search {
    grid-column: 1 / -1;
    width: 100%;
  }

  body[data-page="notes"] .filter-row > select {
    width: 100%;
    min-width: 0;
  }

  body[data-page="notes"] .filter-row > button {
    grid-column: 1 / -1;
    justify-self: end;
  }

  body[data-page="human-resources"] .leave-page .leave-sidebar,
  body:has(.agency-invoice-dashboard) .agency-invoice-sidebar {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-page="human-resources"] .leave-page .leave-toolbar > select,
  body[data-page="human-resources"] .leave-page .leave-date-range {
    flex: 1 1 calc(50% - 6px);
  }

  body[data-page="human-resources"] .leave-page .leave-search,
  body[data-page="human-resources"] .leave-page .leave-request-action {
    flex: 1 1 100%;
    width: 100%;
    margin-inline: 0;
  }

  body:has(.agency-invoice-dashboard) .agency-invoice-filter-row {
    grid-template-columns: minmax(0, 1fr);
  }

  body:has(.agency-invoice-dashboard) .agency-invoice-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body:has(.agency-invoice-dashboard) .agency-invoice-search,
  body:has(.agency-invoice-dashboard) .agency-invoice-toolbar-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  body:has(.agency-invoice-dashboard) .agency-invoice-toolbar-actions .btn {
    flex: 1 1 0;
    min-width: 0;
  }

  body[data-page="overview"] .overview-column-stack:first-child > .chart-panel,
  body[data-page="overview"] .overview-column-stack:nth-child(2) > .score-panel {
    min-height: 0;
  }
}

@media (max-width: 380px) {
  body[data-page="human-resources"] .leave-page .leave-kpis,
  body:has(.agency-invoice-dashboard) .agency-invoice-kpis {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-page="human-resources"] .leave-page .leave-toolbar > select,
  body[data-page="human-resources"] .leave-page .leave-date-range {
    flex-basis: 100%;
  }
}

/* Leave Management only: switch to a stacked layout before its request table
   and balance widgets run out of room. Keep the wide table inside its viewport. */
body[data-page="human-resources"] .hr-workspace > .leave-page,
body[data-page="human-resources"] .hr-workspace > .leave-page > *,
body[data-page="human-resources"] .leave-page .leave-layout > *,
body[data-page="human-resources"] .leave-page .leave-sidebar > * {
  min-width: 0;
  max-width: 100%;
}

body[data-page="human-resources"] .leave-page .leave-table-panel > .table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

body[data-page="human-resources"] .leave-page .leave-table {
  min-width: 960px;
}

body[data-page="human-resources"] .leave-page .leave-toolbar > *,
body[data-page="human-resources"] .leave-page .leave-widget-heading > * {
  min-width: 0;
}

body[data-page="human-resources"] .leave-page .leave-toolbar input,
body[data-page="human-resources"] .leave-page .leave-toolbar select {
  max-width: 100%;
}

/* Match Attendance's full workspace width; layouts.css caps this container. */
body[data-page="human-resources"] .main-area > .content:has([data-leave-management]) {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin-inline: 0;
}

@media (max-width: 1450px) {
  body[data-page="human-resources"] .leave-page .leave-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body[data-page="human-resources"] .leave-page .leave-sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  body[data-page="human-resources"] .leave-page .leave-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body[data-page="human-resources"] .leave-page .leave-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body[data-page="human-resources"] .leave-page .leave-toolbar > select {
    width: 100%;
    min-width: 0;
  }

  body[data-page="human-resources"] .leave-page .leave-date-range,
  body[data-page="human-resources"] .leave-page .leave-search,
  body[data-page="human-resources"] .leave-page .leave-request-action {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    margin: 0;
  }

  body[data-page="human-resources"] .leave-page .leave-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-page="human-resources"] .leave-page .leave-footer {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  body[data-page="human-resources"] .leave-page .leave-footer > span {
    flex: 1 1 100%;
  }
}

@media (max-width: 600px) {
  body[data-page="human-resources"] .leave-page .leave-sidebar,
  body[data-page="human-resources"] .leave-page .leave-kpis {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body[data-page="human-resources"] .leave-page .leave-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-page="human-resources"] .leave-page .leave-toolbar > *,
  body[data-page="human-resources"] .leave-page .leave-date-range,
  body[data-page="human-resources"] .leave-page .leave-search,
  body[data-page="human-resources"] .leave-page .leave-request-action {
    grid-column: 1;
    width: 100%;
  }

  body[data-page="human-resources"] .leave-page .leave-date-range {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  body[data-page="human-resources"] .leave-page .leave-date-range input {
    width: 1%;
    min-width: 0;
    flex: 1 1 0;
  }

  body[data-page="human-resources"] .leave-page .leave-table-heading {
    flex-wrap: wrap;
    gap: 8px;
  }

  body[data-page="human-resources"] .leave-page .leave-table-heading > div {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }

  body[data-page="human-resources"] .leave-page .leave-footer label {
    margin-left: auto;
  }
}
/* Project list: keep the title and its secondary label on one shared left edge. */
body[data-page="project-planning"] .agency-projects-page .agency-project-table th:nth-child(2),
body[data-page="project-planning"] .agency-projects-page .agency-project-table td:nth-child(2) {
  text-align: left !important;
}

body[data-page="project-planning"] .agency-projects-page .agency-project-table td:nth-child(2) .agency-project-name {
  display: grid !important;
  grid-template-columns: 37px minmax(0, 1fr);
  align-items: center;
  justify-content: start;
  width: 100%;
  gap: 9px;
  text-align: left !important;
}

body[data-page="project-planning"] .agency-projects-page .agency-project-table td:nth-child(2) .agency-project-name > div {
  display: flex !important;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  min-width: 0;
  text-align: left !important;
}

body[data-page="project-planning"] .agency-projects-page .agency-project-table td:nth-child(2) .agency-project-name b,
body[data-page="project-planning"] .agency-projects-page .agency-project-table td:nth-child(2) .agency-project-name small {
  align-self: flex-start;
  width: 100%;
  max-width: 100%;
  margin: 0 !important;
  padding: 0 !important;
  text-align: left !important;
}

/* Keep the project view control legible and evenly spaced with its row actions. */
body[data-page="project-planning"] .agency-projects-page .agency-project-table th:last-child,
body[data-page="project-planning"] .agency-projects-page .agency-project-table td:last-child {
  width: 190px !important;
  min-width: 190px !important;
  text-align: center !important;
}

body[data-page="project-planning"] .agency-projects-page .agency-project-table td:last-child {
  padding-inline: 14px !important;
}

body[data-page="project-planning"] .agency-projects-page .agency-project-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  width: 100%;
}

body[data-page="project-planning"] .agency-projects-page .agency-project-actions .agency-project-view {
  display: inline-flex !important;
  flex: 0 0 32px;
  align-items: center !important;
  justify-content: center !important;
  width: 32px !important;
  min-width: 32px !important;
  height: 30px !important;
  min-height: 30px !important;
  padding: 0 !important;
}

body[data-page="project-planning"] .agency-projects-page .agency-project-actions .agency-project-view svg {
  display: block !important;
  flex: none;
  width: 17px !important;
  height: 17px !important;
  fill: none !important;
  stroke: #536987 !important;
  stroke-width: 1.9 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

body[data-page="task-management"] .agency-tasks-page .agency-task-table th:last-child,
body[data-page="task-management"] .agency-tasks-page .agency-task-table td:last-child {
  width: 190px !important;
  min-width: 190px !important;
  text-align: center !important;
}

body[data-page="task-management"] .agency-tasks-page .agency-task-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  width: 100%;
}

body[data-page="task-management"] .agency-tasks-page .agency-task-actions .agency-task-view {
  display: inline-flex !important;
  flex: 0 0 32px;
  align-items: center !important;
  justify-content: center !important;
  width: 32px !important;
  min-width: 32px !important;
  height: 30px !important;
  min-height: 30px !important;
  padding: 0 !important;
  color: #536987;
}

body[data-page="task-management"] .agency-tasks-page .agency-task-actions .agency-task-view svg {
  display: block !important;
  flex: none;
  width: 17px !important;
  height: 17px !important;
  fill: none !important;
  stroke: #536987 !important;
  stroke-width: 1.9 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

body[data-page="notes"] .note-actions .icon-btn svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body[data-page="notes"] .note-actions .note-delete {
  color: #d92f42;
}

/* Client Directory typography: retain the existing layout while making table,
   filters, KPI labels, and insight text comfortable to read. */
body .agency-workspace[data-workspace-page="clients"] .agency-client-kpi>div>small,
body .agency-workspace[data-workspace-page="clients"] .agency-client-kpi em,
body .agency-workspace[data-workspace-page="clients"] .agency-client-kpi em small {
  font-size: 12px;
}

body .agency-workspace[data-workspace-page="clients"] .agency-client-toolbar select,
body .agency-workspace[data-workspace-page="clients"] .agency-client-search input,
body .agency-workspace[data-workspace-page="clients"] .agency-client-toolbar button {
  font-size: 13px;
}

body .agency-workspace[data-workspace-page="clients"] .agency-client-table th,
body .agency-workspace[data-workspace-page="clients"] .agency-client-table td,
body .agency-workspace[data-workspace-page="clients"] .agency-client-name>b,
body .agency-workspace[data-workspace-page="clients"] .agency-client-contact b {
  font-size: 13px;
}

body .agency-workspace[data-workspace-page="clients"] .agency-client-contact small,
body .agency-workspace[data-workspace-page="clients"] .agency-client-pagination,
body .agency-workspace[data-workspace-page="clients"] .agency-client-pagination select,
body .agency-workspace[data-workspace-page="clients"] .agency-client-status {
  font-size: 12px;
}

body .agency-workspace[data-workspace-page="clients"] .agency-client-side-title>a,
body .agency-workspace[data-workspace-page="clients"] .agency-client-side-title select,
body .agency-workspace[data-workspace-page="clients"] .agency-growth-y,
body .agency-workspace[data-workspace-page="clients"] .agency-growth-months,
body .agency-workspace[data-workspace-page="clients"] .agency-growth-legend,
body .agency-workspace[data-workspace-page="clients"] .agency-industry-row,
body .agency-workspace[data-workspace-page="clients"] .agency-industry-row>small,
body .agency-workspace[data-workspace-page="clients"] .agency-industry-row>em,
body .agency-workspace[data-workspace-page="clients"] .agency-client-activity-row b {
  font-size: 12px;
}

body .agency-workspace[data-workspace-page="clients"] .agency-client-activity-row small,
body .agency-workspace[data-workspace-page="clients"] .agency-client-activity-row time {
  font-size: 11px;
}

/* Contacts page typography, scoped separately so other workspace pages keep
   their current sizing and responsive layout. */
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-kpi>div>small,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-kpi em small {
  font-size: 12px;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-toolbar select,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-search input,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-toolbar button {
  font-size: 13px;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-person>b {
  font-size: 13px;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td a,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-type,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-status,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-pagination,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-pagination select,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-legend>div,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-side-heading a,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-quick-actions button {
  font-size: 12px;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-legend small,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-activity-row small,
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-activity-row time {
  font-size: 11px;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-donut small {
  font-size: 12px;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-activity-row b {
  font-size: 12px;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table .agency-inline-view {
  display: inline-flex;
  width: 30px;
  min-width: 30px;
  height: 28px;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  padding: 0;
  vertical-align: middle;
  color: #536987;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table .agency-inline-view svg {
  display: block;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:last-child {
  padding-right: 22px;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table .agency-inline-delete {
  margin-right: 8px !important;
}

/* Keep Contacts columns compact and predictable instead of letting long text
   inflate neighboring columns and create large visual gaps. */
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table {
  width: 100%;
  min-width: 1120px;
  table-layout: fixed;
}

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(1),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(1) { width: 2.5%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(2),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(2) { width: 13%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(2) { width: 13%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(3),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(3) { width: 11%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(3) { width: 11%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(4),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(4) { width: 8%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(4) { width: 8%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(5),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(5) { width: 4.5%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(5) { width: 4.5%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(6),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(6) { width: 11%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(6) { width: 11%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(7),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(7) { width: 21%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(7) { width: 21%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(8),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(8) { width: 11%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(8) { width: 11%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(9),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(9) { width: 5%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(9) { width: 5%; }
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table th:nth-child(10),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(10) { width: 13%; }

body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(4),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(6),
body .agency-workspace[data-workspace-page="contacts"] .agency-contact-table td:nth-child(7) {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Purchase Orders text sizing: improve scanability while keeping its layout. */
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-kpi>div small {
  font-size: 13px;
}

body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-kpi em small,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-toolbar>select,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-toolbar input,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-toolbar button,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-status,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-pagination,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-pagination select,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-pagination button {
  font-size: 12px;
}

body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-sidecard h3 {
  font-size: 15px;
}

body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-side-heading a,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-side-heading select,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-chart,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-chart-legend,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-legend>div {
  font-size: 12px;
}

body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-activity-row b {
  font-size: 12px;
}

body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-activity-row small,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-activity-row time {
  font-size: 11px;
}

/* Keep Purchase Orders table columns proportional so sparse values do not
   leave oversized gaps, while retaining horizontal scrolling on small screens. */
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table {
  width: 100%;
  min-width: 1040px;
  table-layout: fixed;
}

body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th,
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th:nth-child(1),
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td:nth-child(1) { width: 3.5%; }
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th:nth-child(2),
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td:nth-child(2) { width: 8.5%; }
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th:nth-child(3),
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td:nth-child(3) { width: 17%; }
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th:nth-child(4),
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td:nth-child(4) { width: 11%; }
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th:nth-child(5),
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td:nth-child(5) { width: 12%; }
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th:nth-child(6),
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td:nth-child(6) { width: 10.5%; }
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th:nth-child(7),
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td:nth-child(7) { width: 10%; }
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th:nth-child(8),
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td:nth-child(8) { width: 14%; }
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table th:nth-child(9),
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-table td:nth-child(9) {
  width: 13.5%;
  padding-right: 18px;
}

/* Match the Employees eye control size and keep a small inset after Delete. */
body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-row-actions .agency-inline-view {
  width: 30px;
  min-width: 30px;
  height: 28px;
  min-height: 28px;
  margin-right: 4px;
  padding: 0;
}

body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-row-actions .agency-inline-view svg {
  display: block;
  flex: 0 0 15px;
  width: 15px !important;
  min-width: 15px;
  max-width: 15px;
  height: 15px !important;
  min-height: 15px;
  max-height: 15px;
  stroke-width: 1.8;
}

body .agency-workspace[data-workspace-page="purchase-orders"] .agency-po-row-actions .agency-inline-delete {
  margin-right: 6px;
}

/* Quotation dashboard: readable labels and a single desktop filter/action row. */
body .agency-quotation-dashboard .agency-quotation-filter-row {
  grid-template-columns: minmax(0, 1.6fr) minmax(220px, 0.9fr) auto;
  align-items: center;
}

body .agency-quotation-dashboard .agency-quotation-filters {
  grid-template-columns: repeat(3, minmax(105px, 1fr)) minmax(200px, 1.6fr);
}

body .agency-quotation-dashboard .agency-quotation-dashboard-search {
  min-width: 0;
}

body .agency-quotation-dashboard .agency-quotation-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: max-content;
}

body .agency-quotation-dashboard .agency-quotation-toolbar-actions .btn {
  min-height: 38px;
  padding-inline: 12px;
  white-space: nowrap;
  font-size: 12px;
}

body .agency-quotation-dashboard .agency-quotation-kpis small,
body .agency-quotation-dashboard .agency-quotation-list-table th,
body .agency-quotation-dashboard .agency-quotation-list-table td,
body .agency-quotation-dashboard .agency-quotation-list-footer,
body .agency-quotation-dashboard .agency-quotation-list-footer select,
body .agency-quotation-dashboard .agency-quotation-pages button,
body .agency-quotation-dashboard .agency-quotation-filters select,
body .agency-quotation-dashboard .agency-quotation-date-filter,
body .agency-quotation-dashboard .agency-quotation-dashboard-search,
body .agency-quotation-dashboard .agency-quotation-dashboard-search input {
  font-size: 12px;
}

body .agency-quotation-dashboard .agency-quotation-widget,
body .agency-quotation-dashboard .agency-quotation-widget-title select,
body .agency-quotation-dashboard .agency-quotation-chart,
body .agency-quotation-dashboard .agency-quotation-chart-legend,
body .agency-quotation-dashboard .agency-quotation-status-legend,
body .agency-quotation-dashboard .agency-quotation-recent {
  font-size: 12px;
}

@media (max-width: 1250px) {
  body .agency-quotation-dashboard .agency-quotation-filter-row {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.7fr);
  }

  body .agency-quotation-dashboard .agency-quotation-filters {
    grid-column: 1 / -1;
  }

  body .agency-quotation-dashboard .agency-quotation-toolbar-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  body .agency-quotation-dashboard .agency-quotation-filter-row {
    grid-template-columns: minmax(0, 1fr);
  }

  body .agency-quotation-dashboard .agency-quotation-filters {
    grid-column: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body .agency-quotation-dashboard .agency-quotation-date-filter {
    grid-column: 1 / -1;
  }

  body .agency-quotation-dashboard .agency-quotation-dashboard-search {
    grid-column: auto;
  }

  body .agency-quotation-dashboard .agency-quotation-toolbar-actions {
    min-width: 0;
  }
}
