:root {
  --bg: #f6f7f9; --panel: #fff; --line: #e3e6ea; --text: #1d2329; --muted: #6b7480;
  --accent: #134e4a; --accent-2: #0f766e; --accent-soft: #e6f2f0; --note: #fff8e1; --note-line: #f2d98a;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; display: flex; flex-direction: column; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 8px; padding: 7px 14px; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.ghost:hover { background: #eef0f3; }
button:disabled { opacity: .4; cursor: default; }
.muted { color: var(--muted); }
a { color: var(--accent-2); }

/* barra superior */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--text); text-decoration: none; white-space: nowrap; }
.logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.search { flex: 1; position: relative; max-width: 760px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; }
.search input { width: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.search input:focus, .filters input:focus, .filters select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent-2); background: #fff; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; white-space: nowrap; }

/* filtros */
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); align-items: center; }
.filters select, .filters input:not([type=checkbox]) { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 220px; }
.filters select.active, .filters input.active { border-color: var(--accent-2); background: var(--accent-soft); }
.filters .date, .filters .check { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.ac { position: relative; }
.ac-list { position: absolute; z-index: 20; top: 100%; left: 0; width: 340px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow: auto; margin-top: 4px; }
.ac-list div { padding: 7px 10px; cursor: pointer; }
.ac-list div:hover, .ac-list div.sel { background: var(--accent-soft); }
.ac-list small { display: block; color: var(--muted); }

/* layout */
.layout { flex: 1; display: grid; grid-template-columns: minmax(360px, 42%) 1fr; min-height: 0; }
.list-pane { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; background: var(--panel); }
.list-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.pager { display: flex; align-items: center; gap: 6px; }
.pager button { padding: 3px 10px; }
.results { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.results li { padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.results li:hover { background: #fafbfc; }
.results li.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent-2); }
.r-top { display: flex; gap: 8px; align-items: baseline; }
.r-id { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.r-subject { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.r-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.r-snippet { font-size: 12.5px; margin-top: 5px; color: #3b444e; line-height: 1.45; }
mark { background: #fde68a; color: inherit; padding: 0 1px; border-radius: 2px; }
#exact a { display: block; padding: 8px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--line); text-decoration: none; }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: #eef0f3; color: #4a5560; text-transform: uppercase; letter-spacing: .02em; }
.st-open, .st-new { background: #fde2e1; color: #a12a24; }
.st-pending { background: #dbeafe; color: #1e40af; }
.st-hold { background: #ede9fe; color: #5b21b6; }
.st-solved { background: #dcfce7; color: #166534; }
.st-closed { background: #eef0f3; color: #4a5560; }
.st-deleted { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }

/* detalle */
.detail-pane { overflow: auto; min-height: 0; }
.empty { height: 100%; display: grid; place-items: center; color: var(--muted); }
.ticket { padding: 20px 26px 60px; max-width: 1100px; }
.ticket h1 { font-size: 20px; margin: 4px 0 12px; line-height: 1.3; }
.t-head { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.props div > span { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.props a.filter-link { color: var(--text); text-decoration: none; border-bottom: 1px dashed #b9c0c8; cursor: pointer; }
.props a.filter-link:hover { color: var(--accent-2); border-color: var(--accent-2); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { background: #eef0f3; border-radius: 6px; padding: 1px 7px; font-size: 12px; cursor: pointer; }
.tag:hover { background: var(--accent-soft); }

.comment { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); overflow: hidden; }
.comment.internal { background: var(--note); border-color: var(--note-line); }
.c-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.comment.internal .c-head { border-color: var(--note-line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 12px; color: #fff; flex: none; }
.c-who { flex: 1; min-width: 0; }
.c-who b { display: block; }
.c-who small { color: var(--muted); }
.c-when { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.c-body { padding: 12px 14px; }
.c-body pre { white-space: pre-wrap; word-wrap: break-word; font: inherit; margin: 0; line-height: 1.5; }
.c-body iframe { width: 100%; border: 0; display: block; min-height: 40px; }
.c-tools { padding: 0 14px 8px; }
.c-tools button { font-size: 12px; padding: 2px 8px; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 12px; }
.att { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; text-decoration: none; color: var(--text); max-width: 320px; }
.att:hover { border-color: var(--accent-2); }
.att img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; }
.att .ic { width: 34px; height: 34px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 10px; font-weight: 700; flex: none; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { display: block; color: var(--muted); }
.att.missing { opacity: .55; cursor: not-allowed; }

/* login */
.login-body { display: grid; place-items: center; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(380px, 92vw); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 30px rgba(16,24,40,.08); }
.login-card label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.login-card input { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 14px; }
.login-card button { padding: 10px; font-weight: 600; }
.error { color: #b42318; margin: 0; }

.back { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .layout.show-detail .list-pane { display: none; }
  .layout:not(.show-detail) .detail-pane { display: none; }
  .back { display: inline-block; margin-bottom: 10px; }
  .topbar { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  #stats { display: none; }
}
