* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0a0a0a; --panel: #141414; --panel2: #101010; --border: #262626;
  --text: #e0e0e0; --muted: #888; --accent: #7dd3c0; --accent-dim: #6bc4b0;
  --blue: #6aa9ff; --warn: #d68a6b; --danger: #e88; --ok: #8bd17c;
}
html, body { background: var(--bg); color: var(--text); min-height: 100vh; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #0a0a0a; padding: 2px 6px; border-radius: 4px; color: var(--accent); font-size: 12px; }
.muted { color: var(--muted); }
.empty { color: #666; text-align: center; padding: 28px 0; font-size: 13px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.err { background: rgba(220,80,80,.1); border: 1px solid rgba(220,80,80,.3); color: var(--danger); border-radius: 8px; padding: 12px 14px; }

/* ── App shell ── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 24px; background: rgba(10,10,10,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.brand { color: #fff; font-size: 20px; font-weight: 300; letter-spacing: 4px; display: flex; align-items: center; gap: 6px; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 6px; height: 6px; border-radius: 3px; background: var(--accent); display: inline-block; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar select {
  background: var(--panel); color: var(--text); border: 1px solid #333; border-radius: 8px;
  padding: 7px 10px; font-size: 13px; max-width: 220px;
}
.linkbtn { color: var(--muted); cursor: pointer; font-size: 13px; background: none; border: none; }
.linkbtn:hover { color: #fff; text-decoration: none; }

.shell { display: flex; min-height: calc(100vh - 57px); }
.sidenav {
  width: 210px; flex-shrink: 0; padding: 20px 12px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 57px; align-self: flex-start;
  height: calc(100vh - 57px); overflow-y: auto;
}
.sidenav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #666; margin: 14px 10px 6px; }
.sidenav a { color: #aaa; padding: 9px 12px; border-radius: 8px; font-size: 14px; display: block; }
.sidenav a:hover { background: var(--panel); color: #fff; text-decoration: none; }
.sidenav a.active { background: rgba(125,211,192,.1); color: var(--accent); }

.main { flex: 1; min-width: 0; padding: 28px 32px 60px; max-width: 1500px; }
.page-head h1 { font-size: 24px; font-weight: 500; color: #fff; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 13px; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

/* ── Filter bar ── */
.filterbar {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 22px 0 20px;
  padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.filterbar .f { display: flex; flex-direction: column; gap: 4px; }
.filterbar label { font-size: 11px; color: var(--muted); }
.filterbar input[type=date] {
  background: #0a0a0a; border: 1px solid #333; border-radius: 8px; padding: 8px 10px; color: #fff; font-size: 13px;
}
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chipbtn {
  background: #0a0a0a; border: 1px solid #333; color: #bbb; border-radius: 999px; padding: 6px 12px;
  font-size: 12px; cursor: pointer;
}
.chipbtn:hover, .chipbtn.on { border-color: var(--accent); color: var(--accent); }

/* ── Buttons / inputs ── */
.btn {
  background: var(--panel); color: var(--accent); border: 1px solid #333; border-radius: 8px;
  padding: 9px 14px; font-size: 13px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #0a0a0a; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], select.in {
  background: #0a0a0a; border: 1px solid #333; border-radius: 8px; padding: 10px 12px; color: #fff; font-size: 13px;
}
input:focus { outline: none; border-color: var(--accent); }

/* ── Cards / grids ── */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.card h3 { font-size: 14px; font-weight: 500; color: #fff; margin-bottom: 4px; }
.card .hint { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g21 { grid-template-columns: 2fr 1fr; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 28px; font-weight: 500; color: #fff; margin-top: 4px; }
.kpi .s { font-size: 12px; color: #666; margin-top: 2px; }
.callout {
  background: rgba(214,138,107,.08); border: 1px solid rgba(214,138,107,.35); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px; font-size: 13px; color: #e6c3b3;
}
.callout b { color: #fff; }
.callout.good { background: rgba(125,211,192,.07); border-color: rgba(125,211,192,.3); color: #bfe9df; }

/* ── Tables ── */
.tbl-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tbl-search { flex: 1; max-width: 320px; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; color: var(--muted); font-weight: 500; padding: 10px 12px; background: var(--panel2);
  border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0;
}
table.tbl th.sortable { cursor: pointer; user-select: none; }
table.tbl th.sortable:hover { color: #ddd; }
table.tbl th.sort-asc::after { content: ' \25B2'; color: var(--accent); font-size: 10px; }
table.tbl th.sort-desc::after { content: ' \25BC'; color: var(--accent); font-size: 10px; }
table.tbl td { padding: 10px 12px; border-bottom: 1px solid #1a1a1a; color: #ddd; vertical-align: top; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr.clickable { cursor: pointer; }
table.tbl tr.clickable:hover td { background: #181818; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: #aaa; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; border: 1px solid #333; color: #bbb; }
.tag.ok { color: var(--ok); border-color: rgba(139,209,124,.4); }
.tag.bad { color: var(--danger); border-color: rgba(238,136,136,.4); }
.tag.warn { color: var(--warn); border-color: rgba(214,138,107,.4); }

/* ── Charts ── */
.chart svg { display: block; width: 100%; }
.chart .grid { stroke: #222; stroke-width: 1; }
.chart .axis { fill: #777; font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: #aaa; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bl-row { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 96px; gap: 12px; align-items: center; margin-bottom: 9px; }
.bl-label { font-size: 13px; color: #ddd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-track { background: #0a0a0a; border-radius: 6px; height: 18px; overflow: hidden; }
.bl-fill { height: 100%; border-radius: 6px; background: var(--accent); min-width: 2px; }
.bl-val { font-size: 12px; color: #aaa; text-align: right; font-variant-numeric: tabular-nums; }
.donut-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.donut-wrap svg { width: 150px; height: 150px; flex-shrink: 0; }

.fn-row { display: grid; grid-template-columns: minmax(150px, 26%) 1fr 170px; gap: 14px; align-items: center; }
.fn-name { font-size: 13px; color: #ddd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fn-track { background: #0a0a0a; border-radius: 8px; height: 34px; overflow: hidden; }
.fn-fill { height: 100%; border-radius: 8px; background: linear-gradient(90deg, #5fbba8, var(--accent)); }
.fn-fill.low { background: linear-gradient(90deg, #b8735a, var(--warn)); }
.fn-num { font-size: 12px; color: #aaa; text-align: right; }
.fn-drop { margin: 5px 0 5px calc(26% + 14px); font-size: 12px; color: var(--danger); }

/* ── Step editor ── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: #0a0a0a; border: 1px solid #333;
  border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 12px; color: #ddd;
}
.chip b { color: var(--accent); font-weight: 600; }
.chip button {
  background: #1a1a1a; border: none; color: #999; border-radius: 999px; width: 22px; height: 22px;
  cursor: pointer; font-size: 11px;
}
.chip button:hover { color: #fff; background: #262626; }
.step-add { display: flex; gap: 8px; flex-wrap: wrap; }
.step-add input { flex: 1; min-width: 220px; max-width: 420px; }

/* ── Timeline (journey) ── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: #262626; }
.tl-item { position: relative; margin-bottom: 16px; }
.tl-item::before {
  content: ''; position: absolute; left: -24px; top: 5px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
}
.tl-item.last::before { background: var(--danger); }
.tl-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.tl-name { color: #fff; font-weight: 500; }
.tl-time { color: #777; font-size: 12px; }
.tl-gap { color: #666; font-size: 12px; }
.props { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.props .p { background: #0a0a0a; border: 1px solid #262626; border-radius: 6px; padding: 2px 8px; font-size: 11px; color: #aaa; }
.props .p b { color: #ccc; font-weight: 500; }

.copyrow { display: flex; gap: 8px; align-items: center; }
.copyrow .box { flex: 1; background: #0a0a0a; border: 1px solid #333; border-radius: 8px; padding: 10px 12px; font-family: monospace; font-size: 12px; color: var(--accent); overflow-x: auto; white-space: nowrap; }
pre.code { background: #0a0a0a; border: 1px solid #262626; border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-size: 12px; color: #cde; line-height: 1.6; }
.usage-track { background: #262626; border-radius: 999px; height: 8px; overflow: hidden; margin-top: 8px; }
.usage-fill { background: var(--accent); height: 100%; border-radius: 999px; }
.step-list { list-style: none; counter-reset: s; }
.step-list li { counter-increment: s; position: relative; padding: 0 0 22px 44px; }
.step-list li::before {
  content: counter(s); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(125,211,192,.12); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.step-list h4 { color: #fff; font-weight: 500; margin-bottom: 4px; }

/* ── Login page ── */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.auth-card h2 { font-size: 18px; font-weight: 500; color: #fff; margin-bottom: 20px; }
.auth-card label { display: block; font-size: 13px; color: #999; margin: 16px 0 6px; }
.auth-card label:first-of-type { margin-top: 0; }
.auth-card input { width: 100%; }
.auth-card .btn-primary { width: 100%; margin-top: 24px; padding: 13px; font-size: 15px; }
.auth-tag { color: #888; font-size: 14px; margin: 6px 0 36px; text-align: center; max-width: 420px; }
.auth-logo { font-size: 30px; font-weight: 300; color: #fff; letter-spacing: 5px; }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g21 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidenav { width: 100%; flex-direction: row; height: auto; position: static; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 10px 12px; }
  .sidenav .grp { display: none; }
  .sidenav a { white-space: nowrap; }
  .main { padding: 20px 16px 50px; }
  .g2, .g4 { grid-template-columns: 1fr; }
  .presets { margin-left: 0; }
  .fn-row { grid-template-columns: 1fr; gap: 6px; }
  .fn-drop { margin-left: 0; }
  .topbar { padding: 10px 14px; }
}
