/* ============================================================
   HOSTKOLPIX CORE — Panel administrativo (core.hostkolpix.com)
   Hoja de estilos del panel. Misma paleta de marca que el sitio
   público (azules Hostkolpix + acento mint).

   Estructura:
     01. Design tokens
     02. Reset y base
     03. Layout (sidebar + topbar + main)
     04. Sidebar
     05. Topbar
     06. Cards y grids
     07. KPIs / stats
     08. Tablas
     09. Badges, chips y estados
     10. Botones y formularios
     11. Gráficos (SVG generados por JS)
     12. Tickets (vista agente)
     13. Infraestructura (servidores)
     14. Integraciones
     15. Modales, drawer y toasts
     16. Login
     17. Responsive
   ============================================================ */

/* ------------------------------------------------------------
   01. DESIGN TOKENS
   ------------------------------------------------------------ */
:root {
  /* Marca Hostkolpix */
  --primary-700: #003D99;
  --primary-600: #0052CC;
  --primary-500: #2670E0;
  --primary-100: #DBEAFE;
  --primary-50:  #EFF5FF;
  --sky-500:     #0EA5E9;
  --mint-600:    #0BC98F;
  --mint-500:    #0FDFA0;
  --mint-100:    #D9FBEF;

  /* Neutros */
  --ink-900: #0B1026;
  --ink-700: #262D52;
  --ink-500: #4A5170;
  --ink-300: #9AA1C0;
  --surface: #F0F2F9;      /* fondo general del panel */
  --line:    #E6E8F4;
  --white:   #FFFFFF;

  /* Semánticos */
  --success: #0BC98F;
  --success-bg: #D9FBEF;
  --warning: #F5A524;
  --warning-bg: #FDF1DC;
  --danger:  #E5484D;
  --danger-bg: #FDE7E8;
  --info:    #0EA5E9;
  --info-bg: #DFF4FD;

  /* Degradados */
  --grad-brand: linear-gradient(135deg, var(--primary-600) 0%, var(--sky-500) 100%);
  --grad-deep:  linear-gradient(150deg, #003D99 0%, #0052CC 55%, #0EA5E9 130%);
  --grad-mint:  linear-gradient(135deg, #0BC98F 0%, #0FDFA0 100%);

  /* Tipografías */
  --font-display: "Sora", system-ui, sans-serif;
  --font-body:    "Inter", system-ui, sans-serif;

  /* Forma */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --sidebar-w: 248px;
  --topbar-h: 76px;

  /* Sombras */
  --shadow-sm: 0 2px 10px rgba(11, 16, 38, .05);
  --shadow-md: 0 12px 34px rgba(11, 16, 38, .08);
  --shadow-lg: 0 30px 70px rgba(11, 16, 38, .16);
  --shadow-brand: 0 12px 30px rgba(0, 82, 204, .28);
}

/* ------------------------------------------------------------
   02. RESET Y BASE
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: .9375rem;
  line-height: 1.55;
  color: var(--ink-700);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img, svg, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
ul[class], ol[class] { list-style: none; padding: 0; }
a { color: var(--primary-600); text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  color: var(--ink-900);
  text-wrap: balance;
}

:focus-visible {
  outline: 3px solid rgba(38, 112, 224, .45);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--primary-100); }

/* Scrollbars discretos */
* { scrollbar-width: thin; scrollbar-color: var(--ink-300) transparent; }

/* ------------------------------------------------------------
   03. LAYOUT GENERAL
   ------------------------------------------------------------ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.app__main {
  min-width: 0;
  padding: 16px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.view { display: none; animation: viewIn .28s ease both; }
.view.is-active { display: block; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Cabecera de cada vista */
.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.view-head h1 { font-size: 1.7rem; font-weight: 700; }

.view-head p { color: var(--ink-500); margin-top: 4px; max-width: 56ch; }

.view-head__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------
   04. SIDEBAR
   ------------------------------------------------------------ */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--white);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 8px;
  z-index: 40;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
}

.sidebar__brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.12rem;
  color: var(--ink-900);
  line-height: 1.1;
}

.sidebar__brand-name small {
  display: block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--primary-600);
}

.sidebar__label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-300);
  padding: 14px 12px 6px;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-500);
  font-weight: 500;
  font-size: .92rem;
  position: relative;
  transition: background .15s ease, color .15s ease;
  text-align: left;
}

.side-link i {
  width: 20px;
  text-align: center;
  font-size: .95rem;
  color: var(--ink-300);
  transition: color .15s ease;
}

.side-link:hover { background: var(--primary-50); color: var(--primary-700); }
.side-link:hover i { color: var(--primary-600); }

.side-link.is-active {
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: 600;
}

.side-link.is-active i { color: var(--primary-600); }

.side-link.is-active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--grad-brand);
}

.side-link__count {
  margin-left: auto;
  background: var(--primary-600);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.side-link__count--warn { background: var(--warning); }
.side-link__count--danger { background: var(--danger); }

.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }

/* Tarjeta de estado del sistema en el pie del sidebar */
.sidebar__status {
  margin: 12px 4px 8px;
  background: var(--grad-deep);
  border-radius: var(--radius-md);
  padding: 16px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.sidebar__status::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -34px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}

.sidebar__status-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: .85rem;
}

.sidebar__status-title .dot { background: var(--mint-500); box-shadow: 0 0 0 4px rgba(15, 223, 160, .25); }

.sidebar__status p { font-size: .75rem; color: rgba(255, 255, 255, .75); margin-top: 6px; }

.sidebar__status-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  font-size: .76rem;
  font-weight: 600;
  color: rgba(255, 255, 255, .86);
}

.sidebar__status-action {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  flex: none;
}

.sidebar__status-action:hover { background: rgba(255, 255, 255, .24); }

/* ------------------------------------------------------------
   05. TOPBAR
   ------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--topbar-h);
  padding: 8px 0;
}

.topbar__search {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: var(--shadow-sm);
}

.topbar__search i { color: var(--ink-300); }

.topbar__search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: .92rem;
}

.topbar__search input::placeholder { color: var(--ink-300); }

.topbar__search kbd {
  font-family: var(--font-body);
  font-size: .7rem;
  color: var(--ink-300);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
}

.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--ink-500);
  display: grid;
  place-items: center;
  position: relative;
  transition: color .15s, border-color .15s;
}

.icon-btn:hover { color: var(--primary-600); border-color: var(--primary-500); }

.icon-btn .ping {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--white);
}

.topbar__admin {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 16px 5px 5px;
  box-shadow: var(--shadow-sm);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad-brand);
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  flex: none;
}

.avatar--sm { width: 30px; height: 30px; font-size: .68rem; }

.avatar--mint { background: var(--grad-mint); color: var(--ink-900); }
.avatar--ink  { background: var(--ink-700); }
.avatar--sky  { background: var(--sky-500); }

.topbar__admin-name { font-weight: 600; font-size: .86rem; color: var(--ink-900); line-height: 1.2; text-align: left; }
.topbar__admin-name small { display: block; font-weight: 500; font-size: .72rem; color: var(--ink-500); }

.topbar__admin-caret { color: var(--ink-300); font-size: .72rem; margin-left: 2px; transition: transform .2s ease; }
.admin-menu.is-open .topbar__admin-caret { transform: rotate(180deg); }

/* Menú desplegable del administrador */
.admin-menu { position: relative; }

.menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 8px;
  z-index: 60;
  animation: menuIn .16s ease;
}

@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } }

.menu__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.menu__head-id { display: flex; flex-direction: column; min-width: 0; }
.menu__head-id strong { font-weight: 600; font-size: .9rem; color: var(--ink-900); }
.menu__head-id small {
  font-size: .75rem;
  color: var(--ink-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  color: var(--ink-700);
  text-align: left;
  transition: background .14s ease, color .14s ease;
}

.menu__item i { width: 18px; text-align: center; color: var(--ink-300); transition: color .14s ease; }

.menu__item:hover { background: var(--primary-50); color: var(--primary-700); }
.menu__item:hover i { color: var(--primary-600); }

.menu__item--danger:hover { background: var(--danger-bg); color: #B3261E; }
.menu__item--danger:hover i { color: var(--danger); }

.menu__sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* ------------------------------------------------------------
   06. CARDS Y GRIDS
   ------------------------------------------------------------ */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card__head h2 { font-size: 1.05rem; font-weight: 700; }
.card__head .link-more { font-size: .82rem; font-weight: 600; }

.grid { display: grid; gap: 20px; }
.grid--kpis { grid-template-columns: repeat(4, 1fr); }
.grid--main { grid-template-columns: 1.9fr 1fr; align-items: start; }
.grid--halves { grid-template-columns: 1fr 1fr; align-items: start; }
.grid--thirds { grid-template-columns: repeat(3, 1fr); }
.grid--servers { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid--plans { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.stack { display: flex; flex-direction: column; gap: 20px; }

/* ------------------------------------------------------------
   07. KPIs / STATS
   ------------------------------------------------------------ */
.kpi {
  position: relative;
  overflow: hidden;
}

.kpi__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.kpi__label { font-size: .85rem; font-weight: 600; color: var(--ink-500); }

.kpi__icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  background: var(--primary-50);
  color: var(--primary-600);
  flex: none;
}

.kpi__value {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 1.4rem + 1vw, 2.3rem);
  font-weight: 700;
  color: var(--ink-900);
  margin-top: 10px;
  line-height: 1.1;
}

.kpi__trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-500);
}

.kpi__trend .chip-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  background: var(--success-bg);
  color: #067A57;
}

.kpi__trend .chip-trend--down { background: var(--danger-bg); color: #B3261E; }

/* KPI destacado — degradado de marca (como la primera tarjeta de la referencia) */
.kpi--featured { background: var(--grad-deep); border: none; box-shadow: var(--shadow-brand); }
.kpi--featured::after {
  content: "";
  position: absolute;
  right: -46px;
  bottom: -60px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.kpi--featured .kpi__label { color: rgba(255, 255, 255, .8); }
.kpi--featured .kpi__value { color: #fff; }
.kpi--featured .kpi__icon { background: rgba(255, 255, 255, .16); color: #fff; }
.kpi--featured .kpi__trend { color: rgba(255, 255, 255, .75); }
.kpi--featured .kpi__trend .chip-trend { background: rgba(15, 223, 160, .2); color: var(--mint-500); }

/* ------------------------------------------------------------
   08. TABLAS
   ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  min-width: 640px;
}

.table th {
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-300);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-700);
}

.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: var(--primary-50); }
.table tbody tr:last-child td { border-bottom: none; }

.table .cell-strong { font-weight: 600; color: var(--ink-900); }
.table .cell-sub { display: block; font-size: .76rem; color: var(--ink-500); font-weight: 400; }
.table .cell-num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.cell-user { display: flex; align-items: center; gap: 10px; }

/* Filtros encima de tablas */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.filters .field { margin: 0; }

.filter-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  min-width: 230px;
}

.filter-search i { color: var(--ink-300); font-size: .85rem; }
.filter-search input { border: none; outline: none; background: transparent; flex: 1; font-size: .86rem; }

.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.seg button {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-500);
}

.seg button.is-active { background: var(--white); color: var(--primary-700); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------
   09. BADGES, CHIPS Y ESTADOS
   ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge .dot { width: 7px; height: 7px; }

.badge--success { background: var(--success-bg); color: #067A57; }
.badge--warning { background: var(--warning-bg); color: #9A6108; }
.badge--danger  { background: var(--danger-bg);  color: #B3261E; }
.badge--info    { background: var(--info-bg);    color: #0369A1; }
.badge--neutral { background: var(--surface);    color: var(--ink-500); }
.badge--brand   { background: var(--primary-100); color: var(--primary-700); }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.dot--pulse { animation: pulse 1.8s ease infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(11, 201, 143, .45); }
  50%      { box-shadow: 0 0 0 6px rgba(11, 201, 143, 0); }
}

/* ------------------------------------------------------------
   10. BOTONES Y FORMULARIOS
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .88rem;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  white-space: nowrap;
}

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

.btn--primary { background: var(--grad-brand); color: #fff; box-shadow: var(--shadow-brand); }
.btn--primary:hover { box-shadow: 0 16px 36px rgba(0, 82, 204, .38); transform: translateY(-1px); }

.btn--ghost {
  background: var(--white);
  color: var(--ink-700);
  border: 1px solid var(--line);
}

.btn--ghost:hover { border-color: var(--primary-500); color: var(--primary-600); }

.btn--danger { background: var(--danger-bg); color: #B3261E; }
.btn--danger:hover { background: #FBD5D7; }

.btn--sm { padding: 7px 14px; font-size: .8rem; }

.btn--block { width: 100%; }

.btn[disabled] { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* Selector con forma de píldora (mismas curvas que los botones) */
.select-pill {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234A5170' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 14px center / 10px;
  padding: 7px 34px 7px 16px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-700);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}

.select-pill:hover { border-color: var(--primary-500); color: var(--primary-600); }

/* Botón de acción en fila de tabla */
.row-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  color: var(--ink-300);
  border: 1px solid transparent;
  transition: all .15s ease;
}

.row-btn:hover { color: var(--primary-600); background: var(--primary-50); }
.row-btn--danger:hover { color: var(--danger); background: var(--danger-bg); }

/* Campos */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

.field label { font-size: .8rem; font-weight: 600; color: var(--ink-700); }

.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  background: var(--white);
  font-size: .9rem;
  transition: border-color .15s ease, box-shadow .15s ease;
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px rgba(38, 112, 224, .12);
}

.field .hint { font-size: .74rem; color: var(--ink-500); }

.field--row { flex-direction: row; align-items: center; justify-content: space-between; gap: 14px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .field--full { grid-column: 1 / -1; }

/* Interruptor (toggle) */
.switch { position: relative; display: inline-block; width: 44px; height: 25px; flex: none; }

.switch input { opacity: 0; width: 0; height: 0; }

.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--ink-300);
  transition: background .2s ease;
  cursor: pointer;
}

.switch .track::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s ease;
  box-shadow: var(--shadow-sm);
}

.switch input:checked + .track { background: var(--mint-600); }
.switch input:checked + .track::before { transform: translateX(19px); }
.switch input:focus-visible + .track { outline: 3px solid rgba(38, 112, 224, .45); outline-offset: 2px; }

/* ------------------------------------------------------------
   11. GRÁFICOS (SVG generados por JS)
   ------------------------------------------------------------ */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; }

/* Tarjeta que estira su gráfico para igualar la altura de la fila */
.grid--stretch { align-items: stretch; }

.card--fill { display: flex; flex-direction: column; }
.card--fill .chart { flex: 1; min-height: 250px; }
.card--fill .chart svg { height: 100%; }

.chart .bar { fill: var(--primary-100); transition: fill .2s ease; cursor: pointer; }
.chart .bar:hover, .chart .bar.is-hot { fill: var(--primary-600); }
.chart .bar-label { font: 600 11px var(--font-body); fill: var(--ink-300); }
.chart .bar-value { font: 700 11px var(--font-body); fill: var(--ink-900); }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 5; }
.chart .spark { fill: none; stroke: var(--mint-600); stroke-width: 2.5; stroke-linecap: round; }
.chart .spark-fill { fill: url(#sparkGrad); opacity: .35; }

.donut-legend { display: flex; flex-direction: column; gap: 12px; }

.donut-legend li { display: flex; align-items: center; gap: 10px; font-size: .84rem; }

.donut-legend .val { margin-left: auto; font-weight: 700; color: var(--ink-900); font-variant-numeric: tabular-nums; }

/* Lista de actividad / alertas */
.feed { display: flex; flex-direction: column; }

.feed li {
  display: flex;
  gap: 13px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}

.feed li:last-child { border-bottom: none; }

.feed__icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: .85rem;
  flex: none;
}

.feed__icon--success { background: var(--success-bg); color: #067A57; }
.feed__icon--warning { background: var(--warning-bg); color: #9A6108; }
.feed__icon--danger  { background: var(--danger-bg);  color: #B3261E; }
.feed__icon--info    { background: var(--info-bg);    color: #0369A1; }
.feed__icon--brand   { background: var(--primary-50); color: var(--primary-600); }

.feed__body { flex: 1; min-width: 0; }
.feed__body p { font-size: .86rem; color: var(--ink-700); }
.feed__body p strong { color: var(--ink-900); }
.feed__body time { font-size: .74rem; color: var(--ink-300); }

/* ------------------------------------------------------------
   12. TICKETS (vista agente)
   ------------------------------------------------------------ */
.tickets-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

.ticket-list { display: flex; flex-direction: column; gap: 10px; max-height: 640px; overflow-y: auto; padding-right: 4px; }

.ticket-item {
  text-align: left;
  width: 100%;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.ticket-item:hover { border-color: var(--primary-500); }

.ticket-item.is-active {
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(0, 82, 204, .12);
}

.ticket-item__top { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 6px; }
.ticket-item__id { font-size: .72rem; font-weight: 700; color: var(--ink-300); }
.ticket-item__subject { font-weight: 600; color: var(--ink-900); font-size: .9rem; }
.ticket-item__user {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  font-size: .76rem;
  color: var(--ink-500);
}
.ticket-item__user i { color: var(--ink-300); font-size: .72rem; }
.ticket-item__user small { display: block; color: var(--ink-300); line-height: 1.35; }
.ticket-item__meta { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.ticket-item__meta time { font-size: .72rem; color: var(--ink-300); margin-left: auto; }

.ticket-thread { display: flex; flex-direction: column; min-height: 540px; }

.ticket-thread__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.ticket-thread__head h3 { font-size: 1.05rem; }
.ticket-thread__head .meta { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ticket-thread__user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: .82rem;
  color: var(--ink-500);
}
.ticket-thread__user i { color: var(--ink-300); }
.ticket-thread__user strong { color: var(--ink-900); }
.ticket-thread__user small { display: block; color: var(--ink-300); margin-top: 1px; }

.ticket-thread__msgs { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 18px 0; overflow-y: auto; max-height: 400px; }

.msg { display: flex; gap: 12px; max-width: 85%; }

.msg__bubble {
  background: var(--surface);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 16px;
  font-size: .87rem;
}

.msg__bubble .who { font-size: .72rem; font-weight: 700; color: var(--ink-500); display: block; margin-bottom: 4px; }

.msg--agent { align-self: flex-end; flex-direction: row-reverse; }

.msg--agent .msg__bubble {
  background: var(--primary-50);
  border-radius: 16px 4px 16px 16px;
}

.ticket-reply { border-top: 1px solid var(--line); padding-top: 16px; }

.ticket-reply textarea { min-height: 88px; resize: vertical; }

.ticket-reply__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------
   13. INFRAESTRUCTURA (servidores DirectAdmin)
   ------------------------------------------------------------ */
.server-card__head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }

.server-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--primary-50);
  color: var(--primary-600);
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}

.server-card__icon--down { background: var(--danger-bg); color: var(--danger); }

.server-card__name { font-weight: 700; color: var(--ink-900); font-family: var(--font-display); font-size: .98rem; }
.server-card__ip { font-size: .76rem; color: var(--ink-500); }

.server-card__badge { margin-left: auto; }

.meter { margin-top: 12px; }

.meter__top {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-500);
  margin-bottom: 6px;
}

.meter__top .val { color: var(--ink-900); font-variant-numeric: tabular-nums; }

.meter__track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--grad-brand);
  transition: width .6s ease;
}

.meter--ok .meter__fill { background: var(--grad-mint); }
.meter--warn .meter__fill { background: linear-gradient(90deg, #F5A524, #F7C948); }
.meter--danger .meter__fill { background: linear-gradient(90deg, #E5484D, #F97066); }

.server-card__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: .78rem;
  color: var(--ink-500);
}

/* ------------------------------------------------------------
   14. INTEGRACIONES
   ------------------------------------------------------------ */
.integration { display: flex; flex-direction: column; }

.integration__head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }

.integration__logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  color: #fff;
  flex: none;
}

.integration__logo--da    { background: var(--grad-deep); }
.integration__logo--op    { background: var(--grad-mint); color: var(--ink-900); }
.integration__logo--epayco{ background: linear-gradient(135deg, #F5A524, #F7C948); color: var(--ink-900); }
.integration__logo--smtp  { background: var(--ink-700); }

.integration__name { font-weight: 700; color: var(--ink-900); font-family: var(--font-display); }
.integration__desc { font-size: .8rem; color: var(--ink-500); }

.integration__rows { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 16px; }

.integration__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: .83rem;
  color: var(--ink-500);
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

.integration__row .val { font-weight: 600; color: var(--ink-900); font-variant-numeric: tabular-nums; text-align: right; }

.integration__row code {
  font-size: .76rem;
  background: var(--primary-50);
  color: var(--primary-700);
  padding: 2px 8px;
  border-radius: 6px;
  word-break: break-all;
}

.integration__foot { margin-top: auto; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.integration__connect {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-700);
}

.integration__connect .switch {
  width: 38px;
  height: 22px;
}

.integration__connect .switch .track::before {
  width: 16px;
  height: 16px;
}

/* Aviso de seguridad reutilizable */
.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: .84rem;
  color: var(--ink-700);
}

.notice i { color: var(--primary-600); margin-top: 2px; }
.notice strong { color: var(--ink-900); }

.notice--warn { background: var(--warning-bg); border-color: #F8DFB5; }
.notice--warn i { color: #9A6108; }

/* ------------------------------------------------------------
   15. MODALES, DRAWER Y TOASTS
   ------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(11, 16, 38, .55);
  backdrop-filter: blur(4px);
  z-index: 90;
  animation: fadeIn .18s ease;
}

@keyframes fadeIn { from { opacity: 0; } }

.modal__panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: min(620px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .22s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
}

.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal__head h3 { font-size: 1.15rem; }

.modal__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* Drawer lateral (detalle de cliente) */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(11, 16, 38, .55);
  backdrop-filter: blur(4px);
  animation: fadeIn .18s ease;
}

.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 92vw);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  padding: 26px;
  overflow-y: auto;
  animation: drawerIn .25s ease;
}

@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } }

.client-access { margin-top: 18px; }

.client-detail__identity {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.client-detail__id {
  font-size: .78rem;
  font-weight: 700;
  color: var(--ink-300);
}

.client-detail__name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink-900);
}

.client-detail__email {
  font-size: .84rem;
  color: var(--ink-500);
  overflow-wrap: anywhere;
}

.client-access__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.client-access__form {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.client-access__form[hidden] { display: none; }

.client-access__form .field:last-of-type { margin-bottom: 0; }

.client-access__form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* Toasts */
.toasts {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 120;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ink-900);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 13px 18px;
  font-size: .86rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  max-width: 380px;
}

@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } }

.toast i { color: var(--mint-500); }
.toast--error i { color: #F97066; }

/* ------------------------------------------------------------
   16. LOGIN
   ------------------------------------------------------------ */
.login-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--surface);
}

.login-hero {
  background: var(--grad-deep);
  color: #fff;
  padding: clamp(32px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.login-hero::before,
.login-hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
}

.login-hero::before { width: 380px; height: 380px; right: -120px; top: -120px; }
.login-hero::after  { width: 260px; height: 260px; left: -80px; bottom: -80px; }

.login-hero__brand { display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }

.login-hero__center { margin: auto 0; position: relative; z-index: 1; }

.login-hero__center h1 { color: #fff; font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.5rem); max-width: 15ch; }

.login-hero__center p { color: rgba(255, 255, 255, .75); margin-top: 14px; max-width: 42ch; }

.login-hero__feats { margin-top: 30px; display: flex; flex-direction: column; gap: 12px; }

.login-hero__feats li { display: flex; gap: 12px; align-items: center; font-size: .9rem; color: rgba(255, 255, 255, .85); }

.login-hero__feats i {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .12);
  display: grid;
  place-items: center;
  font-size: .8rem;
  color: var(--mint-500);
}

.login-hero__foot { font-size: .76rem; color: rgba(255, 255, 255, .5); position: relative; z-index: 1; }

.login-side { display: grid; place-items: center; padding: 32px 20px; }

.login-card { width: min(420px, 100%); }

.login-card__box {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(26px, 4vw, 38px);
}

.login-card h2 { font-size: 1.4rem; margin-bottom: 6px; }
.login-card > .login-card__box > p { color: var(--ink-500); font-size: .9rem; margin-bottom: 22px; }

.login-card__foot { text-align: center; margin-top: 18px; font-size: .78rem; color: var(--ink-300); }

.pass-wrap { position: relative; }

.pass-wrap input { padding-right: 46px; }

.pass-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--ink-300);
  border-radius: 8px;
}

.pass-toggle:hover { color: var(--primary-600); }

.login-error {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--danger-bg);
  color: #B3261E;
  font-size: .83rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 16px;
}

/* Paso 2 del login: chip con el correo ya verificado */
.login-user {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--mint-100);
  border: 1px solid #BDEEDD;
  border-radius: 999px;
  padding: 9px 16px;
  margin-bottom: 18px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink-700);
  overflow: hidden;
}

.login-user i { color: var(--mint-600); flex: none; }
.login-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------
   17. RESPONSIVE
   ------------------------------------------------------------ */
.nav-burger { display: none; }

@media (max-width: 1200px) {
  .grid--kpis { grid-template-columns: repeat(2, 1fr); }
  .grid--main, .grid--halves { grid-template-columns: 1fr; }
  .tickets-layout { grid-template-columns: 1fr; }
  .grid--thirds { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 84vw);
    max-height: 100dvh;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-105%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar__brand { padding: 4px 10px 12px; }
  .sidebar__label { padding: 10px 12px 4px; }
  .side-link { padding: 9px 12px; font-size: .9rem; }
  .sidebar__status { margin: 10px 4px 8px; padding: 14px; }

  .sidebar.is-open { transform: none; }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 16, 38, .45);
    z-index: 35;
    animation: fadeIn .2s ease;
  }

  .nav-burger {
    display: grid;
  }

  .topbar__admin-name { display: none; }
  .topbar__admin { padding: 5px; }

  .login-body { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

@media (max-width: 620px) {
  .app__main { padding: 12px 14px 28px; }
  .grid--kpis, .grid--thirds { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar__search { display: none; }
  .view-head h1 { font-size: 1.4rem; }
}

/* Accesibilidad: respeta la preferencia de menos movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
