/* Gestor de incidencias IT · Grupo Ayuda T
   Colores y tipografía de ayudatpymes.com */
:root {
  --atp-azul: #004bfb;
  --atp-azul-hover: #003fd4;
  --atp-azul-claro: #09e7fc;
  --atp-verde-mar: #22fbd4;
  --atp-violet: #7c3aed;
  --atp-black: #0f172a;
  --atp-gray: #f1f5f9;
  --atp-gray-200: #e2e8f0;
  --atp-degradado: linear-gradient(90deg, #22fbd4, #09e7fc 33%, #004bfb 65%, #0f172a);

  --bg: #fafafa;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e2e8f0;
  --primary: #18181b;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  font-family: Inter, "Inter Fallback", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; min-height: 100vh; }
a { color: var(--atp-azul); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--atp-azul); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Cabecera ---------- */
.grad-bar { height: 4px; background: var(--atp-degradado); }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 20px; height: 64px; display: flex; align-items: center; gap: 24px; }
.logo { display: flex; align-items: center; gap: 12px; color: var(--text); }
.logo img { height: 24px; width: auto; display: block; }
.logo .tag { font-size: 12px; font-weight: 600; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--border); white-space: nowrap; }
.logo:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--atp-gray); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--atp-gray); }
.user-menu { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--atp-black); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.menu-toggle { display: none; }

/* ---------- Layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 28px 20px 60px; }
.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card + .card { margin-top: 16px; }
.grid > .card, .split > .card { margin-top: 0; }
form .grid, .modal .grid { row-gap: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }

/* ---------- Formularios ---------- */
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
label .req { color: var(--atp-azul); }
.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=time], input[type=date], input[type=number], input[type=tel], select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--text); background: #fff;
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--atp-azul); box-shadow: 0 0 0 3px rgba(0, 75, 251, .12); }
input:disabled, select:disabled, textarea:disabled { background: var(--atp-gray); color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 400; margin: 0 0 10px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--atp-azul); width: 16px; height: 16px; }
.check small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: 14px; font-weight: 500;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--atp-azul); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--atp-azul-hover); }
.btn-dark { background: var(--primary); color: #fafafa; }
.btn-dark:hover:not(:disabled) { background: #000; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--atp-gray); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: none; cursor: pointer; padding: 6px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--atp-gray); color: var(--text); }

/* ---------- Etiquetas ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-pendiente { background: #fff7ed; color: #c2410c; }
.b-progreso { background: #eff6ff; color: var(--atp-azul); }
.b-resuelto { background: #ecfdf5; color: #047857; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--atp-gray); color: #334155; white-space: nowrap; }
.chip-grave { background: #fef2f2; color: var(--danger); font-weight: 600; }
.chip-blue { background: #eff6ff; color: var(--atp-azul); }

/* ---------- KPIs ---------- */
.kpi { padding: 18px 20px; }
.kpi .k-label { font-size: 13px; color: var(--muted); }
.kpi .k-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.kpi .k-sub { font-size: 12px; color: var(--muted); }
.kpi.accent { position: relative; overflow: hidden; }
.kpi.accent::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--atp-degradado); }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { height: 8px; background: var(--atp-gray); border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--atp-azul); border-radius: 4px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tablas ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px; border-bottom: 1px solid var(--border); align-items: center; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; min-width: 140px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fcfcfd; white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: #f8fafc; }
table.data .desc { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 460px; }
.code { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; font-size: 13px; color: var(--muted); gap: 10px; flex-wrap: wrap; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

/* ---------- Detalle ---------- */
.desc-box { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-size: 14px; }
.meta { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-word; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; width: 120px; height: 90px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--atp-gray); }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.thumb button { position: absolute; top: 4px; right: 4px; background: rgba(15, 23, 42, .75); color: #fff; border: none; border-radius: 6px; width: 24px; height: 24px; cursor: pointer; font-size: 14px; line-height: 1; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--border); position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.timeline li.nota::before { background: var(--atp-azul); }
.timeline li.nota .t-text { background: #eff6ff; border-radius: 8px; padding: 8px 10px; margin-top: 4px; white-space: pre-wrap; }
.timeline .t-head { color: var(--muted); font-size: 12px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }

/* ---------- Subida de imágenes ---------- */
.drop {
  border: 1.5px dashed #cbd5e1; border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); font-size: 14px;
  cursor: pointer; transition: border-color .15s, background .15s; background: #fcfcfd;
}
.drop:hover, .drop.over { border-color: var(--atp-azul); background: #f5f8ff; color: var(--text); }
.drop strong { color: var(--atp-azul); }

/* ---------- Avisos ---------- */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; border: 1px solid; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--atp-black); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; opacity: 0; transition: all .2s; z-index: 100; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.lightbox { position: fixed; inset: 0; background: rgba(15, 23, 42, .9); display: grid; place-items: center; z-index: 60; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- Páginas públicas ---------- */
.public-hero { background: var(--atp-black); color: #fff; position: relative; overflow: hidden; }
.public-hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--atp-degradado); }
.public-hero .inner { max-width: 760px; margin: 0 auto; padding: 44px 20px 72px; }
.public-hero h1 { font-size: 34px; margin-top: 10px; }
.public-hero p { color: #cbd5e1; margin: 10px 0 0; max-width: 560px; }
.public-hero .eyebrow { color: var(--atp-azul-claro); }
.public-main { max-width: 760px; margin: -44px auto 0; padding: 0 20px 60px; position: relative; z-index: 1; }
.public-top { background: #fff; border-bottom: 1px solid var(--border); }
.public-top .inner { max-width: 760px; margin: 0 auto; padding: 0 20px; height: 64px; display: flex; align-items: center; justify-content: space-between; }
.public-top img { height: 22px; }
.success { text-align: center; padding: 40px 24px; }
.success .check-circle { width: 64px; height: 64px; border-radius: 50%; background: #ecfdf5; color: var(--ok); display: grid; place-items: center; margin: 0 auto 16px; }
.success .ticket-code { display: inline-block; font-size: 22px; font-weight: 700; padding: 8px 16px; border-radius: 8px; background: var(--atp-gray); margin: 12px 0; letter-spacing: .02em; }
.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 24px 16px; }

.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side { background: var(--atp-black); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-side::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, #22fbd4, #09e7fc 33%, #004bfb 65%, #0f172a); }
.login-side h2 { font-size: 32px; font-weight: 700; max-width: 420px; }
.login-side p { color: #94a3b8; max-width: 420px; }
.login-side img.iso { width: 48px; height: 48px; object-fit: contain; filter: brightness(0) invert(1); }
.login-form { display: grid; place-items: center; padding: 32px 20px; }
.login-form .box { width: 100%; max-width: 380px; }
.login-form img.logo-dark { height: 24px; margin-bottom: 32px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .split { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { display: none; }
}
@media (max-width: 760px) {
  .topbar-inner { height: 56px; gap: 12px; padding: 0 16px; }
  .logo .tag { display: none; }
  .menu-toggle { display: inline-flex; margin-left: auto; }
  .nav { display: none; position: absolute; top: 56px; left: 0; right: 0; background: #fff; flex-direction: column; padding: 8px 16px 14px; border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .user-menu .uname { display: none; }
  .container { padding: 20px 16px 48px; }
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  h1 { font-size: 24px; }
  .public-hero h1 { font-size: 26px; }
  .public-hero .inner { padding: 32px 16px 64px; }
  .public-main { padding: 0 16px 48px; }
  .toolbar input[type=search], .toolbar select { max-width: none; width: 100%; }
  .bar-row { grid-template-columns: 110px 1fr 36px; }
  .meta { grid-template-columns: 100px 1fr; }
  table.data .hide-sm { display: none; }
}
