/* ==========================================================================
   Tickets Corsoft · tema claro/oscuro con tokens. El tema se fija en
   <html data-theme="light|dark"> desde base.html (preferencia guardada o del sistema).
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f6f6f8;
  --bg-grad: radial-gradient(1200px 500px at 10% -10%, #e9e8ff 0%, transparent 60%),
             radial-gradient(900px 400px at 110% 0%, #e2f4ff 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f3f3f6;
  --surface-3: #eaeaef;
  --glass: rgba(255, 255, 255, .72);
  --text: #16171d;
  --text-2: #3f414c;
  --muted: #6e7180;
  --border: #e6e6ec;
  --border-strong: #d6d6de;
  --ring: rgba(99, 91, 255, .35);

  --accent: #5b54f0;
  --accent-hover: #4a43dc;
  --accent-soft: #eeedff;
  --accent-text: #ffffff;

  --green: #0f9f6e;
  --green-strong: #0b8a5f;
  --green-soft: #e3f7ef;
  --red: #dc3545;
  --red-soft: #fdecee;
  --amber: #b86e00;
  --amber-soft: #fff4dd;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 40, .05);
  --shadow: 0 1px 2px rgba(20, 20, 40, .04), 0 4px 16px -4px rgba(20, 20, 40, .08);
  --shadow-lg: 0 10px 40px -10px rgba(20, 20, 40, .25);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0d10;
  --bg-grad: radial-gradient(1200px 500px at 10% -10%, rgba(91, 84, 240, .16) 0%, transparent 60%),
             radial-gradient(900px 400px at 110% 0%, rgba(14, 165, 233, .09) 0%, transparent 55%);
  --surface: #15161b;
  --surface-2: #1c1d24;
  --surface-3: #25262f;
  --glass: rgba(12, 13, 16, .7);
  --text: #ececf1;
  --text-2: #c3c4ce;
  --muted: #8b8d9b;
  --border: #25262e;
  --border-strong: #33343f;
  --ring: rgba(139, 133, 255, .45);

  --accent: #7c75ff;
  --accent-hover: #918bff;
  --accent-soft: rgba(124, 117, 255, .14);

  --green: #34d399;
  --green-strong: #10b981;
  --green-soft: rgba(52, 211, 153, .12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, .12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, .12);

  --shadow-sm: none;
  --shadow: 0 0 0 1px rgba(255, 255, 255, .02);
  --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, .7);
}

/* --------------------------------------------------------------- base */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.5rem; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; margin: 0; }
h2 { font-size: 1rem; letter-spacing: -.01em; font-weight: 600; margin: 0 0 .9rem; }
p { margin: 0; }
pre {
  white-space: pre-wrap; word-break: break-all; font: 500 .78rem/1.6 var(--mono);
  background: var(--surface-2); border: 1px solid var(--border); padding: .75rem .9rem;
  border-radius: var(--radius-sm); margin: .6rem 0 0; color: var(--text-2);
}
pre .k { color: var(--accent); }
kbd {
  font: 600 .7rem var(--mono); padding: .1rem .4rem; border-radius: 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; color: var(--muted); background: var(--surface);
}
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.inline { display: inline; }
.center { text-align: center; justify-content: center; }
.error, .errorlist { color: var(--red); margin: .3rem 0 0; padding: 0; list-style: none; font-size: .85rem; font-weight: 500; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.i {
  width: 1.05em; height: 1.05em; flex: none; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.15em;
}
:root[data-theme="dark"] .only-light, :root:not([data-theme="dark"]) .only-dark { display: none; }

/* --------------------------------------------------------------- banner y barra superior */

.test-banner {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .4rem 16px; font-size: .8rem; color: #5a3a00;
  background: linear-gradient(90deg, #ffe7a8, #ffd479, #ffe7a8);
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}
:root[data-theme="dark"] .test-banner {
  color: #fcd34d; background: linear-gradient(90deg, rgba(251, 191, 36, .08), rgba(251, 191, 36, .16), rgba(251, 191, 36, .08));
  border-bottom-color: rgba(251, 191, 36, .2);
}
.test-banner strong { letter-spacing: .04em; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--glass); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: .6rem 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 700; letter-spacing: -.02em; }
.brand-name span { font-weight: 500; color: var(--muted); margin-left: .3rem; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: #fff;
  background: linear-gradient(135deg, #7c75ff, #5b54f0 55%, #3b82f6);
  box-shadow: 0 4px 12px -2px rgba(91, 84, 240, .5), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.brand-mark .i { width: 18px; height: 18px; }
.brand-mark.lg { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 1rem; }
.brand-mark.lg .i { width: 26px; height: 26px; }

.nav { display: flex; align-items: center; gap: .25rem; }
.nav-link {
  display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .75rem; border-radius: 9px;
  color: var(--muted); font-weight: 500; font-size: .9rem; transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active { color: var(--text); background: var(--surface-3); }
.nav-new { margin-left: .4rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px 80px; }

/* --------------------------------------------------------------- superficies */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.card.narrow { max-width: 420px; margin: 8vh auto; }
.card.login { text-align: center; padding: 32px 28px; }
.card.login form { text-align: left; margin-top: 1.5rem; }
.card.login h1 { margin-bottom: .4rem; }
.form-card { max-width: 720px; margin: 0 auto; }
.form-card .page-head { margin-bottom: 1.25rem; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head p { margin-top: .3rem; font-size: .9rem; }

.back {
  display: inline-flex; align-items: center; gap: .4rem; margin-bottom: 1rem;
  color: var(--muted); font-size: .9rem; font-weight: 500;
}
.back:hover { color: var(--text); }

/* --------------------------------------------------------------- botones */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 38px;
  padding: .45rem .95rem; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: 600 .9rem var(--font); cursor: pointer;
  white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, color .15s, transform .08s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-sm { min-height: 32px; padding: .25rem .7rem; font-size: .83rem; border-radius: 8px; }
.btn-lg { min-height: 44px; font-size: .95rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 4px 14px -4px var(--ring);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-start { background: var(--green-soft); border-color: transparent; color: var(--green); box-shadow: none; }
.btn-start:hover { background: var(--green); color: #fff; }
.btn-stop {
  background: var(--green-strong); border-color: var(--green-strong); color: #fff;
  box-shadow: 0 4px 14px -4px rgba(16, 185, 129, .6);
}
.btn-stop:hover { filter: brightness(1.08); background: var(--green-strong); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red); filter: brightness(1.08); }
.btn-danger-ghost { color: var(--muted); }
.btn-danger-ghost:hover { color: var(--red); background: var(--red-soft); }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }

/* --------------------------------------------------------------- formularios */

label { display: block; }
.field { display: block; margin: 0 0 1rem; font-weight: 600; font-size: .85rem; color: var(--text-2); }
.field > label { display: block; margin-bottom: .35rem; }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=time], select, textarea {
  display: block; width: 100%; margin-top: .35rem; padding: .55rem .75rem; min-height: 42px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text);
  font: 400 .93rem var(--font); transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
textarea { resize: vertical; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8d9b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; }
select[size] { background-image: none; min-height: 240px; padding: .35rem; }
select[size] option { padding: .45rem .6rem; border-radius: 6px; }
select[size] option:checked { background: var(--accent-soft) linear-gradient(0deg, var(--accent-soft), var(--accent-soft)); color: var(--accent); font-weight: 600; }
.hint { color: var(--muted); font-size: .8rem; font-weight: 500; margin-top: .4rem; }
.counter { display: block; text-align: right; font: 500 .72rem var(--mono); color: var(--muted); margin-top: .3rem; }
.counter.near { color: var(--amber); }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.grid-3 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) 64px; gap: 10px; }
.grid-3 input { min-width: 0; padding-left: .6rem; padding-right: .5rem; }

/* búsqueda con icono */
.search { position: relative; display: block; }
.search > .i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.4rem; margin: 0; }
.search kbd { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search input:focus ~ kbd { opacity: 0; }

/* interruptor (checkbox) */
.switch { margin: 0 0 1.1rem; display: inline-flex; align-items: center; gap: .65rem; cursor: pointer; font-size: .9rem; font-weight: 500; color: var(--text-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; width: 38px; height: 22px; flex: none; border-radius: 99px;
  background: var(--surface-3); border: 1px solid var(--border-strong); transition: background .2s var(--ease), border-color .2s;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 4px var(--ring); }

/* --------------------------------------------------------------- avisos (toasts) */

.toasts { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.toast {
  display: flex; align-items: flex-start; gap: .65rem; padding: .75rem .9rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: .9rem; font-weight: 500; animation: toast-in .35s var(--ease);
}
.toast > .i { margin-top: .15rem; }
.toast > span { flex: 1; }
.toast-success > .i { color: var(--green); }
.toast-success { border-color: color-mix(in srgb, var(--green) 30%, var(--border)); }
.toast-warning > .i { color: var(--amber); }
.toast-warning { border-color: color-mix(in srgb, var(--amber) 35%, var(--border)); }
.toast-error > .i { color: var(--red); }
.toast-error { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); background: var(--red-soft); }
.toast-close { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; display: grid; }
.toast.is-leaving { opacity: 0; transform: translateY(-4px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* --------------------------------------------------------------- estadísticas y filtros */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1rem; }
.stat {
  display: flex; flex-direction: column; gap: .2rem; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.stat-label { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.65rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-green .stat-label { color: var(--green); }
.stat-red .stat-label { color: var(--red); }
.stat-amber .stat-label { color: var(--amber); }
.stat .dot { background: var(--muted); }
.stat-green.is-live .dot { background: var(--green); animation: pulse 1.8s infinite; }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  position: sticky; top: 62px; z-index: 10;
}
.filters .search { flex: 1 1 280px; }
.filters .search input { border-color: transparent; background: var(--surface-2); }
.filters .search input:focus { background: var(--surface); border-color: var(--accent); }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.select-wrap { position: relative; display: block; }
.select-wrap > .i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.select-wrap select { margin: 0; padding-left: 2.1rem; min-height: 40px; background-color: var(--surface-2); border-color: transparent; font-weight: 500; font-size: .88rem; width: auto; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 40px; padding: 0 .85rem; border-radius: 10px;
  font-size: .88rem; font-weight: 500; color: var(--text-2); background: var(--surface-2); border: 1px solid transparent;
  cursor: pointer; user-select: none; transition: background .15s, color .15s, border-color .15s;
}
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip:hover { color: var(--text); }
.chip .dot { background: var(--muted); }
.chip:focus-within { box-shadow: 0 0 0 4px var(--ring); }
.chip-green:has(input:checked) { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.chip-green:has(input:checked) .dot { background: var(--green); }
.chip-red:has(input:checked) { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.filter-submit { min-height: 40px; }
.js .filter-submit { display: none; }

.summary { margin: 1rem 2px .75rem; color: var(--muted); font-size: .85rem; }
.summary strong { color: var(--text); }

/* --------------------------------------------------------------- tickets */

.tickets, .timeline, .log { list-style: none; margin: 0; padding: 0; }
.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 12px; }
.ticket {
  position: relative; display: flex; flex-direction: column; gap: .55rem; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 16px 12px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .2s var(--ease), transform .2s var(--ease);
}
.ticket:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.ticket.is-working {
  border-color: color-mix(in srgb, var(--green) 45%, var(--border));
  background: linear-gradient(180deg, var(--green-soft), transparent 70%), var(--surface);
}
.ticket.is-working::before {
  content: ""; position: absolute; left: -1px; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0; background: var(--green);
}
.ticket-head { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.ticket-id { font: 600 .82rem var(--mono); color: var(--muted); letter-spacing: -.01em; }
a.ticket-id:hover { color: var(--accent); }
.ticket-client { flex: 1; min-width: 0; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-work { color: var(--text); font-size: .95rem; line-height: 1.45; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
a.ticket-work:hover { color: var(--accent); }
.ticket-meta { display: flex; flex-wrap: wrap; gap: .3rem 1rem; color: var(--muted); font-size: .8rem; }
.ticket-meta span { display: inline-flex; align-items: center; gap: .35rem; }
.next-note {
  display: flex; gap: .55rem; align-items: flex-start; font-size: .84rem; padding: .55rem .7rem; border-radius: 10px;
  background: var(--surface-2); color: var(--text-2);
}
.next-note > .i { margin-top: .15rem; color: var(--muted); }
.next-note.alert { background: var(--red-soft); color: var(--red); }
.next-note.alert > .i { color: var(--red); }
.next-note em { font-style: normal; font-weight: 600; opacity: .85; }
.next-date { font: 600 .78rem var(--mono); margin-right: .35rem; }
.ticket-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: auto; padding-top: .6rem; border-top: 1px solid var(--border); }
.ticket-actions .push-right { margin-left: auto; }
.timer { font: 600 .8rem var(--mono); background: rgba(0, 0, 0, .18); padding: .05rem .45rem; border-radius: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; white-space: nowrap;
  padding: .15rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.pill .i { width: .9em; height: .9em; }
.pill-red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.pill-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.pill-amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.pill-green .dot { animation: pulse 1.8s infinite; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.empty-state { grid-column: 1 / -1; display: grid; justify-items: center; gap: .6rem; padding: 48px 16px; color: var(--muted); text-align: center; }
.empty-state > .i { width: 36px; height: 36px; stroke-width: 1.5; opacity: .6; }
.tickets .empty-state, .quick-empty { border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }

/* --------------------------------------------------------------- detalle */

.hero {
  position: relative; padding: 22px 22px 16px; margin-bottom: 16px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, #7c75ff, #3b82f6);
}
.hero.is-working::after { background: linear-gradient(90deg, var(--green), #22d3ee); }
.hero-top { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.hero-top .ticket-id { font-size: .9rem; }
.hero-client { font-size: 1.6rem; margin-bottom: .5rem; }
.hero-work { font-size: 1.02rem; color: var(--text-2); margin-bottom: .8rem; overflow-wrap: anywhere; max-width: 75ch; }
.hero .ticket-actions { margin-top: 1rem; padding-top: 1rem; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.sticky { position: sticky; top: 76px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.section-head h2 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.count { font-size: .75rem; font-weight: 600; padding: .05rem .5rem; border-radius: 99px; background: var(--surface-3); color: var(--muted); }

.timeline { position: relative; }
.timeline .note { position: relative; padding: .9rem 0 .9rem 1.4rem; }
.timeline .note::before {
  content: ""; position: absolute; left: 4px; top: 1.3rem; width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); z-index: 1;
}
.timeline .note::after { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.timeline .note:first-child::after { top: 1.3rem; }
.timeline .note:last-child::after { bottom: calc(100% - 1.3rem); }
.timeline .note.highlighted::before { border-color: var(--red); background: var(--red); }
.timeline .note.inactive { opacity: .5; }
.timeline .note.inactive::before { border-color: var(--muted); }
.note p { margin: .35rem 0 0; color: var(--text-2); overflow-wrap: anywhere; font-size: .93rem; }
.note-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.note-date { font-weight: 600; font-size: .85rem; font-variant-numeric: tabular-nums; }
.note.highlighted .note-date { color: var(--red); }
.note-id { font: 500 .75rem var(--mono); }
.avatar {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 .3rem; border-radius: 99px;
  font: 700 .66rem var(--mono); background: var(--accent-soft); color: var(--accent);
}
.note-edit { margin-left: auto; width: 30px; height: 30px; opacity: 0; transition: opacity .15s; }
.note:hover .note-edit, .note-edit:focus-visible { opacity: 1; }
@media (hover: none) { .note-edit { opacity: 1; } }

/* --------------------------------------------------------------- registro */

.log { display: grid; gap: 8px; }
.log-entry { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.log-entry summary { display: flex; align-items: center; gap: .8rem; padding: 12px 14px; cursor: pointer; list-style: none; }
.log-entry summary::-webkit-details-marker { display: none; }
.log-entry details[open] summary { border-bottom: 1px solid var(--border); }
.log-entry pre { margin: 12px 14px 14px; }
.log-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; flex: none; }
.is-simulated .log-icon { background: var(--amber-soft); color: var(--amber); }
.is-sent .log-icon { background: var(--green-soft); color: var(--green); }
.is-error .log-icon { background: var(--red-soft); color: var(--red); }
.log-main { flex: 1; display: grid; min-width: 0; font-size: .9rem; }
.log-main .muted { font-size: .8rem; }
.log-error { color: var(--red); font-size: .82rem; }
.log .empty-state { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }

/* --------------------------------------------------------------- diálogo de confirmación */

dialog.confirm {
  width: min(400px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); text-align: center;
}
dialog.confirm[open] { animation: pop .2s var(--ease); }
dialog.confirm::backdrop { background: rgba(10, 10, 20, .45); backdrop-filter: blur(3px); }
dialog.confirm h2 { font-size: 1.1rem; margin: .8rem 0 .4rem; }
dialog.confirm p { color: var(--muted); font-size: .92rem; }
.confirm-icon {
  display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  background: var(--red-soft); color: var(--red);
}
.confirm-icon .i { width: 22px; height: 22px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 1.4rem; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.narrow.center .confirm-icon { margin-bottom: .8rem; }
.narrow.center h1 { margin-bottom: .6rem; font-size: 1.25rem; }
.narrow.center .muted { margin-top: .5rem; font-size: .85rem; }
.narrow.center .form-actions { justify-content: center; border: 0; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .detail-grid aside { order: -1; }
}
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 1.35rem; }
  .tickets { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; }
  .filter-row { width: 100%; }
  .select-wrap { flex: 1 1 40%; }
  .select-wrap select { width: 100%; }
}
@media (max-width: 600px) {
  .container { padding-top: 16px; }
  .nav-link span, .brand-name span, .nav-new span { display: none; }
  .nav-new { padding: 0; width: 36px; }
  .nav-link { padding: .45rem .6rem; }
  h1 { font-size: 1.3rem; }
  .hero-client { font-size: 1.3rem; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 label:last-child { grid-column: span 2; }
  .ticket-actions > form:first-child, .ticket-actions > form:first-child .btn { flex: 1; }
  .search kbd { display: none; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --------------------------------------------------------------- refresco y acciones sin recarga */

.refresh { display: flex; align-items: center; gap: .25rem; color: var(--muted); font-size: .8rem; }
.is-refreshing [data-refresh-now] .i { animation: spin .8s linear infinite; }
.is-swapped { animation: swap-in .35s var(--ease); }
@keyframes swap-in { from { opacity: .55; } }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-loading, .icon-btn.is-loading { opacity: .6; pointer-events: none; }
.btn.is-loading .i, .icon-btn.is-loading .i { animation: spin .8s linear infinite; }

/* --------------------------------------------------------------- app instalada (PWA) */

.topbar { padding-top: env(safe-area-inset-top); }
.container { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}
