/* rids console — a single stylesheet, no build step, no external assets. */

:root {
  --bg: #0a0e15;
  --bg-2: #0e141d;
  --panel: #111926;
  --panel-2: #16202e;
  --line: #1d2937;
  --line-soft: #172232;
  --fg: #e7eef8;
  --fg-dim: #9aabc0;
  --fg-mute: #6c7f96;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, .14);
  --ok: #34d399;
  --p1: #f87171;
  --p2: #fbbf24;
  --p3: #38bdf8;
  --p4: #8b9db4;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", Roboto,
          "Helvetica Neue", "Apple SD Gothic Neo", sans-serif;
}

[data-theme="light"] {
  --bg: #f2f5f9;
  --bg-2: #e9eef5;
  --panel: #ffffff;
  --panel-2: #f6f8fb;
  --line: #dde4ed;
  --line-soft: #e8edf4;
  --fg: #0f1a28;
  --fg-dim: #4a5c72;
  --fg-mute: #6d7f95;
  --accent: #0284c7;
  --accent-soft: rgba(2, 132, 199, .1);
  --ok: #059669;
  --p1: #dc2626;
  --p2: #b45309;
  --p3: #0284c7;
  --p4: #64748b;
  --shadow: 0 8px 24px rgba(15, 26, 40, .1);
}

* { box-sizing: border-box; }

/* The panels below set `display`, which would otherwise beat the UA rule for
   the `hidden` attribute and leave the drawer and empty state always visible. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  height: 52px;
  flex: 0 0 auto;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 20px; height: 20px; color: var(--accent); }
.brand-name { font-weight: 700; letter-spacing: .02em; }
.brand-sub { color: var(--fg-mute); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }

.topmeta { display: flex; align-items: center; gap: 18px; margin-left: auto; flex-wrap: wrap; }

.meta { display: flex; flex-direction: column; line-height: 1.15; }
.meta b { font: 600 13px/1.2 var(--mono); }
.meta em { color: var(--fg-mute); font-size: 10px; font-style: normal; letter-spacing: .1em; text-transform: uppercase; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 12px; color: var(--fg-dim);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-mute); }
.pill.live .dot { background: var(--ok); box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: ping 2s ease-out infinite; }
.pill.live { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.pill.done .dot { background: var(--accent); }
.pill.down .dot { background: var(--p1); }
.pill.down { color: var(--p1); }

@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.topactions { display: flex; gap: 6px; }

.icon-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--fg-dim);
  cursor: pointer;
}
.icon-btn:hover { color: var(--fg); border-color: var(--accent); }

/* ---------- stat strip ---------- */

.statstrip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  flex: 0 0 auto;
  background: var(--line-soft);
  border-bottom: 1px solid var(--line);
}

.stat {
  background: var(--bg-2);
  padding: 10px 16px 11px;
  display: flex; flex-direction: column; gap: 1px;
  position: relative;
}
.stat em { color: var(--fg-mute); font-size: 10px; font-style: normal; letter-spacing: .12em; text-transform: uppercase; }
.stat b { font: 600 22px/1.15 var(--mono); font-variant-numeric: tabular-nums; }
.stat .rate { color: var(--fg-mute); font: 11px/1.3 var(--mono); }
.stat.alertish b { color: var(--accent); }
.stat.crit b { color: var(--p1); }
.stat.bump b { animation: bump .5s ease-out; }

@keyframes bump {
  0% { color: var(--ok); transform: translateY(-1px); }
  100% { transform: none; }
}

/* ---------- layout ---------- */

.grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
  padding: 14px;
}

.col-main { display: flex; flex-direction: column; gap: 14px; min-height: 0; min-width: 0; }
.col-side { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  /* Sized by content: only the alerts panel absorbs the leftover height, and
     nothing may shrink below what it draws. */
  flex: 0 0 auto;
}
.panel.grow { flex: 1 1 auto; min-height: 0; }

.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  flex: 0 0 auto;
}
.panel-head h2 {
  margin: 0;
  font-size: 11px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--fg-dim);
}
.panel-note { margin-left: auto; color: var(--fg-mute); font: 11px var(--mono); }

/* ---------- timeline ---------- */

.chart-wrap { position: relative; padding: 8px 6px 6px; }
#timeline { width: 100%; height: 128px; display: block; }
#timeline .grid-line { stroke: var(--line-soft); stroke-width: 1; }
#timeline .area { fill: url(#tlGrad); }
#timeline .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
#timeline .hot { fill: var(--accent); }
#timeline .hit { fill: transparent; cursor: crosshair; }
#timeline .hit:hover { fill: var(--accent-soft); }
#timeline text { fill: var(--fg-mute); font: 10px var(--mono); }

.chart-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 5px 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 11px var(--mono);
  color: var(--fg);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

/* ---------- controls ---------- */

.controls { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* 남는 공간은 검색창이 흡수한다(칩은 위에서 이미 고정 폭). */
.controls .btn { flex: 0 0 auto; }
.controls .search { flex: 1 1 auto; min-width: 150px; }
.controls .search input { width: 100%; min-width: 0; }

.search {
  display: flex; align-items: center; gap: 6px;
  padding: 0 9px;
  height: 28px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--fg-mute);
}
.search:focus-within { border-color: var(--accent); color: var(--accent); }
.search input {
  width: 210px;
  border: 0; outline: 0; background: transparent;
  color: var(--fg); font: 12px var(--sans);
}
.search input::placeholder { color: var(--fg-mute); }

.chips { display: flex; gap: 4px; flex: 0 0 auto; }
.chip {
  /* Never shrink: a squeezed chip row is unreadable, wrapping is fine. */
  flex: 0 0 auto;
  height: 28px; padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--fg-mute);
  font: 600 11px/1 var(--mono);
  cursor: pointer;
}
.chip:hover { color: var(--fg); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.p1.on { background: color-mix(in srgb, var(--p1) 16%, transparent); border-color: var(--p1); color: var(--p1); }
.chip.p2.on { background: color-mix(in srgb, var(--p2) 16%, transparent); border-color: var(--p2); color: var(--p2); }
.chip.p3.on { background: color-mix(in srgb, var(--p3) 16%, transparent); border-color: var(--p3); color: var(--p3); }
.chip.p4.on { background: color-mix(in srgb, var(--p4) 18%, transparent); border-color: var(--p4); color: var(--fg-dim); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--fg-dim);
  font: 600 11px/1 var(--sans);
  cursor: pointer;
}
.btn:hover { color: var(--fg); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.paused { background: color-mix(in srgb, var(--p2) 16%, transparent); border-color: var(--p2); color: var(--p2); }

.pause-icon {
  width: 8px; height: 9px;
  border-left: 3px solid currentColor;
  border-right: 3px solid currentColor;
}
.btn.paused .pause-icon {
  width: 0; height: 0;
  border: 5px solid transparent;
  border-left: 8px solid currentColor;
  border-right: 0;
}

/* ---------- alert table ---------- */

.table-wrap { flex: 1 1 auto; overflow: auto; min-height: 0; position: relative; }

table.alerts { width: 100%; border-collapse: collapse; }

.alerts thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
  font: 600 10px/1 var(--sans);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--fg-mute);
  white-space: nowrap;
}

.alerts tbody tr {
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.alerts tbody tr:hover { background: var(--panel-2); }
.alerts tbody tr.sel { background: var(--accent-soft); }
.alerts tbody td {
  padding: 6px 10px;
  font: 12px/1.35 var(--mono);
  white-space: nowrap;
  vertical-align: top;
}
.alerts tbody tr.fresh { animation: fadein .45s ease-out; }
@keyframes fadein {
  from { background: var(--accent-soft); }
  to { background: transparent; }
}

.c-time { width: 96px; }
.c-prio { width: 34px; }
.c-sid { width: 78px; }
.c-proto { width: 54px; }
.c-arrow { width: 16px; }
.c-act { width: 54px; }
.c-src, .c-dst { width: 168px; }

td.c-time { color: var(--fg-mute); }
td.c-sig {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 0; width: 100%;
  font-family: var(--sans); font-size: 12.5px;
  color: var(--fg);
}
td.c-sid, td.c-proto { color: var(--fg-dim); }
td.c-arrow { color: var(--fg-mute); }
td.c-act .act { color: var(--fg-mute); text-transform: uppercase; font-size: 10px; letter-spacing: .06em; }
td.c-act .act.drop, td.c-act .act.reject { color: var(--p1); font-weight: 700; }

.prio {
  display: inline-grid; place-items: center;
  width: 20px; height: 18px;
  border-radius: 5px;
  font: 700 10px/1 var(--mono);
  color: #06111c;
}
.prio.p1 { background: var(--p1); }
.prio.p2 { background: var(--p2); }
.prio.p3 { background: var(--p3); }
.prio.p4 { background: var(--p4); }
[data-theme="light"] .prio { color: #fff; }

tr.row-p1 td.c-time { box-shadow: inset 2px 0 0 var(--p1); }
tr.row-p2 td.c-time { box-shadow: inset 2px 0 0 var(--p2); }

.empty {
  position: absolute; inset: 40px 0 auto;
  display: grid; place-items: center; gap: 4px;
  color: var(--fg-mute);
  text-align: center;
  pointer-events: none;
}
.empty p { margin: 6px 0 0; color: var(--fg-dim); font-weight: 600; }
.empty span { font-size: 12px; }

.table-foot {
  display: flex; justify-content: space-between;
  padding: 7px 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--fg-mute);
  font: 11px var(--mono);
  flex: 0 0 auto;
}

/* ---------- sidebar lists ---------- */

.barlist { list-style: none; margin: 0; padding: 6px 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.barlist li {
  position: relative;
  padding: 6px 8px;
  border-radius: 7px;
  overflow: hidden;
  cursor: pointer;
}
.barlist li:hover { background: var(--panel-2); }
.barlist .bar {
  position: absolute; inset: 0 auto 0 0;
  background: var(--accent-soft);
  border-radius: 7px;
}
.barlist .row { position: relative; display: flex; align-items: baseline; gap: 8px; }
.barlist .label {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px;
}
.barlist .label.mono { font-family: var(--mono); }
.barlist .count { font: 600 12px var(--mono); color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.barlist .sub { position: relative; font: 10px var(--mono); color: var(--fg-mute); }
.barlist .empty-note { padding: 10px; color: var(--fg-mute); font-size: 12px; text-align: center; }

.seg { margin-left: auto; display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button {
  border: 0; background: var(--panel-2); color: var(--fg-mute);
  font: 600 10px/1 var(--sans); letter-spacing: .06em;
  padding: 5px 9px; cursor: pointer;
}
.seg button.on { background: var(--accent-soft); color: var(--accent); }

.split { display: flex; height: 10px; margin: 12px 12px 8px; border-radius: 999px; overflow: hidden; background: var(--panel-2); }
.split span { height: 100%; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0 12px 12px; }
.legend li { display: flex; align-items: center; gap: 6px; font: 11px var(--mono); color: var(--fg-dim); }
.legend li.empty-note { color: var(--fg-mute); font-family: var(--sans); }
.legend i { width: 8px; height: 8px; border-radius: 2px; }

/* ---------- detail drawer ---------- */

.scrim { position: fixed; inset: 0; background: rgba(4, 8, 14, .5); z-index: 20; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 92vw);
  z-index: 21;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: .4; } }

.drawer-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.drawer-head h3 { margin: 6px 0 0; font-size: 15px; line-height: 1.35; }
.drawer-badge {
  display: inline-block; padding: 2px 7px; border-radius: 5px;
  font: 700 10px var(--mono); color: #06111c; background: var(--p4);
}
.drawer-badge.p1 { background: var(--p1); }
.drawer-badge.p2 { background: var(--p2); }
.drawer-badge.p3 { background: var(--p3); }
[data-theme="light"] .drawer-badge { color: #fff; }

.kv { margin: 0; padding: 12px 16px; display: grid; grid-template-columns: 104px 1fr; gap: 6px 12px; }
.kv dt { color: var(--fg-mute); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.kv dd { margin: 0; font: 12.5px var(--mono); word-break: break-all; }

.drawer-json { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line-soft); }
.drawer-json-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  color: var(--fg-mute); font: 10px var(--sans); letter-spacing: .12em; text-transform: uppercase;
}
.drawer-json pre {
  margin: 0; padding: 0 16px 16px;
  overflow: auto;
  font: 12px/1.55 var(--mono);
  color: var(--fg-dim);
  white-space: pre-wrap; word-break: break-all;
}

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

@media (max-width: 1180px) {
  .grid { grid-template-columns: 1fr; overflow-y: auto; }
  .col-side { flex-direction: row; flex-wrap: wrap; overflow: visible; }
  .col-side .panel { flex: 1 1 300px; }
  .panel.grow { min-height: 460px; }
}

@media (max-width: 900px) {
  .statstrip { grid-template-columns: repeat(3, 1fr); }
  .topmeta .meta { display: none; }
  .controls .search input { width: 130px; }
}

/* ---------- report view ---------- */

.report {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.report-bar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.report-range { color: var(--fg-mute); font: 11px var(--mono); }
.report-actions { margin-left: auto; display: flex; gap: 6px; }

.report-body { display: flex; flex-direction: column; gap: 14px; }

.report-off {
  margin: 40px auto;
  max-width: 560px;
  padding: 28px 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}
.report-off h3 { margin: 0 0 8px; font-size: 15px; }
.report-off p { margin: 0 0 16px; color: var(--fg-dim); font-size: 13px; }
.report-off pre {
  margin: 0 0 12px; padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  text-align: left;
  font: 12px/1.6 var(--mono);
  color: var(--accent);
  overflow-x: auto;
}
.report-off span { color: var(--fg-mute); font-size: 12px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.card em { color: var(--fg-mute); font: 10px/1 var(--sans); font-style: normal; letter-spacing: .12em; text-transform: uppercase; }
.card b { font: 600 24px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.card span { color: var(--fg-mute); font: 11px var(--mono); }
.card.accent b { color: var(--accent); }
.card.crit b { color: var(--p1); }

#daily-chart { width: 100%; height: 170px; display: block; }
#daily-chart .bar { fill: var(--accent); opacity: .78; }
#daily-chart .bar:hover { opacity: 1; }
#daily-chart .bar.weekend { fill: var(--p4); }
#daily-chart .grid-line { stroke: var(--line-soft); }
#daily-chart text { fill: var(--fg-mute); font: 10px var(--mono); }

/* 7 weekday rows × 24 hour columns, plus a label column. */
.heatmap {
  display: grid;
  grid-template-columns: 34px repeat(24, 1fr);
  gap: 2px;
  padding: 10px 14px 14px;
}
.heatmap .hl {
  color: var(--fg-mute);
  font: 10px/1 var(--mono);
  display: flex; align-items: center;
}
.heatmap .hh {
  color: var(--fg-mute);
  font: 9px/1 var(--mono);
  text-align: center;
  padding-bottom: 2px;
}
.heatmap .cell {
  /* Fixed height, not a square: 24 columns across a wide panel would make
     square cells taller than the whole report. */
  height: 22px;
  border-radius: 3px;
  background: var(--panel-2);
  cursor: default;
}
.heatmap .cell.hot { background: var(--accent); }

.report-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  align-items: start;
}

table.rank { width: 100%; border-collapse: collapse; }
table.rank td {
  padding: 6px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  vertical-align: middle;
}
table.rank tr:last-child td { border-bottom: 0; }
table.rank tr.clickable { cursor: pointer; }
table.rank tr.clickable:hover { background: var(--panel-2); }
table.rank td.rank-n { width: 26px; color: var(--fg-mute); font: 11px var(--mono); }
table.rank td.rank-label { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.rank td.rank-label small { display: block; color: var(--fg-mute); font: 10px var(--mono); }
table.rank td.rank-label.mono { font-family: var(--mono); }
table.rank td.rank-count { width: 64px; text-align: right; font: 600 12px var(--mono); font-variant-numeric: tabular-nums; }
table.rank td.rank-share { width: 70px; }
table.rank .share-bar { height: 5px; border-radius: 3px; background: var(--accent-soft); }
table.rank .share-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
table.rank .empty-note { color: var(--fg-mute); text-align: center; padding: 16px; }

.prio-bars { display: flex; flex-direction: column; gap: 6px; padding: 10px 14px 14px; border-top: 1px solid var(--line-soft); }
.prio-row { display: flex; align-items: center; gap: 8px; font: 11px var(--mono); color: var(--fg-dim); }
.prio-row .track { flex: 1 1 auto; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.prio-row .track i { display: block; height: 100%; }
.prio-row .n { width: 52px; text-align: right; font-variant-numeric: tabular-nums; }

.table-wrap.drill { max-height: 420px; }
/* Drill rows can span days, so their time column carries the date too. */
.drill .c-time { width: 132px; }

@media (max-width: 900px) {
  .heatmap { grid-template-columns: 28px repeat(24, 1fr); gap: 1px; }
  .heatmap .hh { display: none; }
}

/* ---------- hover explanations ---------- */

.hint {
  position: fixed;
  z-index: 40;
  max-width: 360px;
  padding: 10px 12px 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.hint h4 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}
.hint .hint-meta {
  display: block;
  margin-top: 2px;
  color: var(--fg-mute);
  font: 10px var(--mono);
}
.hint .hint-line {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.5;
  color: var(--fg-dim);
}
.hint .hint-line b {
  color: var(--accent);
  font-weight: 600;
}
.hint .hint-line b::after {
  content: ' — ';
  color: var(--fg-mute);
  font-weight: 400;
}

/* 설명이 붙은 요소. 클릭 동작이 따로 있는 행은 그 커서를 유지하고,
   클릭할 게 없는 요소만 도움말 커서로 바꾼다. */
.tipped { cursor: help; }
.alerts tbody tr .tipped,
.barlist li.tipped,
table.rank tr.tipped { cursor: pointer; }

.drawer-note {
  margin: 0 16px 14px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--fg-dim);
}
.drawer-note div + div { margin-top: 5px; }
.drawer-note b { color: var(--accent); font-weight: 600; }
.drawer-note b::after { content: ' — '; color: var(--fg-mute); font-weight: 400; }
.drawer-note:empty { display: none; }

/* ---------- priority colour coding ---------- */

/* 어느 화면에서든 P1=빨강, P2=주황, P3=파랑, P4+=회색으로 통일한다.
   칩에 색 점을 상시 노출해 막대 색과의 대응을 따로 설명하지 않아도 되게 한다.
   묶음 클래스는 `.sev`: `.prio` 는 알림 테이블의 우선순위 뱃지가 쓰고 있다. */
.chips.sev .chip { display: inline-flex; align-items: center; gap: 5px; }
.chips.sev .chip::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--p4);
}
.chips.sev .chip.p1::before { background: var(--p1); }
.chips.sev .chip.p2::before { background: var(--p2); }
.chips.sev .chip.p3::before { background: var(--p3); }

/* 사이드바 막대: 우선순위별 구간으로 나뉜 배경 띠 */
.barlist .bar {
  display: flex;
  background: none;
  overflow: hidden;
}
.barlist .bar i { display: block; height: 100%; opacity: .3; }

/* 순위 표 막대: 트랙 + 채움(폭=상대 비중) + 우선순위 구간 */
table.rank .share-bar { background: var(--panel-2); overflow: hidden; }
table.rank .share-bar .fill { display: flex; height: 100%; border-radius: 3px; overflow: hidden; }
table.rank .share-bar i { display: block; height: 100%; }

.prio-row { border-radius: 6px; padding: 2px 4px; margin: -2px -4px; cursor: pointer; }
.prio-row:hover { background: var(--panel-2); }
.prio-row.on { background: var(--accent-soft); }
.prio-row.on span:first-child { color: var(--fg); font-weight: 700; }

.filter-note { color: var(--p2); font: 11px var(--mono); }
.report-bar .chips.sev { margin-left: 4px; }

/* ---------- drill-down conditions ---------- */

/* 조회 조건은 조합된다. 각 칩이 하나의 조건이고, ✕ 로 하나씩 뺄 수 있다. */
.drill-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.drill-chips:empty { display: none; }
.drill-chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 260px;
  padding: 3px 6px 3px 9px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 11px/1 var(--sans);
  cursor: pointer;
}
.drill-chip span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.drill-chip em {
  font-style: normal;
  color: var(--fg-mute);
  font-family: var(--mono);
}
.drill-chip b {
  display: grid; place-items: center;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  font-size: 10px;
}
.drill-chip:hover b { background: var(--accent); color: var(--bg); }

table.rank tr.on { background: var(--accent-soft); }
table.rank tr.on td.rank-label { color: var(--accent); font-weight: 600; }

/* ---------- rules view ---------- */

table.ledger { width: 100%; border-collapse: collapse; }
table.ledger th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 7px 14px;
  text-align: left;
  font: 600 10px/1 var(--sans);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--fg-mute);
  white-space: nowrap;
}
table.ledger td {
  padding: 7px 14px;
  border-bottom: 1px solid var(--line-soft);
  font: 12px/1.4 var(--mono);
  vertical-align: top;
}
table.ledger tr:last-child td { border-bottom: 0; }
table.ledger td.wrap { font-family: var(--sans); word-break: break-word; }
table.ledger td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.ledger td.dim { color: var(--fg-mute); }
table.ledger .tag {
  display: inline-block; padding: 2px 7px; border-radius: 5px;
  font: 600 10px/1.4 var(--sans);
}
table.ledger .tag.changed { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
table.ledger .tag.same { background: var(--panel-2); color: var(--fg-mute); }
table.ledger .empty-note { color: var(--fg-mute); text-align: center; padding: 18px; font-family: var(--sans); }

.rules .table-wrap { max-height: 420px; }
