/* ============================================================
   Cloud Shift — Design System
   A workforce-scheduling app for care homes and shift-based teams.
   Light theme is the default and is fully self-sufficient; dark.css
   (loaded separately when data-theme="dark") only overrides the
   custom properties below, so every component re-themes automatically.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Brand */
  --brand: #1B4F8F;
  --brand-dark: #123A6B;
  --brand-light: #DCE7F5;
  --brand-tint: #F1F6FC;
  --accent: #B8802E;
  --accent-light: #FBF1DD;

  /* Ink / neutrals (warm-toned, not blue-grey) */
  --ink: #16231F;
  --ink-soft: #4B5D57;
  --ink-faint: #7C8C86;
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-alt: #FBFAF6;
  --border: #E4E0D6;
  --border-strong: #D2CCBE;

  /* Status */
  --success: #2E8F57;
  --success-bg: #E7F5EC;
  --success-border: #BFE2CC;
  --warning: #B4740F;
  --warning-bg: #FBF0DA;
  --warning-border: #EDD8A6;
  --danger: #BB3F35;
  --danger-bg: #FBEAE8;
  --danger-border: #EFC7C2;
  --info: #2A6F97;
  --info-bg: #E9F1F6;
  --info-border: #C6DEEA;
  --draft: #8A8375;
  --draft-bg: #F0EDE5;

  /* Sidebar (always dark, regardless of theme) */
  --sidebar-bg: #11243A;
  --sidebar-bg-alt: #16304C;
  --sidebar-hover: #1B3A5C;
  --sidebar-active: #23486F;
  --sidebar-text: #B7C8DA;
  --sidebar-text-dim: #7C92A8;
  --sidebar-text-active: #FFFFFF;
  --sidebar-border: rgba(255,255,255,.08);

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(20,28,38,.06), 0 1px 1px rgba(20,28,38,.04);
  --shadow-md: 0 6px 20px rgba(20,28,38,.08), 0 2px 6px rgba(20,28,38,.05);
  --shadow-lg: 0 18px 48px rgba(20,28,38,.14), 0 4px 14px rgba(20,28,38,.06);

  /* Shape */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Type */
  --font-display: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Layout */
  --sidebar-w: 252px;
  --sidebar-w-collapsed: 80px;
  --header-h: 66px;

  /* Legacy aliases some page stylesheets still reference */
  --text-main: var(--ink);
  --text-muted: var(--ink-soft);
  --text-soft: var(--ink-soft);
  --text-subtle: var(--ink-faint);
  --bg-card: var(--surface);
  --card: var(--surface);
  --ok: var(--success);
  --bad: var(--danger);
  --warn: var(--warning);
}

/* ============================================================
   Reset + base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

p { margin: 0 0 8px; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.92em;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* <button>, <input>, <select> and <textarea> do not inherit font or colour
   from their surroundings. Without this, any control lacking an explicit
   colour falls back to the browser default (black) - which is invisible on
   the dark theme. This is the root cause behind the unreadable staff names
   on the rota and the Notes box on My Profile. */
button, input, select, textarea, optgroup {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

::selection { background: var(--brand); color: #fff; }

/* Consistent, visible focus ring everywhere (accessibility floor) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.kr-btn:focus-visible,
.kr-nav-item:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-light), 0 0 0 1px var(--brand);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   App shell: sidebar + header + content
   ============================================================ */
body.kr-shell {
  display: flex;
  min-height: 100vh;
}

.kr-sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-border);
  transition: width .18s ease, flex-basis .18s ease;
  scrollbar-width: thin;
}

.kr-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 8px;
}

.kr-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(150deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  flex: none;
  overflow: hidden;
}

.kr-brand-logo-img { width: 38px; height: 38px; border-radius: var(--radius-md); object-fit: cover; flex: none; }

.kr-brand { min-width: 0; }
.kr-brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kr-brand-sub { font-size: 11.5px; color: var(--sidebar-text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.kr-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 12px;
  flex: 1;
}

.kr-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  transition: background-color .12s ease, color .12s ease;
}
.kr-nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.kr-nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 700;
}
.kr-nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.kr-nav-item.disabled { opacity: .45; pointer-events: none; }

.kr-nav-ico, .kr-ico {
  flex: none;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  opacity: .92;
}
.kr-nav-ico svg { width: 18px; height: 18px; }
.kr-nav-label { overflow: hidden; text-overflow: ellipsis; flex: 1; }

.kr-nav-badge {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kr-sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
}
.kr-build-meta { font-size: 10.5px; color: var(--sidebar-text-dim); padding: 4px 12px 8px; }
.kr-nav-logout { color: var(--sidebar-text-dim); }
.kr-nav-logout:hover { color: #fff; background: rgba(187,63,53,.35); }

/* Desktop collapsed state (icon rail only) */
body.kr-sidebar-collapsed .kr-sidebar { width: var(--sidebar-w-collapsed); flex-basis: var(--sidebar-w-collapsed); }
body.kr-sidebar-collapsed .kr-brand,
body.kr-sidebar-collapsed .kr-nav-label,
body.kr-sidebar-collapsed .kr-brand-sub,
body.kr-sidebar-collapsed .kr-build-meta { display: none; }
body.kr-sidebar-collapsed .kr-nav-item { justify-content: center; }
body.kr-sidebar-collapsed .kr-nav-item.active::before { left: 0; }
body.kr-sidebar-collapsed .kr-sidebar-logo { justify-content: center; padding: 20px 8px 16px; }

.kr-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,16,14,.5);
  z-index: 40;
}

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

.kr-header {
  height: var(--header-h);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 16px;
}
.kr-header-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.kr-header-title { font-size: 19px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kr-header-right { display: flex; gap: 12px; align-items: center; }

.kr-sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  flex: none;
}
.kr-sidebar-toggle:hover { background: var(--surface-alt); }

.kr-content {
  flex: 1;
  padding: 22px 26px 40px;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
}

.kr-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.kr-user-avatar {
  width: 30px; height: 30px;
  border-radius: 999px;
  background: linear-gradient(150deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 12.5px;
}
.kr-user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.kr-user-name { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.kr-user-role { font-size: 11px; color: var(--ink-faint); }

.kr-icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.kr-icon-btn:hover { background: var(--surface-alt); color: var(--ink); }
.kr-icon-btn svg { width: 19px; height: 19px; }

.kr-notif-wrap { position: relative; }
.kr-notif-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
}
.kr-notif-panel {
  display: none;
  position: fixed;
  right: 22px;
  top: 74px;
  width: 360px;
  max-width: 88vw;
  max-height: 70vh;
  overflow-y: auto;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 2000000000;
}
.kr-notif-panel.show { display: block; }
.kr-notif-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.kr-notif-list { display: flex; flex-direction: column; gap: 8px; }
.kr-notif-item { padding: 10px 12px; border-radius: var(--radius-md); cursor: pointer; border: 1px solid var(--border); background: var(--surface-alt); }
.kr-notif-item:hover { border-color: var(--border-strong); }
.kr-notif-item.unread { border-color: var(--brand); box-shadow: 0 0 0 1px rgba(27,79,143,.15); background: var(--brand-tint); }
.kr-notif-title { font-size: 13px; font-weight: 700; color: var(--ink); }
.kr-notif-body { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; word-break: break-word; }
.kr-notif-time { font-size: 11px; color: var(--ink-faint); margin-top: 6px; }

/* ============================================================
   Page scaffolding
   ============================================================ */
.kr-page { display: flex; flex-direction: column; gap: 20px; }
.kr-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.kr-page-title { font-size: 24px; margin: 0; }
.kr-page-sub, .kr-sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 2px; }
.kr-title { font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.kr-h3 { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin: 0 0 8px; }
.kr-section-title { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.kr-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.kr-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.kr-muted { color: var(--ink-soft); }
.kr-small { font-size: 12.5px; }
.kr-help { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

/* ============================================================
   Cards & panels
   ============================================================ */
.kr-panel, .kr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.kr-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.kr-panel-title, .kr-card-title { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; margin: 0; }
.kr-panel-sub { color: var(--ink-soft); font-size: 12.5px; margin-top: 2px; }

/* Status accent bar — the app's recurring "scan status at a glance" motif */
.kr-panel.kr-accent-draft, .kr-card.kr-accent-draft, .kr-list-row.kr-accent-draft { border-left: 4px solid var(--draft); }
.kr-panel.kr-accent-pending, .kr-card.kr-accent-pending, .kr-list-row.kr-accent-pending { border-left: 4px solid var(--warning); }
.kr-panel.kr-accent-approved, .kr-card.kr-accent-approved, .kr-list-row.kr-accent-approved { border-left: 4px solid var(--success); }
.kr-panel.kr-accent-danger, .kr-card.kr-accent-danger, .kr-list-row.kr-accent-danger { border-left: 4px solid var(--danger); }

.kr-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

/* "Modern" stat / KPI cards - used on Dashboard, HR, Payroll, Reports */
.kr-dash-stat-grid, .kr-modern-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.kr-stat-card, .kr-modern-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kr-modern-stat { flex-direction: row; align-items: baseline; justify-content: space-between; gap: 10px; }
.kr-modern-stat span { color: var(--ink-soft); font-size: 12.5px; font-weight: 600; }
.kr-modern-stat strong { font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--ink); }
.kr-stat-primary { background: linear-gradient(155deg, var(--brand-tint), var(--surface) 65%); border-color: var(--brand-light); }
.kr-stat-label { color: var(--ink-soft); font-size: 12.5px; font-weight: 600; }
.kr-stat-value { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.kr-stat-meta { font-size: 12px; color: var(--ink-faint); }
.kr-stat-mini-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; margin-top: 4px; }
.kr-stat-mini-grid strong { font-family: var(--font-display); font-size: 18px; }
.kr-stat-mini-grid span { display: block; font-size: 11.5px; color: var(--ink-faint); }

/* ============================================================
   Buttons
   ============================================================ */
.kr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease, transform .05s ease;
  white-space: nowrap;
}
.kr-btn:hover { background: var(--surface-alt); border-color: var(--ink-faint); }
.kr-btn:active { transform: translateY(1px); }
.kr-btn:disabled, .kr-btn[disabled] { opacity: .5; cursor: not-allowed; }

.kr-btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.kr-btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.kr-btn-secondary {
  background: var(--brand-tint);
  border-color: var(--brand-light);
  color: var(--brand-dark);
}
.kr-btn-secondary:hover { background: var(--brand-light); }

.kr-btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink-soft);
}
.kr-btn-ghost:hover { background: var(--surface-alt); color: var(--ink); }

.kr-btn-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}
.kr-btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.kr-btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: var(--radius-sm); }
.kr-btn-xs { height: 27px; padding: 0 9px; font-size: 11.5px; border-radius: var(--radius-sm); }
.kr-modern-button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ============================================================
   Forms
   ============================================================ */
.kr-form-row, .kr-field, .kr-field-compact { display: flex; flex-direction: column; gap: 6px; }
.kr-field-compact { gap: 4px; }

/* Wrapper around an input (+ optional help text) — layout only, never a
   bordered control in its own right. */
.kr-form-control { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/* Two-column field layout (HR profile form) */
.kr-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  align-items: start;
}
.kr-form-grid .kr-form-row--full { grid-column: 1 / -1; }
@media (max-width: 820px) { .kr-form-grid { grid-template-columns: 1fr; } }

.kr-label, .kr-form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.kr-filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }

.kr-input, .kr-select, .kr-modern-input,
input[type="text"].kr-input, textarea.kr-input {
  height: 40px;
  padding: 0 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13.5px;
  width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea.kr-input { height: auto; min-height: 88px; padding: 10px 13px; resize: vertical; }
.kr-input:focus, .kr-select:focus, .kr-form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.kr-input::placeholder { color: var(--ink-faint); }
.kr-input-sm { height: 34px; font-size: 12.5px; padding: 0 10px; }
.kr-input:disabled, .kr-select:disabled { background: var(--surface-alt); color: var(--ink-faint); cursor: not-allowed; }

select.kr-select, select.kr-input {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234B5D57' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.kr-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* ============================================================
   Tables
   ============================================================ */
.kr-table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.kr-table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
.kr-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-alt);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.kr-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.kr-table tbody tr:last-child td { border-bottom: none; }
.kr-table tbody tr:hover { background: var(--surface-alt); }

/* ============================================================
   Badges / pills / alerts
   ============================================================ */
.kr-badge, .kr-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--draft-bg);
  color: var(--draft);
  border: 1px solid transparent;
  white-space: nowrap;
}
.kr-badge-ok { background: var(--success-bg); color: var(--success); }
.kr-badge-warn { background: var(--warning-bg); color: var(--warning); }
.kr-badge-bad { background: var(--danger-bg); color: var(--danger); }

.kr-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 13px;
  color: var(--ink);
}
/* Text colours follow the status tokens so they stay readable when the
   backgrounds flip dark - hardcoded dark text on a dark alert was invisible. */
.kr-alert-ok, .kr-alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.kr-alert-warn { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.kr-alert-bad, .kr-alert-danger, .kr-alert-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.kr-alert strong { color: inherit; }

/* ============================================================
   Login / auth shell (shared by login.php, mfa_setup.php, mfa_verify.php)
   ============================================================ */
.kr-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
}
.kr-login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(700px 420px at 15% 10%, rgba(27,79,143,.10), transparent 60%),
    radial-gradient(600px 380px at 85% 90%, rgba(184,128,46,.10), transparent 60%);
}
.kr-login-shell {
  position: relative;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  width: min(980px, 94vw);
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.kr-login-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(560px, 94vw);
  min-height: 0;
}
.kr-login-panel {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 34px 36px;
}
.kr-login-wrap { position: relative; padding: 24px; }
.kr-login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.kr-login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.kr-login-brand img { width: 44px; height: 44px; border-radius: var(--radius-md); }
.kr-login-title, .kr-auth-title { font-family: var(--font-display); font-weight: 800; font-size: 21px; }
.kr-login-sub, .kr-auth-sub { color: var(--ink-soft); font-size: 13px; }
.kr-login-head { margin-bottom: 18px; }
.kr-login-form { display: flex; flex-direction: column; gap: 14px; }
.kr-login-field { display: flex; flex-direction: column; gap: 6px; }
.kr-login-field label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.kr-login-field input {
  height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--ink);
}
.kr-login-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.kr-login-hint { font-size: 12px; color: var(--ink-faint); }
.kr-login-error, .kr-login-alert { padding: 10px 12px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 12px; }
.kr-login-error, .kr-login-alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.kr-login-footer { text-align: center; margin-top: 4px; }
.kr-login-divider { display: flex; align-items: center; gap: 10px; color: var(--ink-faint); font-size: 12px; margin: 2px 0; }
.kr-login-divider::before, .kr-login-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.kr-link { color: var(--brand); font-size: 13px; font-weight: 600; }

.kr-auth-split, .kr-auth-shell { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100vh; }
.kr-auth-mark, .kr-auth-left {
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 46px 42px;
  background:
    radial-gradient(900px 500px at 20% 20%, rgba(184,128,46,.20), transparent 55%),
    radial-gradient(700px 420px at 80% 40%, rgba(255,255,255,.06), transparent 60%),
    linear-gradient(150deg, var(--sidebar-bg-alt), var(--sidebar-bg));
  color: #fff;
}
.kr-auth-mark-inner, .kr-auth-brand { position: relative; max-width: 520px; }
.kr-auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.kr-auth-badge {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  font-family: var(--font-display); font-weight: 800; letter-spacing: .4px; color: #fff;
}
.kr-auth-h1 { font-size: 32px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 10px; color: #fff; }
.kr-auth-p { margin: 0 0 18px; color: rgba(255,255,255,.78); max-width: 52ch; }
.kr-auth-pillrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.kr-auth-formwrap, .kr-auth-right { display: flex; align-items: center; justify-content: center; padding: 34px 16px; background: var(--bg); }
.kr-auth-card.kr-auth-card--wide { width: min(460px, 95vw); padding: 30px; border-radius: var(--radius-xl); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }

@media (max-width: 900px) {
  .kr-auth-split, .kr-auth-shell, .kr-login-shell { grid-template-columns: 1fr; }
  .kr-auth-mark, .kr-login-panel:first-child { display: none; }
  .kr-auth-formwrap { min-height: 100vh; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .kr-sidebar {
    position: fixed;
    z-index: 50;
    top: 0; left: 0;
    height: 100vh;
    width: 268px;
    flex-basis: 268px;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  body.kr-sidebar-open .kr-sidebar { transform: translateX(0); }
  body.kr-sidebar-open .kr-backdrop { display: block; }
  .kr-sidebar-toggle { display: grid; place-items: center; }
  .kr-content { padding: 16px 14px 32px; }
  .kr-header { padding: 0 14px; }
  .kr-header-title { font-size: 16px; }
  .kr-dash-stat-grid, .kr-modern-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

@media (min-width: 901px) {
  .kr-sidebar-toggle { display: grid; place-items: center; }
}

/* ============================================================
   Shared components used across multiple pages (modal, accordion,
   toggle, segmented control, chips, empty states, layout utilities)
   ============================================================ */

/* Modal dialog (shift editor, leave approve/reject, etc.) */
.kr-modal-backdrop{
  position:fixed; inset:0;
  background: rgba(10,18,28,.55);
  display:grid; place-items:center;
  z-index:9999;
  padding:18px;
}
.kr-modal{
  width:min(560px, 96vw);
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow:hidden;
}
.kr-modal-head{
  display:flex; align-items:flex-start; justify-content:space-between;
  padding:16px 16px 10px;
  border-bottom:1px solid var(--border);
}
.kr-modal-title{font-family: var(--font-display); font-size:16px; font-weight:800; line-height:1.2;}
.kr-modal-sub{font-size:12px; color: var(--ink-soft); margin-top:4px;}
.kr-modal-close{ border:0; background:transparent; cursor:pointer; width:34px; height:34px; border-radius:10px; color: var(--ink-soft); font-size: 16px; }
.kr-modal-close:hover{ background: var(--surface-alt); color: var(--ink); }
.kr-modal-body{padding:14px 16px 16px;}
.kr-modal-grid{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
@media (max-width:520px){ .kr-modal-grid{grid-template-columns:1fr;} }
.kr-modal .kr-field label{display:block; font-size:12px; font-weight:700; margin-bottom:6px; color: var(--ink-soft);}
.kr-modal .kr-field input,.kr-modal .kr-field select,.kr-modal .kr-field textarea{
  width:100%; border:1px solid var(--border-strong); border-radius:10px; padding:10px 12px;
  background: var(--surface); color: var(--ink); font-family: var(--font-body);
}
.kr-modal .kr-field textarea{min-height:88px; resize:vertical;}
.kr-modal-metrics{ display:flex; gap:10px; flex-wrap:wrap; margin-top:10px; color: var(--ink-soft); font-size:12px; }
.kr-modal-foot{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:12px 16px; border-top:1px solid var(--border); background: var(--surface-alt);
}
.kr-modal-actions{display:flex; gap:10px; justify-content:flex-end; width:100%; flex-wrap: wrap;}
.kr-leave-modal-icon { width: 40px; height: 40px; border-radius: var(--radius-md); display: grid; place-items: center; background: var(--brand-tint); color: var(--brand); flex: none; }
.kr-leave-modal-top { display: flex; gap: 12px; align-items: flex-start; }
.kr-leave-modal-intro { color: var(--ink-soft); font-size: 13px; }
.kr-leave-modal-hint { font-size: 12px; color: var(--ink-faint); margin-top: 8px; }
.kr-leave-modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kr-leave-modal-card-full { grid-column: 1 / -1; }
@media (max-width: 520px) { .kr-leave-modal-grid { grid-template-columns: 1fr; } }

/* Accordion (native <details>/<summary>) — templates, availability rules, HR records */
.kr-acc-list { display: flex; flex-direction: column; gap: 10px; }
details.kr-acc, details.kr-hr-acc, details.kr-person-acc {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.kr-acc-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}
.kr-acc-summary::-webkit-details-marker { display: none; }
.kr-acc-summary::before {
  content: '';
  width: 8px; height: 8px;
  border-right: 2px solid var(--ink-faint);
  border-bottom: 2px solid var(--ink-faint);
  transform: rotate(-45deg);
  transition: transform .15s ease;
  flex: none;
  margin-right: 2px;
}
details[open] > .kr-acc-summary::before { transform: rotate(45deg); }
.kr-acc-title { font-weight: 700; color: var(--ink); }
.kr-acc-meta { color: var(--ink-faint); font-size: 12px; margin-left: auto; margin-right: 8px; }
.kr-acc-summary:hover { background: var(--surface-alt); }
.kr-acc-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); }

/* Toggle switch (checkbox styled as a switch) */
.kr-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
input.kr-toggle {
  appearance: none;
  width: 40px; height: 24px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background-color .15s ease;
}
input.kr-toggle::before {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
}
input.kr-toggle:checked { background: var(--brand); }
input.kr-toggle:checked::before { transform: translateX(16px); }
input.kr-toggle.kr-toggle-sm { width: 32px; height: 20px; }
input.kr-toggle.kr-toggle-sm::before { width: 14px; height: 14px; }
input.kr-toggle.kr-toggle-sm:checked::before { transform: translateX(12px); }
.kr-switch-text { font-size: 13px; font-weight: 600; color: var(--ink); }

/* Segmented control (radio inputs styled as a button group) */
.kr-seg {
  display: flex;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  gap: 4px;
}
.kr-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.kr-seg label {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s ease, color .12s ease;
}
.kr-seg label:hover { color: var(--ink); }
/* Selected state uses the brand colour so it is unmistakable - the previous
   white-on-light-grey treatment was almost invisible. */
.kr-seg input[type="radio"]:checked + label {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.kr-seg input[type="radio"]:checked + label:hover { color: #fff; }
.kr-seg input[type="radio"]:focus-visible + label { box-shadow: 0 0 0 3px var(--brand-light); }

/* Chips / tags */
.kr-chip, .kr-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* Empty states */
.kr-empty, .kr-empty-state, .kr-empty-row {
  padding: 26px 16px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
}
.kr-empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; }

/* Layout utilities */
.kr-stack { display: flex; flex-direction: column; gap: 14px; }
.kr-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.kr-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.kr-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.kr-grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; align-items: end; }
.kr-create-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.kr-divider { height: 1px; background: var(--border); margin: 4px 0; }
.kr-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.kr-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); }
@media (max-width: 900px) { .kr-grid-2, .kr-grid-3 { grid-template-columns: 1fr; } }

/* Split panel layout (Payroll / Reports / System Logs) */
.kr-split-panels { display: grid; grid-template-columns: 1.1fr 1.6fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .kr-split-panels { grid-template-columns: 1fr; } }

/* Reusable "person row" pieces (Timesheets / Payroll / Reports) */
.kr-ts-avatar {
  width: 34px; height: 34px; border-radius: 999px;
  background: var(--surface-alt); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex: none;
  font-weight: 700; font-size: 13px; color: var(--ink-soft);
}
.kr-ts-avatar img { width: 100%; height: 100%; object-fit: cover; }
.kr-ts-name { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.kr-ts-sub { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.kr-list-person { display: flex; align-items: center; gap: 10px; }
.kr-list-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kr-modern-list { display: flex; flex-direction: column; gap: 8px; }
.kr-modern-mini-badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  background: var(--brand-tint); color: var(--brand-dark); font-size: 11.5px; font-weight: 700;
}

/* Status pill variants (Users page) */
.kr-user-pill--ok { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.kr-user-pill--warn { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.kr-user-pill--bad, .kr-user-pill--danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }

/* Avatar placeholder (People page) */
.kr-avatar-ph {
  width: 42px; height: 42px; border-radius: 999px;
  background: var(--brand-tint); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 14px;
  flex: none;
}

/* Log viewer (System Logs page) */
.kr-log-viewer {
  background: #0C1119;
  color: #DCE3EC;
  border-radius: var(--radius-lg);
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  max-height: 65vh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Semantic alias: some pages combine .kr-btn with a bare .kr-primary modifier */
.kr-btn.kr-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.kr-btn.kr-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.kr-leave-approve { background: var(--success); border-color: var(--success); color: #fff; }
.kr-leave-approve:hover { filter: brightness(.92); }
.kr-leave-reject { background: var(--danger); border-color: var(--danger); color: #fff; }
.kr-leave-reject:hover { filter: brightness(.92); }

/* Generic "modern page" toolbar pattern shared by Timesheets, Payroll,
   Reports, System Logs, and Admin Tools */
.kr-modern-page { display: flex; flex-direction: column; gap: 20px; }
.kr-modern-toolbar { padding: 16px 18px; }
.kr-modern-toolbar-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; }
.kr-modern-toolbar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; align-items: end; }
.kr-timesheets-toolbar-left, .kr-timesheets-toolbar-right { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.kr-timesheets-field { display: flex; flex-direction: column; gap: 6px; }

/* Timesheets weekly grid (mirrors the Rota grid's structure) */
.kr-modern-board { border-radius: var(--radius-lg); }
.kr-modern-board.is-dragging { cursor: grabbing; user-select: none; }
.kr-ts-grid {
  display: grid;
  grid-template-columns: 230px repeat(7, minmax(196px, 1fr)) 92px 124px;
  min-width: 1810px;
  background: var(--surface);
}
.kr-ts-head {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-alt);
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.kr-ts-head span { font-weight: 500; text-transform: none; font-size: 10.5px; color: var(--ink-faint); }
.kr-ts-head-emp { align-items: flex-start; justify-content: center; }
.kr-ts-employee {
  display: flex; align-items: center; gap: 10px;
  padding: 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; left: 0; z-index: 2;
  min-width: 0;
}
.kr-ts-employee > div { min-width: 0; }
.kr-ts-cell {
  padding: 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 70px;
  min-width: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kr-ts-empty { color: var(--ink-faint); font-size: 12px; padding: 8px; text-align: center; }

.kr-ts-shift {
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  padding: 11px;
  background: var(--surface-alt);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kr-ts-shift-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-width: 0; flex-wrap: wrap; }
.kr-ts-shift-headtext { min-width: 0; }
.kr-ts-shift-title { font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.kr-ts-shift-sub {
  font-size: 11px; color: var(--ink-soft); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kr-ts-shift-head .kr-badge { flex: none; padding: 2px 7px; font-size: 10px; }

/* Native <input type="time"> has a fixed intrinsic width and cannot shrink
   to half a column, so the two fields stack instead of sitting side by side. */
.kr-ts-actuals { display: flex; flex-direction: column; gap: 5px; }
.kr-ts-actual { display: flex; align-items: center; gap: 6px; min-width: 0; }
.kr-ts-actual > span {
  flex: none; width: 26px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; color: var(--ink-faint);
}
.kr-ts-actual input { flex: 1; min-width: 0; height: 30px; font-size: 12px; padding: 0 7px; }

.kr-ts-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.kr-ts-actions .kr-btn { flex: 1 1 auto; min-width: 0; }

.kr-ts-total, .kr-ts-status {
  padding: 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  background: var(--surface);
  min-width: 0;
}
.kr-ts-status { border-right: none; }

/* ============================================================
   Structural classes used in the views that previously had no CSS
   at all (so those areas fell back to unstyled block layout).
   ============================================================ */

/* Page header actions cluster */
.kr-page-actions, .kr-modern-actions {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
}
.kr-modern-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.kr-h1 { font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -0.01em; margin: 0; }

/* Forms */
.kr-form { display: flex; flex-direction: column; gap: 12px; }
.kr-form-inline { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.kr-form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.kr-form-row-wide, .kr-form-row--full, .kr-user-wide, .kr-span2 { grid-column: 1 / -1; }
.kr-filters { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.kr-switch-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kr-select-sm { height: 34px; font-size: 12.5px; padding: 0 10px; }
.kr-textarea {
  width: 100%;
  min-height: 96px;
  padding: 10px 13px;
  resize: vertical;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background-color: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13.5px;
}
.kr-textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.kr-textarea::placeholder { color: var(--ink-faint); }

/* Switch built as <label class="kr-switch"><input><span class="kr-slider"></span></label> */
.kr-switch > input[type="checkbox"]:not(.kr-toggle) { position: absolute; opacity: 0; width: 0; height: 0; }
.kr-slider {
  position: relative;
  display: inline-block;
  width: 40px; height: 24px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background-color .15s ease;
  flex: none;
  cursor: pointer;
}
.kr-slider::before {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
}
.kr-switch > input[type="checkbox"]:checked + .kr-slider { background: var(--brand); }
.kr-switch > input[type="checkbox"]:checked + .kr-slider::before { transform: translateX(16px); }
.kr-switch > input[type="checkbox"]:focus-visible + .kr-slider { box-shadow: 0 0 0 3px var(--brand-light); }

/* Two-column working layouts (Rota sidebar, Availability, Templates) */
.kr-rota-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.kr-rota-main { min-width: 0; }
.kr-rota-side { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 1100px) { .kr-rota-layout { grid-template-columns: 1fr; } }

.kr-summary-title { font-family: var(--font-display); font-weight: 700; font-size: 14px; margin-bottom: 8px; }

/* Rota toolbar */
.kr-rota-toolbar { display: flex; flex-direction: column; gap: 12px; }
.kr-rota-toolbar-head, .kr-rota-toolbar-main, .kr-rota-toolbar-subrow {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
}
.kr-rota-toolbar-head { justify-content: space-between; }
.kr-rota-toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.kr-rota-week-picker { display: flex; align-items: center; gap: 8px; }
.kr-rota-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.kr-rota-emp-text { min-width: 0; overflow: hidden; }
.kr-rota-load-wrap { display: flex; align-items: center; gap: 8px; }
.kr-rota-assignment { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* Users / People / accordion bodies */
.kr-user-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; align-items: start; }
.kr-user-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.kr-user-body, .kr-person-body, .kr-day-body { padding: 4px 0 2px; }
.kr-user-actions-row, .kr-actions-row, .kr-table-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.kr-user-idline { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.kr-user-idval { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink); }
@media (max-width: 820px) { .kr-user-grid2 { grid-template-columns: 1fr; } }

/* Nested tables inside accordions */
.kr-table-wrap-inner { border-radius: var(--radius-md); }
.kr-table-inner { font-size: 13px; }

/* Dashboard / My Profile / Compliance modifiers */
.kr-dash-chart-card, .kr-dash-panel-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.kr-dash-field, .kr-dash-site-field, .kr-dash-week-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kr-myprofile-form { display: flex; flex-direction: column; gap: 14px; }
.kr-myprofile-hero-copy { min-width: 0; }
.kr-compliance-grid--top { align-items: start; }
.kr-form-row--mfa { display: flex; flex-direction: column; gap: 8px; }

/* Toolbar action clusters on the modern pages */
.kr-payroll-toolbar-actions, .kr-reports-toolbar-actions, .kr-timesheets-toolbar-row {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
}
.kr-timesheets-toolbar-row { justify-content: space-between; width: 100%; }
.kr-reports-check-field { display: flex; flex-direction: column; gap: 6px; justify-content: flex-end; }
.kr-modern-chip {
  display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px;
  background: var(--surface-alt); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
}

/* Leave approve/reject modal detail cards */
.kr-leave-modal-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  min-width: 0;
}
.kr-leave-modal-card > span,
.kr-leave-modal-card > .kr-label {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-faint); margin-bottom: 4px;
}
.kr-leave-modal-card strong { color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }

/* ============================================================
   File input — replaces the browser's default
   "Choose file | No file chosen" control.
   The .kr-file wrapper is added by public/js/app.js; the
   ::file-selector-button rules below style the raw control too,
   so it still looks right before/without JS.
   ============================================================ */
.kr-file {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  transition: border-color .12s ease, background-color .12s ease;
  min-width: 0;
  width: 100%;
}
.kr-file:hover, .kr-file.is-dragover { border-color: var(--brand); background: var(--brand-tint); }
.kr-file.is-filled { border-style: solid; border-color: var(--brand-light); background: var(--brand-tint); }

/* The real input sits invisibly on top so clicks and keyboard focus,
   form submission and `required` validation all behave normally. */
.kr-file > input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.kr-file > input[type="file"]:focus-visible ~ .kr-file-face { box-shadow: 0 0 0 3px var(--brand-light); border-radius: var(--radius-sm); }

.kr-file-face { display: flex; align-items: center; gap: 12px; min-width: 0; width: 100%; pointer-events: none; }
.kr-file-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
}
.kr-file-btn svg { width: 14px; height: 14px; }
.kr-file-name {
  min-width: 0;
  font-size: 13px;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kr-file.is-filled .kr-file-name { color: var(--ink); font-weight: 600; }
.kr-file.is-filled .kr-file-btn { background: var(--surface); border-color: var(--brand-light); }

/* Fallback styling for any file input not enhanced by JS */
input[type="file"]:not(.kr-file > input) {
  padding: 7px 10px;
  height: auto;
  font-size: 13px;
  color: var(--ink-soft);
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  height: 30px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-alt); border-color: var(--ink-faint); }

/* ============================================================
   People page cards
   ============================================================ */
.kr-people-cardgrid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 18px 24px;
  align-items: start;
}
.kr-people-cardcol { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.kr-people-cardcol .kr-section-title { margin-bottom: 2px; }
.kr-people-danger {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  margin-top: 4px;
}
.kr-people-danger .kr-actions-row form { margin: 0; }
@media (max-width: 900px) { .kr-people-cardgrid { grid-template-columns: 1fr; } }

/* Person avatar used directly on an <img> (People page summary) */
img.kr-avatar {
  width: 42px; height: 42px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  flex: none;
  display: block;
}
.kr-person-acc > .kr-acc-summary { padding: 14px 16px; gap: 14px; }

/* ============================================================
   Log viewers
   The global `pre` rule (light background + border) was overriding the
   dark log panels, which is why the log text was unreadable on both the
   Admin Tools and System Logs pages.
   ============================================================ */
.kr-log-viewer pre,
.kr-admintools-logpanel pre {
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.kr-admintools-logpanel {
  background: #0C1119 !important;
  border: 1px solid #1E2733 !important;
}
.kr-admintools-logpanel pre { color: #DCE3EC; padding: 18px; max-height: 420px; overflow: auto; }

/* ============================================================
   Day picker chips (Availability rules)
   ============================================================ */
.kr-daychip { position: relative; display: inline-flex; cursor: pointer; }
.kr-daychip input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.kr-daychip > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.kr-daychip:hover > span { border-color: var(--brand); color: var(--ink); }
.kr-daychip input[type="checkbox"]:checked + span {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.kr-daychip input[type="checkbox"]:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-light); }

/* ============================================================
   Rota — Assign staff panel
   ============================================================ */
.kr-rota-assignment .kr-staff-grid { width: 100%; }
.kr-rota-assignment > .kr-inline { width: 100%; align-items: flex-start; }

/* ============================================================
   Explainer / help panel (Compliance "how it works", etc.)
   ============================================================ */
.kr-explain { display: flex; flex-direction: column; gap: 14px; }
.kr-explain-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.kr-explain-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
}
.kr-explain-item h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}
.kr-explain-item p { margin: 0; font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }
.kr-explain-item code { font-size: 11.5px; }

/* ============================================================
   Uniform internal spacing
   Panels lay their children out in a column with a consistent gap, so
   spacing no longer depends on ad-hoc inline margins (which differed
   from page to page).
   ============================================================ */
.kr-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.kr-panel > .kr-panel-head { margin-bottom: 0; }
.kr-panel > .kr-divider { margin: 0; }
/* The timesheets board is a scroll container holding a single grid */
.kr-panel.kr-modern-board { display: block; }

/* ============================================================
   Fixes for panels that carry a second layout class
   .kr-filters set align-items:flex-end; combined with .kr-panel's
   column direction that right-aligned the whole panel's contents,
   leaving a large empty gutter on the left (Availability, Templates).
   ============================================================ */
.kr-panel.kr-filters { align-items: stretch; gap: 14px; }

/* Two-column working layouts need the same section rhythm as a page */
.kr-rota-main { display: flex; flex-direction: column; gap: 20px; }

/* ============================================================
   Rota — week controls
   ============================================================ */
.kr-rota-actiongrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.kr-rota-actionblock {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
}
.kr-rota-actionhead { display: flex; flex-direction: column; gap: 2px; }
.kr-rota-actionhead .kr-help { margin-top: 0; }
.kr-rota-actionblock .kr-modern-button-row { gap: 8px; }
.kr-rota-actionblock .kr-rota-check { font-size: 12.5px; color: var(--ink-soft); }

/* ============================================================
   Notifications page
   ============================================================ */
.kr-notifications-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.kr-notifications-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.kr-notifications-filters .kr-input { min-width: 200px; width: auto; }

.kr-nc-list { display: flex; flex-direction: column; gap: 10px; }
.kr-nc-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color .12s ease, background-color .12s ease;
}
.kr-nc-item:hover { border-color: var(--border-strong); }
.kr-nc-item.is-unread {
  border-left-color: var(--brand);
  background: var(--brand-tint);
}
.kr-nc-item-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.kr-nc-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kr-nc-item-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.kr-nc-item.is-unread .kr-nc-item-title { color: var(--brand-dark); }
.kr-nc-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--brand); flex: none; }
.kr-nc-item-body { font-size: 13px; color: var(--ink-soft); white-space: pre-wrap; word-break: break-word; }
.kr-nc-item-time { font-size: 11.5px; color: var(--ink-faint); }
.kr-nc-item-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.kr-nc-item .kr-badge { text-transform: capitalize; }

@media (max-width: 720px) {
  .kr-nc-item { flex-direction: column; align-items: stretch; }
  .kr-nc-item-actions { justify-content: flex-start; }
  .kr-notifications-filters .kr-input { min-width: 0; flex: 1 1 160px; }
}

/* Users list: the name was inline-styled color:#0f172a (near-black), which
   is unreadable on the dark theme. */
.kr-user-listname { font-size: 16px; font-weight: 800; color: var(--ink); }
.kr-user-acc summary .kr-avatar-ph { width: 42px; height: 42px; }

/* ============================================================
   Toasts
   ============================================================ */
.kr-toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}
.kr-toast {
  pointer-events: auto;
  position: relative;
  padding: 13px 38px 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
}
.kr-toast.is-in { opacity: 1; transform: translateY(0); }
.kr-toast.is-leaving { opacity: 0; transform: translateY(8px); }
.kr-toast.is-clickable { cursor: pointer; }
.kr-toast.is-clickable:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg), 0 0 0 3px var(--brand-light); }
.kr-toast-title { font-family: var(--font-display); font-weight: 700; font-size: 13.5px; margin-bottom: 3px; }
.kr-toast-body { font-size: 12.5px; color: var(--ink-soft); line-height: 1.45; word-break: break-word; }
.kr-toast-close {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-faint);
  font-size: 16px; line-height: 1; cursor: pointer;
}
.kr-toast-close:hover { background: var(--surface-alt); color: var(--ink); }
.kr-toast-ok    { border-left-color: var(--success); }
.kr-toast-warn  { border-left-color: var(--warning); }
.kr-toast-error { border-left-color: var(--danger); }

@media (max-width: 600px) {
  .kr-toast-host { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ============================================================
   Small screens (phones)
   Care staff mostly open this on a phone. The data grids stay
   horizontally scrollable — that's correct for a rota — but the
   sticky name column and cell widths are reduced so a useful
   amount of the week is visible, and all the surrounding chrome
   stacks instead of overflowing.
   ============================================================ */
@media (max-width: 600px) {
  .kr-content { padding: 12px 10px 28px; }
  .kr-header { padding: 0 10px; }

  /* headings and page furniture */
  .kr-page, .kr-modern-page { gap: 14px; }
  .kr-page-title, .kr-h1 { font-size: 20px; }
  .kr-page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .kr-page-actions, .kr-modern-actions { width: 100%; }
  .kr-page-actions .kr-btn, .kr-modern-actions .kr-btn { flex: 1 1 auto; }

  /* panels tighten up */
  .kr-panel { padding: 14px; gap: 12px; }

  /* stat cards go single-file */
  .kr-stat-row, .kr-modern-statgrid, .kr-grid,
  .kr-modern-toolbar-grid, .kr-grid-form, .kr-create-grid {
    grid-template-columns: 1fr !important;
  }
  .kr-split-panels { grid-template-columns: 1fr; }
  .kr-form-grid, .kr-user-grid2, .kr-people-cardgrid { grid-template-columns: 1fr; }

  /* toolbars stack rather than squeeze */
  .kr-filters, .kr-form-inline, .kr-modern-toolbar-row,
  .kr-rota-toolbar-head, .kr-rota-toolbar-main, .kr-timesheets-toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }
  .kr-filters > *, .kr-form-inline > * { width: 100%; }

  /* action rows: full-width tap targets */
  .kr-actions-row .kr-btn, .kr-form-actions .kr-btn, .kr-modern-button-row .kr-btn {
    flex: 1 1 auto;
    min-height: 40px;
  }

  /* modals fill the screen */
  .kr-modal { width: 100%; max-height: 92vh; overflow-y: auto; }
  .kr-modal-grid, .kr-leave-modal-grid { grid-template-columns: 1fr; }

  /* segmented control and day chips wrap */
  .kr-seg { width: 100%; }
  .kr-daychip > span { min-width: 44px; padding: 0 10px; }

  /* tables stay readable */
  .kr-table { font-size: 12.5px; }
  .kr-table th, .kr-table td { padding: 8px 10px; }
}

/* Rota + timesheets grids: keep the week usable on a narrow screen */
@media (max-width: 700px) {
  .kr-rota-grid {
    grid-template-columns: 116px repeat(7, minmax(104px, 1fr));
    min-width: 844px;
  }
  .kr-rota-emp { min-width: 0; padding: 8px; gap: 6px; }
  .kr-rota-emp-name { font-size: 12px; }
  .kr-rota-emp .kr-avatar, .kr-rota-emp img { width: 26px; height: 26px; }

  .kr-ts-grid {
    grid-template-columns: 124px repeat(7, minmax(150px, 1fr)) 70px 92px;
    min-width: 1336px;
  }
  .kr-ts-employee { padding: 8px; gap: 6px; }
  .kr-ts-avatar { width: 26px; height: 26px; font-size: 11px; }
  .kr-ts-name { font-size: 12px; }

  /* make it obvious the grid scrolls sideways */
  .kr-modern-board, .kr-rota-scroll { -webkit-overflow-scrolling: touch; }
}

/* Very narrow (≤380px) */
@media (max-width: 380px) {
  .kr-content { padding: 10px 8px 24px; }
  .kr-rota-grid { grid-template-columns: 96px repeat(7, minmax(96px, 1fr)); min-width: 768px; }
  .kr-toast-host { left: 8px; right: 8px; bottom: 8px; }
}

/* Pager for long list pages */
.kr-pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-alt);
}
.kr-pager-info { font-size: 12.5px; color: var(--ink-soft); }
.kr-pager-links { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 600px) {
  .kr-pager { flex-direction: column; align-items: stretch; }
  .kr-pager-links .kr-btn { flex: 1 1 auto; }
}

/* The notification opened from the bell — highlighted so it is obvious which
   one you clicked, since the list shows the full history around it. */
.kr-nc-item.is-focused {
  border-color: var(--brand);
  border-left-width: 4px;
  box-shadow: 0 0 0 3px var(--brand-light);
}
.kr-nc-item.is-focused::after {
  content: 'Opened from your notifications';
  display: block;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--brand);
  font-weight: 600;
}
