:root {
    --bg: #f4f6f8; --surface: #fff; --text: #1f2933; --muted: #6b7280;
    --border: #e3e8ee; --primary: #2f6f4f; --primary-d: #245a40;
    --danger: #c0392b; --warn: #b7791f;
}
html[data-theme="dark"], body[data-theme="dark"] {
    --bg: #161a1d; --surface: #1f2528; --text: #e7ebee; --muted: #9aa4ad;
    --border: #2c343a; --primary: #4caf80;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }

/* Gate */
.gate { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.gate-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2.2rem 2.6rem; text-align: center; max-width: 420px; }
.gate-emoji { font-size: 2.6rem; }
.gate-card h2 { margin: 0.6rem 0 0.4rem; }
.gate-card p { color: var(--muted); margin: 0; }

/* App */
.app { max-width: 1400px; margin: 0 auto; padding: 1rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.filters { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.filters label { font-size: 0.74rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.filters select, .filters input, .btn {
    font: inherit; font-size: 0.82rem; padding: 0.35rem 0.55rem; border: 1px solid var(--border);
    border-radius: 6px; background: var(--surface); color: var(--text);
}
.filters input[type="search"] { min-width: 220px; }
.count { font-size: 0.8rem; color: var(--muted); }

.btn { cursor: pointer; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { border: none; background: none; font-size: 1rem; }
.btn.small { font-size: 0.74rem; padding: 0.2rem 0.45rem; }
a.btn { text-decoration: none; display: inline-block; }

/* Split layout */
.split { display: flex; gap: 1rem; align-items: flex-start; }
.list-pane { flex: 1 1 60%; min-width: 0; }
.detail-pane { flex: 1 1 40%; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }

/* Table */
table.tickets { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: 0.84rem; }
.tickets th { text-align: left; padding: 0.5rem 0.6rem; background: var(--bg); color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
.tickets td { padding: 0.5rem 0.6rem; border-top: 1px solid var(--border); }
.tickets tr.row { cursor: pointer; }
.tickets tr.row:hover { background: var(--bg); }
.tickets .title { font-weight: 600; }
.tickets .snap { font-size: 0.8rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.small { font-size: 0.74rem; }
.muted { color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 0.08rem 0.4rem; border-radius: 999px; font-size: 0.68rem; font-weight: 700; }
.badge-open { background: #fde68a44; color: var(--warn); }
.badge-in_progress { background: #93c5fd44; color: #2563eb; }
.badge-resolved { background: #86efac44; color: var(--primary); }
.badge-closed { background: #cbd5e144; color: var(--muted); }
.badge-net { background: #fecaca66; color: var(--danger); }
.badge-warn { background: #fde68a66; color: var(--warn); }

/* Detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; padding: 0.8rem 0.9rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.detail-head h2 { margin: 0; font-size: 1rem; }
.detail-body { padding: 0.9rem; }
.desc { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 0.6rem 0.7rem; font-size: 0.86rem; margin-bottom: 0.8rem; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 0.7rem; font-size: 0.8rem; margin: 0 0 0.8rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
.logs { font-size: 0.8rem; margin-bottom: 0.5rem; }
.logs summary { cursor: pointer; color: var(--muted); }
.logs ul { margin: 0.3rem 0; padding-left: 1rem; }
.logs li { margin: 0.15rem 0; word-break: break-word; }
.log-empty { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.3rem; }

.triage { border-top: 1px solid var(--border); padding-top: 0.8rem; margin-top: 0.4rem; display: flex; flex-direction: column; gap: 0.5rem; }
.triage label { font-size: 0.8rem; }
.triage select, .triage textarea { font: inherit; font-size: 0.82rem; padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); width: 100%; }
.triage-actions { display: flex; align-items: center; gap: 0.5rem; }

/* Snapshot */
.snap-block { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.7rem; }
.snap-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.snap-frame { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

@media (max-width: 900px) {
    .split { flex-direction: column; }
    .detail-pane { position: static; width: 100%; max-height: none; }
}
