/* ===========================================================================
   Centro de Soporte · Dato Estratégico
   Paleta: navy #0F2A5C · cyan #00d4ff · verde #7DC242 · Inter
   =========================================================================== */
:root {
  --navy: #0F2A5C;
  --navy-deep: #0a1c3f;
  --navy-darkest: #06121f;
  --cyan: #00d4ff;
  --cyan-d: #00b8db;
  --green: #7DC242;
  --green-d: #5fa030;

  --ink: #0f1b2d;
  --muted: #5b6b82;
  --muted-soft: #8aa0b8;
  --bg: #eef4fa;
  --surface: #ffffff;
  --surface-2: #f7fafd;
  --border: #e1eaf3;
  --border-strong: #cdd9e8;

  --grad: linear-gradient(135deg, #0F2A5C 0%, #00d4ff 55%, #7DC242 100%);
  --grad-90: linear-gradient(90deg, #0F2A5C 0%, #00d4ff 55%, #7DC242 100%);
  --grad-cyan: linear-gradient(135deg, #00d4ff, #00b8db);

  --glow: 0 0 0 1px rgba(0, 212, 255, .14), 0 18px 40px -16px rgba(15, 42, 92, .22);
  --shadow: 0 1px 2px rgba(15, 42, 92, .06), 0 8px 24px -12px rgba(15, 42, 92, .14);
  --shadow-lg: 0 24px 60px -20px rgba(15, 42, 92, .28);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cyan-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
img { max-width: 100%; display: block; }

/* ----------------------------- Topbar ----------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--navy-deep);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.topbar::after {
  content: ""; display: block; height: 3px;
  background: var(--grad-90);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 22px;
  height: 64px; display: flex; align-items: center; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 30px; width: auto; }
.brand .sub {
  color: #bfeefa; font-size: 11px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; border-left: 1px solid rgba(255,255,255,.18);
  padding-left: 12px;
}
.nav { display: flex; gap: 4px; margin-left: 10px; }
.nav a {
  color: #c8d6ea; font-weight: 600; font-size: 14px; padding: 8px 14px;
  border-radius: 10px; transition: .15s; text-decoration: none;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: rgba(0, 212, 255, .16); color: #eafaff; }
.topbar-spacer { flex: 1; }

.usermenu { display: flex; align-items: center; gap: 12px; }
.usermenu .name { color: #dbe7f5; font-size: 13px; font-weight: 600; text-align: right; }
.usermenu .name small { display: block; color: var(--muted-soft); font-weight: 500; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  color: var(--navy); background: var(--grad-cyan);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, .3);
}
.btn-logout {
  color: #c8d6ea; border: 1px solid rgba(255,255,255,.16);
  padding: 7px 13px; border-radius: 10px; font-size: 13px; font-weight: 600;
  background: transparent; cursor: pointer; transition: .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }

/* ----------------------------- Layout ----------------------------------- */
.shell { max-width: 1180px; margin: 0 auto; padding: 32px 22px 64px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head h1 { font-size: 26px; }
.page-head .lead { color: var(--muted); margin: 0; }

/* ----------------------------- Buttons ---------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font-weight: 700; font-size: 14px; padding: 11px 20px; border-radius: 12px;
  border: 1px solid transparent; cursor: pointer; transition: .16s; text-decoration: none;
  line-height: 1;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary {
  background: var(--grad-cyan); color: var(--navy);
  box-shadow: 0 10px 24px -10px rgba(0, 212, 255, .6);
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--cyan); color: var(--cyan-d); text-decoration: none; }
.btn-green { background: linear-gradient(135deg, #7DC242, #5fa030); color: #fff; }
.btn-green:hover { filter: brightness(1.05); text-decoration: none; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }

/* ----------------------------- Cards ------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 24px; }

/* ----------------------------- KPIs ------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden;
  box-shadow: var(--shadow); transition: .18s;
}
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad-90); opacity: .85; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--glow); }
.kpi .num { font-size: 30px; font-weight: 800; letter-spacing: -.02em; color: var(--navy); }
.kpi .lbl { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi.is-danger .num { color: var(--danger); }
.kpi.is-cyan .num { color: var(--cyan-d); }
.kpi.is-green .num { color: var(--green-d); }

/* ----------------------------- Badges ----------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 4px 11px; border-radius: 999px; line-height: 1.4; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.estado-abierto   { background: #e0f2fe; color: #0369a1; }
.estado-proceso   { background: #ede9fe; color: #6d28d9; }
.estado-esperando { background: #fef3c7; color: #b45309; }
.estado-resuelto  { background: #dcfce7; color: #15803d; }
.estado-cerrado   { background: #e9eef4; color: #64748b; }

.prio { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 7px; text-transform: uppercase; letter-spacing: .03em; }
.prio-baja    { background: #f1f5f9; color: #64748b; }
.prio-media   { background: #e0f2fe; color: #0369a1; }
.prio-alta    { background: #ffedd5; color: #c2410c; }
.prio-urgente { background: #fee2e2; color: #b91c1c; }

/* ----------------------------- Ticket list ------------------------------ */
.ticket-list { display: flex; flex-direction: column; gap: 12px; }
.ticket-row {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: .15s; text-decoration: none; color: inherit;
}
.ticket-row:hover { border-color: var(--cyan); box-shadow: var(--glow); transform: translateY(-1px); text-decoration: none; }
.ticket-row .code { font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; font-weight: 700; color: var(--muted-soft); width: 78px; flex-shrink: 0; }
.ticket-row .main { flex: 1; min-width: 0; }
.ticket-row .main .asunto { font-weight: 700; color: var(--ink); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-row .main .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.ticket-row .right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ----------------------------- Forms ------------------------------------ */
.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 7px; color: var(--ink); }
.field .help { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border-strong);
  border-radius: 12px; font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface); transition: .15s;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(0, 212, 255, .14);
}
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--danger); font-size: 12.5px; font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Dropzone capturas */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: 14px; padding: 22px;
  text-align: center; color: var(--muted); background: var(--surface-2);
  transition: .15s; cursor: pointer;
}
.dropzone:hover { border-color: var(--cyan); color: var(--cyan-d); background: #f0fbff; }
.dropzone svg { width: 30px; height: 30px; margin-bottom: 6px; opacity: .8; }
.dropzone input { display: none; }
.file-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.file-pill {
  display: inline-flex; align-items: center; gap: 7px; background: #e0f2fe; color: #0369a1;
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}

/* ----------------------------- Conversation ----------------------------- */
.detalle-grid { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.thread { display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 14px; }
.msg .avatar-sm {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; display: grid;
  place-items: center; font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, #64748b, #475569);
}
.msg.is-soporte .avatar-sm { background: var(--grad-cyan); color: var(--navy); }
.msg .bubble {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow);
}
.msg.is-soporte .bubble { background: #f0fbff; border-color: #bae9fb; }
.msg.is-interna .bubble { background: #fffbeb; border-color: #fde68a; }
.msg .bubble .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.msg .bubble .head .who { font-weight: 700; font-size: 14px; }
.msg .bubble .head .when { color: var(--muted-soft); font-size: 12px; }
.msg .bubble .body { white-space: pre-wrap; word-wrap: break-word; }
.tag-soporte { background: var(--cyan); color: var(--navy); font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: .04em; }
.tag-interna { background: var(--warn); color: #fff; font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; }

.adjuntos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.adjunto-img img { width: 120px; height: 90px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.adjunto-file {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.adjunto-file svg { width: 18px; height: 18px; color: var(--cyan-d); }

/* Sidebar ticket */
.side-card { margin-bottom: 18px; }
.side-card .card-pad { padding: 18px; }
.side-card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 14px; }
.dl { display: flex; flex-direction: column; gap: 12px; }
.dl .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13.5px; }
.dl .row .k { color: var(--muted); font-weight: 600; }
.dl .row .v { font-weight: 700; text-align: right; }

/* ----------------------------- Filters ---------------------------------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; }
.filters .search { flex: 1; min-width: 220px; position: relative; }
.filters .search input { padding-left: 40px; }
.filters .search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted-soft); }
.filters select { width: auto; min-width: 150px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  text-decoration: none; transition: .15s;
}
.chip:hover { border-color: var(--cyan); color: var(--cyan-d); text-decoration: none; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ----------------------------- Tabla bandeja ---------------------------- */
.tabla { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); }
.tabla th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 13px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tabla td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.tabla tr:last-child td { border-bottom: none; }
.tabla tbody tr { transition: .12s; cursor: pointer; }
.tabla tbody tr:hover { background: #f0fbff; }
.tabla .code { font-family: ui-monospace, monospace; font-weight: 700; color: var(--cyan-d); font-size: 12.5px; }
.tabla a { color: inherit; text-decoration: none; }

/* ----------------------------- Messages --------------------------------- */
.flash-wrap { max-width: 1180px; margin: 16px auto -8px; padding: 0 22px; }
.flash { padding: 13px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.flash-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.flash-info { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.flash-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }

/* ----------------------------- Empty state ------------------------------ */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .ico { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px; background: var(--grad); display: grid; place-items: center; box-shadow: var(--glow); }
.empty .ico svg { width: 30px; height: 30px; color: #fff; }
.empty h3 { color: var(--ink); font-size: 19px; }

/* ----------------------------- Auth (login/registro) -------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-brand {
  background: var(--navy-darkest); color: #fff; padding: 56px 56px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-brand::before {
  content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,212,255,.28), transparent 65%);
  top: -160px; right: -160px; filter: blur(10px);
}
.auth-brand::after {
  content: ""; position: absolute; width: 460px; height: 460px; border-radius: 50%;
  background: radial-gradient(circle, rgba(125,194,66,.22), transparent 65%);
  bottom: -180px; left: -120px;
}
.auth-brand .inner { position: relative; z-index: 2; }
.auth-brand img.logo { height: 38px; margin-bottom: 48px; }
.auth-brand h2 { font-size: 34px; line-height: 1.15; letter-spacing: -.02em; margin-bottom: 16px; }
.auth-brand h2 span { background: linear-gradient(90deg, #00d4ff, #7DC242); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-brand p.tag { color: #a8c2dd; font-size: 16px; max-width: 420px; }
.features { list-style: none; padding: 0; margin: 36px 0 0; display: flex; flex-direction: column; gap: 16px; position: relative; z-index: 2; }
.features li { display: flex; gap: 14px; align-items: flex-start; color: #d6e4f2; font-size: 15px; }
.features li .ck { width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0; background: rgba(0,212,255,.16); display: grid; place-items: center; }
.features li .ck svg { width: 15px; height: 15px; color: var(--cyan); }
.features li strong { color: #fff; }
.auth-foot { position: relative; z-index: 2; color: #6f87a6; font-size: 13px; }

.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface); }
.auth-form .box { width: 100%; max-width: 400px; }
.auth-form .box > h1 { font-size: 26px; }
.auth-form .box > .sub { color: var(--muted); margin-bottom: 28px; }
.auth-form .alt { text-align: center; margin-top: 22px; color: var(--muted); font-size: 14px; }
.auth-form .forgot { text-align: right; margin-top: -8px; margin-bottom: 14px; font-size: 13px; }
.auth-mobile-logo { display: none; }

@media (max-width: 880px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-mobile-logo { display: block; text-align: center; margin-bottom: 24px; }
  .auth-mobile-logo img { height: 34px; margin: 0 auto; }
  .detalle-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .nav { display: none; }
  .usermenu .name { display: none; }
}

/* ----------------------------- Helpers ---------------------------------- */
.muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.divider { height: 1px; background: var(--border); margin: 20px 0; border: none; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
