/* ============================================================
   DEEP SIIH — Design System
   ============================================================ */

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

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --sidebar-w: 260px;
  --sidebar-bg: #1B3A6B;
  --sidebar-text: #7BAFD4;
  --sidebar-active-bg: #0F2447;
  --sidebar-active-text: #ffffff;
  --sidebar-hover-bg: #0F2447;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;

  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;

  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);

  --transition: 0.2s ease;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
}

.page-content {
  padding: 28px 32px;
  flex: 1;
}

/* ── Site Footer ────────────────────────────────────────────── */
.site-footer {
  margin-top: auto;
  padding: 12px 32px;
  border-top: 1px solid #f1f5f9;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 11px;
  color: #c8d0d8 !important;
  letter-spacing: 0.3px;
}

.site-footer span,
.site-footer strong {
  color: #c8d0d8 !important;
  font-weight: 400;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
  transition: width var(--transition), transform var(--transition);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
}
.sidebar-overlay.active { display: block; }

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  font-size: 19px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  margin-right: 4px;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg); }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.sidebar-header > div:not(.sidebar-logo) {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 18px;
}

.sidebar-brand {
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.3px;
}

.sidebar-brand span {
  font-weight: 400;
  color: var(--sidebar-text);
  font-size: 10.5px;
  display: block;
  margin-top: 2px;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(123, 175, 212, 0.5);
  padding: 8px 10px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: #e2e8f0;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.nav-item .nav-icon {
  width: 20px;
  font-size: 15px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item.danger { color: #f87171; }
.nav-item.danger:hover { background: rgba(220,38,38,0.12); color: #fca5a5; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

/* ── Top Bar ────────────────────────────────────────────────── */
.top-bar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-bar-title .page-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 50px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.user-avatar {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header-custom {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Stat Cards */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.amber  { background: var(--warning-light); color: var(--warning); }
.stat-icon.cyan   { background: var(--info-light);    color: var(--info); }
.stat-icon.red    { background: var(--danger-light);  color: var(--danger); }

.stat-info { flex: 1; min-width: 0; }

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-top: 2px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
}
.btn-primary:hover { background: var(--primary-hover); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 7px 15px;
}
.btn-outline:hover { background: var(--primary-light); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  padding: 8px 16px;
}
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
  display: block;
}

.form-control, .form-select {
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-control::placeholder { color: #94a3b8; }

.form-group { margin-bottom: 16px; }

textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* DataTables overrides */
table.dataTable {
  font-size: 13px;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  width: 100% !important;
}

table.dataTable thead th {
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border) !important;
  border-top: none !important;
  white-space: nowrap;
}

table.dataTable tbody tr {
  transition: background var(--transition);
}

table.dataTable tbody tr:hover td {
  background: #f8fafc !important;
}

table.dataTable tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9 !important;
  color: var(--text);
  vertical-align: middle;
}

table.dataTable tbody tr:last-child td {
  border-bottom: none !important;
}

.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  outline: none;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
  font-size: 12.5px;
  color: var(--text-muted);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--radius-sm) !important;
  font-size: 13px !important;
  color: var(--text-muted) !important;
  padding: 4px 9px !important;
  border: none !important;
  box-shadow: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--primary) !important;
  color: #fff !important;
  border: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  border: none !important;
}

.dataTables_wrapper {
  padding: 16px 20px;
}

.dt-top-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* ── Badges / Status ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-blue   { background: var(--primary-light); color: var(--primary); }
.badge-green  { background: var(--success-light); color: var(--success); }
.badge-amber  { background: var(--warning-light); color: var(--warning); }
.badge-red    { background: var(--danger-light);  color: var(--danger); }
.badge-gray   { background: #f1f5f9; color: var(--text-muted); }
.badge-cyan   { background: var(--info-light);    color: var(--info); }
.badge-purple { background: #f3e8ff; color: #7c3aed; }
.badge-indigo { background: #e0e7ff; color: #4338ca; }
.badge-teal   { background: #ccfbf1; color: #0f766e; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-orange { background: #ffedd5; color: #c2410c; }

.file-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-weight: 500;
}
.file-link:hover { text-decoration: underline; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-content {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-family: 'Inter', sans-serif;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.modal-body { padding: 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

/* ── Toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-notif {
  background: #1e293b;
  color: #f8fafc;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 500;
  pointer-events: all;
  animation: slideIn 0.25s ease;
  max-width: 360px;
  border-left: 3px solid var(--primary);
}

.toast-notif.toast-success { border-left-color: var(--success); }
.toast-notif.toast-success .toast-icon { color: #4ade80; }
.toast-notif.toast-error { border-left-color: var(--danger); }
.toast-notif.toast-error .toast-icon { color: #f87171; }
.toast-notif.toast-warning { border-left-color: var(--warning); }
.toast-notif.toast-warning .toast-icon { color: #fbbf24; }

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-fade { animation: fadeOut 0.3s ease forwards; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ── Login Page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.login-left {
  flex: 1;
  background: linear-gradient(145deg, #0a1628 0%, #0f2650 40%, #1a3a6c 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(37,99,235,0.25) 0%, transparent 70%);
  top: -100px;
  left: -100px;
}

.login-left::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(8,145,178,0.2) 0%, transparent 70%);
  bottom: -80px;
  right: -80px;
}

.login-brand {
  position: relative;
  z-index: 1;
  text-align: center;
}

.login-logo {
  width: 80px;
  height: 80px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto 24px;
  backdrop-filter: blur(10px);
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.55);
  line-height: 1.6;
  max-width: 280px;
}

.login-features {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.7);
  font-size: 13.5px;
}

.login-feature i {
  width: 32px;
  height: 32px;
  background: rgba(37,99,235,0.25);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
  font-size: 14px;
}

.login-right {
  width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--card-bg);
}

.login-form-card { width: 100%; max-width: 360px; }

.login-form-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.login-form-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-btn {
  width: 100%;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition), transform var(--transition);
  margin-top: 8px;
}

.login-btn:hover { background: var(--primary-hover); }
.login-btn:active { transform: scale(0.98); }

/* ── Dashboard Charts ───────────────────────────────────────── */
.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Schedule Grid ──────────────────────────────────────────── */
.schedule-table {
  font-size: 12px;
}

.schedule-table th {
  font-size: 11px !important;
  padding: 8px 6px !important;
}

.schedule-table td {
  padding: 6px 8px !important;
  cursor: pointer;
}

.schedule-table .weekend-row td:first-child { background: #fafafa; }

.regime-folga       { background: #fee2e2 !important; color: #991b1b; font-size: 11px; }
.regime-plantao     { background: #fef3c7 !important; color: #92400e; font-size: 11px; }
.regime-expediente  { background: #dcfce7 !important; color: #166534; font-size: 11px; }
.regime-cell-text   { font-size: 10px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }

/* ── Map ────────────────────────────────────────────────────── */
#map {
  height: calc(100vh - 60px - 80px);
  min-height: 400px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ── Utilities ──────────────────────────────────────────────── */
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.text-muted { color: var(--text-muted); }
.fw-600 { font-weight: 600; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .login-left { display: none; }
  .login-right { width: 100%; }
  .page-content { padding: 16px; }
  .top-bar { padding: 0 16px; }
  .stat-value { font-size: 22px; }
  .sidebar-toggle { display: flex; }
  .top-bar-title { font-size: 14px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
}

/* ── Tom Select overrides ───────────────────────────────────── */
.ts-wrapper.form-control {
  padding: 0;
  border: none;
}

.ts-control {
  font-family: 'Inter', sans-serif !important;
  font-size: 13.5px !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 6px 10px !important;
  min-height: 38px !important;
  box-shadow: none !important;
}

.ts-control:focus-within {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12) !important;
}

.ts-dropdown {
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow) !important;
}

.ts-dropdown .option { padding: 8px 12px !important; }
.ts-dropdown .option:hover, .ts-dropdown .option.active { background: var(--primary-light) !important; color: var(--primary) !important; }

.ts-control .item {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  border: none !important;
  border-radius: 4px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  padding: 2px 8px !important;
}

/* ── Loading Spinner ────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Drag-and-Drop Calendar ─────────────────────────────────── */
.cal-layout { display: flex; gap: 16px; align-items: flex-start; }

.cal-main { flex: 1; min-width: 0; }

.cal-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  margin-bottom: 12px; box-shadow: var(--shadow-sm);
}

.cal-range-label {
  font-size: 13px; font-weight: 600; color: var(--text);
  padding: 0 8px; flex: 1; text-align: center;
}

.cal-container {
  overflow: auto;
  max-height: calc(100vh - 280px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
}

.cal-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: max-content;
  width: 100%;
}

/* Sticky corner header */
.cal-res-header {
  position: sticky; left: 0; top: 0; z-index: 4;
  background: #f1f5f9;
  min-width: 160px; max-width: 160px;
  padding: 10px 12px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  border-right: 2px solid var(--border);
}

/* Date column headers */
.cal-date-th {
  position: sticky; top: 0; z-index: 2;
  background: #f8fafc;
  min-width: 110px;
  padding: 8px 4px;
  text-align: center;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid #f1f5f9;
  white-space: nowrap;
}
.cal-date-th.today-col  { background: #eff6ff; border-bottom-color: var(--primary); }
.cal-date-th.weekend-col { background: #fafafa; }

.cal-weekday { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.4px; }
.cal-daynum  { font-size: 13px; font-weight: 600; color: var(--text); margin-top: 2px; }
.cal-date-th.today-col .cal-daynum { color: var(--primary); }

/* Group separator rows */
.cal-group-row td {
  position: sticky; left: 0; z-index: 1;
  background: linear-gradient(135deg, #0a1628 0%, #0f2650 100%);
  color: rgba(255,255,255,0.85);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; padding: 7px 14px;
  border-top: 2px solid var(--primary);
}
.cal-group-row td i { margin-right: 6px; opacity: 0.7; }

/* Resource name cells */
.cal-res-name {
  position: sticky; left: 0; z-index: 1;
  background: var(--card-bg);
  min-width: 160px; max-width: 160px;
  padding: 6px 12px;
  font-size: 12.5px; font-weight: 500; color: var(--text);
  border-right: 2px solid var(--border);
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-res-name .res-sub { font-size: 10px; color: var(--text-muted); font-weight: 400; }

/* Calendar cells */
.cal-cell {
  min-width: 110px;
  min-height: 44px;
  padding: 4px 5px;
  border-right: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
  position: relative;
  transition: background 0.15s;
}
.cal-cell.weekend-cell { background: #fafafa; }
.cal-cell.today-cell   { background: #eff6ff; }
.cal-cell.drag-over    { background: #dbeafe !important; outline: 2px dashed var(--primary); outline-offset: -2px; }

/* Event chips */
.event-chip {
  display: flex; flex-direction: column;
  border-radius: 5px;
  padding: 4px 7px;
  margin-bottom: 3px;
  font-size: 11px;
  cursor: grab;
  position: relative;
  border-left: 3px solid;
  transition: opacity 0.15s, transform 0.15s;
  user-select: none;
}
.event-chip:active { cursor: grabbing; opacity: 0.7; }
.event-chip.dragging { opacity: 0.4; transform: scale(0.97); }

.chip-project { font-weight: 700; font-size: 11px; line-height: 1.3; }
.chip-sub     { font-size: 10px; opacity: 0.75; margin-top: 1px; }
.chip-delete  {
  position: absolute; top: 2px; right: 3px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; line-height: 1; color: inherit;
  opacity: 0.5; padding: 0; display: none;
}
.event-chip:hover .chip-delete { display: block; }
.chip-delete:hover { opacity: 1 !important; }

/* Cell add button */
.cell-add-btn {
  display: none;
  width: 20px; height: 20px;
  background: var(--primary-light); color: var(--primary);
  border-radius: 50%; font-size: 14px; line-height: 20px;
  text-align: center; cursor: pointer;
  position: absolute; bottom: 3px; right: 3px;
  font-weight: 700; transition: background 0.15s;
}
.cal-cell:hover .cell-add-btn { display: block; }
.cell-add-btn:hover { background: var(--primary); color: #fff; }

/* Right: Add panel */
.cal-add-panel {
  width: 230px; flex-shrink: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  position: sticky; top: 0;
}
.cal-add-panel h6 {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 14px;
}

.drag-chip-source {
  background: var(--primary-light); color: var(--primary);
  border: 2px dashed var(--primary); border-radius: var(--radius-sm);
  padding: 10px; text-align: center;
  cursor: grab; font-size: 12px; font-weight: 600;
  transition: background 0.15s;
  margin-top: 12px;
  user-select: none;
}
.drag-chip-source:hover { background: #bfdbfe; }
.drag-chip-source:active { cursor: grabbing; opacity: 0.7; }

/* Quick-add modal row */
.quick-add-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Legend */
.cal-legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }
.cal-legend-dot  { width: 10px; height: 10px; border-radius: 2px; }

/* ── Admin Sidebar Section ───────────────────────────────────── */
.sidebar-admin-section { display: none; }

/* ── Charts Section (workschedules + admin_effort) ──────────── */
.charts-section { margin-top: 24px; }

.charts-section-title {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
  margin-bottom: 16px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* Sector regime charts: always exactly 2 columns, fills full width */
.chart-grid-sectors {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* Taller canvas for sector doughnut charts */
.chart-grid-sectors .chart-canvas-wrap {
  height: 340px;
}

@media (max-width: 768px) {
  .chart-grid-sectors { grid-template-columns: 1fr; }
}

.chart-card h6 {
  font-size: 12px; font-weight: 600; color: var(--text);
  margin-bottom: 16px; display: flex; align-items: center; gap: 6px;
}

.chart-canvas-wrap { position: relative; height: 220px; }

.chart-empty {
  height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px; text-align: center;
  background: #fafafa; border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  padding: 20px;
}

/* ── Sector filter pills ─────────────────────────────────────── */
.sector-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.sector-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  line-height: 1;
}

.sector-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.sector-pill.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.sector-pill.active i { opacity: 1; }

/* ── Expand chevron (table row) ──────────────────────────────── */
.expand-btn {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; padding: 0; flex-shrink: 0;
  transition: all .15s;
}
.expand-btn:hover,
.expand-btn.open {
  border-color: var(--info);
  color: var(--info);
  background: var(--info-light);
}
.expand-btn i { transition: transform .2s; }

/* DataTables child row wrapper */
.sub-row-child > td { padding: 0 !important; background: #f8fafc !important; }

/* Inline sub-survey panel */
.sub-row-panel {
  padding: 14px 20px 16px;
  border-top: 2px solid var(--info-light);
}
.sub-row-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--info);
  margin-bottom: 12px;
}
.sub-manage-btn {
  font-size: 11px !important; gap: 4px;
  color: var(--primary) !important;
}
.sub-row-grid {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.sub-row-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-width: 220px; flex: 1; max-width: 380px;
}
.sub-row-card-header {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; font-size: 12px; margin-bottom: 5px;
}
.sub-row-metric {
  font-size: 11px; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 3px;
}
.sub-row-files {
  display: flex; gap: 12px; font-size: 11px; margin-top: 5px;
}
.sub-row-files a {
  color: var(--primary); text-decoration: none;
  display: inline-flex; align-items: center; gap: 3px;
}
.sub-row-files a:hover { text-decoration: underline; }
.sub-row-products { margin-top: 5px; display: flex; gap: 4px; flex-wrap: wrap; }
.sub-row-desc {
  margin-top: 5px; font-size: 11px; color: var(--text-muted);
  border-left: 2px solid var(--border); padding-left: 8px;
}
/* highlight expanded row */
tr.row-expanded > td { background: #f0f9ff !important; }

/* Sub-survey inline table */
.sub-row-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: #fff;
}
.sub-row-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px; white-space: nowrap;
}
.sub-row-table thead tr {
  background: #f1f5f9;
  border-bottom: 1.5px solid var(--border);
}
.sub-row-table thead th {
  padding: 8px 12px;
  font-weight: 600; color: var(--text-muted);
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .03em;
}
.sub-row-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background .12s;
}
.sub-row-table tbody tr:last-child { border-bottom: none; }
.sub-row-table tbody tr:hover { background: #f8fafc; }
.sub-row-table td {
  padding: 9px 12px; vertical-align: middle;
}
.sub-table-seq {
  color: var(--text-muted); font-size: 11px; font-weight: 600;
  width: 28px; text-align: center;
}
.sub-table-date { min-width: 130px; }
.sub-table-num  { text-align: right; min-width: 70px; }
.sub-table-prods { min-width: 140px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.sub-table-obs  { max-width: 200px; white-space: normal; color: var(--text-muted); }
.sub-file-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--primary); text-decoration: none; font-weight: 500;
  padding: 2px 8px; border-radius: 5px;
  background: var(--primary-light); font-size: 11px;
  transition: opacity .15s;
}
.sub-file-link:hover { opacity: .8; text-decoration: underline; }

/* ── Sub-surveys ──────────────────────────────────────────────── */
.sub-survey-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.sub-survey-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.sub-survey-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sub-survey-date {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.sub-survey-date i { color: var(--primary); }
.sub-survey-card-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.sub-survey-desc {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  border-left: 3px solid var(--border);
  padding-left: 10px;
}
.sub-survey-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.sub-survey-meta span { display: flex; align-items: center; gap: 5px; }
.sub-survey-meta a { color: var(--primary); text-decoration: none; font-weight: 500; }
.sub-survey-meta a:hover { text-decoration: underline; }
.sub-survey-products {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.sub-survey-products i { color: var(--info); }
.sub-product-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--info-light);
  color: var(--info);
}
.sub-survey-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}
.sub-survey-form-panel {
  background: #f8fafc;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 12px;
}
.sub-survey-form-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 7px;
}
/* sub-surveys button in table actions */
.sub-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--info-light);
  color: var(--info);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
}
.sub-btn:hover { border-color: var(--info); background: #cffafe; }
.sub-btn .sub-count {
  background: var(--info);
  color: #fff;
  border-radius: 10px;
  padding: 0 5px;
  font-size: 10px;
  min-width: 16px;
  text-align: center;
}
.sub-btn .sub-count.zero { background: var(--text-muted); }

/* lh-day-btn — botão de Dias de LH na coluna ID */
.lh-day-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #f0fdf4;
  color: var(--success);
  border-radius: var(--radius-sm);
  font-size: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  margin-left: 4px;
}
.lh-day-btn:hover { border-color: var(--success); background: #dcfce7; }
.lh-day-btn .sub-count {
  background: var(--success);
  color: #fff;
  border-radius: 10px;
  padding: 0 5px;
  font-size: 10px;
  min-width: 16px;
  text-align: center;
}
.lh-day-btn .sub-count.zero { background: var(--text-muted); }

/* ── Access Level Control ────────────────────────────────────── */
/* geral users: read-only — hide all write/edit/delete buttons   */
body[data-access-level="geral"] .top-bar-actions .btn-primary,
body[data-access-level="geral"] .edit-btn,
body[data-access-level="geral"] #deleteBtn,
body[data-access-level="geral"] .chip-delete,
body[data-access-level="geral"] .cell-add-btn,
body[data-access-level="geral"] .drag-chip-source,
body[data-access-level="geral"] .cal-add-panel { display: none !important; }

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
