:root {
  --bg: #f6f7f9; --card: #fff; --text: #1a202c; --muted: #64748b;
  --accent: #2563eb; --border: #e2e8f0;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 960px; margin: 1.5rem auto; padding: 0 1rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #0f172a; color: #fff; padding: .7rem 1.25rem;
}
.topbar a { color: #cbd5e1; margin-left: 1rem; }
.topbar .brand { font-weight: 700; font-size: 1.1rem; color: #fff; margin: 0; }

.btn {
  display: inline-block; background: var(--accent); color: #fff !important;
  border: 0; border-radius: 6px; padding: .45rem .9rem; font-size: .95rem;
  cursor: pointer;
}
.btn:hover { background: #1d4ed8; text-decoration: none; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem; margin: .75rem 0;
}
.form label { display: block; margin-bottom: .75rem; font-weight: 600; }
.form input, .form select, .form textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .5rem;
  border: 1px solid var(--border); border-radius: 6px; font: inherit; font-weight: 400;
}

.toolbar { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  align-items: center; margin-bottom: 1rem; }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); border-radius: 999px; padding: .15rem .7rem;
  font-size: .85rem; background: var(--card); color: var(--text);
}
.chip.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.search input { padding: .45rem .7rem; border: 1px solid var(--border);
  border-radius: 6px; min-width: 240px; }

.ticket-table { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ticket-table th, .ticket-table td { text-align: left; padding: .6rem .75rem;
  border-bottom: 1px solid var(--border); }
.ticket-table th { background: #f1f5f9; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); }
.tid { font-family: ui-monospace, Consolas, monospace; font-weight: 600; }

.badge { border-radius: 999px; padding: .15rem .65rem; font-size: .8rem;
  font-weight: 600; white-space: nowrap; }
.badge.big { font-size: 1rem; padding: .3rem .9rem; }
.status-open        { background: #dbeafe; color: #1e40af; }
.status-in_progress { background: #fef3c7; color: #92400e; }
.status-pending     { background: #ede9fe; color: #5b21b6; }
.status-resolved    { background: #dcfce7; color: #166534; }
.status-closed      { background: #e2e8f0; color: #475569; }

.prio { font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.prio-low { color: #64748b; } .prio-medium { color: #2563eb; }
.prio-high { color: #d97706; } .prio-urgent { color: #dc2626; }

.muted { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); text-align: center; margin: 3rem 0; }
.flash { padding: .6rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

.detail-head { display: flex; justify-content: space-between; align-items: start;
  gap: 1rem; flex-wrap: wrap; }
.detail-head h1 { margin: 0 0 .25rem; font-size: 1.3rem; }
.timeline { list-style: none; padding: 0; }
.update-meta { display: flex; gap: .6rem; align-items: center; margin-bottom: .4rem; }
.prewrap { white-space: pre-wrap; font: inherit; margin: 0; }
.json { background: #0f172a; color: #e2e8f0; padding: .75rem; border-radius: 6px;
  overflow-x: auto; font-size: .85rem; }
details summary { cursor: pointer; color: var(--muted); font-size: .85rem;
  margin-top: .5rem; }

.auth-box { max-width: 420px; margin: 2rem auto; }

.attachments { list-style: none; padding: .25rem 0 0; margin: .25rem 0 0;
  border-top: 1px dashed var(--border); }
.attachments li { padding: .15rem 0; font-size: .9rem; }

.row-attn { background: #fffbeb; }
.flag { border-radius: 4px; padding: .1rem .45rem; font-size: .75rem;
  font-weight: 600; white-space: nowrap; margin-right: .25rem; }
.flag-reply { background: #fee2e2; color: #991b1b; }
.flag-reopen { background: #fef3c7; color: #92400e; }
.flag-esc { background: #ede9fe; color: #5b21b6; }
.score summary { cursor: pointer; list-style: none; }
.score pre { position: absolute; z-index: 10; min-width: 180px; }
.ticket-table td { position: relative; }
.whoami { color: #94a3b8; font-size: .85rem; margin-left: 1rem; }
.inline-form { display: inline; margin-left: .5rem; }
.linkbtn { background: none; border: 0; color: #cbd5e1; cursor: pointer;
  font: inherit; font-size: .9rem; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
