*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-hover: #252838;
  --bg-input: #252838;
  --border: #2d3148;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0b4;
  --text-muted: #6b7280;
  --accent: #d4a017;
  --accent-hover: #e6b422;
  --accent-bg: rgba(212, 160, 23, 0.12);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.12);
  --orange: #f59e0b;
  --orange-bg: rgba(245, 158, 11, 0.12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.12);
  --gold: #d4a017;
  --gold-bg: rgba(212, 160, 23, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --sidebar-width: 260px;
  --transition: 0.2s ease;
  --spi-color: #3b82f6;
  --net-color: #8b5cf6;
  --si-color: #06b6d4;
}

body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg-primary); color: var(--text-primary); line-height: 1.6; overflow-x: hidden; }
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-width); background: var(--bg-secondary); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform var(--transition); }
.sidebar-header { padding: 24px 20px; border-bottom: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; color: var(--accent); }
.logo i { font-size: 26px; }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; font-size: 14px; font-weight: 500; transition: all var(--transition); }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); }
.nav-item i { font-size: 20px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.env-badge { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--green); background: var(--green-bg); padding: 8px 12px; border-radius: var(--radius-sm); }

/* Main */
.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 32px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.menu-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 24px; cursor: pointer; }
.topbar-title { font-size: 18px; font-weight: 600; flex: 1; }
.week-indicator { font-size: 13px; color: var(--text-secondary); background: var(--bg-hover); padding: 6px 14px; border-radius: 20px; }
.page-container { padding: 32px; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; 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: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.gold { background: var(--gold-bg); color: var(--gold); }
.stat-icon.red { background: var(--red-bg); color: var(--red); }
.stat-value { display: block; font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 12px; }
.card-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-header h3 i { color: var(--accent); }
.card-body { padding: 24px; }
.mb-4 { margin-bottom: 24px; }
.mt-4 { margin-top: 24px; }

/* Table */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.table td { padding: 14px 16px; font-size: 14px; border-bottom: 1px solid var(--border); }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.loading-cell { text-align: center; color: var(--text-muted); padding: 40px !important; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-inactive { background: var(--red-bg); color: var(--red); }
.badge-plantao { background: var(--accent-bg); color: var(--accent); }
.badge-escalation { background: var(--orange-bg); color: var(--orange); }
.badge-spi { background: rgba(59,130,246,0.12); color: var(--spi-color); }
.badge-networking { background: rgba(139,92,246,0.12); color: var(--net-color); }
.badge-si { background: rgba(6,182,212,0.12); color: var(--si-color); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; border: none; cursor: pointer; transition: all var(--transition); font-family: inherit; }
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px 12px; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); padding: 8px 16px; font-size: 13px; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-escalation { background: var(--orange); color: #fff; border: none; }
.btn-escalation:hover { background: #d97706; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 6px; font-size: 18px; transition: all var(--transition); }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon.danger:hover { background: var(--red-bg); color: var(--red); }
.btn-group { display: flex; gap: 10px; align-items: center; }
.page-actions { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }

/* Filter */
.filter-group { display: flex; align-items: center; gap: 12px; }
.filter-group select { padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; font-family: inherit; }
.filter-group select option { background: var(--bg-card); }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 14px; }
.search-box i { color: var(--text-muted); font-size: 16px; }
.search-box input { background: none; border: none; color: var(--text-primary); font-size: 13px; outline: none; width: 140px; }
.search-box input::placeholder { color: var(--text-muted); }

/* Date Nav */
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-label { font-size: 14px; font-weight: 500; min-width: 220px; text-align: center; }

/* Week Timeline (Dashboard escalation) */
.week-timeline { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.day-column { background: var(--bg-hover); border-radius: var(--radius-sm); padding: 14px; min-height: 120px; transition: border-color var(--transition); border: 1px solid transparent; }
.day-column.today { border-color: var(--accent); }
.day-column-header { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; text-align: center; }
.day-column-header .day-number { display: block; font-size: 20px; font-weight: 700; color: var(--text-primary); margin-top: 2px; }
.day-column.today .day-column-header { color: var(--accent); }
.day-column.today .day-column-header .day-number { color: var(--accent); }
.day-esc-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--orange-bg); border-radius: 6px; margin-bottom: 6px; border-left: 3px solid var(--orange); }
.day-esc-item .esc-avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(245,158,11,0.2); color: var(--orange); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.day-esc-item .esc-info { flex: 1; min-width: 0; }
.day-esc-item .esc-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-esc-item .esc-team { font-size: 10px; color: var(--text-muted); }
.day-empty { text-align: center; color: var(--text-muted); font-size: 11px; padding: 16px 4px; }

/* Teams Grid (Dashboard) */
.teams-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.team-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.team-card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.team-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.team-card-header h4 { font-size: 15px; font-weight: 600; flex: 1; }
.team-card-body { padding: 16px 20px; }
.team-person { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg-hover); border-radius: var(--radius-sm); margin-bottom: 8px; }
.team-person:last-child { margin-bottom: 0; }
.team-person-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.team-person-info { flex: 1; }
.team-person-name { font-size: 14px; font-weight: 600; }
.team-person-phone { font-size: 12px; color: var(--text-secondary); }
.team-person .badge { flex-shrink: 0; }
.team-escalation-divider { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--orange); margin: 12px 0 8px; padding-left: 4px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.team-escalation-divider::after { content: ''; flex: 1; height: 1px; background: rgba(245,158,11,0.2); }

/* Week View (Escalas page) */
.week-view { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.wv-day { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; min-height: 200px; }
.wv-day.today { border-color: var(--accent); }
.wv-day-header { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: center; }
.wv-day-header .wv-day-name { font-size: 11px; text-transform: uppercase; font-weight: 600; color: var(--text-muted); }
.wv-day-header .wv-day-num { font-size: 18px; font-weight: 700; }
.wv-day.today .wv-day-header { background: var(--accent-bg); }
.wv-day.today .wv-day-header .wv-day-name, .wv-day.today .wv-day-header .wv-day-num { color: var(--accent); }
.wv-day-body { padding: 10px; }
.wv-team-label { font-size: 10px; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; margin: 8px 0 4px; padding-left: 4px; }
.wv-team-label:first-child { margin-top: 0; }
.wv-person { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 4px; margin-bottom: 3px; font-size: 12px; background: var(--bg-hover); }
.wv-person.escalation { background: var(--orange-bg); border-left: 2px solid var(--orange); }
.wv-person-order { font-weight: 700; font-size: 11px; color: var(--text-muted); min-width: 18px; }
.wv-person-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 480px; margin: 20px; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--border); }
.modal-header-escalation h3 i { color: var(--orange); }
.escalation-info-box { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; background: var(--orange-bg); border-radius: var(--radius-sm); border: 1px solid rgba(245,158,11,0.15); font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.escalation-info-box i { color: var(--orange); font-size: 18px; flex-shrink: 0; margin-top: 1px; }

/* Form */
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input, .form-group select { width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; font-family: inherit; outline: none; transition: border-color var(--transition); }
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--text-muted); }
.form-group select option { background: var(--bg-card); }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; box-shadow: var(--shadow); animation: slideIn 0.3s ease; min-width: 280px; }
.toast.success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.toast.error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.toast.info { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* Empty */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }

/* Responsive */
@media (max-width: 1200px) { .week-timeline, .week-view { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); } .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; } .menu-toggle { display: block; }
  .topbar { padding: 16px 20px; } .page-container { padding: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .week-timeline, .week-view { grid-template-columns: repeat(2, 1fr); }
  .teams-grid { grid-template-columns: 1fr; }
  .page-actions { flex-direction: column; align-items: stretch; }
  .date-nav { justify-content: center; }
  .filter-group { flex-wrap: wrap; }
  .btn { min-height: 44px; justify-content: center; }
  .btn-group { flex-direction: column; width: 100%; }
  .btn-group .btn { width: 100%; }
  .modal { max-width: 100%; margin: 10px; max-height: 90vh; display: flex; flex-direction: column; }
  .modal-body { overflow-y: auto; flex: 1; }
  .modal-overlay { padding: 10px; }
  .nav-item { min-height: 44px; }
  .btn-icon { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .sidebar.open + .main-content::before { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }
}
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } .week-timeline, .week-view { grid-template-columns: 1fr; } }
