/* ===========================================================================
   Kirrho Payroll — design system
   Theme is driven by a `data-theme` attribute on #app-root (light | dark).
   =========================================================================== */
:root {
  --primary: #FF6B35;
  --primary-2: #FF8C42;
  --secondary: #2E7D32;
  --secondary-2: #4CAF50;
  --brand-grad: var(--primary);  /* solid brand primary (enterprise; was a gradient) */
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F1F3F6;
  --text: #1A1A1A;
  --muted: #6B7280;
  --border: #E5E7EB;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --radius: 16px;
  --sidebar-w: 248px;
}

[data-theme="dark"] {
  --primary: #FF8C42;
  --primary-2: #FFA05C;
  --secondary: #4CAF50;
  --secondary-2: #66BB6A;
  --bg: #0E1116;
  --surface: #171B22;
  --surface-2: #1E242D;
  --text: #E6E8EB;
  --muted: #9AA4B2;
  --border: #2A313C;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app-root { background: var(--bg); color: var(--text); min-height: 100vh; }

/* ----------------------------------------------------------------- Login -- */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1.25rem;
  background: var(--surface-2);
}
.login-card {
  width: 100%; max-width: 420px; padding: 2.5rem 2.25rem;
  border-radius: 20px; background: var(--surface);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.login-card .form-control {
  border-radius: 10px; padding: .7rem .9rem; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text);
}

/* --------------------------------------------------------------- Layout --- */
.app-frame { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: .35rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 0 .5rem 1.25rem; }
.sidebar .brand img { height: 42px; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .page-title { font-weight: 700; font-size: 1.15rem; margin: 0; }
.topbar .spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer; transition: .15s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.hamburger { display: none; }

/* Topbar unmapped-users alert: amber so orphaned device users stand out. */
.unmapped-alert { color: #f5a524; border-color: #f5a52455; text-decoration: none; }
.unmapped-alert:hover { border-color: #f5a524; color: #f5a524; }

/* Theme toggle is now an icon-btn in the topbar, see .icon-btn above. */

/* Notification bell (topbar, managers) */
.notif-menu { display: inline-flex; }
.notif-toggle { padding: 0 !important; background: var(--surface-2) !important;
  color: var(--text) !important; box-shadow: none !important; }
.notif-toggle:hover, .notif-toggle:focus { border-color: var(--primary) !important;
  color: var(--primary) !important; }
.notif-menu, .notif-toggle { overflow: visible !important; }
.topbar { overflow: visible; }
.notif-bell { position: relative; display: inline-flex; align-items: center;
  justify-content: center; width: 100%; height: 100%; overflow: visible; }
/* Count sits above the top-right corner of the bell so both read clearly. */
.notif-badge {
  position: absolute; top: -9px; right: -9px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px; background: #e5484d; color: #fff;
  font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface); z-index: 20;
}
.notif-menu .dropdown-menu {
  max-width: 340px; min-width: 280px; max-height: 60vh; overflow-y: auto;
}
.notif-menu .dropdown-item { white-space: normal; }
.notif-menu .dropdown-item .text-truncate { max-width: 260px; }
.notif-dot { color: #e5484d; font-size: .7rem; }
.notif-item-read { opacity: .55; }
.notif-item-read .notif-dot { display: none; }
.notif-more { text-align: center; color: var(--primary); border-top: 1px solid var(--border); }

/* Personal month calendar (employee "My Attendance") */
.pm-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 8px; }
.pm-head { text-align: center; font-weight: 700; font-size: .72rem; color: var(--muted);
  padding: 2px 0; }
.pm-cell { min-height: 54px; border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 8px; display: flex; flex-direction: column; justify-content: space-between;
  cursor: pointer; transition: .12s; background: var(--surface-2); }
.pm-cell:hover { border-color: var(--primary); transform: translateY(-1px); }
.pm-empty { border: none; background: transparent; cursor: default; }
.pm-empty:hover { transform: none; }
.pm-day-num { font-weight: 600; font-size: .82rem; }
.pm-day-ico { align-self: flex-end; font-size: .95rem; }
.pm-present { background: rgba(46,125,50,.10); border-color: rgba(46,125,50,.30); }
.pm-late { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.35); }
.pm-early { background: rgba(147,51,234,.12); border-color: rgba(147,51,234,.35); }
.pm-absent { background: rgba(220,38,38,.10); border-color: rgba(220,38,38,.30); }
.pm-off { background: transparent; opacity: .6; }
.pm-future { background: transparent; opacity: .45; border-style: dashed; }
/* Previous month's trailing days shown in the first week — muted, not clickable. */
.pm-outside { opacity: .4; cursor: default; }
.pm-outside:hover { border-color: var(--border); transform: none; }
@media (max-width: 640px) { .pm-cell { min-height: 44px; padding: 4px 5px; } }

/* Leave grid "Days" column: render the newline-joined weekday+date list as lines. */
.leave-days-cell { white-space: pre-line; line-height: 1.45; padding-top: 6px !important;
  padding-bottom: 6px !important; }

/* ---- Date picker (dcc.DatePickerSingle) — styled to match .form-control ---- */
.app-datepicker, .app-datepicker .SingleDatePicker { width: 100%; display: block; }
.app-datepicker .SingleDatePickerInput {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; }
.app-datepicker .DateInput { width: 100%; background: transparent; border-radius: 10px; }
.app-datepicker .DateInput_input {
  width: 100%; font-size: .92rem; font-weight: 400; line-height: 1.4;
  padding: .48rem .75rem; background: transparent; color: var(--text);
  border: none; border-bottom: 2px solid transparent; border-radius: 10px; }
.app-datepicker .DateInput_input__focused { border-bottom-color: var(--primary); }
.app-datepicker .DateInput_input::placeholder { color: var(--muted); }
[data-theme="dark"] .app-datepicker .SingleDatePickerInput { background: var(--surface-2); }
[data-theme="dark"] .app-datepicker .DateInput_input { color: var(--text); }
/* Calendar popup — anchored directly under the clicked input, as a popover. */
.SingleDatePicker_picker { z-index: 1300 !important; }
.app-datepicker .DayPicker__withBorder {
  box-shadow: var(--shadow-lg); border-radius: 12px; }
/* On phones, dock the calendar as a bottom sheet so it can't be clipped inside a
   scrolling modal and stays thumb-reachable. */
@media (max-width: 640px) {
  .SingleDatePicker_picker {
    position: fixed !important; top: auto !important; bottom: 0 !important;
    left: 0 !important; right: 0 !important; width: 100% !important;
    display: flex; justify-content: center;
    background: var(--surface); box-shadow: 0 -6px 24px rgba(0,0,0,.28);
    border-top: 1px solid var(--border); padding: .4rem 0 .6rem; }
}
.CalendarDay__selected, .CalendarDay__selected:hover, .CalendarDay__selected:active {
  background: var(--primary) !important; border-color: var(--primary) !important; color: #fff; }
.CalendarDay__today { font-weight: 700; color: var(--primary); }
.DayPickerKeyboardShortcuts_show { display: none !important; }
[data-theme="dark"] .DayPicker, [data-theme="dark"] .CalendarMonthGrid,
[data-theme="dark"] .CalendarMonth, [data-theme="dark"] .DayPicker_transitionContainer,
[data-theme="dark"] .DayPicker_focusRegion {
  background: var(--surface) !important; color: var(--text); }
[data-theme="dark"] .CalendarMonth_caption, [data-theme="dark"] .DayPicker_weekHeader {
  color: var(--text); }
[data-theme="dark"] .CalendarDay__default {
  background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .CalendarDay__default:hover {
  background: var(--surface-2); border-color: var(--primary); color: var(--text); }
[data-theme="dark"] .DayPickerNavigation_button__default {
  background: var(--surface-2); border-color: var(--border); }

.page { padding: 1.75rem; }
.page { overflow-x: hidden; }  /* never let a wide child push the whole page sideways */
/* AG grids + plain tables scroll inside their own card on small screens */
.ag-root-wrapper { max-width: 100%; }
.render-table-wrap, .dbc-table-wrap, .data-table { overflow-x: auto; }
.page .table { min-width: 0; }
/* AG grid keeps its own horizontal scrollbar; the wrapper must let it scroll
   rather than push the page sideways. */
.ag-root-wrapper, .ag-center-cols-viewport, .ag-body-viewport { overflow-x: auto; }
/* Notification dropdown must never exceed the viewport on a phone. */
.notif-menu .dropdown-menu { min-width: min(280px, 88vw); max-width: min(340px, 92vw); }
@media (max-width: 991px) {
  .sidebar { display: none; }
  .hamburger { display: inline-flex; }
  .page { padding: 1.15rem; }
}
@media (max-width: 640px) {
  .section-head { flex-wrap: wrap; gap: .5rem; }
  .section-head > div { flex-wrap: wrap; }
  .modal-body { max-height: 78vh; overflow-y: auto; }
  /* Table pagination controls (#1): keep them on-screen on phones. */
  .ag-paging-panel {
    flex-wrap: wrap; justify-content: center; gap: .1rem .35rem;
    height: auto !important; min-height: 0 !important;
    padding: .45rem .4rem !important; font-size: .76rem; line-height: 1.4;
  }
  .ag-paging-panel .ag-paging-row-summary-panel { margin: 0 .3rem; }
  .ag-paging-panel .ag-paging-page-size { margin-right: .3rem; }
  /* the device-table Prev/Next pager */
  .pg-bar { flex-wrap: wrap; justify-content: center !important; row-gap: .35rem; }
  /* stacked dropdowns/inputs in toolbars go full width so they don't overflow */
  .section-head .Select, .section-head .dash-dropdown { min-width: 130px; }
  /* Many filter dropdowns / year inputs carry an inline fixed px width
     (e.g. width:220px). On phones that overflows the row — force them full
     width (!important beats the inline style) so they stack cleanly. */
  .page .Select, .page .dash-dropdown,
  .page input[type="number"], .page input[type="date"] {
    width: 100% !important; max-width: 100% !important; min-width: 0 !important;
  }
  /* Compact the topbar so its action cluster (sync + alerts + bell + avatar)
     fits without overflowing; allow it to wrap to a second line when the
     controls (manager sync split-control + unmapped alert) are too wide — the
     flex:1 spacer forces the break so nothing spills off-screen. */
  .topbar { gap: .4rem; padding: .7rem .8rem; flex-wrap: wrap; }
  .topbar .spacer { min-width: 1rem; }
  .topbar .page-title { font-size: 1rem; }
  .icon-btn { width: 36px; height: 36px; }
  .notif-menu .dropdown-menu { max-width: 92vw; }
}
@media (max-width: 480px) {
  /* On the tightest phones the breadcrumb carries the page name, so the topbar
     title can step aside to make room for the actions. */
  .topbar .page-title { display: none; }
  .page { padding: .9rem; }
  /* Toolbars wrap under the heading instead of forcing horizontal overflow.
     (Button GROUPS like the Sync split-control must stay on one line, so they
     are intentionally not wrapped.) */
  .section-head > div { width: 100%; }
}

/* ------------------------------------------------------------------- Nav -- */
.nav-link {
  color: var(--text) !important; border-radius: 10px !important;
  padding: .62rem .85rem !important; font-weight: 500; display: flex;
  align-items: center; gap: .1rem; transition: .15s;
}
.nav-link:hover { background: var(--surface-2) !important; color: var(--primary) !important; }
.nav-link.active {
  background: var(--primary) !important; color: #fff !important;
  box-shadow: 0 2px 6px rgba(255,107,53,.25);
}
.nav-link i { width: 22px; text-align: center; }

/* ----------------------------------------------------------------- Cards -- */
.card {
  border-radius: var(--radius) !important; border: 1px solid var(--border) !important;
  background: var(--surface) !important; color: var(--text) !important;
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-lg); }
/* Consistent internal spacing for every card. */
.card > .card-body { padding: 1.4rem 1.5rem !important; }
.card h5 { line-height: 1.3; }

/* Even vertical rhythm between stacked rows/cards. */
.page > .row { margin-bottom: .25rem; }
.page .card { margin-bottom: 1rem; }

.stat-card { position: relative; overflow: hidden; }
.stat-card > .card-body { padding: 1.5rem 1.5rem !important; }
.stat-card .stat-icon {
  position: absolute; right: 1.25rem; top: 1.25rem; width: 46px; height: 46px;
  border-radius: 13px; display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; color: #fff;
}
.stat-card .stat-label { color: var(--muted); font-size: .8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; padding-right: 3.25rem; }
.stat-card .stat-value { font-size: 2.1rem; font-weight: 800; line-height: 1.1; margin-top: .5rem; }

/* Reports page: block icon badge with proper spacing (not the corner stat badge). */
.report-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.3rem; margin: 0 0 1rem;
}
.bg-grad   { background: var(--primary); }
.bg-orange { background: #FF6B35; }
.bg-green  { background: #2E7D32; }
.bg-amber  { background: #F59E0B; }
.bg-red    { background: #DC2626; }
.bg-blue   { background: #2563EB; }

/* ---------------------------------------------------------------- Tables -- */
.dash-table-container { --dt-border: var(--border); }
.data-table table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: .8rem 1rem; border-bottom: 1px solid var(--border);
}
.data-table td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); font-size: .92rem;
  vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }

.pill { display: inline-block; padding: .13rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; line-height: 1.35; white-space: nowrap; }
.pill-green { background: rgba(46,125,50,.14); color: var(--secondary-2); }
.pill-amber { background: rgba(245,158,11,.16); color: #D97706; }
.pill-red   { background: rgba(220,38,38,.14); color: #EF4444; }
.pill-muted { background: var(--surface-2); color: var(--muted); }

/* --------------------------------------------------------------- Buttons -- */
.btn-primary { background: var(--primary) !important; border: none !important;
  font-weight: 600; box-shadow: 0 2px 6px rgba(255,107,53,.22); }
.btn-primary:hover { filter: brightness(.95); }
.btn-outline-secondary { color: var(--text) !important; border-color: var(--border) !important; }

.section-head { display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.section-head h3 { margin: 0; font-weight: 700; }
.page > h3 { margin-bottom: 1.5rem; font-weight: 700; }
/* Status pills render identically inside AG-grid cells and render_table cells. */
.pill { margin: 0; vertical-align: middle; }
.ag-cell .pill { margin: 0; }
.data-table td .pill { margin: 0; }
.btn { padding: .5rem 1.05rem; }
.stat-icon.mb-2 { margin-bottom: .85rem !important; }

/* Bootstrap surface overrides for dark mode */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select { background: var(--surface-2); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .form-control::placeholder { color: var(--muted); }
[data-theme="dark"] .modal-content { background: var(--surface); color: var(--text); }
[data-theme="dark"] .modal-header, [data-theme="dark"] .modal-footer { border-color: var(--border); }
[data-theme="dark"] .offcanvas { background: var(--surface); color: var(--text); }
[data-theme="dark"] .card { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .dropdown-menu { background: var(--surface-2); border-color: var(--border); }
[data-theme="dark"] .dropdown-item { color: var(--text); }
[data-theme="dark"] .dropdown-item:hover, [data-theme="dark"] .dropdown-item:focus {
  background: var(--surface); color: var(--primary); }
[data-theme="dark"] .table { color: var(--text); }
/* Bootstrap semantic text colors are too dark on the dark surface — brighten them
   (used by the device-health counts, sync-runs table, and elsewhere). */
[data-theme="dark"] .text-success { color: #4ADE80 !important; }
[data-theme="dark"] .text-danger  { color: #F87171 !important; }
[data-theme="dark"] .text-warning { color: #FBBF24 !important; }
[data-theme="dark"] .pill-amber { color: #FBBF24; }

/* Alerts (dbc.Alert) — Bootstrap's light pastels are near-white on the dark
   surface (worst on color="light" info banners). Retint with a transparent
   brand/semantic wash + a readable border so they sit on the dark theme. */
[data-theme="dark"] .alert-light,
[data-theme="dark"] .alert-secondary {
  background: var(--surface-2); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .alert-info {
  background: rgba(59,130,246,.14); color: #93C5FD; border-color: rgba(59,130,246,.4); }
[data-theme="dark"] .alert-success {
  background: rgba(34,197,94,.14); color: #4ADE80; border-color: rgba(34,197,94,.4); }
[data-theme="dark"] .alert-warning {
  background: rgba(245,158,11,.14); color: #FBBF24; border-color: rgba(245,158,11,.4); }
[data-theme="dark"] .alert-danger {
  background: rgba(239,68,68,.14); color: #F87171; border-color: rgba(239,68,68,.4); }
[data-theme="dark"] .alert-primary {
  background: rgba(255,107,53,.14); color: #FF9B6B; border-color: rgba(255,107,53,.4); }
[data-theme="dark"] .alert a, [data-theme="dark"] .alert .alert-link { color: inherit; }

/* Toasts (flash messages) — readable in both themes. */
.toast { box-shadow: var(--shadow-lg); border-radius: 12px; }
[data-theme="dark"] .toast { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .toast .toast-header { background: var(--surface-2); color: var(--text);
  border-bottom-color: var(--border); }
[data-theme="dark"] .toast .toast-body { color: var(--text); }
[data-theme="dark"] .toast .btn-close { filter: invert(1) grayscale(1) brightness(1.6); }

/* Confirmation modal (delete / undo / sync yes-no) — polished + eye-catching. */
.confirm-modal .modal-content { border: none; border-radius: 16px; overflow: hidden;
  border-top: 5px solid var(--primary); }
.confirm-modal .modal-header { border-bottom: none; padding-bottom: .25rem; }
.confirm-modal .modal-title { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.confirm-icon { width: 42px; height: 42px; border-radius: 12px; flex: 0 0 42px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem;
  color: #fff; background: #F59E0B; }
.confirm-modal .modal-body { color: var(--muted); padding-top: .25rem; }
.confirm-modal .modal-footer { border-top: none; }
.confirm-modal .modal-footer .btn { min-width: 96px; font-weight: 600; }

/* dcc.Dropdown (react-select) — dark theme. Without this the menu is white-on-white. */
[data-theme="dark"] .Select-control,
[data-theme="dark"] .Select.is-focused > .Select-control {
  background: var(--surface-2) !important; border-color: var(--border) !important; color: var(--text); }
[data-theme="dark"] .Select-menu-outer,
[data-theme="dark"] .VirtualizedSelectFocusedOption { background: var(--surface-2) !important;
  border-color: var(--border) !important; color: var(--text); }
[data-theme="dark"] .Select-option { background: var(--surface-2) !important; color: var(--text) !important; }
[data-theme="dark"] .Select-option.is-focused { background: var(--surface) !important; }
[data-theme="dark"] .Select-option.is-selected { background: rgba(255,107,53,.22) !important; }
[data-theme="dark"] .Select-value-label,
[data-theme="dark"] .Select--single > .Select-control .Select-value .Select-value-label,
[data-theme="dark"] .Select-input > input { color: var(--text) !important; }
[data-theme="dark"] .Select-placeholder,
[data-theme="dark"] .Select--single > .Select-control .Select-placeholder { color: var(--muted) !important; }
[data-theme="dark"] .Select--multi .Select-value {
  background: rgba(255,107,53,.18); border-color: var(--primary); color: var(--text); }
[data-theme="dark"] .Select-arrow { border-color: var(--muted) transparent transparent; }
[data-theme="dark"] .is-open .Select-arrow { border-color: transparent transparent var(--muted); }
.text-muted { color: var(--muted) !important; }

/* ---- Brand logo (horizontal Kirrhosoft mark) ---- */
.brand-logo { max-height: 40px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.brand { display: flex; align-items: center; justify-content: center; }
/* Clickable brand logo (sidebar/offcanvas) → dashboard. */
.brand-link { display: inline-flex; align-items: center; cursor: pointer; transition: opacity .15s; }
.brand-link:hover { opacity: .8; }
/* Logo shown on the dashboard body greeting. */
.dash-greeting .brand-logo { max-height: 38px; margin-bottom: .35rem; }
.login-logo { display: flex; justify-content: center; }
.login-logo .brand-logo { max-height: 48px; }
/* The wordmark is dark; on dark surfaces sit it on a small light chip so it stays legible. */
[data-theme="dark"] .brand-logo {
  background: #fff; border-radius: 8px; padding: 5px 9px;
}

/* ---- Reports preview modal ---- */
.report-modal .modal-content { border: none; border-radius: 16px; overflow: hidden;
  border-top: 4px solid var(--primary); }
.report-modal .modal-title { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.report-modal-icon { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 38px;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
  background: var(--primary); font-size: 1rem; }
.report-modal .modal-body { padding: 1.25rem 1.5rem; }
.report-preview-head { display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: .85rem; flex-wrap: wrap; }
.report-count-chip { background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: .3rem .8rem; font-weight: 700; font-size: .82rem; color: var(--text); }
.report-preview-table { border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.report-preview-table .data-table th { background: var(--surface-2); position: sticky; top: 0; }
.report-modal .modal-footer { gap: .5rem; }

/* Field picker (include/exclude columns before CSV/PDF export) — Reports + Analytics.
   The native checkboxes are hidden and each option is styled as a toggle chip. */
.field-picker { background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 14px; padding: .8rem .9rem; margin-bottom: 1rem; }
.field-picker-bar { display: flex; align-items: center; gap: .5rem; margin-bottom: .65rem; }
.field-picker-ico { color: var(--primary); font-size: .9rem; }
.field-picker-label { font-weight: 700; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text); }
.field-picker-count { font-size: .75rem; color: var(--muted); font-weight: 600; }
.field-picker-actions { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.field-picker-act { border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); border-radius: 8px; padding: .2rem .55rem; font-size: .76rem;
  font-weight: 600; cursor: pointer; transition: all .15s ease; }
.field-picker-act:hover { border-color: var(--primary); color: var(--primary); }

/* Toggle chips */
.field-chips { display: flex; flex-wrap: wrap; gap: .45rem; padding: 0; }
.field-chips .form-check { margin: 0; padding: 0; min-height: 0; display: inline-flex; }
.field-chips .form-check-input { position: absolute; opacity: 0; width: 0; height: 0;
  margin: 0; pointer-events: none; }
.field-chips .form-check-label { display: inline-flex; align-items: center; gap: .4rem;
  padding: .34rem .72rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: .82rem; font-weight: 500;
  cursor: pointer; transition: all .15s ease; user-select: none; line-height: 1.2; }
.field-chips .form-check-label::before { content: "+"; font-weight: 700; font-size: .82rem;
  opacity: .5; transition: all .15s ease; }
.field-chips .form-check-label:hover { border-color: var(--primary); color: var(--primary); }
.field-chips .form-check-input:checked + .form-check-label {
  background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600;
  box-shadow: 0 2px 7px rgba(255,107,53,.30); }
.field-chips .form-check-input:checked + .form-check-label::before {
  content: "\2713"; opacity: 1; }
.field-chips .form-check-input:focus-visible + .form-check-label {
  outline: 2px solid var(--primary); outline-offset: 2px; }
[data-theme="dark"] .field-chips .form-check-input:checked + .form-check-label { color: #fff; }

/* ---- Sync split-control (button + caret dropdown) ---- */
.btn-group > .dropdown > .dropdown-toggle-split { padding-left: .5rem; padding-right: .5rem; }
.btn-group > .dropdown .dropdown-menu { min-width: 220px; }
.dropdown-toggle-split::after { margin-left: 0; }

/* ---- App footer (copyright) ---- */
.app-footer { margin-top: auto; padding: 1.1rem 1.5rem; text-align: center;
  color: var(--muted); font-size: .82rem; border-top: 1px solid var(--border); }
.app-footer .app-footer-sep { opacity: .7; }
.main-page { flex: 1 0 auto; }
.main-col { display: flex; flex-direction: column; min-height: 100vh; }

/* ---- Settings page: horizontal tabs + single visible panel ---- */
.settings-tabs {
  display: flex; flex-wrap: nowrap; gap: .15rem; margin-bottom: 1.4rem;
  border-bottom: 2px solid var(--border); overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.settings-tabs .settings-navlink {
  color: var(--muted) !important; cursor: pointer; white-space: nowrap;
  padding: .72rem 1.1rem !important; font-weight: 600; display: flex; align-items: center;
  border: none !important; border-radius: 10px 10px 0 0 !important;
  border-bottom: 2px solid transparent !important; margin-bottom: -2px;
  background: transparent !important; transition: .15s;
}
.settings-tabs .settings-navlink:hover {
  color: var(--primary) !important; background: var(--surface-2) !important;
}
.settings-tabs .settings-navlink.active {
  color: var(--primary) !important; background: transparent !important;
  border-bottom-color: var(--primary) !important; box-shadow: none !important;
}
.settings-tabs .settings-navlink i { width: 18px; text-align: center; }
.settings-content { min-width: 0; }
@media (max-width: 768px) {
  .settings-tabs .settings-navlink { padding: .6rem .85rem !important; }
}

/* ---- Payroll Rules deduction sub-cards ---- */
.policy-subcard { background: var(--surface-2); border: 1px solid var(--border); }
.policy-subcard .card-body { padding: 1.1rem 1.15rem !important; }
[data-theme="dark"] .policy-subcard { background: var(--surface-2); }

/* ---- Payroll detail summary tiles ---- */
.pay-tile { border-radius: 10px; padding: .8rem 1rem; text-align: center; border: 1px solid; }
.pay-tile-label { font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; opacity: .8; }
.pay-tile-value { font-size: 1.25rem; font-weight: 800; margin-top: .2rem; }
.pay-tile.tile-green { background: rgba(46,125,50,.10); border-color: rgba(46,125,50,.4); color: #2E7D32; }
.pay-tile.tile-red { background: rgba(198,40,40,.10); border-color: rgba(198,40,40,.4); color: #C62828; }
.pay-tile.tile-orange { background: rgba(255,107,53,.12); border-color: rgba(255,107,53,.5); color: #FF6B35; }
[data-theme="dark"] .pay-tile.tile-green { color: #66BB6A; }
[data-theme="dark"] .pay-tile.tile-red { color: #EF5350; }
[data-theme="dark"] .pay-tile.tile-orange { color: #FF9E7A; }

/* ---- Payslip Breakdown modal (redesigned) ---- */
.pay-detail-body { padding: 1.25rem 1.4rem 1.5rem !important; }
.pay-detail-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: 1rem 1.15rem; margin-bottom: 1.1rem;
  border-radius: 12px; border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255,107,53,.10), rgba(255,107,53,.02));
}
.pay-detail-name { font-size: 1.2rem; font-weight: 800; line-height: 1.1; }
.pay-detail-period { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.pay-sec { margin: 0 !important; }
.pay-sec > .card-body { padding: 1rem 1.15rem !important; }
.pay-sec-title { font-weight: 700; margin-bottom: .6rem; font-size: .95rem; }
/* Inner tables in the modal sit flush with the card padding. */
.pay-detail .data-table { margin: 0; }
.pay-detail .data-table table { width: 100%; }
@media (max-width: 640px) {
  .pay-detail-body { padding: 1rem !important; }
  .pay-detail-head { flex-wrap: wrap; padding: .85rem 1rem; }
  .pay-detail-name { font-size: 1.05rem; }
}

/* ---- Leave action button (LeaveActionButton cell renderer) ---- */
.lv-action-btn { border: none; border-radius: 6px; padding: 3px 12px; font-size: .78rem;
  font-weight: 700; cursor: pointer; color: #fff; line-height: 1.4; }
.lv-action-review { background: #FF6B35; }
.lv-action-undo { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.lv-action-btn:hover { opacity: .9; }
.ag-theme-quartz .ag-cell.ag-action, .ag-theme-quartz-dark .ag-cell.ag-action {
  display: flex; align-items: center; }

/* ---- AG Grid status pill (StatusPill cell renderer) ----
   The pill is a self-contained <span>; keep it tight (auto width, not stretched)
   and vertically centred in the cell so it never "spreads" across the row. */
.ag-theme-quartz .ag-cell .pill,
.ag-theme-quartz-dark .ag-cell .pill {
  width: auto; max-width: 100%; align-self: center; vertical-align: middle;
}
/* Give the pill's cell a flex box so the span centres both ways. */
.ag-theme-quartz .ag-cell:has(> .pill),
.ag-theme-quartz-dark .ag-cell:has(> .pill) {
  display: flex; align-items: center;
}

/* ---- Attendance calendar ---- */
.cal-legend { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  margin: .25rem 0 1rem; font-size: .85rem; }
.cal-legend .cal-legend-icon { font-size: 1rem; }
.ag-cal { text-align: center; cursor: pointer; font-size: 1rem; padding: 0 !important; }
.ag-cal-h { justify-content: center; }
.ag-cal-h .ag-header-cell-label { justify-content: center; }
/* Week starts on Sunday: a divider on each Sunday column (cell + header) marks
   the start of a new week across the horizontal day strip. */
.ag-cal-wk { border-left: 2px solid var(--primary) !important; }
/* Leading cells = previous month's trailing days (dimmed so they read as
   "not this month" while still showing the real status colour/dot). */
.ag-cal-pad { opacity: .45; cursor: default; }
.ag-cal-pad-h { opacity: .6; }
.ag-cal-pad-h .ag-header-cell-text { font-style: italic; }

/* Mobile: tighten ALL tables + page chrome so data isn't crowded out by
   padding, and lay filter bars out as one even row. Desktop is untouched. */
@media (max-width: 640px) {
  /* Less page/card chrome → more width for the data. */
  .page { padding: .7rem; }
  .card > .card-body { padding: .8rem; }

  /* Denser AG-Grid tables (system-wide): trim cell padding, grid spacing,
     header height and font so more columns/rows are visible. */
  .ag-theme-quartz, .ag-theme-quartz-dark {
    --ag-cell-horizontal-padding: 6px;
    --ag-grid-size: 4px;
    --ag-font-size: 12px;
    --ag-header-height: 40px;
    --ag-row-height: 38px;
  }
  /* Denser HTML render_table tables. */
  .data-table th, .data-table td { padding: .45rem .55rem; font-size: .8rem; }

  /* Filter bars (month/year/apply, etc.): two fields per row, evenly sized with
     consistent gaps and a uniform height. A lone trailing field (e.g. the 3rd of
     three, or a single Apply button) spans the full width on its own row. */
  .filter-bar { display: grid !important; grid-template-columns: 1fr 1fr;
    column-gap: .8rem !important; row-gap: .7rem !important; gap: .7rem .8rem !important;
    width: 100%; align-items: end;
    margin-left: 0 !important; margin-right: 0 !important; --bs-gutter-x: 0 !important; }
  .filter-bar > * { width: 100% !important; min-width: 0 !important;
    margin: 0 !important; padding-left: 0 !important; padding-right: 0 !important; }
  .filter-bar > *:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .filter-bar .Select-control, .filter-bar input, .filter-bar .btn { min-height: 40px; }
}
/* Status-tinted calendar cells (mirrors the employee month view) so the admin
   grid is scannable at a glance. Emoji is kept for colour-blind redundancy. */
.ag-cal.cal-present { background: rgba(46,125,50,.12); }
.ag-cal.cal-late    { background: rgba(245,158,11,.15); }
.ag-cal.cal-early   { background: rgba(147,51,234,.15); }
.ag-cal.cal-absent  { background: rgba(220,38,38,.12); }
.ag-cal.cal-off     { background: transparent; opacity: .55; }
[data-theme="dark"] .ag-cal.cal-present { background: rgba(74,222,128,.16); }
[data-theme="dark"] .ag-cal.cal-late    { background: rgba(251,191,36,.16); }
[data-theme="dark"] .ag-cal.cal-early   { background: rgba(192,132,252,.18); }
[data-theme="dark"] .ag-cal.cal-absent  { background: rgba(248,113,113,.16); }

/* ---- Empty states (tables + grids) ---- */
.empty-state { display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .5rem; padding: 2.25rem 1rem; text-align: center; }
.empty-state-icon { font-size: 2rem; color: var(--muted); opacity: .55; }
.empty-state-text { color: var(--muted); font-size: .92rem; }
.ag-empty-state { display: flex; flex-direction: column; align-items: center;
  gap: .5rem; color: var(--muted); padding: 1rem; }
.ag-empty-state i { font-size: 1.9rem; opacity: .5; }

/* Number-input spin buttons are near-invisible on the dark surface — brighten. */
[data-theme="dark"] input[type="number"]::-webkit-inner-spin-button,
[data-theme="dark"] input[type="number"]::-webkit-outer-spin-button {
  filter: invert(0.85); }

/* ---- Breadcrumbs ---- */
.breadcrumb-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .7rem 1.75rem 0; font-size: .85rem; }
.breadcrumb-bar .bc-link { color: var(--primary); text-decoration: none; }
.breadcrumb-bar .bc-link:hover { text-decoration: underline; }
.breadcrumb-bar .bc-current { color: var(--muted); font-weight: 600; }
.breadcrumb-bar .bc-sep { color: var(--muted); }
@media (max-width: 991px) { .breadcrumb-bar { padding: .6rem 1.15rem 0; } }

/* ---- AG Grid: link + action cells ---- */
.ag-link { color: var(--primary); font-weight: 600; cursor: pointer; }
.ag-link:hover { text-decoration: underline; }
.ag-action { cursor: pointer; text-align: center; font-size: 1.05rem; }
.ag-theme-quartz, .ag-theme-quartz-dark {
  --ag-font-family: inherit; --ag-border-radius: 10px;
  --ag-header-background-color: var(--surface-2);
}
.ag-theme-quartz { --ag-active-color: var(--primary); }

/* ---- Avatars ---- */
.avatar-img { border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.avatar-initials {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-grad); color: #fff; font-weight: 700;
}

/* ---- Top-bar user chip ---- */
.user-chip {
  display: flex; align-items: center; gap: .6rem; text-decoration: none;
  padding: .25rem .6rem .25rem .3rem; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text); transition: .15s; margin-left: .15rem;
}
.user-chip:hover { border-color: var(--primary); color: var(--text); }
.user-chip-text { display: flex; flex-direction: column; line-height: 1.1; }
.user-chip-name { font-weight: 600; font-size: .88rem; }
.user-chip-role { font-size: .72rem; color: var(--muted); }
@media (max-width: 640px) { .user-chip-text { display: none; } }

/* Loading spinners (dcc.Loading): overlay a centered spinner while keeping the
   underlying content visible (dimmed) instead of blanking the page. */
.kirrho-loading { min-height: 60px; position: relative; }
/* Pin the spinner to the CENTRE OF THE VIEWPORT (fixed), not its container, so it
   always shows in the middle of the screen regardless of scroll position. */
.kirrho-loading .dash-spinner {
  position: fixed !important; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(1.3); z-index: 1200;
}
.kirrho-loading .dash-spinner * {
  border-color: var(--primary) transparent var(--primary) transparent !important;
}
._dash-loading-callback, .dash-loading { color: var(--primary); }
/* Button spinner spacing */
.btn .spinner-border-sm { width: 1rem; height: 1rem; vertical-align: -0.15em; }
