:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #101828;
  --muted: #667085;
  --line: #d7dee8;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --header-bg: #0f2f2d;
  --primary-soft: #e6f5f2;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --success: #167245;
  --success-soft: #eaf7ef;
  --warning: #a05a00;
  --warning-soft: #fff7e8;
  --indigo: #3730a3;
  --violet: #6d28d9;
  --shadow: 0 18px 44px rgba(16, 24, 40, 0.10);
  --shadow-soft: 0 10px 24px rgba(16, 24, 40, 0.07);
  --radius: 8px;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; letter-spacing: 0; }
h2 { font-size: 18px; margin-bottom: 12px; }

.shell { width: min(1240px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 34px; }
.topbar {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  background: var(--header-bg);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.topbar p { margin-top: 7px; color: #cce3df; font-weight: 600; }
.brand-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.site-logo {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.site-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 7px;
}
.site-subtitle {
  margin-top: 4px !important;
  font-size: 13px;
  color: #e5f5f2 !important;
}
.clock {
  min-width: 190px;
  min-height: 66px;
  display: grid;
  place-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
}
.clock strong { font-size: 22px; }
.clock span { color: #cce3df; font-size: 13px; }

.tabs {
  display: inline-flex;
  gap: 6px;
  margin: 16px 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}
.tab {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 16px;
  font-weight: 800;
}
.tab.active { background: var(--primary); color: #fff; }
.view { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }

.panel, .message, .table-wrap, .metrics > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.panel { padding: 18px; }
.muted, .topbar p, .work-grid span, .metrics span { color: var(--muted); }

html, body { max-width: 100%; overflow-x: hidden; }

#instructionsView,
#employeeView {
  min-height: 0;
  display: none;
}
#instructionsView.active {
  display: block;
}
#employeeView.active {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: start;
}
.work-grid {
  display: grid;
  gap: 10px;
  margin: 0;
}
.work-grid > div {
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.work-grid > div:nth-child(2) { background: var(--warning-soft); border-color: #efcb8d; }
.work-grid strong { font-size: 24px; }
.work-grid small { color: var(--warning); font-size: 13px; font-weight: 800; }
.employee-portal-tabs {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
}
.employee-mode {
  flex: 1 1 150px;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 900;
}
.employee-mode.active { background: var(--primary); color: #fff; }
.employee-mode.locked {
  opacity: 0.55;
  cursor: not-allowed;
}
#employeeView > .employee-login-panel,
#employeeView > .employee-clock-panel {
  width: min(720px, 100%);
  min-height: 0;
  display: grid;
  justify-self: center;
  align-content: start;
  gap: 14px;
}
#employeeView > .employee-login-panel {
  margin-top: 2px;
  padding: 24px;
  text-align: center;
}
#employeeView > .panel label { font-size: 16px; }
.employee-self-panel,
.employee-request-panel,
.employee-advance-panel,
.employee-requests-panel,
#employeeMessage {
  grid-column: 1 / -1;
}
.employee-login-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(620px, 100%);
  margin: 0 auto;
}
.employee-login-row .primary { grid-column: 1 / -1; }
.employee-period,
.employee-auth-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.employee-request-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.employee-advance-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}
.employee-request-reason { grid-column: 1 / -1; }
.employee-self-table { min-width: 960px; }
.employee-requests-table { min-width: 900px; }
.requests-table { min-width: 1180px; }
.auth-hint {
  min-height: 44px;
  display: grid;
  align-items: center;
  padding: 0 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-weight: 800;
}
.action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 2px; }
.action-grid button { min-height: 58px; font-size: 17px; }

label { display: grid; gap: 8px; font-weight: 800; color: #1f2937; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}
textarea { min-height: 104px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.primary, .secondary, .danger, .save-btn {
  min-height: 46px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  padding: 0 16px;
}
.primary { background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: #fff; color: var(--text); border-color: var(--line); }
.secondary:hover { color: var(--primary); border-color: var(--primary); }
.danger { background: var(--danger-soft); color: var(--danger); border-color: #f1aaa3; }
.danger:hover { background: #ffe4e1; }
.compact { min-height: 42px; }
.save-btn { width: 78px; min-height: 38px; background: #102d2b; color: #fff; }

.message {
  grid-column: 1 / -1;
  min-height: 88px;
  padding: 17px 19px;
  display: grid;
  gap: 6px;
}
.message span { color: var(--muted); }
.message.success { background: var(--success-soft); border-color: #a9d9bd; }
.message.warning { background: var(--warning-soft); border-color: #efcb8d; }
.message.danger { background: var(--danger-soft); border-color: #f1aaa3; }
.message.big-reward {
  min-height: 150px;
  place-items: center;
  text-align: center;
  border-width: 2px;
  box-shadow: var(--shadow);
}
.message.big-reward strong { font-size: clamp(26px, 4vw, 44px); line-height: 1.2; }
.message.big-reward span { max-width: 720px; font-size: clamp(16px, 2vw, 22px); font-weight: 800; }

.employee-popup {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, 0.58);
}
.employee-popup-card {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
  position: relative;
  padding: 24px;
  border: 2px solid #ef4444;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 28px 80px rgba(16, 24, 40, 0.28);
  text-align: center;
}
.employee-popup-card > strong {
  color: var(--danger);
  font-size: clamp(26px, 5vw, 40px);
  line-height: 1.2;
}
.employee-popup-card p {
  color: #344054;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.7;
}
.popup-close {
  position: absolute;
  inset-block-start: 10px;
  inset-inline-end: 10px;
  width: 36px;
  min-height: 36px;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 24px;
  font-weight: 900;
}
.popup-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.popup-meta > div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.popup-meta span { color: var(--muted); font-size: 12px; font-weight: 800; }
.popup-meta strong { font-size: 18px; }
.popup-meta .over {
  background: var(--danger-soft);
  border-color: #ef9a94;
  color: var(--danger);
}

.login-panel { max-width: 480px; }
.login-row, .employee-row { display: grid; grid-template-columns: minmax(0, 1fr) 100px; gap: 8px; }
.login-row.employee-login-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(620px, 100%);
  margin: 0 auto;
}
.login-row.employee-login-row .primary { grid-column: 1 / -1; }
.admin-mode-tabs {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-soft);
}
.admin-mode {
  flex: 1 1 130px;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 900;
}
.admin-mode.active { background: var(--primary); color: #fff; }
.admin-panel-view { display: none; }
.admin-panel-view.active { display: block; }

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, 0.85fr);
  gap: 12px;
  margin-bottom: 12px;
}
.settings-grid, .metrics, .filters, .payroll-filters { display: grid; gap: 10px; }
.settings-grid { grid-template-columns: repeat(3, 1fr); }
.checkbox { min-height: 44px; display: flex; align-items: center; gap: 8px; margin: 12px 0; }
.checkbox input { width: 18px; min-height: 18px; accent-color: var(--primary); }
.status-line, .error-line { min-height: 22px; margin-top: 8px; color: var(--danger); }
.employee-manage { display: grid; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.employee-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.legal-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.04);
}
.legal-profile-grid .checkbox { align-self: end; min-height: 42px; }
.absence-tools { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 110px 120px; gap: 8px; align-items: end; }
.messages-panel textarea { min-height: 92px; }
.messages-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1.2fr);
  gap: 12px;
  align-items: start;
}
.sound-settings {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.sound-settings h3 { margin: 0; font-size: 16px; }
.sound-grid, .direct-alert-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.75fr);
  gap: 12px;
  align-items: end;
}
.sound-grid > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.direct-alert-panel { margin-top: 12px; }
.direct-alert-history-panel { margin-top: 12px; }
.upload-files-panel { margin-top: 12px; }
.direct-alert-history-table { min-width: 1080px; }
.upload-files-table { min-width: 860px; }
.direct-alert-history-table td:nth-child(3) {
  max-width: 320px;
  white-space: normal;
  line-height: 1.7;
}
.upload-files-table td:first-child {
  direction: ltr;
  text-align: left;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}
.direct-alert-grid label:nth-child(3) { grid-column: span 2; }
.employee-direct-alerts {
  grid-column: 1 / -1;
  width: min(820px, 100%);
  justify-self: center;
  position: sticky;
  top: 8px;
  z-index: 8;
  display: grid;
  gap: 10px;
}
.employee-direct-alert {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius);
  background: #ecfdf5;
  box-shadow: var(--shadow-soft);
}
.employee-direct-alert strong { display: block; margin-bottom: 4px; color: var(--primary-dark); }
.employee-direct-alert p { margin: 0; color: #1f2937; font-weight: 800; line-height: 1.7; }
.direct-alert-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.request-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#employeeMessage {
  width: min(720px, 100%);
  justify-self: center;
}
.section-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.appearance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.appearance-grid label:nth-child(1),
.appearance-grid label:nth-child(2),
.appearance-grid label:nth-child(3),
.appearance-grid .logo-preview {
  grid-column: span 2;
}
.appearance-grid input[type="color"] {
  min-height: 52px;
  padding: 6px;
}
.logo-preview {
  display: grid;
  gap: 8px;
  font-weight: 800;
  color: #1f2937;
}
.logo-preview-box {
  min-height: 100px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
}
.logo-preview-box.has-logo {
  border-style: solid;
  background: #fff;
}
.logo-preview-box img {
  max-width: 100%;
  max-height: 96px;
  object-fit: contain;
}

.metrics { grid-template-columns: repeat(6, 1fr); margin-bottom: 12px; }
.metrics > div {
  min-height: 92px;
  padding: 15px 16px;
  display: grid;
  align-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.metrics > div::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--primary);
}
.metric-late::before { background: var(--danger) !important; }
.metric-absence::before { background: var(--indigo) !important; }
.metric-open::before { background: var(--violet) !important; }
.metric-grace::before { background: var(--warning) !important; }
.metric-early::before { background: var(--success) !important; }
.metrics strong { font-size: 30px; }

.section-head, .analytics-head, .report-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.report-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.alerts-panel, .analytics-panel, .report-panel { margin-bottom: 12px; }
.system-alerts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.system-alert, .alert-empty {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.system-alert strong { font-size: 28px; }
.system-alert small { color: var(--muted); font-weight: 700; }
.system-alert.danger { background: var(--danger-soft); border-color: #ef9a94; color: var(--danger); }
.system-alert.warning { background: var(--warning-soft); border-color: #efcb8d; color: var(--warning); }
.system-alert.indigo { background: #eef2ff; border-color: #c7d2fe; color: var(--indigo); }
.system-alert.violet { background: #f5f3ff; border-color: #ddd6fe; color: var(--violet); }
.alert-empty { color: var(--muted); font-weight: 800; text-align: center; }

.analytics-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.analytics-head strong {
  min-width: 92px;
  text-align: center;
  padding: 9px 12px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
}
.analytics-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.chart-box { min-height: 238px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.chart-box h3 { margin: 0 0 14px; font-size: 15px; color: #1f2937; }
.bar-chart, .rank-chart { display: grid; gap: 11px; }
.chart-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) 54px; gap: 10px; align-items: center; }
.chart-label { color: #344052; font-weight: 800; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-track { height: 14px; border-radius: 999px; overflow: hidden; background: #e8edf3; box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.08); }
.chart-fill { height: 100%; width: var(--value); min-width: 7px; border-radius: inherit; background: linear-gradient(90deg, #14b8a6, #0f766e); }
.chart-value { color: #111827; font-weight: 900; text-align: left; font-variant-numeric: tabular-nums; }
.chart-empty { min-height: 132px; display: grid; place-items: center; color: var(--muted); border: 1px dashed #cfd8e5; border-radius: var(--radius); background: #fff; }
.tone-late { background: linear-gradient(90deg, #fb7185, #b42318); }
.tone-absence { background: linear-gradient(90deg, #818cf8, #3730a3); }
.tone-grace { background: linear-gradient(90deg, #fbbf24, #a05a00); }
.tone-early { background: linear-gradient(90deg, #34d399, #167245); }
.tone-open { background: linear-gradient(90deg, #a78bfa, #6d28d9); }

.filters {
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(210px, 1.35fr) minmax(150px, 0.9fr) 96px 96px;
  column-gap: 16px;
  row-gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.report-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.employee-profile-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.employee-profile-summary > div {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.employee-profile-summary span { color: var(--muted); font-size: 13px; }
.employee-profile-summary strong { font-size: 20px; overflow-wrap: anywhere; }
.report-metrics > div {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.report-metrics span { color: var(--muted); font-size: 13px; }
.report-metrics strong { font-size: 22px; }
.report-metrics > div.limit-danger { background: var(--danger-soft); border-color: #ef9a94; box-shadow: 0 10px 22px rgba(180, 35, 24, 0.12); }
.report-metrics > div.limit-danger span, .report-metrics > div.limit-danger strong { color: var(--danger); }
.report-alert { margin: 0 0 12px; padding: 12px 14px; border: 1px solid #ef9a94; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); font-weight: 900; line-height: 1.8; }
.mini-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.mini-table { min-width: 860px; }
.link-btn { padding: 0; border: 0; background: transparent; color: var(--primary); font-weight: 900; text-decoration: underline; text-underline-offset: 3px; }

.payroll-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 14px; align-items: start; margin-bottom: 12px; }
.payroll-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.payroll-totals > div { min-height: 78px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); display: grid; gap: 4px; align-content: center; }
.payroll-totals span { color: var(--muted); font-size: 13px; }
.payroll-totals strong { font-size: 21px; }
.payroll-filters { grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(210px, 1.35fr) 110px 130px; gap: 12px; align-items: end; margin-bottom: 12px; }
.payroll-table { min-width: 1660px; }
.payroll-table input { min-width: 130px; }
.time-edit { min-width: 116px; margin-top: 0; }
.deduction-notes { min-width: 220px; display: grid; gap: 8px; }
.deduction-notes > div { display: grid; gap: 3px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.deduction-notes span, .deduction-notes small { color: var(--muted); font-size: 12px; }
.payroll-adjustments { margin-top: 8px; }

.table-wrap { overflow: auto; }
table { width: 100%; min-width: 1160px; border-collapse: separate; border-spacing: 0; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
thead th { background: #f1f5f9; font-size: 13px; color: #344052; position: sticky; top: 0; z-index: 1; }
tbody tr:hover td { background: #fbfdff; }
td input, td select { margin-top: 6px; }
.pill { display: inline-flex; min-height: 28px; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.pill.early { background: var(--success-soft); color: var(--success); }
.pill.grace { background: #fff2df; color: var(--warning); }
.pill.late { background: var(--danger-soft); color: var(--danger); }
.pill.leave { background: #ecfdf5; color: #047857; }
.pill.absence { background: #eef2ff; color: var(--indigo); }
.empty { min-height: 88px; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 920px) {
  .shell { width: min(100% - 20px, 1240px); padding-top: 10px; }
  .topbar, #employeeView.active, .admin-grid, .settings-grid, .metrics, .filters, .login-row, .employee-login-row, .employee-period, .employee-request-grid, .employee-advance-grid, .employee-auth-grid, .employee-row, .legal-profile-grid, .absence-tools, .payroll-head, .payroll-totals, .payroll-filters, .system-alerts, .messages-grid, .sound-grid, .direct-alert-grid, .appearance-grid, .employee-direct-alert {
    grid-template-columns: 1fr;
  }
  .topbar { display: grid; }
  .clock { width: 100%; min-width: 0; }
  .brand-head { align-items: flex-start; }
  .site-logo { width: 58px; height: 58px; }
  .appearance-grid label:nth-child(1),
  .appearance-grid label:nth-child(2),
  .appearance-grid label:nth-child(3),
  .appearance-grid .logo-preview {
    grid-column: auto;
  }
  .direct-alert-grid label:nth-child(3) { grid-column: auto; }
  .sound-grid > div { grid-template-columns: 1fr; }
  .tabs { display: grid; grid-template-columns: 1fr; width: 100%; }
  .admin-mode-tabs, .employee-portal-tabs { display: grid; grid-template-columns: 1fr; position: static; }
  .employee-portal-tabs { gap: 6px; padding: 5px; }
  #employeeView.active { gap: 8px; }
  .panel { padding: 14px; }
  #employeeView > .employee-login-panel,
  #employeeView > .employee-clock-panel {
    width: 100%;
    padding: 16px;
  }
  .employee-login-row { width: 100%; }
  .employee-direct-alerts { position: static; width: 100%; }
  .employee-request-reason { grid-column: auto; }
  .analytics-head, .analytics-grid, .section-head, .report-head { display: grid; grid-template-columns: 1fr; }
  .employee-profile-summary { grid-template-columns: 1fr; }
  .report-metrics { grid-template-columns: repeat(2, 1fr); }
  .action-grid, .employee-actions { grid-template-columns: 1fr; }
  .popup-meta { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
}

@media (max-width: 640px) {
  .mobile-card-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  table.mobile-card-table {
    display: block;
    width: 100%;
    min-width: 0 !important;
    border-spacing: 0;
  }
  .mobile-card-table thead {
    display: none;
  }
  .mobile-card-table tbody {
    display: grid;
    gap: 10px;
  }
  .mobile-card-table tr {
    display: grid;
    gap: 9px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
  }
  .mobile-card-table td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 0;
    border: 0;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .mobile-card-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }
  .mobile-card-table td > * {
    min-width: 0;
  }
  .mobile-card-table td input,
  .mobile-card-table td select,
  .mobile-card-table td textarea {
    width: 100%;
    min-width: 0;
    margin-top: 0;
  }
  .mobile-card-table .save-btn,
  .mobile-card-table .danger.compact {
    width: 100%;
  }
  .mobile-card-table .request-actions {
    justify-content: stretch;
  }
  .mobile-card-table .request-actions button {
    flex: 1 1 110px;
  }
  .employee-self-wrap,
  .employee-requests-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }
  table.employee-self-table,
  table.employee-requests-table {
    display: block;
    width: 100%;
    min-width: 0;
    border-spacing: 0;
  }
  .employee-self-table thead,
  .employee-requests-table thead {
    display: none;
  }
  .employee-self-table tbody,
  .employee-requests-table tbody {
    display: grid;
    gap: 10px;
  }
  .employee-self-table tr,
  .employee-requests-table tr {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
  }
  .employee-self-table td,
  .employee-requests-table td {
    display: grid;
    grid-template-columns: 102px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 0;
    border: 0;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .employee-self-table td::before,
  .employee-requests-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }
  .employee-self-table td > *,
  .employee-requests-table td > * {
    justify-self: start;
  }
}
