/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e4e6ed;
  --border-soft: #f0f1f5;
  --text: #1a1d2e;
  --text-muted: #6b7080;
  --text-light: #9ca3b0;
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --primary-dark: #3730a3;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --teal: #0d9488;
  --teal-bg: #f0fdfa;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}

.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

/* ===== SIDEBAR ===== */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 1px solid var(--border-soft);
}
.sidebar-logo i { font-size: 22px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.nav-link i { font-size: 18px; flex-shrink: 0; }
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--primary-light); color: var(--primary); }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-soft);
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; line-height: 1.3; }
.user-email { font-size: 11px; color: var(--text-muted); }

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-muted);
  padding: 4px;
}
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.outlook-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid #bfdbfe;
  font-weight: 500;
}
.notif-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
  transition: background 0.15s;
}
.notif-btn:hover { background: var(--bg); }
.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--surface);
}

/* ===== CONTENT ===== */
.content {
  flex: 1;
  padding: 28px 28px;
  max-width: 1200px;
  width: 100%;
}

/* ===== VIEWS ===== */
.view { display: none; }
.view.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 20px; font-weight: 600; }
.page-header span { font-size: 13px; color: var(--text-muted); }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.amber { background: var(--amber-bg); color: var(--amber); }
.stat-icon.red { background: var(--red-bg); color: var(--red); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.stat-value { font-size: 22px; font-weight: 600; line-height: 1; }

/* ===== DASHBOARD GRID ===== */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
}

/* ===== PANELS ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 500;
  font-size: 13.5px;
}
.panel-head span { display: flex; align-items: center; gap: 7px; }
.panel-head i { font-size: 16px; color: var(--text-muted); }

/* ===== TICKET ROWS (dashboard) ===== */
.ticket-list { padding: 4px 0; }
.tk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s;
}
.tk-row:last-child { border-bottom: none; }
.tk-row:hover { background: var(--bg); }
.tk-cat-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.tk-info { flex: 1; min-width: 0; }
.tk-title-text {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tk-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ===== BADGES / STATUS ===== */
.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-open { background: var(--blue-bg); color: var(--blue); }
.badge-prog { background: var(--amber-bg); color: var(--amber); }
.badge-done { background: var(--green-bg); color: var(--green); }
.badge-urg  { background: var(--red-bg); color: var(--red); }
.badge-alta { background: var(--purple-bg); color: var(--purple); }
.badge-ti   { background: var(--primary-light); color: var(--primary); }
.badge-avion { background: var(--teal-bg); color: var(--teal); }
.badge-acceso { background: var(--amber-bg); color: var(--amber); }
.badge-equipo { background: #fef3c7; color: #92400e; }
.badge-computo { background: var(--blue-bg); color: var(--blue); }

/* ===== FILTER TOOLBAR ===== */
.filter-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 36px;
  min-width: 200px;
}
.search-wrap i { color: var(--text-light); font-size: 16px; }
.search-wrap input {
  border: none;
  outline: none;
  background: none;
  font-size: 13px;
  color: var(--text);
  width: 160px;
}

.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12px;
  padding: 5px 13px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.chip:hover { background: var(--bg); color: var(--text); }
.chip.active { background: var(--primary-light); color: var(--primary); border-color: #c7d2fe; }

#estado-filter {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

/* ===== TABLE ===== */
.ticket-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ticket-table th {
  background: var(--bg);
  text-align: left;
  padding: 11px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ticket-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.ticket-table tr:last-child td { border-bottom: none; }
.ticket-table tbody tr:hover { background: var(--bg); }
.ticket-table .tk-id { font-weight: 600; color: var(--primary); font-size: 12px; }

.action-btns { display: flex; gap: 6px; }
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.danger:hover { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }

/* ===== FORM ===== */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  max-width: 820px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}
.form-group input,
.form-group select,
.form-group textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-group textarea { resize: vertical; min-height: 90px; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.section-title i { font-size: 17px; color: var(--primary); }

/* ===== TOGGLE ===== */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
}
.toggle-row:last-of-type { border-bottom: none; }
.toggle-label { font-size: 13.5px; font-weight: 500; }
.toggle-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ===== NOTIF LIST ===== */
.notif-item {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  align-items: flex-start;
}
.notif-item:last-child { border-bottom: none; }
.notif-marker {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.notif-content { flex: 1; }
.notif-title { font-size: 13px; font-weight: 500; }
.notif-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--text-light); margin-top: 3px; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,15,25,0.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px; }
.modal-field { margin-bottom: 12px; }
.modal-field label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 3px; }
.modal-field p { font-size: 13.5px; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.modal-foot select {
  flex: 1;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  outline: none;
}

/* ===== BUTTONS ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm {
  font-size: 12px;
  padding: 5px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 500;
  transition: background 0.12s;
}
.btn-sm:hover { background: var(--border-soft); color: var(--text); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #f1f5f9;
  padding: 13px 20px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 10px;
  max-width: 340px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: slideUp 0.2s ease;
}
.toast.show { display: flex; }
.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 28px 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 0 100vw rgba(0,0,0,0.3);
  }
  .main-wrap { margin-left: 0; }
  .menu-btn { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}
