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

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;

  /* Brand: navy + blue */
  --navy: #142b4a;
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;

  --sidebar-bg: #142b4a;
  --sidebar-bg-hover: rgba(255, 255, 255, 0.07);
  --sidebar-text: #b4c2d8;
  --sidebar-border: rgba(255, 255, 255, 0.09);

  --text: #172033;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f5f7fb;
  --surface: #ffffff;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --error: #dc2626;
  --error-bg: #fee2e2;
  --info: #0284c7;
  --info-bg: #e0f2fe;

  --tile-blue: #2563eb; --tile-blue-bg: #dbeafe;
  --tile-green: #16a34a; --tile-green-bg: #dcfce7;
  --tile-red: #dc2626; --tile-red-bg: #fee2e2;
  --tile-amber: #d97706; --tile-amber-bg: #fef3c7;
  --tile-purple: #0284c7; --tile-purple-bg: #e0f2fe;
  --tile-pink: #475569; --tile-pink-bg: #e2e8f0;

  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(20, 43, 74, 0.05);
  --shadow: 0 2px 6px rgba(20, 43, 74, 0.08);
  --shadow-md: 0 4px 12px rgba(20, 43, 74, 0.12);
  --shadow-lg: 0 16px 32px -8px rgba(20, 43, 74, 0.22);

  --sidebar-width: 260px;
}
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy);
  padding: 1.5rem;
}
.login-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}
.login-brand .mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.login-brand .company { font-weight: 700; font-size: 1.1rem; color: var(--text); line-height: 1.2; }
.login-brand .tagline { font-size: 0.78rem; color: var(--muted); }
.login-box h1 { display: none; }

/* Split login layout */
.login-split-page { margin: 0; background: var(--bg); }
.login-split { display: flex; min-height: 100vh; }
.login-panel-left {
  flex: 1.1;
  background:
    radial-gradient(circle at 85% 10%, rgba(59, 130, 246, 0.28), rgba(0,0,0,0) 45%),
    linear-gradient(165deg, #142b4a 0%, #0f2240 100%);
  color: #fff;
  padding: 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-brand-lg { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 2.5rem; }
.login-brand-lg .mark {
  width: 52px; height: 52px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.05rem; flex-shrink: 0;
}
.login-brand-lg .company { font-weight: 700; font-size: 1.3rem; }
.login-brand-lg .tagline { font-size: 0.82rem; color: #b4c2d8; }
.login-panel-left h2 { font-size: 2.2rem; font-weight: 800; line-height: 1.2; margin: 0 0 1rem; max-width: 420px; }
.login-panel-left p { color: #cbd5e6; font-size: 1rem; line-height: 1.6; max-width: 400px; }
.login-panel-right {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  background: var(--bg);
}
.login-panel-right .login-box { box-shadow: none; border: 1px solid var(--border); }
.login-title { font-size: 1.6rem; font-weight: 700; margin: 0 0 0.25rem; display: block !important; }
.login-subtitle { margin: 0 0 1.5rem; }

@media (max-width: 900px) {
  .login-panel-left { display: none; }
  .login-panel-right { padding: 1.25rem; }
}

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform 0.2s ease;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.35rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand .mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; letter-spacing: -0.02em;
  flex-shrink: 0;
}
.sidebar-brand .name { color: #fff; font-weight: 600; font-size: 0.92rem; line-height: 1.25; }
.sidebar-brand .sub { display: block; color: var(--sidebar-text); font-size: 0.68rem; font-weight: 400; }

.sidebar-nav { flex: 1; padding: 0.75rem; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.86rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.sidebar-nav a:hover { background: var(--sidebar-bg-hover); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: var(--brand-600); color: #fff; }
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--sidebar-border); }
.sidebar-user { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; }
.sidebar-user .avatar {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--brand-500); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.78rem; flex-shrink: 0;
}
.sidebar-user .info { line-height: 1.25; min-width: 0; }
.sidebar-user .name { color: #fff; font-size: 0.83rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .role { font-size: 0.68rem; color: var(--sidebar-text); text-transform: uppercase; letter-spacing: 0.04em; }
.sidebar-footer .logout {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--sidebar-text); font-size: 0.82rem; font-weight: 500;
}
.sidebar-footer .logout svg { width: 16px; height: 16px; }
.sidebar-footer .logout:hover { color: #fff; text-decoration: none; }

.sidebar-backdrop { display: none; }

.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar-width); }
.mobile-topbar { display: none; }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 25;
}
.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search svg {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
.topbar-search input { padding-left: 2.25rem; background: var(--bg); border-color: transparent; }
.topbar-search input:focus { background: var(--surface); }
.topbar-spacer { flex: 1; }
.topbar-icons { display: flex; align-items: center; gap: 0.4rem; }
.topbar-icon-btn {
  width: 38px; height: 38px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); position: relative; flex-shrink: 0;
  background: transparent; border: none; box-shadow: none;
}
.topbar-icon-btn:hover { background: var(--bg); text-decoration: none; }
.topbar-icon-btn svg { width: 19px; height: 19px; }
.topbar-icon-btn .dot {
  position: absolute; top: 6px; right: 7px;
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--error); border: 2px solid var(--surface);
}
.topbar-user { display: flex; align-items: center; gap: 0.6rem; padding-left: 0.5rem; }
.topbar-user .avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--brand-500); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.8rem; flex-shrink: 0;
}
.topbar-user .info { line-height: 1.2; }
.topbar-user .name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.topbar-user .role { font-size: 0.72rem; color: var(--muted); }
@media (max-width: 900px) { .topbar { display: none; } }
.sidebar-mobile-only { display: none; }
@media (max-width: 900px) { .sidebar-mobile-only { display: flex; } }

.content { padding: 2rem; max-width: 1200px; margin: 0 auto; }
.content > h2:first-child { margin-top: 0; }

/* Forms */
form { display: flex; flex-direction: column; gap: 0.9rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; font-weight: 500; color: var(--text); }
input, select, textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
.password-field { position: relative; }
.password-field input { padding-right: 2.5rem; width: 100%; }
.password-toggle {
  position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; box-shadow: none; color: var(--muted);
  width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;
}
.password-toggle:hover { color: var(--text); background: var(--bg); border-radius: var(--radius-sm); }
.password-toggle svg { width: 17px; height: 17px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid > * { min-width: 0; }
.form-stack { display: flex; flex-direction: column; gap: 0.9rem; }
#hours-section { display: flex; flex-direction: column; gap: 0.9rem; }
input, select, textarea { max-width: 100%; }
input[type="file"] { width: 100%; min-width: 0; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 0.25rem; }

button, .btn {
  background: var(--brand-600);
  color: #fff;
  border: none;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
button:hover, .btn:hover { background: var(--brand-700); text-decoration: none; box-shadow: var(--shadow); }
button:active, .btn:active { transform: translateY(1px); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--error); }
.btn-danger:hover { background: #b91c1c; }

/* Cards / panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.panel h2 { margin-top: 0; font-size: 1.05rem; font-weight: 600; }
.panel .toolbar h2 { font-size: 1.05rem; font-weight: 600; margin: 0; }
.panel h3 { font-size: 0.95rem; font-weight: 600; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.action-grid .btn {
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.5rem 1rem;
  font-size: 0.95rem;
}
.action-grid .btn svg { width: 24px; height: 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.stat-card .icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: var(--brand-50);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  order: 2;
}
.stat-card .icon svg { width: 20px; height: 20px; }
.stat-card .body { order: 1; }
.stat-card .value { font-size: 1.85rem; font-weight: 700; line-height: 1.15; color: var(--text); }
.stat-card .label { color: var(--muted); font-size: 0.82rem; margin-top: 0.15rem; }
.stat-card .label a { color: inherit; }
.stat-card .label .unavailable { color: var(--muted); font-style: italic; }

.stat-card--blue .icon { background: var(--tile-blue-bg); color: var(--tile-blue); }
.stat-card--green .icon { background: var(--tile-green-bg); color: var(--tile-green); }
.stat-card--red .icon { background: var(--tile-red-bg); color: var(--tile-red); }
.stat-card--amber .icon { background: var(--tile-amber-bg); color: var(--tile-amber); }
.stat-card--purple .icon { background: var(--tile-purple-bg); color: var(--tile-purple); }
.stat-card--pink .icon { background: var(--tile-pink-bg); color: var(--tile-pink); }

.chart-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 0.75rem; font-size: 0.8rem; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.chart-legend .dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; }

.avatar-sm {
  width: 32px; height: 32px; border-radius: 999px;
  object-fit: cover; border: 1px solid var(--border);
  background: var(--bg); flex-shrink: 0;
}
.avatar-sm-fallback {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--brand-100); color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.72rem; flex-shrink: 0;
}
.cell-with-avatar { display: flex; align-items: center; gap: 0.6rem; }

/* Profile tabs */
.profile-header { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.profile-header .photo-preview { margin: 0; }
.profile-avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; flex-shrink: 0; box-shadow: var(--shadow-sm); }
.profile-avatar--initial { display: inline-flex; align-items: center; justify-content: center; background: var(--brand-100); color: var(--brand-700); font-size: 2rem; font-weight: 700; }
.profile-facts { flex: 1; min-width: 260px; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.9rem 1.5rem; }
.profile-facts dt { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.profile-facts dd { margin: 0.15rem 0 0; font-size: 0.92rem; font-weight: 500; }
.profile-qr { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; margin-left: auto; }
@media (max-width: 640px) { .profile-qr { margin-left: 0; } }
.tab-nav { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; }
.tab-nav button {
  background: none; border: none; box-shadow: none; color: var(--muted);
  padding: 0.7rem 1rem; font-weight: 600; font-size: 0.85rem;
  border-radius: 0; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab-nav button:hover { background: var(--bg); color: var(--text); }
.tab-nav button.active { color: var(--brand-600); border-bottom-color: var(--brand-600); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.87rem; }
th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; background: var(--bg); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
/* Row actions: compact and inline. (Never display:flex on a <td> — it breaks the table row.) */
td.table-actions { white-space: nowrap; text-align: right; }
td.table-actions > a { font-weight: 600; font-size: 0.85rem; margin-left: 0.6rem; vertical-align: middle; }
td.table-actions > a:first-child { margin-left: 0; }
td.table-actions form { display: inline-flex; gap: 0.4rem; align-items: center; margin-left: 0.6rem; vertical-align: middle; }
div.table-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
td button:not(.tab-btn):not(.password-toggle), td .btn { padding: 0.32rem 0.7rem; font-size: 0.78rem; white-space: nowrap; }
/* Key/value detail tables (rows of <th> label + <td> value, no header row) */
tbody th { background: transparent; width: 210px; white-space: nowrap; vertical-align: top; }
tbody tr:hover th { background: transparent; }

/* Bulk-add spreadsheet-style table */
.bulk-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; }
.bulk-table { width: auto; min-width: 100%; }
.bulk-table th { white-space: nowrap; }
.bulk-table td { padding: 0.35rem; }
.bulk-table input, .bulk-table select { width: 100%; min-width: 0; padding: 0.4rem 0.5rem; font-size: 0.83rem; }
.bulk-table tr:hover td { background: transparent; }
.bulk-row--error td { background: var(--error-bg); }
.bulk-row--error:hover td { background: var(--error-bg); }
.bulk-row-error-msg td { color: var(--error); font-size: 0.8rem; padding: 0.15rem 0.85rem 0.6rem; border-bottom: 1px solid var(--border); }
.bulk-table .remove-row { padding: 0.3rem 0.55rem; color: var(--error); }
#paste-box { width: 100%; margin-top: 0.5rem; }

/* Summary strip: clickable status counts above a list table */
.summary-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 1.25rem; }
.summary-chip {
  display: inline-flex; align-items: baseline; gap: 0.4rem;
  padding: 0.5rem 0.95rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  color: var(--text); font-size: 0.82rem; text-decoration: none;
}
.summary-chip strong { font-size: 1.15rem; font-weight: 700; }
.summary-chip.active { border-color: var(--brand-500); background: var(--brand-50, var(--bg)); color: var(--brand-700, var(--text)); }
.summary-chip--active strong { color: var(--success); }
.summary-chip--bench strong { color: var(--warning); }
.summary-chip--inactive strong { color: var(--muted); }
@media (max-width: 640px) {
  .summary-strip { gap: 0.5rem; }
  .summary-strip .muted-note { margin-left: 0 !important; width: 100%; order: 5; }
}
td .btn-secondary[data-confirm], td button[data-confirm].btn-secondary { color: var(--error); }
td .btn-secondary[data-confirm]:hover { background: #fef2f2; border-color: #fecaca; }
.reject-form input[type="text"] { padding: 0.4rem 0.6rem; }

.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.badge-active, .badge-approved { background: var(--success-bg); color: var(--success); }
.badge-bench, .badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-inactive { background: #f1f5f9; color: var(--muted); }
.badge-rejected { background: var(--error-bg); color: var(--error); }

.muted-note { color: var(--muted); font-size: 0.85rem; margin-top: -0.4rem; }
/* A hint inside a field label is shown as helper text under the input, so side-by-side inputs stay level. */
label > .muted-note, label .muted-note[style] { order: 5; margin: 0.1rem 0 0 !important; font-size: 0.75rem; font-weight: 400; }

.calc-preview-box {
  margin: 0.4rem 0 1rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--muted);
}

.photo-preview {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 0.35rem;
}

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.toolbar h2 { font-size: 1.35rem; font-weight: 700; }
.filter-bar {
  display: flex; flex-direction: row; gap: 0.75rem 1rem; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 1.25rem; padding: 0.9rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.filter-bar label {
  flex-direction: column; align-items: stretch; gap: 0.3rem;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.filter-bar input, .filter-bar select { min-width: 150px; font-size: 0.875rem; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text); }
.filter-bar input[type="text"], .filter-bar input[type="search"] { min-width: 240px; }
.filter-bar > button, .filter-bar > .btn { align-self: flex-end; }
@media (max-width: 640px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input, .filter-bar select, .filter-bar input[type="text"] { min-width: 0; width: 100%; }
  .filter-bar > button, .filter-bar > .btn { align-self: stretch; }
}

.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.88rem;
  border-left: 3px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.alert-error { background: var(--error-bg); color: var(--error); border-color: var(--error); }

.empty-state { color: var(--muted); padding: 2.5rem 1rem; text-align: center; font-size: 0.9rem; }

/* Attendance state picker (segmented pill control) */
.state-picker { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.state-pill { position: relative; width: auto; }
.state-pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.state-pill span {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.6rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.88rem; font-weight: 600; color: var(--text);
  cursor: pointer; user-select: none; transition: all 0.12s ease;
}
.state-pill span:hover { border-color: var(--brand-500); }
.state-pill--present.active span { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.state-pill--half.active span { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.state-pill--absent.active span { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.state-pill--leave.active span { background: var(--brand-50); border-color: var(--brand-500); color: var(--brand-700); }

/* Site picker (chip-based multi-select) */
.site-picker { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; background: var(--bg); }
.site-picker-toolbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.site-picker-search { position: relative; flex: 1; min-width: 220px; }
.site-picker-search svg { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.site-picker-search input { width: 100%; padding-left: 2.1rem; background: var(--surface); }
.site-picker-count { font-size: 0.78rem; color: var(--muted); white-space: nowrap; font-weight: 600; }
.site-picker-body { max-height: 320px; overflow-y: auto; padding-right: 0.25rem; }
.site-group { margin-bottom: 1rem; }
.site-group:last-child { margin-bottom: 0; }
.site-group-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.5rem; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.site-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.site-chip-label {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.45rem 0.85rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.82rem; font-weight: 500; color: var(--text);
  cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  user-select: none;
}
.site-chip-label:hover { border-color: var(--brand-500); background: var(--brand-50); }
.site-chip.selected .site-chip-label { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.site-chip-check { width: 12px; height: 12px; display: none; flex-shrink: 0; }
.site-chip.selected .site-chip-check { display: inline-block; }

/* Searchable picker (combobox) */
.combobox { position: relative; width: 100%; }
.combobox input[type="text"] { width: 100%; box-sizing: border-box; }
.combobox-results {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 30;
}
.combobox-results.open { display: block; }
.combobox-option {
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 40px;
}
.combobox-option:hover, .combobox-option.active { background: var(--bg); }
.combobox-option .combobox-sub { color: var(--muted); font-size: 0.78rem; flex-shrink: 0; }
.combobox-empty { padding: 0.65rem 0.85rem; color: var(--muted); font-size: 0.85rem; }

/* Sidebar collapses to an off-canvas drawer */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 25;
  }
  .mobile-topbar .brand { font-weight: 600; font-size: 0.92rem; flex: 1; }
  .menu-btn {
    background: none; border: 1px solid var(--border); box-shadow: none;
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    color: var(--text); font-size: 1.1rem; padding: 0;
  }
  .menu-btn:hover { background: var(--bg); }

  .sidebar-backdrop.open {
    display: block;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 35;
  }
}

/* Landing page */
.landing {
  --ink: #050505;
  --card-dark: #15171d;
  background: var(--surface);
}

.landing-brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.05rem; color: inherit; }
.landing-brand .mark {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.82rem; letter-spacing: -0.02em;
  flex-shrink: 0;
}

.landing-nav {
  position: sticky; top: 0; z-index: 20;
  background: rgba(5, 5, 5, 0.6);
  backdrop-filter: blur(10px);
  color: #fff;
}
.landing-nav-inner { max-width: 1100px; margin: 0 auto; padding: 1rem 1.5rem; display: flex; align-items: center; gap: 2rem; }
.landing-nav-inner nav { display: flex; gap: 1.5rem; flex: 1; }
.landing-nav-inner nav a { color: rgba(255,255,255,0.72); font-weight: 500; font-size: 0.92rem; }
.landing-nav-inner nav a:hover { color: #fff; text-decoration: none; }
.landing-nav-inner .btn { font-weight: 700; }

.landing-eyebrow {
  text-align: center; text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 0.78rem; font-weight: 700; color: var(--brand-500);
  margin: 0 0 0.6rem;
}
.landing-section-dark .landing-eyebrow { color: var(--brand-500); }

.landing-hero {
  background:
    radial-gradient(circle at 82% 18%, rgba(59, 130, 246, 0.28), rgba(0,0,0,0) 32%),
    linear-gradient(135deg, var(--ink) 0%, #111827 60%, #0b1120 100%);
  color: #fff;
  padding: 7rem 1.5rem 5rem;
  text-align: center;
}
.landing-hero-inner { max-width: 700px; margin: 0 auto; }
.landing-hero h1 { font-size: 3rem; font-weight: 800; line-height: 1.15; margin: 0 0 1.1rem; letter-spacing: -0.01em; }
.landing-hero p { font-size: 1.08rem; color: #cbd5e1; line-height: 1.65; margin: 0 0 2.25rem; }
.landing-hero-actions { display: flex; gap: 0.85rem; justify-content: center; flex-wrap: wrap; }

.btn-lg { padding: 0.9rem 1.7rem; font-size: 1rem; font-weight: 800; box-shadow: 0 16px 34px rgba(37, 99, 235, 0.34); }
.btn-lg:hover { box-shadow: 0 18px 38px rgba(37, 99, 235, 0.42); }
.landing-hero .btn-secondary, .landing-nav .btn-secondary {
  background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.22); box-shadow: none;
}
.landing-hero .btn-secondary:hover, .landing-nav .btn-secondary:hover { background: rgba(255,255,255,0.18); }

.landing-section { max-width: 1100px; margin: 0 auto; padding: 5rem 1.5rem; }
.landing-section h2 { font-size: 2rem; font-weight: 700; text-align: center; margin: 0 0 2.5rem; }
.landing-section-dark {
  background: var(--ink); color: #fff;
  max-width: none; padding: 4.5rem 1.5rem;
}
.landing-section-dark h2 { color: #fff; }
.landing-section-dark > * { max-width: 700px; margin-left: auto; margin-right: auto; }

.landing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.5rem; }
.landing-card {
  background: var(--card-dark); color: #fff;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius); padding: 1.75rem;
}
.landing-card-icon {
  width: 44px; height: 44px; border-radius: var(--radius);
  background: rgba(59, 130, 246, 0.15); color: var(--brand-500);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1.1rem;
}
.landing-card-icon svg { width: 22px; height: 22px; }
.landing-card h3 { font-size: 1.05rem; font-weight: 700; margin: 0 0 0.5rem; color: #fff; }
.landing-card p { color: rgba(255,255,255,0.62); font-size: 0.9rem; line-height: 1.55; margin: 0; }

.landing-checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1.1rem; }
.landing-checklist li { padding-left: 2rem; position: relative; font-size: 1rem; line-height: 1.5; color: rgba(255,255,255,0.85); }
.landing-checklist li::before {
  content: "✓"; position: absolute; left: 0; top: -0.05rem;
  width: 1.4rem; height: 1.4rem; border-radius: 999px;
  background: rgba(59, 130, 246, 0.18); color: var(--brand-500);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
}

.landing-contact-text { text-align: center; max-width: 560px; margin: 0 auto 2rem; color: var(--muted); }

.landing-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  max-width: 1100px; margin: 0 auto;
  color: var(--text);
}
.landing-footer p { color: var(--muted); font-size: 0.85rem; margin: 0; }

@media (max-width: 640px) {
  .content { padding: 1.1rem; }
  .login-box { padding: 2rem 1.5rem; }
  .form-grid, .action-grid { grid-template-columns: 1fr; }

  input, select, textarea, button, .btn { font-size: 16px; min-height: 44px; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .btn, .toolbar a.btn { text-align: center; }

  /* Dashboard tiles: two per row instead of one long column */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .stat-card { padding: 0.9rem; flex-direction: column-reverse; align-items: flex-start; gap: 0.6rem; }
  .stat-card .value { font-size: 1.5rem; }
  td button:not(.tab-btn):not(.password-toggle), td .btn { min-height: 34px; font-size: 13px; }

  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }

  .landing-nav-inner { flex-wrap: wrap; gap: 0.75rem; }
  .landing-nav-inner nav { order: 3; width: 100%; justify-content: center; gap: 1rem; }
  .landing-hero { padding: 3.5rem 1.25rem; }
  .landing-hero h1 { font-size: 1.7rem; }
  .landing-section { padding: 3rem 1.25rem; }
}

/* Daily attendance grid (reports/attendance_grid.php) */
.att-grid-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.att-grid { border-collapse: separate; border-spacing: 0; width: auto; min-width: 100%; font-size: 0.72rem; }
.att-grid th, .att-grid td { padding: 0; text-align: center; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.att-grid thead th { background: var(--brand-600); color: #fff; font-size: 0.68rem; font-weight: 600; text-transform: none; letter-spacing: 0; height: 22px; min-width: 30px; border-color: rgba(255,255,255,0.18); }
.att-grid tr.att-weeks th { background: var(--bg); color: var(--muted); height: 20px; border-color: var(--border); }
.att-grid th.g-sun-h { background: #dc2626; }
.att-grid th.att-total, .att-grid td.att-total { min-width: 46px; font-weight: 700; background: var(--brand-50); color: var(--text); }
.att-grid thead th.att-total { background: var(--brand-600); color: #fff; }
.att-grid .att-name { position: sticky; left: 0; z-index: 2; min-width: 250px; max-width: 340px; text-align: left; padding: 0 0.6rem; background: var(--surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.78rem; }
.att-grid thead th.att-name { background: var(--brand-600); color: #fff; z-index: 3; }
.att-grid tr.att-weeks th.att-name { background: var(--bg); }
.att-grid tfoot td { background: var(--brand-50); font-weight: 700; }
.att-grid tfoot td.att-name { background: var(--brand-50); }
.att-grid tr:hover td { background: inherit; }
.g-cell { height: 36px; min-width: 30px; }
.g-cell a { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 36px; color: var(--text); font-weight: 700; font-size: 0.7rem; line-height: 1.15; }
.g-cell a small { color: var(--warning); font-weight: 600; font-size: 0.6rem; }
.g-cell.g-sun { background: #fdf3f3; }
.g-present { background: #dcf5e8 !important; }
.g-half { background: #dbeafe !important; }
.g-absent { background: #fde2e2 !important; }
.g-leave { background: #fdf0d9 !important; }
.att-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; align-items: center; font-size: 0.8rem; margin-bottom: 1rem; color: var(--text); }
.g-key { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); vertical-align: -2px; margin-right: 4px; }

/* Insights: needs-attention list and data-health score */
.health-score { display: inline-flex; align-items: baseline; gap: 0.4rem; padding: 0.35rem 0.85rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--surface-2, var(--bg)); }
.health-score strong { font-size: 1.15rem; }
.health-score--good { background: var(--success-bg); color: var(--success); }
.health-score--ok { background: var(--warning-bg); color: var(--warning); }
.health-score--bad { background: var(--error-bg); color: var(--error); }
.issue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.issue { display: flex; align-items: flex-start; gap: 0.9rem; padding: 0.8rem 1rem; border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-sm); background: var(--surface); }
.issue--high { border-left-color: var(--error); }
.issue--medium { border-left-color: #d97706; }
.issue--low { border-left-color: var(--muted); }
.issue-count { font-size: 1.25rem; font-weight: 700; min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums; }
.issue-body { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.issue-body span { color: var(--muted); font-size: 0.84rem; }
.issue-details { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.82rem; }
.issue-details li { margin: 0.1rem 0; }
.issue .btn { align-self: center; flex-shrink: 0; }
@media (max-width: 640px) { .issue { flex-wrap: wrap; } .issue-count { text-align: left; } }

/* Wide content stays inside its own box instead of stretching the page */
.form-actions { flex-wrap: wrap; }
.chart-grid > * { min-width: 0; }
.chart-grid > .panel { overflow-x: auto; }
.table-scroll { overflow-x: auto; }

/* Daily calendar cells: D day shift, N night shift, hours = late / short day */
.g-day { background: #dcf5e8 !important; }
.g-night { background: #dbe4ff !important; }
.g-short { background: #fff4c4 !important; }
.g-cell.g-short a { font-size: 0.68rem; }
.att-grid td.g-ot { color: var(--warning); font-weight: 600; font-size: 0.66rem; }

/* Worked day with no shift linked: shown as plain hours, visibly different from a full D/N day */
.g-noshift { background: repeating-linear-gradient(45deg, #f1f1f6, #f1f1f6 4px, #e8e8f0 4px, #e8e8f0 8px) !important; }
.g-cell.g-noshift a { color: var(--muted); font-weight: 600; }
.fix-panel { border-left: 4px solid var(--warning); }

/* A day whose shift was worked out automatically (none was selected): dotted corner */
.g-cell.g-inferred { box-shadow: inset -5px -5px 0 -3px rgba(79, 70, 229, 0.0); background-image: radial-gradient(circle at calc(100% - 3px) 3px, rgba(79,70,229,0.55) 1.6px, transparent 2px); }
.att-grid tfoot td.att-total { font-size: 0.7rem; }

/* Daily summary (Record attendance page): companies that open to show their workers */
.day-picker { display: flex; align-items: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.day-picker label { flex-direction: row; align-items: center; gap: 0.4rem; }
.day-actions { margin-left: auto; display: inline-flex; gap: 0.4rem; }
.day-actions button { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.co-list { display: flex; flex-direction: column; gap: 0.6rem; }
.co-block { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.co-block > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.8rem 1rem; }
.co-block > summary::-webkit-details-marker { display: none; }
.co-block > summary::before { content: '\25B8'; color: var(--muted); margin-right: 0.5rem; transition: transform 0.15s ease; display: inline-block; }
.co-block[open] > summary::before { transform: rotate(90deg); }
.co-block[open] > summary { border-bottom: 1px solid var(--border); background: var(--bg); }
.co-block > summary:hover { background: var(--bg); }
.co-name { font-weight: 600; flex: 1; min-width: 160px; }
.co-stats { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; font-size: 0.8rem; color: var(--muted); }
.co-stats strong { color: var(--text); font-size: 0.95rem; }
.co-stats .co-ot strong { color: var(--warning); }
.co-stats .co-pending strong { color: var(--error); }
.co-block .table-scroll { padding: 0 0.25rem; }.co-list, .co-list > .co-block, #daily-summary { min-width: 0; max-width: 100%; }
.co-block .table-scroll { overflow-x: auto; max-width: 100%; }
.co-block table { min-width: 880px; }

/* Day picker: one tidy control — previous / date / next, then Today, all on one line */
form.day-picker { flex-direction: row; align-items: center; flex-wrap: nowrap; gap: 0.6rem; margin: 0; }
.day-nav { display: inline-flex; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); overflow: hidden; }
.day-nav:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.day-nav input[type="date"] { border: 0; border-radius: 0; box-shadow: none; background: transparent; padding: 0.5rem 0.7rem; width: 9.75rem; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.day-nav input[type="date"]:focus { box-shadow: none; }
.day-nav-btn { display: flex; align-items: center; justify-content: center; width: 2.4rem; color: var(--muted); border: 0; text-decoration: none; background: var(--surface); }
.day-nav-btn:first-child { border-right: 1px solid var(--border); }
.day-nav-btn:last-child { border-left: 1px solid var(--border); }
.day-nav-btn:hover { background: var(--bg); color: var(--brand-600); }
.day-today.is-today { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
@media (max-width: 640px) {
  form.day-picker { width: 100%; }
  .day-nav { flex: 1; }
  .day-nav input[type="date"] { flex: 1; width: auto; min-width: 0; }
}
/* Three linked pickers in one row on wide screens */
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .form-grid-3 { grid-template-columns: 1fr; } }

.co-name .co-company { display: block; font-weight: 400; font-size: 0.74rem; color: var(--muted); letter-spacing: 0.02em; }

/* Anything with the hidden attribute stays hidden, even if a layout rule gives it display */
[hidden] { display: none !important; }

/* One worker / Several workers switch */
.mode-switch { display: inline-flex; padding: 0.2rem; gap: 0.2rem; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; margin-bottom: 1rem; }
.mode-btn { background: transparent; color: var(--muted); border: 0; box-shadow: none; padding: 0.4rem 1.1rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600; min-height: 0; }
.mode-btn:hover { color: var(--text); background: transparent; }
.mode-btn.active { background: var(--surface); color: var(--brand-700); box-shadow: var(--shadow-sm); }

/* Several workers: the list */
.bulk-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1.25rem; flex-wrap: wrap; margin: 0.25rem 0 0.6rem; }
.bulk-toolbar-left, .bulk-toolbar-right { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.bulk-toolbar button { padding: 0.35rem 0.8rem; font-size: 0.8rem; min-height: 0; }
.bulk-toolbar input[type="text"] { width: 5.2rem; padding: 0.35rem 0.5rem; text-align: center; font-size: 0.85rem; }
.bulk-table { min-width: 760px; }
.bulk-table th { white-space: nowrap; }
.bulk-table td { padding: 0.45rem 0.6rem; vertical-align: middle; }
.bulk-table td.bulk-check { width: 2rem; }
.bulk-table input[type="text"] { width: 5.2rem; padding: 0.35rem 0.5rem; text-align: center; font-size: 0.85rem; }
.bulk-table .bulk-in, .bulk-table .bulk-out { width: 5.2rem; }
.bulk-name { font-weight: 600; }
.bulk-note { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.bulk-table tr.is-off .bulk-name { color: var(--muted); }
.bulk-table tr.is-locked { opacity: 0.55; }
.mini-pills { display: inline-flex; gap: 0.25rem; }
.mini-pill { display: inline-flex; cursor: pointer; }
.mini-pill input { position: absolute; opacity: 0; pointer-events: none; width: 0; }
.mini-pill span { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 0.78rem; font-weight: 700; color: var(--muted); transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease; }
.mini-pill:hover span { border-color: var(--brand-500); color: var(--text); }
.mini-pill input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-100); }
.mini-pill--present input:checked + span { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.mini-pill--half_day input:checked + span { background: #dbeafe; border-color: #3b82f6; color: #1d4ed8; }
.mini-pill--absent input:checked + span { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.mini-pill--leave input:checked + span { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
@media (max-width: 640px) {
  .mode-switch { display: flex; }
  .mode-btn { flex: 1; }
  .bulk-toolbar-right { width: 100%; }
}
.bulk-toolbar input[type="text"], .bulk-toolbar input.time24 { width: 6.5rem; }


/* Collapsible side menu (desktop): icons only when collapsed */
.sidebar, .app-main { transition: width 0.18s ease, margin-left 0.18s ease; }
@media (min-width: 901px) {
  html.sidebar-collapsed { --sidebar-width: 72px; }
  html.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 1.35rem 0; }
  html.sidebar-collapsed .sidebar-brand .name,
  html.sidebar-collapsed .sidebar-nav a span,
  html.sidebar-collapsed .sidebar-user { display: none; }
  html.sidebar-collapsed .sidebar-nav { padding: 0.75rem 0.6rem; }
  html.sidebar-collapsed .sidebar-nav a { justify-content: center; padding-left: 0; padding-right: 0; }
  html.sidebar-collapsed .sidebar-footer { padding: 1rem 0; }
  html.sidebar-collapsed .sidebar-footer .logout { font-size: 0; justify-content: center; gap: 0; }
}
@media (max-width: 900px) { .sidebar-toggle { display: none; } }

/* Name column keeps its own background when the row is hovered, so day cells never show through it */
.att-grid td.att-name { background: var(--surface) !important; }
.att-grid tfoot td.att-name { background: var(--brand-50) !important; }
.att-grid td.att-name { box-shadow: 1px 0 0 var(--border); }

/* Late arrival / early finish: still a full D or N day, with the missing time underneath */
.g-cell a small.g-late { color: #c2410c; }
.att-grid th.att-name, .att-grid td.att-name { z-index: 4; }
/* Menu toggle: a round button on the edge of the side menu, always in view */
.sidebar-toggle { position: fixed; top: 20px; left: calc(var(--sidebar-width) - 15px); z-index: 60; width: 30px; height: 30px; border-radius: 999px; padding: 0; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--brand-700); border: 1px solid var(--border); box-shadow: var(--shadow-md, 0 2px 8px rgba(20,20,60,.18)); transition: left 0.18s ease, transform 0.18s ease; cursor: pointer; }
.sidebar-toggle:hover { background: var(--brand-50); }
.sidebar-toggle svg { width: 16px; height: 16px; }
html.sidebar-collapsed .sidebar-toggle { transform: rotate(180deg); }
@media (max-width: 900px) { .sidebar-toggle { display: none !important; } }

.att-grid td.g-latecol { color: #c2410c; min-width: 62px; }
.att-grid td.g-latecol small { font-weight: 500; font-size: 0.62rem; color: var(--muted); }
.att-grid td.g-late-f { color: #c2410c; font-weight: 600; font-size: 0.66rem; }

/* Worker codes: system code + company employee code, shown next to a name */
.code-pair { display: inline-flex; gap: 0.25rem; vertical-align: middle; margin-left: 0.35rem; }
.code-pair span { font-size: 0.68rem; font-weight: 600; line-height: 1; padding: 0.2rem 0.4rem; border-radius: 5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.code-sys { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.code-co { background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-100); }

/* Bulk approval bar */
.bulk-bar { display: flex; flex-direction: row; align-items: center; gap: 0.6rem 1rem; flex-wrap: wrap; padding: 0.6rem 0.9rem; margin-bottom: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); position: sticky; top: 64px; z-index: 5; }
.bulk-bar .count { font-weight: 600; }
.bulk-bar input[type="text"] { width: 12rem; padding: 0.35rem 0.6rem; }
.bulk-bar button { padding: 0.4rem 0.9rem; min-height: 0; }.bulk-bar .bulk-reject-group { margin-left: auto; display: inline-flex; gap: 0.4rem; align-items: center; }
.bulk-bar .count { min-width: 8.5rem; }
@media (max-width: 700px) { .bulk-bar .bulk-reject-group { margin-left: 0; width: 100%; } .bulk-bar .bulk-reject-group input { flex: 1; width: auto; } }

/* Sunday paid as double OT: hours only, not a shift */
.g-dot { background: #fbe3f3 !important; }
.g-cell.g-dot a { color: #9d174d; }
.notes-entry { margin: 0.25rem 0 1rem; } .notes-entry label { display: block; font-weight: 600; font-size: 0.82rem; } .notes-entry textarea { width: 100%; margin-top: 0.3rem; font-weight: 400; resize: vertical; }

.pay-box { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 0.9rem 1rem; margin: 0.5rem 0 1rem; background: var(--bg); }

/* ===== Salary / allowances / advances: page header, tabs, figures ===== */
.page-head { margin: 0 0 0.9rem; }
.page-head h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.01em; }
.page-head p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.88rem; max-width: 70ch; }
.pay-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.pay-tabs a { padding: 0.6rem 1rem; color: var(--muted); font-weight: 600; font-size: 0.88rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.pay-tabs a:hover { color: var(--text); text-decoration: none; }
.pay-tabs a.active { color: var(--brand-700); border-bottom-color: var(--brand-600); }
.pill { display: inline-block; min-width: 1.3rem; padding: 0.05rem 0.4rem; border-radius: 999px; background: var(--warning-bg); color: var(--warning); font-size: 0.7rem; font-weight: 700; text-align: center; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.tag { display: inline-flex; align-items: center; justify-content: center; width: 1.15rem; height: 1.15rem; border-radius: 4px; font-size: 0.8rem; font-weight: 700; line-height: 1; }
.tag-plus { background: var(--success-bg); color: var(--success); }
.tag-minus { background: var(--error-bg); color: var(--error); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.9rem; margin: 0 0 1.1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1.1rem; box-shadow: var(--shadow-sm); }
.stat span { display: block; color: var(--muted); font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat strong { display: block; margin-top: 0.2rem; font-size: 1.3rem; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat.stat-main { background: linear-gradient(135deg, var(--brand-600), var(--brand-700)); border-color: transparent; }
.stat.stat-main span { color: rgba(255,255,255,0.8); }
.stat.stat-main strong { color: #fff; }
.stat small { display: block; color: var(--muted); font-size: 0.74rem; margin-top: 0.15rem; }

/* Status steps of a salary run */
.steps { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; margin: 0.25rem 0 0.9rem; }
.steps .step { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.steps .step i { width: 1.35rem; height: 1.35rem; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--border); font-style: normal; font-size: 0.7rem; background: var(--surface); }
.steps .step.done { color: var(--text); }
.steps .step.done i { background: var(--success); border-color: var(--success); color: #fff; }
.steps .step.now { color: var(--brand-700); }
.steps .step.now i { border-color: var(--brand-600); color: var(--brand-700); box-shadow: 0 0 0 3px var(--brand-100); }
.steps .sep { width: 1.6rem; height: 1.5px; background: var(--border); }

/* Salary table */
.pay-table { font-size: 0.82rem; border-collapse: separate; border-spacing: 0; width: 100%; }
.pay-table th, .pay-table td { padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.pay-table thead th { background: var(--bg); color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0; }
.pay-table thead tr.group th { text-align: center; color: var(--brand-700); background: var(--brand-50); border-bottom: 1px solid var(--brand-100); letter-spacing: 0.06em; }
.pay-table td.num, .pay-table th.num { text-align: right; }
.pay-table tbody tr:hover td { background: var(--bg); }
.pay-table tfoot td { background: var(--brand-50); font-weight: 700; border-top: 2px solid var(--brand-100); }
.pay-table td.net { font-weight: 700; color: var(--brand-700); }
.pay-table .sep-l { border-left: 1px solid var(--border); }
.warn-row td { background: var(--warning-bg) !important; }

/* Monthly entry grid */
.entry-table { font-size: 0.85rem; }
.entry-table th, .entry-table td { padding: 0.45rem 0.6rem; vertical-align: middle; }
.entry-table td.num input { text-align: right; }
.entry-table .sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 230px; }
.entry-table thead .sticky-col { background: var(--bg); }
.entry-table tfoot td { background: var(--brand-50); border-top: 2px solid var(--brand-100); }
.amt { width: 7.5rem; padding: 0.4rem 0.55rem; font-variant-numeric: tabular-nums; }
.amt-approved { border-color: var(--success); background: var(--success-bg); }
.amt-pending { border-color: var(--warning); background: var(--warning-bg); }
.amt-rejected { border-color: var(--error); background: var(--error-bg); }
.amt[readonly] { cursor: not-allowed; opacity: 0.85; }
.note-in { min-width: 10rem; }
.legend-inline { display: inline-flex; align-items: center; gap: 0.35rem 0.6rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); }
.legend-inline .dot { width: 0.7rem; height: 0.7rem; border-radius: 3px; display: inline-block; border: 1px solid; }
.dot-approved { background: var(--success-bg); border-color: var(--success) !important; }
.dot-pending { background: var(--warning-bg); border-color: var(--warning) !important; }
.dot-rejected { background: var(--error-bg); border-color: var(--error) !important; }

.site-card { margin-bottom: 1rem; }
.site-card > h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }

/* Allowances / deductions: choosing people */
.pool-box { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-top: 0.4rem; }
.pool-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.pool-list { max-height: 15rem; overflow-y: auto; padding: 0.25rem 0.4rem; }
.pool-row { display: flex !important; flex-direction: row !important; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem; border-radius: 6px; font-weight: 400 !important; cursor: pointer; }
.pool-row:hover { background: var(--bg); }

/* =====================================================================
   Design system v2 - enterprise light theme (navy / blue)
   ===================================================================== */
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
h1, h2, h3, h4 { color: var(--text); letter-spacing: -0.01em; }
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand-100); }

/* ---- Sidebar ---- */
.sidebar { border-right: 1px solid rgba(0,0,0,0.12); }
.sidebar-brand { padding: 1.1rem 1.25rem; min-height: 72px; }
.sidebar-brand .mark { background: var(--brand-600); border-radius: 10px; box-shadow: 0 2px 6px rgba(37,99,235,0.45); }
.sidebar-brand .name { font-size: 0.95rem; }
.sidebar-nav { padding: 0.6rem 0.75rem 1rem; }
.nav-group + .nav-group { margin-top: 0.9rem; }
.nav-label { padding: 0.35rem 0.75rem; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(180,194,216,0.55); }
.sidebar-nav a { padding: 0.55rem 0.75rem; border-radius: 8px; font-size: 0.875rem; font-weight: 500; position: relative; margin-bottom: 1px; }
.sidebar-nav a:hover { background: var(--sidebar-bg-hover); color: #fff; }
.sidebar-nav a.active { background: rgba(37,99,235,0.28); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--brand-500); }
.sidebar-nav a svg { width: 18px; height: 18px; }
.sidebar-footer { padding: 0.75rem 1rem; }
html.sidebar-collapsed .nav-label { visibility: hidden; height: 0.5rem; padding: 0; overflow: hidden; }
html.sidebar-collapsed .nav-group + .nav-group { margin-top: 0.4rem; border-top: 1px solid var(--sidebar-border); padding-top: 0.4rem; }

/* ---- Top bar ---- */
.topbar { padding: 0.65rem 2rem; gap: 1.25rem; border-bottom: 1px solid var(--border); box-shadow: none; }
.topbar-crumb { display: flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.topbar-crumb b { color: var(--text); font-size: 0.95rem; font-weight: 600; }
.topbar-crumb .sep { color: #cbd5e1; }
.topbar-search { max-width: 380px; }
.topbar-search input { background: var(--bg); border: 1px solid transparent; height: 38px; }
.topbar-search input:focus { background: var(--surface); }
.topbar-icon-btn:hover { background: var(--bg); color: var(--text); }
.profile-menu { position: relative; }
.profile-menu summary { list-style: none; cursor: pointer; padding: 0.25rem 0.5rem 0.25rem 0.35rem; border-radius: 10px; }
.profile-menu summary::-webkit-details-marker { display: none; }
.profile-menu summary:hover, .profile-menu[open] summary { background: var(--bg); }
.profile-menu .chev { width: 16px; height: 16px; color: var(--muted); }
.topbar-user .avatar { background: var(--navy); }
.profile-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 0.4rem; z-index: 60; }
.profile-menu .menu .who { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); margin-bottom: 0.3rem; display: flex; flex-direction: column; }
.profile-menu .menu .who span { font-size: 0.78rem; color: var(--muted); }
.profile-menu .menu a { display: flex; align-items: center; justify-content: space-between; padding: 0.55rem 0.7rem; border-radius: 8px; color: var(--text); font-size: 0.875rem; text-decoration: none; }
.profile-menu .menu a:hover { background: var(--bg); }
.profile-menu .menu a.danger { color: var(--error); }

/* ---- Content ---- */
.content { padding: 1.75rem 2rem 3rem; max-width: 1440px; }
.toolbar h2 { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.panel { border-radius: 12px; padding: 1.35rem 1.5rem; box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 1rem; font-weight: 600; }
.sidebar-toggle { color: var(--brand-700); }

/* ---- Buttons ---- */
button, .btn { border-radius: 8px; padding: 0.55rem 1.1rem; min-height: 38px; box-shadow: none; }
button:hover, .btn:hover { box-shadow: var(--shadow-sm); }
button:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: #cbd5e1; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ---- Inputs ---- */
input, select, textarea { border-radius: 8px; padding: 0.55rem 0.75rem; min-height: 38px; border-color: #d5deea; }
input:hover, select:hover, textarea:hover { border-color: #b8c4d6; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
input[type="checkbox"], input[type="radio"] { min-height: 0; accent-color: var(--brand-600); }
input::placeholder, textarea::placeholder { color: #94a3b8; }
label { color: #334155; font-weight: 600; }
input[readonly] { background: var(--bg); }
input:disabled, select:disabled { background: var(--bg); color: var(--muted); }

/* ---- Tables ---- */
table { font-size: 0.875rem; }
th { background: #f8fafc; color: #475569; font-size: 0.7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th, td { padding: 0.7rem 1rem; }
tbody tr:hover td { background: #f8fafc; }
.table-scroll { border-radius: 10px; }
table a { font-weight: 500; }

/* ---- Badges & alerts ---- */
.badge { padding: 0.18rem 0.65rem; font-size: 0.72rem; border: 1px solid transparent; }
.badge-active, .badge-approved { background: var(--success-bg); color: #15803d; border-color: #bbf7d0; }
.badge-bench, .badge-pending { background: var(--warning-bg); color: #b45309; border-color: #fde68a; }
.badge-rejected { background: var(--error-bg); color: #b91c1c; border-color: #fecaca; }
.badge-inactive { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.alert { border-radius: 10px; border: 1px solid transparent; border-left-width: 4px; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; border-left-color: var(--success); color: #166534; }
.alert-error { background: #fef2f2; border-color: #fecaca; border-left-color: var(--error); color: #991b1b; }
.alert-info { background: var(--info-bg); border-color: #bae6fd; border-left-color: var(--info); color: #075985; }
.empty-state { color: var(--muted); text-align: center; padding: 2.25rem 1rem; font-size: 0.9rem; }

/* ---- Cards, tabs, chips ---- */
.stat-card { border-radius: 12px; padding: 1.15rem 1.25rem; }
.stat-card .value { font-size: 1.7rem; letter-spacing: -0.02em; }
.stat-card .icon { border-radius: 10px; }
.summary-chip { border-radius: 10px; box-shadow: none; }
.summary-chip.active { background: var(--brand-50); border-color: #93c5fd; color: var(--brand-700); }
.tab-nav button.active, .pay-tabs a.active { color: var(--brand-700); border-bottom-color: var(--brand-600); }
.stat.stat-main { background: var(--navy); }
.code-sys { background: #f1f5f9; }
.code-co { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
.mode-btn.active { color: var(--brand-700); }
.steps .step.done i { background: var(--success); border-color: var(--success); }

/* ---- Tablet / mobile ---- */
@media (max-width: 1100px) { .content { padding: 1.25rem 1.25rem 2.5rem; } .topbar { padding: 0.6rem 1.25rem; } .topbar-crumb .sep, .topbar-crumb span:first-child { display: none; } }
@media (max-width: 900px) {
  .content { padding: 1rem 1rem 2rem; }
  .panel { padding: 1.1rem; }
  .form-grid, .form-grid-3, .action-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: flex-start; }
  .profile-menu .menu { right: 0; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .toolbar h2 { font-size: 1.2rem; }
  th, td { padding: 0.6rem 0.7rem; }
}
.table-scroll, .att-grid-wrap, .bulk-table-wrap { max-width: 100%; }
.panel, .content > * { min-width: 0; }

/* ---- Printing: no navigation chrome ---- */
@media print {
  .sidebar, .sidebar-backdrop, .sidebar-toggle, .topbar, .mobile-topbar, .filter-bar, .toolbar .btn, .form-actions, .pay-tabs, .no-print { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .panel { box-shadow: none; border-color: #cbd5e1; }
}
.login-panel-left h1, .login-panel-left h2, .login-panel-left h3 { color: #fff; }
.login-box h1, .login-box h2 { color: var(--text); }

.topbar { padding-left: 2.75rem; }
@media (max-width: 1100px) { .topbar { padding-left: 2.5rem; } }

/* Payroll workflow pieces */
.badge-info { background: var(--info-bg); color: #0369a1; border-color: #bae6fd; }
.crumbs { font-size: 0.82rem; color: var(--muted); margin: -0.4rem 0 0.9rem; }
.crumbs a { color: var(--muted); } .crumbs span { margin: 0 0.35rem; color: #cbd5e1; } .crumbs strong { color: var(--text); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; font-size: 0.86rem; }
.timeline li { position: relative; padding-left: 1.1rem; }
.timeline li::before { content: ''; position: absolute; left: 0; top: 0.45rem; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-500); }
.timeline li span { display: block; color: var(--muted); font-size: 0.76rem; }
.timeline li em { display: block; color: var(--text); font-style: normal; font-size: 0.8rem; background: var(--bg); border-radius: 6px; padding: 0.25rem 0.5rem; margin-top: 0.2rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; font-size: 0.85rem; color: var(--muted); }
.pager .disabled { pointer-events: none; opacity: 0.45; }
.sort-link { color: inherit; text-decoration: none; } .sort-link:hover { color: var(--brand-700); }
.pay-table .sticky-name { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 190px; }
.pay-table thead .sticky-name, .pay-table tfoot .sticky-name { background: #f8fafc; }
.pay-table tfoot .sticky-name { background: var(--brand-50); }
dialog.dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; box-shadow: var(--shadow-lg); width: min(440px, 94vw); }
dialog.dialog::backdrop { background: rgba(20, 43, 74, 0.45); }
.dialog-body { padding: 1.4rem; }

.mode-switch { align-self: flex-start; }

/* Confirmation card shown after choosing a worker */
.confirm-card { border: 1px solid #bfdbfe; background: var(--brand-50); border-radius: 10px; padding: 0.8rem 1rem; }
.confirm-title { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand-700); }
.confirm-name { font-size: 1.05rem; font-weight: 700; margin: 0.15rem 0 0.5rem; }
.confirm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.4rem 1.2rem; margin: 0; }
.confirm-grid dt { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.confirm-grid dd { margin: 0.1rem 0 0; font-size: 0.9rem; font-weight: 600; }
/* Add allowance / deduction form: even spacing between its parts */
#add-form { gap: 0.9rem; }
#add-form > h3 { margin: 0.8rem 0 0 !important; padding-top: 0.9rem; border-top: 1px solid var(--border); font-size: 0.95rem; }
#add-form > .toolbar { margin-bottom: 0; }
#add-form .muted-note { margin: 0; }
#add-form .mode-switch { margin: 0; }
#add-form .form-grid, #add-form .form-grid-3 { margin: 0; align-items: start; }
#add-form .combobox { position: relative; }
#add-form .combobox input[type="text"] { width: 100%; }
#add-form #mode-one, #add-form #mode-many { display: flex; flex-direction: column; gap: 0.6rem; }
#add-form #mode-one[hidden], #add-form #mode-many[hidden] { display: none; }
#add-form .pool-box { margin-top: 0; }
#add-form > .toolbar + h3 { border-top: 0; padding-top: 0; margin-top: 0.2rem !important; }

.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 900px) { .form-grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .form-grid-4 { grid-template-columns: 1fr; } }

/* Pay rates by shift */
.link-btn { background: none; border: 0; box-shadow: none; padding: 0 0 0 0.6rem; min-height: 0; color: var(--brand-600); font-size: 0.78rem; font-weight: 600; cursor: pointer; }
.link-btn:hover { background: none; text-decoration: underline; box-shadow: none; }
.pay-table tr.group-head td { background: #f8fafc; padding: 0.3rem 0.65rem; }
.pay-table tr.sub-row td { background: #fcfdff; }
.pay-table tr.sub-row td.sub-label { padding-left: 1.6rem; color: var(--muted); font-size: 0.82rem; }
.pay-table tr[hidden] { display: none; }

/* On / off tick with a short explanation */
.switch-row { flex-direction: row !important; align-items: center; gap: 0.6rem; padding: 0.45rem 0.8rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; font-weight: 400; }
.switch-row input[type="checkbox"] { width: 1.15rem; height: 1.15rem; flex-shrink: 0; }
.switch-row span { display: flex; flex-direction: column; line-height: 1.25; }
.switch-row small { color: var(--muted); font-size: 0.74rem; font-weight: 400; }
.epf-switch { margin: 0.4rem 0 0.2rem; }

.amount-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.poya-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.poya-chip { flex-direction: row; align-items: center; gap: 0.4rem; margin: 0; padding: 0.3rem 0.4rem 0.3rem 0.8rem; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); font-size: 0.82rem; }
.poya-chip button { background: none; color: var(--muted); padding: 0 0.4rem; min-height: 0; box-shadow: none; font-size: 1.1rem; }
.poya-chip button:hover { background: none; color: var(--error); }

.amount-pair > label { min-width: 0; }
.amount-pair select, .amount-pair input { width: 100%; min-width: 0; }
.extra-form .form-grid-3 > * { min-width: 0; }

/* salary sheet: the table scrolls inside its card so the sideways scrollbar is always in view; headings stay put */
.site-card .table-scroll { max-height: calc(100vh - 170px); overflow: auto; }
.pay-table.grouped thead tr.group th { top: 0; z-index: 3; }
.pay-table.grouped thead tr:not(.group) th { top: 2.1rem; z-index: 3; }
.pay-table thead .sticky-name { z-index: 5; }
.pay-table tr.dept-row td { background: var(--brand-50); color: var(--brand-700); font-weight: 700; padding: 0.35rem 0.65rem; position: sticky; left: 0; }

/* attendance grid: a worker who did two shifts in a day shows both, one under the other */
.g-cell.g-multi { height: auto; }
.g-cell.g-multi a { min-height: 18px; }
.g-cell .g-plus { display: none; }

/* salary sheet: a person whose salary is on hold */
.pay-table tr.hold-row td { background: #fef2f2; }
.pay-table .hold-cell { text-align: center; white-space: nowrap; }
.pay-table .hold-cell input { width: auto; }
.pay-table .hold-tag { margin-left: 0.35rem; font-weight: 800; font-size: 0.68rem; color: #b91c1c; letter-spacing: 0.05em; }

.pay-table tfoot tr.hold-net td { background: #fff; border-top: 1px dashed var(--border); font-weight: 600; }
.pay-table tfoot tr.hold-net .sticky-name { background: #fff; }

/* salary sheet form: tick the departments */
.dept-pick { flex: 1 1 100%; display: flex; flex-direction: column; gap: 0.35rem; }
.dept-pick-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.dept-pick-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.dept-chip { display: inline-flex; flex-direction: row; align-items: center; gap: 0.35rem; margin: 0; padding: 0.3rem 0.7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 0.82rem; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text); cursor: pointer; }
.dept-chip input { width: auto; margin: 0; }
.dept-chip:has(input:checked) { background: var(--brand-50); border-color: var(--brand-500, #2563eb); color: var(--brand-700); font-weight: 600; }

/* reports: the table scrolls inside its card, so the sideways scrollbar is always in view and the headings stay put */
.att-grid-wrap { max-height: calc(100vh - 170px); overflow: auto; }
.att-grid thead tr:nth-child(1) th { position: sticky; top: 0; z-index: 3; }
.att-grid thead tr:nth-child(2) th { position: sticky; top: 20px; z-index: 3; }
.att-grid thead tr:nth-child(3) th { position: sticky; top: 42px; z-index: 3; }
.att-grid thead th.att-name { z-index: 6 !important; }
.report-scroll { max-height: calc(100vh - 170px); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.report-scroll table { border-collapse: separate; border-spacing: 0; width: 100%; }
.report-scroll thead th { position: sticky; top: 0; z-index: 3; background: var(--bg); }
.dept-pick--bar { flex: 1 1 100%; }

/* attendance grid: Emp code and Name in their own columns, names wrap, department headings */
.att-grid .att-code { position: sticky; left: 0; z-index: 5; min-width: 78px; max-width: 78px; width: 78px; text-align: left; padding: 0 0.5rem; font-weight: 700; white-space: nowrap; background: var(--surface) !important; box-shadow: none; }
.att-grid thead th.att-code { background: var(--brand-600) !important; color: #fff; z-index: 7; }
.att-grid tr.att-weeks th.att-code { background: var(--bg) !important; }
.att-grid td.att-name, .att-grid th.att-name { left: 78px; min-width: 210px; max-width: 250px; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.25; padding: 0.2rem 0.6rem; }
.att-grid tfoot td.att-name[colspan] { left: 0; max-width: none; min-width: 288px; white-space: nowrap; }
.att-grid tr.att-dept td { background: var(--brand-50); color: var(--brand-700); font-weight: 700; text-align: left; padding: 0.3rem 0.7rem; position: sticky; left: 0; z-index: 2; }
.att-grid tr:hover td.att-code { background: var(--surface) !important; }

/* attendance grid: the heading cells of the two left columns stay above the Emp code / Name cells scrolling beneath them */
.att-grid thead th.att-code, .att-grid thead th.att-name { z-index: 9 !important; }
.att-grid thead tr:nth-child(1) th:not(.att-code):not(.att-name),
.att-grid thead tr:nth-child(2) th:not(.att-code):not(.att-name),
.att-grid thead tr:nth-child(3) th { z-index: 3; }

/* advances & loans */
.adv-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.8rem; margin-bottom: 1rem; }
.adv-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1.1rem; display: flex; flex-direction: column; gap: 0.15rem; }
.adv-card span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.adv-card strong { font-size: 1.35rem; color: var(--text); }
.adv-card small { color: var(--muted); font-size: 0.78rem; }
.adv-card--main { background: #142B4A; border-color: #142B4A; }
.adv-card--main span, .adv-card--main small { color: rgba(255, 255, 255, 0.75); }
.adv-card--main strong { color: #fff; }
.adv-card--warn { background: var(--warning-bg); border-color: var(--warning); }
.adv-steps { display: grid; grid-template-columns: 1fr 1.7fr; gap: 1.4rem; align-items: start; }
@media (max-width: 900px) { .adv-steps { grid-template-columns: 1fr; } }
.adv-step h3 { margin: 0 0 0.7rem; font-size: 0.95rem; }
.adv-num { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--brand-600); color: #fff; font-size: 0.75rem; margin-right: 0.35rem; }
.adv-plan { margin-top: 0.7rem; padding: 0.6rem 0.85rem; background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 8px; color: var(--brand-700); font-size: 0.85rem; }
.adv-bar { height: 8px; background: #e5e9f2; border-radius: 999px; overflow: hidden; margin-bottom: 0.2rem; }
.adv-bar span { display: block; height: 100%; background: #16a34a; border-radius: 999px; }
.adv-bar--wide { height: 10px; margin: 0.3rem 0; }
.adv-kind { font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 999px; }
.adv-kind--loan { background: #ede9fe; color: #5b21b6; }
.adv-kind--advance { background: #e0f2fe; color: #075985; }
.adv-table tr.adv-pending td { background: var(--warning-bg); }
.adv-facts { margin: 0; display: grid; gap: 0.5rem; }
.adv-facts > div { display: grid; grid-template-columns: 130px 1fr; gap: 0.6rem; border-bottom: 1px solid var(--border); padding-bottom: 0.45rem; }
.adv-facts dt { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.adv-facts dd { margin: 0; }

/* Roles & permissions matrix */
.perm-scroll { overflow: auto; max-height: 72vh; border-radius: 12px 12px 0 0; }
.perm-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 640px; }
.perm-table th, .perm-table td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); background: var(--surface); text-align: center; }
.perm-table thead th { position: sticky; top: 0; z-index: 3; font-size: 0.8rem; font-weight: 700; color: var(--text); background: #f8fafc; white-space: nowrap; }
.perm-table thead th small { display: block; color: var(--muted); font-weight: 500; font-size: 0.7rem; }
.perm-table .perm-name { text-align: left; position: sticky; left: 0; z-index: 2; min-width: 15rem; max-width: 24rem; }
.perm-table thead .perm-name { z-index: 4; }
.perm-table .perm-name strong { display: block; font-size: 0.86rem; }
.perm-table .perm-name small { display: block; color: var(--muted); font-size: 0.74rem; font-weight: 400; line-height: 1.3; }
.perm-table .perm-group td { text-align: left; background: #eef4ff; color: var(--brand-700); font-size: 0.72rem; letter-spacing: 0.07em; text-transform: uppercase; font-weight: 700; padding: 0.4rem 0.7rem; }
.perm-table tbody tr:hover td { background: #f8fbff; }
.perm-table tbody tr.perm-group:hover td { background: #eef4ff; }
.perm-cell.perm-changed { background: #fff7e0 !important; }
.perm-box-wrap { display: inline-flex; cursor: pointer; }
.perm-box-wrap input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.perm-box { display: inline-flex; width: 1.6rem; height: 1.6rem; border-radius: 7px; border: 1.5px solid #cbd5e1; background: #fff; align-items: center; justify-content: center; transition: background 0.12s, border-color 0.12s; }
.perm-box-wrap:hover .perm-box { border-color: var(--brand-500); }
.perm-box-wrap input:focus-visible + .perm-box { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.perm-box-wrap input:checked + .perm-box { background: var(--brand-600); border-color: var(--brand-600); }
.perm-box-wrap input:checked + .perm-box::after { content: "\2713"; color: #fff; font-weight: 800; font-size: 0.95rem; line-height: 1; }
.perm-box-wrap input:disabled + .perm-box { opacity: 0.6; cursor: default; }
.perm-box.locked { background: #e2e8f0; border-color: #e2e8f0; color: #64748b; font-weight: 800; }
.perm-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.8rem 1.1rem; border-top: 1px solid var(--border); background: #f8fafc; border-radius: 0 0 12px 12px; position: sticky; bottom: 0; }

/* Roles page extras */
.role-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.role-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 0.9rem; display: flex; flex-direction: column; gap: 0.15rem; }
.role-card small { color: var(--muted); font-size: 0.74rem; line-height: 1.3; }
.perm-tools { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.7rem; }
.perm-tools input[type=search] { flex: 1; min-width: 220px; }
.perm-toggle { background: transparent; border: 0; box-shadow: none; padding: 0; min-height: 0; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; font-weight: 700; }
.perm-toggle:hover { background: transparent; }
.perm-caret { display: inline-block; width: 1em; }
.perm-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.5rem 0; }
.perm-chips b { width: 100%; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.perm-chip { font-size: 0.78rem; padding: 0.2rem 0.6rem; border-radius: 999px; border: 1px solid var(--border); }
.perm-chip.yes { background: #e8f7ee; border-color: #b9e6c9; color: #166534; }
.perm-chip.no { background: #f8fafc; color: #94a3b8; }

/* Invoice report */
.invoice-table td, .invoice-table th { text-align: right; }
.invoice-table td:first-child, .invoice-table th:first-child { text-align: left; }
.invoice-table .invoice-subtotal td { background: #f1f5f9; }
.invoice-site-total { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; align-items: center; margin-top: 0.9rem; padding: 0.6rem 0.8rem; background: #eef4ff; border-radius: 8px; }
@media print { .invoice-site { break-inside: avoid-page; } }

/* Invoice report grid */
.inv-grid .inv-cell { text-align: center; min-width: 1.9rem; font-variant-numeric: tabular-nums; }
.inv-grid .inv-cell small.inv-n { display: block; font-size: 0.6rem; color: #1e3a8a; line-height: 1; }
.inv-grid td.g-sun-c { background: #fef2f2; }
.inv-grid td.g-day { background: #dcf5e6; font-weight: 600; }
.inv-grid .att-foot td { background: #eff6ff; font-size: 0.78rem; }
.inv-grid .att-name { left: 0 !important; min-width: 11rem; max-width: 14rem; }

.invoice-table tr.inv-sun td { background: #fef2f2; }

.inv-dept-day { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 0.5rem; background: var(--surface); }
.inv-dept-day > summary { cursor: pointer; padding: 0.6rem 0.9rem; list-style: none; }
.inv-dept-day > summary::-webkit-details-marker { display: none; }
.inv-dept-day > summary::before { content: "\25B8"; display: inline-block; width: 1.1em; color: var(--muted); }
.inv-dept-day[open] > summary::before { content: "\25BE"; }
.inv-dept-day[open] > summary { border-bottom: 1px solid var(--border); }
.inv-dept-day .table-scroll { padding: 0.4rem 0.6rem 0.6rem; }
@media print { .inv-dept-day { break-inside: avoid-page; } .inv-dept-day:not([open]) > :not(summary) { display: block; } }

.rep-tools { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0.4rem 0 0.7rem; }
.rep-tools .btn-secondary { min-height: 0; padding: 0.35rem 0.8rem; }
