/* ============================================================================
   ADS Dashboard - compact layout  (Option D: command-centre with a role rail)
   ----------------------------------------------------------------------------
   LAYOUT / SPACING ONLY.  No markup, element IDs, handlers, filters, role rules,
   API calls or JavaScript are touched.  Every widget that exists today is still
   on the page (nothing is hidden or removed); they are re-flowed and tightened.

   NOTE: earlier layers (01-core-base, 15-core-bento, 18-core-dashboard-refresh, 19-core-compact) use !important
   heavily, so declarations here carry !important too - that is intentional, not sloppiness.

   Loaded LAST (after 28-ads-theme-overrides.css).  Colours come from the --ads-*
   tokens, so light and dark themes both work.  To roll back, delete this file's
   <link> line from Core/templates/_styles.html.

   Layout (content width of the Dashboard page):
     >= 1500px  3 columns : [calendar + My month] [stat pills + tickets] [To-Do rail]
                            System Exceptions / HR Overview run full width underneath
     1101-1499  2 columns : [calendar + My month] [stat pills + tickets]
                            To-Do becomes a one-line strip, then Exceptions / HR below
     <= 1100    1 column  : everything stacks (existing mobile behaviour kept)
   ========================================================================== */

/* 18-core-dashboard-refresh.css caps the dashboard at 1120px and centres it on screens >= 1400px, which leaves
   the sides of large monitors empty.  Lift that cap so the compact grid can use the full content width. */
html body #page-dashboard { max-width: none !important; margin-left: 0 !important; margin-right: 0 !important; container-type: inline-size !important; container-name: dash !important; }

/* ---------- shared tightening (all widths) ---------- */
html body #page-dashboard .page-body { padding: 8px 12px 16px !important; max-width: 1760px !important; }

/* calendar ------------------------------------------------------------- */
html body #page-dashboard #leave-calendar-card { padding: 8px 10px !important; margin: 0 !important; }
html body #page-dashboard #leave-calendar-card .lcal-head { padding: 0 0 5px !important; margin: 0 0 3px !important; }
html body #page-dashboard #leave-calendar-card .lcal-title { font-size: 12px !important; }
html body #page-dashboard #leave-calendar-card .lcal-nav { margin: 0 0 3px !important; }
html body #page-dashboard #leave-calendar-card .lcal-month-label { font-size: 12.5px !important; }
html body #page-dashboard #leave-calendar-card .lcal-nav-btn { width: 22px !important; height: 22px !important; font-size: 10px !important; }
html body #page-dashboard #leave-calendar-card .lcal-weekdays span { font-size: 9.5px !important; padding: 0 !important; }
html body #page-dashboard #leave-calendar-card .leave-calendar-grid { gap: 2px 3px !important; }
html body #page-dashboard #leave-calendar-card .lcal-cell {
  width: 26px !important; height: 26px !important; line-height: 26px !important; font-size: 11px !important; margin: 0 auto !important;
}
html body #page-dashboard #leave-calendar-card .lcal-footer { padding-top: 4px !important; margin-top: 3px !important; }
html body #page-dashboard #leave-calendar-card .leave-calendar-legend { gap: 1px 8px !important; font-size: 9.5px !important; line-height: 1.5 !important; }

/* "My month": leave & balances + attendance ------------------------------ */
html body #page-dashboard #dash-mini-row { display: flex !important; flex-direction: column !important; gap: 8px !important; margin: 0 !important; }
html body #page-dashboard #dash-mini-row > .ts-card { margin: 0 !important; padding: 8px 10px !important; width: auto !important; max-width: none !important; flex: none !important; }
html body #page-dashboard #dash-mini-row .lv-balance-header {
  display: flex !important; align-items: center !important; gap: 6px !important; font-size: 12px !important; font-weight: 700 !important;
  padding: 0 0 5px !important; margin: 0 0 5px !important; border-bottom: 1px solid var(--ads-line-2) !important;
}
html body #page-dashboard #dash-mini-row .lv-balance-header .lv-balance-year { margin-left: auto !important; }
html body #page-dashboard #dash-mini-row .att-month-picker { height: 22px !important; font-size: 11px !important; padding: 0 4px !important; width: auto !important; }
/* leave / comp-off / WFH tiles: three small tiles across instead of a tall stack */
html body #page-dashboard #leave-balance-card #lvb-list { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 5px !important; margin: 0 !important; }
html body #page-dashboard #leave-balance-card #lvb-list .lvb-item { padding: 5px 7px !important; border-radius: 8px !important; min-width: 0 !important; }
html body #page-dashboard #leave-balance-card #lvb-list .lvb-label { font-size: 9px !important; letter-spacing: .03em !important; line-height: 1.2 !important; }
html body #page-dashboard #leave-balance-card #lvb-list .lvb-value { font-size: 16px !important; line-height: 1.1 !important; margin-top: 1px !important; }
html body #page-dashboard #leave-balance-card #lvb-list .lvb-unit { font-size: 10px !important; margin-left: 2px !important; }
html body #page-dashboard #leave-balance-card #lvb-list .lv-balance-bar-track { height: 3px !important; margin: 3px 0 2px !important; }
html body #page-dashboard #leave-balance-card #lvb-list .lvb-notes { font-size: 9.5px !important; line-height: 1.25 !important; padding: 0 !important; }
html body #page-dashboard #attendance-card .lv-balance-stats { display: grid !important; grid-template-columns: repeat(3, 1fr) !important; gap: 5px !important; padding: 0 !important; margin: 0 0 4px !important; }
html body #page-dashboard #attendance-card .lv-balance-stat { padding: 4px 2px !important; border-radius: 8px !important; }
html body #page-dashboard #attendance-card .lv-balance-stat-value { font-size: 16px !important; line-height: 1.1 !important; }
html body #page-dashboard #attendance-card .lv-balance-stat-label { font-size: 8.5px !important; letter-spacing: .03em !important; margin-top: 1px !important; }
html body #page-dashboard #attendance-card .lv-balance-bar-track { height: 3px !important; margin: 0 0 3px !important; }
html body #page-dashboard #attendance-card .lv-balance-footer { font-size: 10px !important; }
html body #page-dashboard #dm-exceptions-summary-card { padding: 6px 10px !important; }

/* stat pills (Total / Open / In progress / Closed) ------------------------ */
html body #page-dashboard #role-dashboard { margin: 0 !important; gap: 6px !important; }
html body #page-dashboard #role-dashboard .dashboard-stat-cards { display: flex !important; flex-wrap: wrap !important; gap: 6px !important; margin: 0 !important; }
html body #page-dashboard #role-dashboard .stat-card {
  flex: 1 1 140px !important; min-width: 0 !important; height: 38px !important; padding: 0 12px !important; margin: 0 !important;
  display: flex !important; align-items: center !important; gap: 8px !important; border-radius: 999px !important; box-shadow: none !important;
}
html body #page-dashboard #role-dashboard .stat-card .stat-card-icon {
  order: 3 !important; margin-left: auto !important; width: 22px !important; height: 22px !important; border-radius: 50% !important; font-size: 11px !important;
  display: grid !important; place-items: center !important; flex: none !important;
}
html body #page-dashboard #role-dashboard .stat-card .stat-card-body {
  display: flex !important; flex-direction: row-reverse !important; align-items: baseline !important; justify-content: flex-end !important; gap: 6px !important; min-width: 0 !important;
}
html body #page-dashboard #role-dashboard .stat-card .stat-card-num { font-size: 16px !important; line-height: 1 !important; font-weight: 800 !important; }
html body #page-dashboard #role-dashboard .stat-card .stat-card-label {
  font-size: 10.5px !important; font-weight: 600 !important; text-transform: uppercase !important; letter-spacing: .04em !important; white-space: nowrap !important;
}
html body #page-dashboard #role-dashboard .stat-card.stat-card-wide,
html body #page-dashboard #role-dashboard #stat-closed { flex: 2 1 300px !important; height: auto !important; min-height: 38px !important; }
html body #page-dashboard #role-dashboard .stat-repo-breakdown {
  order: 2 !important; display: flex !important; flex-wrap: nowrap !important; gap: 10px !important; margin-left: 6px !important; padding-left: 10px !important;
  border-left: 1px solid var(--ads-line) !important; white-space: nowrap !important; font-size: 10px !important;
}
html body #page-dashboard #role-dashboard .dashboard-repo-scope-bar { margin: 0 0 6px !important; padding: 5px 10px !important; }
html body #page-dashboard #role-dashboard .dashboard-action-cards { display: flex !important; flex-wrap: wrap !important; gap: 6px !important; margin: 0 0 6px !important; }

/* My Assigned Tickets ---------------------------------------------------- */
html body #page-dashboard #assigned-tickets-section {
  margin: 0 !important; padding: 8px 10px !important; height: auto !important; box-sizing: border-box !important; min-width: 0 !important; max-width: 100% !important;
}
html body #page-dashboard #assigned-tickets-section .section-header { padding: 0 0 5px !important; margin: 0 0 6px !important; }
html body #page-dashboard #assigned-tickets-section .section-header h3 { font-size: 12.5px !important; margin: 0 !important; }
html body #page-dashboard #assigned-tickets-section .ticket-filters-row {
  display: flex !important; flex-wrap: wrap !important; gap: 6px !important; padding: 6px 8px !important; margin: 0 0 6px !important; align-items: flex-end !important;
}
html body #page-dashboard #assigned-tickets-section .ticket-filter-group { flex: 1 1 120px !important; min-width: 0 !important; margin: 0 !important; }
html body #page-dashboard #assigned-tickets-section .ticket-filter-group label { font-size: 9.5px !important; margin: 0 0 2px !important; }
html body #page-dashboard #assigned-tickets-section .ticket-filter-select { height: 28px !important; font-size: 12px !important; padding: 0 6px !important; width: 100% !important; }
html body #page-dashboard #assigned-tickets-section .tickets-table-wrap { max-height: calc(100vh - 210px) !important; min-height: 120px !important; }
html body #page-dashboard #assigned-tickets-section .tickets-table { font-size: 12.5px !important; min-width: 680px !important; }
html body #page-dashboard #assigned-tickets-section .tickets-table thead th { padding: 6px 10px !important; font-size: 10.5px !important; position: sticky !important; top: 0 !important; z-index: 2 !important; }
html body #page-dashboard #assigned-tickets-section .tickets-table tbody td { padding: 5px 10px !important; line-height: 1.25 !important; }
html body #page-dashboard #assigned-tickets-section .tickets-table td { white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
html body #page-dashboard .tickets-pagination { padding: 5px 2px 0 !important; }
html body #page-dashboard .tickets-pagination-controls .ts-btn-sm { width: 26px !important; height: 26px !important; }

/* To-Do ------------------------------------------------------------------ */
html body #page-dashboard #todo-card { margin: 0 !important; padding: 7px 10px !important; }
html body #page-dashboard #todo-card .todo-header { margin: 0 !important; padding: 0 !important; border: 0 !important; }
html body #page-dashboard #todo-card .todo-title { font-size: 12.5px !important; }
html body #page-dashboard #todo-card .todo-add { margin: 0 !important; gap: 6px !important; }
html body #page-dashboard #todo-card .todo-add input { height: 28px !important; font-size: 12px !important; }
html body #page-dashboard #todo-card .todo-error { margin: 4px 0 0 !important; }
html body #page-dashboard #todo-card .todo-list { max-height: 180px !important; margin-top: 4px !important; }
html body #page-dashboard #todo-card .todo-list .todo-empty { padding: 4px 0 !important; font-size: 12px !important; }
html body #page-dashboard #todo-card .todo-footer { font-size: 10.5px !important; margin: 4px 0 0 !important; padding: 0 !important; }

/* System Exceptions + HR Overview (full width bands) -------------------- */
html body #page-dashboard .dash-bottom-row { margin: 0 !important; gap: 8px !important; }
html body #page-dashboard .dash-bottom-row > .ts-card { margin: 0 !important; padding: 8px 10px !important; }
html body #page-dashboard .dash-bottom-row .section-header { padding: 0 0 5px !important; margin: 0 0 5px !important; }
html body #page-dashboard .dash-bottom-row .section-header h3 { font-size: 12.5px !important; margin: 0 !important; }
html body #page-dashboard .dash-bottom-row .ts-workflow-hint { font-size: 11px !important; line-height: 1.35 !important; margin: 0 0 6px !important; padding: 4px 8px !important; max-width: none !important; }
html body #page-dashboard .dash-bottom-row .ticket-filters-row {
  display: flex !important; flex-wrap: wrap !important; gap: 6px 8px !important; align-items: flex-end !important; padding: 6px 8px !important; margin: 0 0 6px !important;
}
html body #page-dashboard .dash-bottom-row .ticket-filter-group { flex: 0 1 150px !important; min-width: 110px !important; margin: 0 !important; }
html body #page-dashboard .dash-bottom-row .ticket-filter-group label { font-size: 9.5px !important; margin: 0 0 2px !important; }
html body #page-dashboard .dash-bottom-row .ticket-filter-select { height: 28px !important; font-size: 12px !important; padding: 0 6px !important; width: 100% !important; }
html body #page-dashboard .dash-bottom-row .ticket-filter-group .ts-btn { height: 28px !important; }
html body #page-dashboard .dash-bottom-row .timesheet-table { font-size: 12.5px !important; }
html body #page-dashboard .dash-bottom-row .timesheet-table thead th { padding: 6px 10px !important; font-size: 10.5px !important; }
html body #page-dashboard .dash-bottom-row .timesheet-table tbody td { padding: 5px 10px !important; line-height: 1.25 !important; }
html body #page-dashboard #dash-exceptions-table-wrap { max-height: 360px !important; overflow: auto !important; }
html body #page-dashboard #dash-exceptions-table-wrap thead th { position: sticky !important; top: 0 !important; z-index: 2 !important; }
html body #page-dashboard #hr-overview-card #hr-overview-totals { margin-bottom: 6px !important; gap: 6px !important; }
html body #page-dashboard #hr-overview-card .lv-balance-stat { padding: 5px 8px !important; }
html body #page-dashboard #hr-overview-card .lv-balance-stat-value { font-size: 16px !important; }
html body #page-dashboard #hr-overview-card .lv-balance-stat-label { font-size: 9.5px !important; }

/* ============================================================================
   GRID  (desktop, content width > 1100px)
   ========================================================================== */
@container dash (min-width: 1101px) {
  html body #page-dashboard .page-body {
    display: grid !important; align-items: start !important; row-gap: 8px !important; column-gap: 8px !important;
    grid-template-columns: minmax(280px, 300px) minmax(0, 1fr) !important;
    grid-template-rows: auto auto auto !important;
  }
  /* wrappers dissolve so their children can sit on the page grid */
  html body #page-dashboard .dash-top-row,
  html body #page-dashboard .dash-bottom-row { display: contents !important; }

  html body #page-dashboard #dash-top-left {
    grid-column: 1 !important; grid-row: 1 / span 2 !important; display: flex !important; flex-direction: column !important; gap: 8px !important;
    min-width: 0 !important; max-width: none !important; width: auto !important; flex: none !important;
  }
  html body #page-dashboard #role-dashboard { grid-column: 2 !important; grid-row: 1 !important; min-width: 0 !important; }
  html body #page-dashboard #dash-top-right { display: block !important; grid-column: 2 !important; grid-row: 2 !important; min-width: 0 !important; max-width: none !important; width: auto !important; flex: none !important; }

  /* To-Do: one compact strip under the grid - title left, add box right */
  html body #page-dashboard #todo-card {
    grid-column: 1 / -1 !important; grid-row: 3 !important;
    display: grid !important; grid-template-columns: auto minmax(0, 1fr) !important; align-items: center !important; column-gap: 14px !important; row-gap: 4px !important;
  }
  html body #page-dashboard #todo-card > * { grid-column: 1 / -1 !important; }
  html body #page-dashboard #todo-card > .todo-header { grid-column: 1 !important; grid-row: 1 !important; }
  html body #page-dashboard #todo-card > .todo-add { grid-column: 2 !important; grid-row: 1 !important; }
  html body #page-dashboard #todo-card .todo-list { max-height: 140px !important; }

  /* exceptions + HR: full-width bands below */
  html body #page-dashboard #dash-exceptions-card,
  html body #page-dashboard #hr-overview-card { grid-column: 1 / -1 !important; }
  html body #page-dashboard #dash-exceptions-card { grid-row: 4 !important; }
  html body #page-dashboard #hr-overview-card { grid-row: 5 !important; }
  /* if only one of the cards is visible the empty rows collapse to 0 */

  /* exceptions filters on a single line when there is room */
  html body #page-dashboard #dash-exceptions-filters .ticket-filter-group { flex: 1 1 130px !important; }
  html body #page-dashboard #dash-exceptions-filters .ticket-filter-group:first-child { flex: 2 1 190px !important; }
}

/* ============================================================================
   WIDE  (content width >= 1500px): To-Do becomes a right-hand rail
   ========================================================================== */
@container dash (min-width: 1500px) {
  html body #page-dashboard .page-body {
    grid-template-columns: minmax(280px, 300px) minmax(0, 1fr) minmax(250px, 300px) !important;
  }
  html body #page-dashboard #dash-top-left { grid-column: 1 !important; grid-row: 1 / span 2 !important; }
  html body #page-dashboard #role-dashboard { grid-column: 2 !important; grid-row: 1 !important; }
  html body #page-dashboard #dash-top-right { grid-column: 2 !important; grid-row: 2 !important; }
  html body #page-dashboard #todo-card {
    grid-column: 3 !important; grid-row: 1 / span 2 !important; align-self: stretch !important;
    display: flex !important; flex-direction: column !important; align-items: stretch !important; position: sticky !important; top: 8px !important; max-height: calc(100vh - 80px) !important;
  }
  html body #page-dashboard #todo-card > .todo-header,
  html body #page-dashboard #todo-card > .todo-add { grid-column: auto !important; grid-row: auto !important; }
  html body #page-dashboard #todo-card .todo-header { margin: 0 0 6px !important; padding: 0 0 5px !important; border-bottom: 1px solid var(--ads-line-2) !important; }
  html body #page-dashboard #todo-card .todo-list { flex: 1 1 auto !important; max-height: none !important; min-height: 60px !important; overflow-y: auto !important; }
  html body #page-dashboard #dash-exceptions-card { grid-row: 3 !important; }
  html body #page-dashboard #hr-overview-card { grid-row: 4 !important; }
}

/* ============================================================================
   NARROW  (<= 1100px): stack, but keep the tighter spacing
   ========================================================================== */
@container dash (max-width: 1100px) {
  html body #page-dashboard .page-body { display: flex !important; flex-direction: column !important; gap: 8px !important; }
  html body #page-dashboard .dash-top-row { display: flex !important; flex-direction: column !important; gap: 8px !important; }
  html body #page-dashboard #dash-top-left { max-width: 100% !important; min-width: 0 !important; width: 100% !important; }
  html body #page-dashboard #dash-mini-row { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  html body #page-dashboard #dm-exceptions-summary-card { grid-column: 1 / -1 !important; }
  html body #page-dashboard #role-dashboard .stat-card { flex: 1 1 45% !important; }
  html body #page-dashboard #role-dashboard .stat-card.stat-card-wide,
  html body #page-dashboard #role-dashboard #stat-closed { flex: 1 1 100% !important; }
}
@container dash (max-width: 640px) {
  html body #page-dashboard #dash-mini-row { grid-template-columns: 1fr !important; }
  html body #page-dashboard .dash-bottom-row .ticket-filter-group { flex: 1 1 45% !important; }
}

/* ---- My Assigned Tickets: column widths (fixed-layout table) so Updated / Due Status are not clipped ---- */
@container dash (min-width: 1101px) {
  html body #page-dashboard #assigned-tickets-section .tickets-table th:nth-child(1),
  html body #page-dashboard #assigned-tickets-section .tickets-table td:nth-child(1) { width: 66px !important; }
  html body #page-dashboard #assigned-tickets-section .tickets-table th:nth-child(2),
  html body #page-dashboard #assigned-tickets-section .tickets-table td:nth-child(2) { width: auto !important; }
  html body #page-dashboard #assigned-tickets-section .tickets-table th:nth-child(3),
  html body #page-dashboard #assigned-tickets-section .tickets-table td:nth-child(3) { width: 104px !important; }
  html body #page-dashboard #assigned-tickets-section .tickets-table th:nth-child(4),
  html body #page-dashboard #assigned-tickets-section .tickets-table td:nth-child(4) { width: 124px !important; }
  html body #page-dashboard #assigned-tickets-section .tickets-table th:nth-child(5),
  html body #page-dashboard #assigned-tickets-section .tickets-table td:nth-child(5) { width: 120px !important; }
  html body #page-dashboard #assigned-tickets-section .tickets-table th:nth-child(6),
  html body #page-dashboard #assigned-tickets-section .tickets-table td:nth-child(6) { width: 84px !important; }
  html body #page-dashboard #assigned-tickets-section .tickets-table th:nth-child(7),
  html body #page-dashboard #assigned-tickets-section .tickets-table td:nth-child(7) { width: 116px !important; }
  html body #page-dashboard #assigned-tickets-section .tickets-table { min-width: 760px !important; }
}
