/* =========================================================
   Sistema de Servicio Técnico — Hoja de estilos principal
   Paleta: azul corporativo + acento naranja industrial
   ========================================================= */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --sidebar-bg: #0f2440;
  --sidebar-bg-2: #0a1c33;
  --sidebar-text: #a7b4cc;
  --sidebar-active: #f97316;
  --bg: #eef1f6;
  --card: #ffffff;
  --text: #334155;
  --muted: #8592a6;
  --border: #e5e9f0;
  --success: #16a34a;
  --info: #0ea5e9;
  --warning: #f59e0b;
  --danger: #ef4444;
  --secondary: #94a3b8;
  --shadow: 0 2px 12px rgba(30, 41, 66, .07);
  --shadow-lg: 0 8px 30px rgba(30, 41, 66, .14);
  --radius: 12px;
  --sidebar-w: 240px;
}

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

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-profile {
  background: var(--accent);
  padding: 22px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}
.avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  border: 2px solid rgba(255,255,255,.5);
}
.sidebar-profile .info { line-height: 1.25; }
.sidebar-profile .name { font-weight: 600; font-size: 14px; }
.sidebar-profile .role { font-size: 11.5px; opacity: .85; }

.sidebar-brand {
  padding: 16px 20px;
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  letter-spacing: .3px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand svg { color: var(--accent); }

.menu { list-style: none; padding: 10px 0; overflow-y: auto; flex: 1; }
.menu-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
  color: rgba(255,255,255,.35); padding: 14px 22px 6px;
}
.menu li a {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 22px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: all .15s ease;
}
.menu li a svg { width: 18px; height: 18px; }
.menu li a:hover { background: rgba(255,255,255,.05); color: #fff; }
.menu li a.active {
  background: rgba(37,99,235,.18);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 600;
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 62px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topbar .left { display: flex; align-items: center; gap: 14px; }
.topbar h1 { font-size: 17px; font-weight: 600; }
.menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); }

.search {
  display: flex; align-items: center;
  background: var(--bg);
  border-radius: 20px;
  padding: 7px 14px; gap: 8px;
  width: 260px; max-width: 40vw;
}
.search input { border: none; background: none; outline: none; width: 100%; font-size: 13px; color: var(--text); }
.topbar .right { display: flex; align-items: center; gap: 18px; }
.icon-badge { position: relative; color: var(--muted); cursor: pointer; }
.icon-badge .dot {
  position: absolute; top: -6px; right: -8px;
  background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 10px; padding: 1px 6px;
}

.content { padding: 24px; flex: 1; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; cursor: pointer;
  padding: 9px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  transition: all .15s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: var(--bg); color: var(--text); }
.btn-light:hover { background: #e2e5ee; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  background: var(--primary);
  color: #fff;
  padding: 12px 18px;
  font-weight: 600; font-size: 13.5px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-head.plain { background: var(--card); color: var(--text); border-bottom: 1px solid var(--border); }
.card-body { padding: 18px; }

/* ---------- Métricas (stat cards) ---------- */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 18px; margin-bottom: 22px;
}
.stat {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
}
.stat .stat-icon {
  width: 50px; height: 50px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.stat .stat-icon svg { width: 24px; height: 24px; }
.stat .value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat .label { font-size: 12px; color: var(--muted); }
.bg-primary { background: var(--primary); }
.bg-info { background: var(--info); }
.bg-success { background: var(--success); }
.bg-warning { background: var(--warning); }

/* ---------- Grids del dashboard ---------- */
.dash-row { display: grid; gap: 18px; margin-bottom: 18px; }
.dash-row.main-row { grid-template-columns: 2.4fr 1fr; }
.dash-row.bottom-row { grid-template-columns: 1fr 1.2fr 1fr; }

/* ---------- Grid de gráficos estadísticos ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}
.chart-card { display: flex; flex-direction: column; }
.chart-card .card-head .ch-ico { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }
.chart-card .card-body { position: relative; height: 300px; }
.chart-card .card-body canvas { width: 100% !important; }

.donut-wrap { position: relative; display: flex; justify-content: center; align-items: center; height: 100%; }
.donut-center {
  position: absolute; text-align: center;
}
.donut-center .num { font-size: 26px; font-weight: 700; }
.donut-center .txt { font-size: 11px; color: var(--muted); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 11px 14px;
  color: var(--muted); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 2px solid var(--border);
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
table.data tbody tr:hover { background: #fafbfd; }
table.data tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-secondary { background: #eceef4; color: var(--secondary); }
.badge-info { background: #e3f0fa; color: var(--info); }
.badge-primary { background: #dbeafe; color: var(--primary); }
.badge-success { background: #e2f3ea; color: var(--success); }
.badge-warning { background: #fdf0dc; color: #c88519; }
.badge-danger { background: #fbe3e7; color: var(--danger); }

.prio-urgente { color: var(--danger); font-weight: 700; }
.prio-alta { color: var(--warning); font-weight: 600; }

/* ---------- Progreso ---------- */
.progress { background: var(--bg); border-radius: 20px; height: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 20px; }

/* ---------- Página / cabecera ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-head h2 { font-size: 20px; font-weight: 700; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.input, select.input {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; background: var(--card); color: var(--text);
  outline: none;
}
.input:focus { border-color: var(--primary); }

/* ---------- Formularios ---------- */
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.fld { display: flex; flex-direction: column; }
.fld label { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.fld .input, .fld select.input, .fld textarea.input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font-size: 13.5px; background: var(--card); color: var(--text);
  outline: none; font-family: inherit;
}
.fld .input:focus, .fld select.input:focus, .fld textarea.input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.fld .hint, .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.fld ul.errorlist, ul.errorlist { list-style: none; color: var(--danger); font-size: 12px; margin-top: 5px; }
@media (max-width: 768px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ---------- Paginación ---------- */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--text); background: var(--card);
  cursor: pointer; transition: all .15s ease;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { opacity: .4; pointer-events: none; }
.page-btn svg { width: 16px; height: 16px; }
.page-info { margin-left: 10px; font-size: 12px; color: var(--muted); }

/* ---------- Línea de tiempo de seguimiento ---------- */
.timeline { list-style: none; position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 16px 12px; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--card); box-shadow: 0 0 0 2px var(--primary); }
.timeline li:last-child { padding-bottom: 0; }
.timeline .tl-fecha { font-size: 11px; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty svg { width: 40px; height: 40px; margin-bottom: 10px; opacity: .5; }

.messages { margin-bottom: 16px; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 10px; font-size: 13px; }
.alert.success { background: #e2f3ea; color: #2f7d54; }
.alert.info { background: #e3f0fa; color: #2b6f9c; }
.alert.warning { background: #fdf0dc; color: #9c6c19; }
.alert.danger { background: #fbe3e7; color: #b23a4c; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f2440 0%, #2563eb 90%, #f97316 175%);
  padding: 20px;
}
.login-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 400px; overflow: hidden;
}
.login-head { background: var(--primary); color: #fff; padding: 34px 30px; text-align: center; }
.login-head .logo {
  width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 50%;
  background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,.5);
}
.login-head h1 { font-size: 19px; font-weight: 700; }
.login-head p { font-size: 12.5px; opacity: .9; margin-top: 4px; }
.login-body { padding: 30px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.form-control {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 14px; font-size: 14px; outline: none; transition: border .15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }
.login-error { background: #fbe3e7; color: #b23a4c; padding: 10px 14px; border-radius: 8px; font-size: 12.5px; margin-bottom: 16px; }
.login-hint { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row.main-row, .dash-row.bottom-row { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr; }
  .search { width: 150px; }
}
