:root {
  --bg: #f0f2f5;
  --surface: #fff;
  --border: #e0e3e8;
  --text: #1a1d23;
  --text2: #6b7280;
  --primary: #2563eb;
  --primary-h: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --radius: 8px;
  --header-h: 52px;
  --legend-h: 32px;
  --footer-h: 36px;
  --info-w: 280px;
  font-size: 13px;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* TOP BAR */
.top-bar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}
.top-left { display:flex; align-items:center; gap:8px; }
.app-title { font-size:16px; font-weight:700; }
.undo-group { display:flex; gap:2px; margin-left:4px; }
.btn-undo {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 16px;
  padding: 2px 5px;
  cursor: pointer;
  color: #5f6368;
  transition: all 0.15s;
  line-height: 1;
}
.btn-undo:hover { background: #e8eaed; border-color: #dadce0; color: #1a1d23; }
.btn-undo:active { background: #d2d5da; }
.btn-undo:disabled { opacity: 0.3; cursor: default; background: none; border-color: transparent; }
.emp-count {
  background: var(--primary);
  color:#fff;
  font-size:11px;
  padding:2px 8px;
  border-radius:10px;
  font-weight:600;
}
.top-center { display:flex; gap:6px; align-items:center; margin-left:auto; }
.top-center select {
  padding:4px 10px;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:#fff;
  font-size:13px;
  cursor:pointer;
}
.top-right { display:flex; gap:6px; align-items:center; }

/* LEGEND BAR */
.legend-bar {
  height: var(--legend-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
}
.lg-item { display:flex; align-items:center; gap:6px; font-size:13px; color:var(--text2); }
.lg-dot { width:16px; height:16px; border-radius:4px; display:inline-block; }

/* GRID */
.grid-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
}
#gridTable {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
}
#gridTable th {
  background: #f8f9fa;
  border: 1px solid var(--border);
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  position: sticky;
  z-index: 2;
}
#gridTable thead { position: sticky; top: 0; z-index: 3; }
#gridTable thead th { top: 0; }
#gridTable thead tr:first-child th { top: 0; }
#gridTable thead tr:nth-child(2) th { top: 22px; }

#gridTable td {
  border: 1px solid var(--border);
  padding: 3px 4px;
  text-align: center;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  min-width: 26px;
  height: 26px;
  line-height: 26px;
}
#gridTable td:hover { filter: brightness(0.92); }
#gridTable td.col-info { cursor: default; }

/* Sticky info columns */
.col-info-1 { position: sticky; left: 0; z-index: 1; background: #fff !important; border-right: 2px solid #c0c4cc; min-width: 32px; width: 32px; }
.col-info-2 { position: sticky; left: 32px; z-index: 1; background: #fff !important; min-width: 80px; max-width: 90px; text-align: left !important; padding-left: 8px !important; font-size: 11px; }
.col-info-3 { position: sticky; left: 112px; z-index: 1; background: #fff !important; min-width: 100px; max-width: 120px; text-align: left !important; padding-left: 8px !important; }
.col-info-4 { position: sticky; left: 212px; z-index: 1; background: #fff !important; min-width: 80px; max-width: 100px; text-align: left !important; padding-left: 8px !important; }
.col-info-5 { position: sticky; left: 292px; z-index: 1; background: #fff !important; min-width: 68px; max-width: 80px; text-align: left !important; padding-left: 8px !important; }
#gridTable thead .col-info-1,
#gridTable thead .col-info-2,
#gridTable thead .col-info-3,
#gridTable thead .col-info-4,
#gridTable thead .col-info-5 { background: #104861 !important; color: #fff !important; z-index: 4; }

/* Header styling */
.header-weekday { background: #104861 !important; color: #fff !important; }
.header-weekend { background: #E85555 !important; color: #fff !important; }
.header-daynum { background: #808080 !important; color: #fff !important; }

/* Weekend columns (body) */
.col-weekend { background: #f5f5f5; }

/* EXCEL COLORS from VBA macro */
.ct-normal { background: #a9d08e; color: #2d5a1a; }
.ct-doble { background: #f4b084; color: #7a3a0a; }
.ct-noche { background: #bdd7ee; color: #1a3a6a; }
.ct-noche-doble { background: #418cf1; color: #fff; }
.ct-feriado { background: #eb6b1d; color: #fff; }
.ct-libre { background: #FFC000; color: #5a3e00; }
.ct-licencia { background: #ffe699; color: #6a5200; }
.ct-inasistencia { background: #d1a7cc; color: #4a1a4a; }
.ct-vacaciones { background: #40e0d0; color: #004a40; }
.ct-bloqueado { background: #bfbfbf; color: #444; }
.ct-suspension-temporal { background: #186A22; color: #fff; }
.ct-muerte-familiar { background: #333; color: #fff; }

/* COMMENT INDICATOR (red dot top-right) */
.has-comment {
  position: relative;
  cursor: help;
}
.has-comment::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 6px;
  height: 6px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(239,68,68,0.5);
  pointer-events: none;
}

/* CUSTOM TOOLTIP (JS-managed, at body level for z-index supremacy) */
.cell-tooltip {
  position: fixed;
  z-index: 2147483647;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  background: #1f2937;
  color: #f0f0f0;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 280px;
  min-width: 80px;
  width: max-content;
  text-align: left;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  font-weight: 400;
  transform: scale(0.92);
}
.cell-tooltip.visible {
  opacity: 1;
  transform: scale(1);
}

/* TOTALS COLUMNS */
.col-total { font-weight: 600; background: #f8f9fa; min-width: 38px; }
#gridTable td.col-total { cursor: default; }
#gridTable thead .col-total { background: #104861 !important; color: #fff !important; z-index: 2; }

/* FOOTER */
.footer-bar {
  height: var(--footer-h);
  background: #1a1d23;
  color: #e0e0e0;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 12px;
  gap: 16px;
  flex-shrink: 0;
  border-top: 1px solid #333;
}
.footer-bar .ft-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.footer-bar .ft-label { color: #999; font-size: 11px; }
.footer-bar .ft-value { color: #fff; font-weight: 600; }
.footer-bar .ft-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* MODALS */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: none;
}
.modal-overlay.active { display: block; }

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  z-index: 101;
  display: none;
  min-width: 420px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}
.modal.active { display: block; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}
.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #999;
  padding: 2px 6px;
}
.btn-close:hover { color: #333; }
.modal-body { padding: 14px 18px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

/* Form elements */
.form-row {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.form-row label { font-size: 12px; font-weight: 500; color: var(--text2); }
.form-input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  font-size: 13px;
  outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.form-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
  background: #fafbfc;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  border-radius: 6px;
}
.form-textarea:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* Radio grid */
.radio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.radio-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
  background: #fafafa;
}
.radio-card:hover { border-color: var(--primary); background: #f0f4ff; }
.radio-card input[type="radio"] { accent-color: var(--primary); cursor: pointer; }
.radio-card:has(input:checked) {
  font-weight: 600;
}
.radio-card:has(input[value="normal"]:checked) {
  background: #a9d08e;
  border-color: #8fbc6e;
  color: #2d5a1a;
}
.radio-card:has(input[value="doble"]:checked) {
  background: #f4b084;
  border-color: #e08a5e;
  color: #7a3a0a;
}
.radio-card:has(input[value="noche"]:checked) {
  background: #bdd7ee;
  border-color: #8fb8d8;
  color: #1a3a6a;
}
.radio-card:has(input[value="noche-doble"]:checked) {
  background: #418cf1;
  border-color: #2563eb;
  color: #fff;
}
.radio-card:has(input[value="feriado"]:checked) {
  background: #eb6b1d;
  border-color: #cc5510;
  color: #fff;
}
.radio-card:has(input[value="libre"]:checked) {
  background: #FFC000;
  border-color: #e0a800;
  color: #5a3e00;
}
.radio-card:has(input[value="licencia"]:checked) {
  background: #ffe699;
  border-color: #e6cc70;
  color: #6a5200;
}
.radio-card:has(input[value="inasistencia"]:checked) {
  background: #d1a7cc;
  border-color: #b888b3;
  color: #4a1a4a;
}
.radio-card:has(input[value="vacaciones"]:checked) {
  background: #40e0d0;
  border-color: #30c0b0;
  color: #004a40;
}
.radio-card:has(input[value="bloqueado"]:checked) {
  background: #bfbfbf;
  border-color: #999;
  color: #444;
}
.radio-card:has(input[value="suspension-temporal"]:checked) {
  background: #186A22;
  border-color: #0f4a16;
  color: #fff;
}
.radio-card:has(input[value="muerte-familiar"]:checked) {
  background: #333;
  border-color: #222;
  color: #fff;
}

/* Buttons */
.btn {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm, 4px);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-secondary { background: #e8eaed; color: #333; }
.btn-secondary:hover { background: #d2d5da; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* Context menu */
.context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 200;
  display: none;
  min-width: 170px;
  overflow: hidden;
}
.context-menu.active { display: block; }
.ctx-item {
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.ctx-item:hover { background: #f0f4ff; color: var(--primary); }
.ctx-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* SELECTED CELLS (range selection) */
.cell-selected {
  outline: 2px solid #2563eb !important;
  outline-offset: -1px;
  position: relative;
  z-index: 1;
}

/* BATCH SELECTION PANEL */
.batch-panel {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-bottom: 2px solid var(--primary);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 50;
  display: none;
  min-width: 100%;
}
.batch-panel.active { display: block; }
.batch-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: #f0f4ff;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}
.batch-body {
  padding: 10px 14px;
}
.batch-body .radio-grid {
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.batch-body .radio-card {
  padding: 4px 6px;
  font-size: 11px;
  gap: 4px;
}
.batch-inline {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 8px;
}
.batch-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.batch-field label { font-size: 11px; font-weight: 500; color: var(--text2); }
.batch-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* SELECTION MODE CURSOR */
.grid-wrap.select-mode #gridBody td {
  cursor: crosshair !important;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* Export Modal */
.export-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 8px 0;
}
.export-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  background: #fafafa;
  user-select: none;
}
.export-card:hover {
  border-color: var(--primary);
  background: #f0f4ff;
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.15);
}
.export-card:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(37,99,235,0.1);
}
.export-icon { font-size: 36px; line-height: 1; }
.export-name { font-size: 16px; font-weight: 700; color: var(--text); }
.export-desc { font-size: 11px; color: var(--text2); line-height: 1.4; }

@media (max-width: 600px) {
  .export-grid { grid-template-columns: 1fr; gap: 8px; }
  .export-card { padding: 14px 12px; flex-direction: row; text-align: left; gap: 10px; }
  .export-icon { font-size: 28px; }
  .export-name { font-size: 14px; }
  .export-desc { font-size: 10px; }
}

/* Scrollbar */
.grid-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.grid-wrap::-webkit-scrollbar-track { background: #f0f0f0; }
.grid-wrap::-webkit-scrollbar-thumb { background: #c0c4cc; border-radius: 4px; }
.grid-wrap::-webkit-scrollbar-thumb:hover { background: #a0a4aa; }

/* ============================================================
   LOGIN PAGE STYLES
   ============================================================ */
.login-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #1d4ed8 100%);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}
.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
  animation: slideUp 0.5s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-header {
  text-align: center;
  padding: 40px 30px 20px;
}
.login-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a1d23;
  margin: 0 0 6px;
}
.login-subtitle {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
}
.login-form {
  padding: 0 30px 30px;
}
.login-field {
  margin-bottom: 16px;
}
.login-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}
.login-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e0e3e8;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  background: #fafbfc;
}
.login-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  background: #fff;
}
.login-input::placeholder { color: #9ca3af; }
.login-btn {
  width: 100%;
  padding: 12px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.login-btn:hover { background: #1d4ed8; }
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.login-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.login-error {
  background: #fef2f2;
  color: #dc2626;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: none;
  text-align: center;
  border: 1px solid #fca5a5;
}

/* ============================================================
   ADMIN PANEL STYLES
   ============================================================ */
.admin-body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1d23;
  height: 100vh;
  overflow: hidden;
}
.admin-nav {
  background: #1a1d23;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  flex-shrink: 0;
}
.admin-nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-nav-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}
.admin-nav-badge {
  background: #2563eb;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.admin-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.admin-nav-user {
  font-size: 13px;
  color: #ccc;
}
.admin-nav-logout {
  background: none;
  border: 1px solid #444;
  color: #ccc;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.admin-nav-logout:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.admin-layout {
  display: flex;
  height: calc(100vh - 56px);
}
.admin-sidebar {
  width: 200px;
  background: #fff;
  border-right: 1px solid #e0e3e8;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.admin-sidebar-btn {
  padding: 10px 14px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #4b5563;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.admin-sidebar-btn:hover {
  background: #f3f4f6;
  color: #2563eb;
}
.admin-sidebar-btn.active {
  background: #eff6ff;
  color: #2563eb;
  font-weight: 600;
}
.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.admin-section {
  display: none;
}
.admin-section.active {
  display: block;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.admin-section-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

/* Dashboard Cards */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.dash-card {
  background: #fff;
  border: 1px solid #e0e3e8;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.2s;
}
.dash-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.dash-card-icon {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eff6ff;
  border-radius: 12px;
}
.dash-card-info {
  display: flex;
  flex-direction: column;
}
.dash-card-number {
  font-size: 28px;
  font-weight: 700;
  color: #1a1d23;
  line-height: 1;
}
.dash-card-label {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

/* Admin Table Card */
.admin-card {
  background: #fff;
  border: 1px solid #e0e3e8;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}
.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e0e3e8;
  gap: 12px;
}
.admin-card-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.admin-card-body {
  overflow-x: auto;
}
.admin-search {
  flex: 0 0 200px;
}
.admin-filters {
  display: flex;
  gap: 8px;
}
.admin-filters .form-input,
.admin-search .form-input {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* Admin Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #f9fafb;
  border-bottom: 1px solid #e0e3e8;
  white-space: nowrap;
}
.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.admin-table tr:hover td {
  background: #fafbfc;
}
.admin-table tr:last-child td {
  border-bottom: none;
}
.table-empty {
  text-align: center !important;
  color: #9ca3af !important;
  padding: 30px 14px !important;
  font-style: italic;
}
.table-actions {
  white-space: nowrap;
  display: flex;
  gap: 4px;
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.status-active {
  background: #dcfce7;
  color: #166534;
}
.status-inactive {
  background: #f3f4f6;
  color: #6b7280;
}

/* Small Button */
.btn-sm {
  padding: 4px 8px;
  font-size: 14px;
  min-width: 32px;
  text-align: center;
}

/* App page - user info */
.app-user-info {
  font-size: 12px;
  color: #6b7280;
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid #e0e3e8;
}
.app-project-info {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid #e0e3e8;
}

/* Responsive Admin */
@media (max-width: 768px) {
  .admin-sidebar {
    width: 56px;
    padding: 16px 6px;
  }
  .admin-sidebar-btn {
    font-size: 0;
    padding: 10px;
    text-align: center;
  }
  .admin-sidebar-btn::before {
    font-size: 16px;
  }
  .admin-content {
    padding: 16px;
  }
  .dashboard-cards {
    grid-template-columns: 1fr;
  }
  .admin-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .admin-filters {
    flex-direction: column;
  }
  .admin-table {
    font-size: 12px;
  }
  .admin-table th,
  .admin-table td {
    padding: 8px 10px;
  }
  .admin-card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .admin-search {
    flex: 1;
    width: 100%;
  }
}

/* ============================================================
   PRINT STYLES - Preserve colors when printing
   ============================================================ */
@media print {
  body {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
    overflow: visible !important;
    height: auto !important;
  }
  .app {
    height: auto !important;
    overflow: visible !important;
  }
  .grid-wrap {
    overflow: visible !important;
    height: auto !important;
  }
  #gridTable td,
  #gridTable th {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  .top-bar,
  .footer-bar,
  .legend-bar {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  .modal-overlay,
  .modal,
  .context-menu,
  .toast,
  .batch-panel,
  .cell-tooltip,
  .btn-undo,
  #addEmpBtn {
    display: none !important;
  }
}

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

/* --- Small Tablets / Large Phones (≤ 900px) --- */
@media (max-width: 900px) {
  .top-bar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
  }
  .top-left {
    flex: 1 1 auto;
    min-width: 0;
  }
  .app-title { font-size: 14px; }
  .emp-count { font-size: 10px; padding: 1px 6px; }
  .btn-undo { font-size: 14px; padding: 1px 4px; }
  .top-center {
    margin-left: 0;
    order: 3;
    flex: 0 0 100%;
    justify-content: flex-start;
  }
  .top-center select {
    font-size: 12px;
    padding: 3px 8px;
    flex: 1;
    min-width: 0;
  }
  .top-right {
    order: 2;
    flex: 0 0 auto;
  }
  .top-right .btn {
    font-size: 11px;
    padding: 5px 10px;
  }

  .legend-bar {
    height: auto;
    min-height: var(--legend-h);
    padding: 4px 10px;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .lg-item { font-size: 11px; }
  .lg-dot { width: 12px; height: 12px; }

  .modal {
    min-width: 0;
    width: 94vw;
    max-height: 90vh;
  }
  .modal-header { padding: 12px 14px; font-size: 14px; }
  .modal-body { padding: 12px 14px; }
  .modal-footer { padding: 10px 14px; flex-wrap: wrap; gap: 6px; }
  .modal-footer .btn { flex: 1; text-align: center; min-width: 80px; }

  .radio-grid { gap: 4px; }
  .radio-card { padding: 5px 8px; font-size: 11px; }

  .form-input { font-size: 12px; padding: 5px 8px; }
  .form-textarea { font-size: 12px; padding: 8px 10px; min-height: 60px; }

  #gridTable td {
    font-size: 11px;
    padding: 2px 3px;
    min-width: 22px;
    height: 22px;
    line-height: 22px;
  }
  #gridTable th {
    font-size: 10px;
    padding: 3px 4px;
  }

  .col-info-1 { min-width: 26px; width: 26px; }
  .col-info-2 { left: 26px; min-width: 70px; }
  .col-info-3 { left: 96px; min-width: 80px; max-width: 90px; }
  .col-info-4 { left: 176px; min-width: 70px; max-width: 80px; }
  .col-info-5 { left: 246px; min-width: 60px; max-width: 70px; }
  #gridTable thead tr:nth-child(2) th { top: 20px; }

  .col-total { min-width: 32px; }

  .footer-bar {
    height: auto;
    min-height: var(--footer-h);
    padding: 6px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .footer-bar .ft-item { font-size: 11px; }

  .batch-header {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12px;
  }
  .batch-body { padding: 8px 10px; }
  .batch-body .radio-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .batch-body .radio-card { font-size: 10px; padding: 3px 5px; }
  .batch-inline { flex-direction: column; align-items: stretch; gap: 6px; }

  .export-grid { grid-template-columns: repeat(2, 1fr); }

  .context-menu { min-width: 140px; }
  .ctx-item { padding: 6px 10px; font-size: 12px; }

  .cell-tooltip {
    font-size: 11px;
    padding: 8px 10px;
    max-width: 200px;
  }
}

/* --- Phones (≤ 600px) --- */
@media (max-width: 600px) {
  :root {
    font-size: 12px;
    --header-h: auto;
    --legend-h: 28px;
    --footer-h: 32px;
  }

  .top-bar { padding: 6px 10px; gap: 6px; }
  .app-title { font-size: 13px; }
  .top-center {
    order: 2;
    flex: 0 0 100%;
    gap: 4px;
  }
  .top-center select {
    font-size: 11px;
    padding: 2px 6px;
  }
  .top-right {
    order: 3;
    flex: 0 0 100%;
    justify-content: flex-start;
  }
  .top-right .btn {
    flex: 1;
    font-size: 11px;
    padding: 5px 8px;
    text-align: center;
  }
  .undo-group { margin-left: 2px; }
  .btn-undo { font-size: 13px; padding: 1px 3px; }

  .modal {
    width: 96vw;
    max-height: 92vh;
    border-radius: 6px;
  }
  .modal-header { padding: 10px 12px; font-size: 13px; }
  .modal-body { padding: 10px 12px; }
  .modal-footer { padding: 8px 12px; }
  .modal-footer .btn { 
    min-width: 0;
    padding: 6px 12px;
    font-size: 11px;
  }

  .radio-grid { grid-template-columns: 1fr 1fr; gap: 3px; }
  .radio-card { padding: 4px 6px; font-size: 10px; }
  .radio-card input[type="radio"] { width: 14px; height: 14px; }

  .form-row { margin-bottom: 8px; }
  .form-row label { font-size: 11px; }
  .form-input { font-size: 12px; padding: 4px 8px; }
  .form-textarea { font-size: 12px; padding: 6px 8px; min-height: 50px; }
  #hoursInput { width: 60px; }

  .checkbox-label { font-size: 12px; }
  .checkbox-label input[type="checkbox"] { width: 14px; height: 14px; }

  .legend-bar {
    min-height: 26px;
    padding: 3px 8px;
    gap: 4px;
  }
  .lg-item { font-size: 10px; gap: 3px; }
  .lg-dot { width: 10px; height: 10px; border-radius: 3px; }

  #gridTable td {
    font-size: 10px;
    padding: 1px 2px;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
  }
  #gridTable th {
    font-size: 9px;
    padding: 2px 3px;
  }

  .col-info-1 { min-width: 22px; width: 22px; }
  .col-info-2 { left: 22px; min-width: 60px; }
  .col-info-3 { left: 82px; min-width: 70px; max-width: 80px; padding-left: 4px !important; }
  .col-info-4 { left: 152px; min-width: 60px; max-width: 70px; }
  .col-info-5 { left: 212px; min-width: 50px; max-width: 60px; }

  .col-total { min-width: 28px; }

  .footer-bar {
    padding: 4px 10px;
    gap: 4px 8px;
  }
  .footer-bar .ft-item { font-size: 10px; }

  .batch-header { padding: 5px 8px; font-size: 11px; }
  .batch-body { padding: 6px 8px; }
  .batch-body .radio-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .batch-body .radio-card { font-size: 9px; padding: 2px 4px; }
  .batch-field label { font-size: 10px; }
  .batch-actions { flex-wrap: wrap; }
  .batch-actions .btn { font-size: 10px; padding: 4px 8px; flex: 1; text-align: center; }

  .context-menu { min-width: 120px; }
  .ctx-item { padding: 5px 8px; font-size: 11px; }

  .toast {
    bottom: 40px;
    font-size: 12px;
    padding: 6px 14px;
    max-width: 90vw;
  }

  .cell-tooltip {
    font-size: 10px;
    padding: 6px 10px;
    max-width: 160px;
    min-width: 60px;
  }

  #gridTable thead tr:nth-child(2) th { top: 18px; }

  .grid-wrap::-webkit-scrollbar { width: 4px; height: 4px; }
}

/* --- Small Phones (≤ 400px) --- */
@media (max-width: 400px) {
  .app-title { font-size: 12px; }
  .top-center select { font-size: 10px; padding: 2px 4px; }
  .top-right .btn { font-size: 10px; padding: 4px 6px; }

  .modal { width: 98vw; }
  .radio-grid { grid-template-columns: 1fr 1fr; gap: 2px; }
  .radio-card { font-size: 9px; padding: 3px 4px; }

  .col-info-1 { min-width: 22px; width: 22px; }
  .col-info-2 { left: 22px; min-width: 50px; }
  .col-info-3 { left: 72px; min-width: 60px; max-width: 70px; }
  .col-info-4 { left: 132px; min-width: 50px; max-width: 60px; }
  .col-info-5 { left: 182px; min-width: 45px; max-width: 50px; }

  .footer-bar .ft-item { font-size: 9px; }
}
