:root {
  --bg: #f8fafb;
  --card: #ffffff;
  --line: #dde4e8;
  --line-strong: #c2cfd6;
  --text: #13222b;
  --dim: #526470;
  --accent: #0f6b75;
  --accent-hover: #0a525a;
  --amber: #c97a16;
  --blue: #2364aa;
  --bad: #b9382c;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font: 15px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0 0 12px; font-size: 24px; font-weight: 700; }
h2 { margin: 0; font-size: 15px; font-weight: 600; }
.box {
  max-width: 400px; margin: 11vh auto 0; padding: 28px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.wide { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.dim { color: var(--dim); }
.small-text { font-size: 12.5px; }
.subnote { margin: 0 0 18px; }
.error { color: var(--bad); margin: 0 0 14px; font-size: 14px; }
.or { margin: 14px 0; text-align: center; color: var(--dim); font-size: 13px; }
.foot { margin: 20px 0 0; font-size: 14px; }
input {
  width: 100%; padding: 9px 12px; margin: 0 0 10px;
  border-radius: 9px; border: 1px solid var(--line-strong); background: #ffffff; color: var(--text); font: inherit;
}
input:focus { outline: none; border-color: var(--accent); }
.button {
  display: block; width: 100%; padding: 9px 14px;
  border-radius: 9px; border: 1px solid var(--line-strong); background: #ffffff; color: var(--text);
  font: 500 14px/1.2 inherit; text-align: center; text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.button.primary { background: var(--accent); color: #ffffff; border-color: var(--accent); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #ffffff; }
.button.small { display: inline-block; width: auto; padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.button.toggle.active { border-color: var(--accent); background: #e7f4f5; color: var(--accent); }
.row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.row input { flex: 1; margin: 0; }
.row .button { width: auto; white-space: nowrap; }
.inline-form { margin: 0; display: inline; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: #ffffff; }
.seg-btn { border: 0; background: transparent; color: var(--dim); padding: 6px 13px; font: 13px/1.2 inherit; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent); color: #ffffff; font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { margin-bottom: 0; padding: 15px 18px; }
.kpi-head { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 5px; }
.kpi-val { font-size: 28px; font-weight: 700; line-height: 1.2; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; }

.info { position: relative; display: inline-block; color: var(--dim); cursor: help; font-size: 12px; }
.info:hover::after, .info:focus::after {
  content: attr(data-tip); position: absolute; left: 0; top: 20px; z-index: 20;
  width: 240px; padding: 8px 10px; border-radius: 8px;
  background: #13222b; color: #f4f7f8; font-size: 12px; line-height: 1.4; font-weight: 400;
  box-shadow: 0 8px 24px rgba(19, 34, 43, 0.2);
}
.kpi:nth-child(n+3) .info:hover::after, .kpi:nth-child(n+3) .info:focus::after { left: auto; right: 0; }

.chart-card { padding-bottom: 14px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--dim); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.swatch.teal { background: var(--accent); }
.swatch.amber { background: var(--amber); }
.chart-wrap { width: 100%; overflow: hidden; }
.chart-svg { width: 100%; height: auto; display: block; }
.grid-line { stroke: var(--line); stroke-dasharray: 3 3; }
.axis-lbl { fill: var(--dim); font-size: 11px; }
.bar-hit { fill: transparent; }
.bar-group:hover .bar-hit { fill: rgba(19, 34, 43, 0.04); }
.bar-teal { fill: var(--accent); }
.bar-amber { fill: var(--amber); }
.chart-tip { margin-top: 6px; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.two-col .card { margin-bottom: 0; }
.search-input { width: 250px; margin: 0; padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { color: var(--dim); font-weight: 500; font-size: 12px; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.right, td.right { text-align: right; white-space: nowrap; }

.pill {
  display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11px; line-height: 1.4;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); margin-left: 6px; white-space: nowrap;
}
.pill.muted { color: var(--dim); margin-left: 0; }
.pill.admin-tag { border-color: #9fd0d5; color: var(--accent); background: #e7f4f5; }
.pill.bad { border-color: #e9b3ae; color: var(--bad); background: #fdf1f0; }
.pill.chip-teal { margin: 0; color: var(--accent); border-color: #9fd0d5; background: #e7f4f5; }
.pill.chip-amber { margin: 0; color: var(--amber); border-color: #eed0a4; background: #fdf6ea; }
.pill.chip-blue { margin: 0; color: var(--blue); border-color: #b7d3f2; background: #eef5fc; }
.pill.chip-muted { margin: 0; color: var(--dim); }

.action-btn { margin-left: 6px; }
.recent-list { max-height: 290px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.recent-row {
  display: grid; grid-template-columns: 68px auto 1fr auto; gap: 8px; align-items: center;
  padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.recent-row:last-child { border-bottom: 0; }
.recent-target { font-weight: 500; white-space: nowrap; }
.recent-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.recent-time { font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .search-input { width: 100%; }
}
