:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #0f1d24;
  --muted: #5b6b74;
  --line: #dde3e7;
  --soft: #eef2f4;
  --accent: #00757a;
  --accent-soft: #d8eeee;
  --pending: #9aa7ae;
  --running: #2f6fdb;
  --done: #1a8f4c;
  --failed: #d0342c;
  --warn: #c27a00;
  --frame-project: #c9d3d8;
  --frame-cluster: #a9b84a;
  --frame-managed: #8e6aa0;
  --shadow: 0 1px 2px rgba(15, 29, 36, .06), 0 4px 16px rgba(15, 29, 36, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1418; --card: #131e23; --ink: #e6eef1; --muted: #8fa1aa; --line: #24343b; --soft: #1a282e;
    --accent: #3cc3bd; --accent-soft: #143436; --pending: #5d6d75; --running: #5b95f5; --done: #3cc47a;
    --failed: #f0645c; --warn: #f0ac3c; --frame-project: #34464e; --frame-cluster: #7d8a35; --frame-managed: #8a68a0;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #0c1418; --card: #131e23; --ink: #e6eef1; --muted: #8fa1aa; --line: #24343b; --soft: #1a282e;
  --accent: #3cc3bd; --accent-soft: #143436; --pending: #5d6d75; --running: #5b95f5; --done: #3cc47a;
  --failed: #f0645c; --warn: #f0ac3c; --frame-project: #34464e; --frame-cluster: #7d8a35; --frame-managed: #8a68a0;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 18px; font-weight: 650; }
h2 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hidden { display: none !important; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.mark { width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), #0a3d4a); position: relative; }
.mark::after { content: ""; position: absolute; inset: 9px; border: 2.5px solid #fff; border-radius: 4px; border-right-color: transparent; }
.meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { background: var(--accent-soft); color: var(--accent); padding: 1px 8px; border-radius: 99px; font-weight: 600; font-size: 12px; }
.clock { display: flex; align-items: center; gap: 10px; }
.ring { width: 44px; height: 44px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4.5; }
.ring-bg { stroke: var(--soft); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 119.4; transition: stroke-dashoffset .6s; }
.clock.over .ring-fg { stroke: var(--failed); }
.clock-time { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.clock-sub { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-right: 6px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--pending); }
.live.on i { background: var(--done); box-shadow: 0 0 0 0 var(--done); animation: ping 2s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--done) 60%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }

.btn { font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--accent); background: var(--accent);
  color: #fff; border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost:hover { background: var(--soft); }

main { max-width: 1480px; margin: 0 auto; padding: 20px 24px 8px; }
.summary { margin: 0 0 16px; color: var(--muted); max-width: 900px; }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi .bar { height: 5px; background: var(--soft); border-radius: 9px; margin-top: 8px; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; background: var(--accent); border-radius: 9px; transition: width .6s; }
.kpi.good .v { color: var(--done); } .kpi.bad .v { color: var(--failed); } .kpi.warn .v { color: var(--warn); }

.adminbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; margin-bottom: 16px;
  border: 1px dashed var(--accent); border-radius: 12px; background: var(--accent-soft); }
.adminbar input { flex: 1; min-width: 200px; font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.side { grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); margin-top: 16px; }
.grid.halves { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: 16px; align-content: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.count { background: var(--soft); border-radius: 99px; padding: 0 9px; font-weight: 700; font-size: 12px; }
.count.hot { background: var(--failed); color: #fff; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: -1px; }
.lg { display: inline-block; width: 16px; height: 8px; border-radius: 3px; margin: 0 2px 0 6px; vertical-align: 0; }
.lg.plan { background: var(--soft); border: 1px solid var(--line); }
.lg.act { background: var(--accent); }
.lg.now { width: 2px; height: 12px; background: var(--failed); }

/* diagram */
.diagram-wrap { width: 100%; max-width: 1180px; margin: 0 auto; }
#diagram { width: 100%; height: auto; display: block; }
#diagram text { fill: var(--ink); font-family: inherit; }
#diagram .sub { fill: var(--muted); font-size: 10.5px; }
#diagram .ttl { font-size: 12px; font-weight: 650; }
#diagram .frame { fill: none; stroke-width: 1.5; }
#diagram .frame.project { stroke: var(--frame-project); }
#diagram .frame.cluster { stroke: var(--frame-cluster); stroke-dasharray: 5 4; fill: color-mix(in srgb, var(--frame-cluster) 5%, transparent); }
#diagram .frame.managed { stroke: var(--frame-managed); fill: color-mix(in srgb, var(--frame-managed) 6%, transparent); }
#diagram .ftitle { font-size: 11.5px; font-weight: 650; fill: var(--muted); }
#diagram .edge { fill: none; stroke: var(--muted); stroke-width: 1.4; opacity: .7; }
#diagram .edge.dashed { stroke-dasharray: 5 4; }
#diagram .edge.flow { stroke: var(--accent); opacity: 1; stroke-dasharray: 6 6; animation: flow 1s linear infinite; }
#diagram .elabel { font-size: 10px; fill: var(--muted); }
@keyframes flow { to { stroke-dashoffset: -12; } }
#diagram .node { cursor: pointer; }
#diagram .node .halo { fill: var(--card); stroke-width: 3; }
#diagram .node:hover .halo, #diagram .node.sel .halo { stroke-width: 4.5; }
#diagram .node.pending image { opacity: .35; filter: grayscale(1); }
#diagram .node.pending .ttl { fill: var(--muted); }
#diagram .chipbox { fill: var(--card); stroke-width: 2; }
#diagram .badge { stroke: var(--card); stroke-width: 2; }
#diagram .s-pending { stroke: var(--pending); fill: var(--pending); }
#diagram .s-deploying { stroke: var(--running); fill: var(--running); }
#diagram .s-ready { stroke: var(--done); fill: var(--done); }
#diagram .s-degraded { stroke: var(--warn); fill: var(--warn); }
#diagram .s-failed { stroke: var(--failed); fill: var(--failed); }
#diagram .halo.s-pending, #diagram .halo.s-deploying, #diagram .halo.s-ready, #diagram .halo.s-degraded, #diagram .halo.s-failed,
#diagram .chipbox.s-pending, #diagram .chipbox.s-deploying, #diagram .chipbox.s-ready, #diagram .chipbox.s-degraded, #diagram .chipbox.s-failed { fill: var(--card); }
#diagram .node.deploying .halo, #diagram .node.deploying .chipbox { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { stroke-opacity: .25; } }
#diagram .userbox { fill: var(--soft); stroke: var(--line); }

/* links + alerts */
.links, .alerts, .log { list-style: none; margin: 0; padding: 0; }
.links li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.links li:last-child { border-bottom: 0; }
.links .n { font-weight: 600; }
.links .u { font-size: 12px; color: var(--muted); word-break: break-all; }
.links .pr { font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 650; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok, .pill.done, .pill.ready { color: var(--done); background: color-mix(in srgb, var(--done) 13%, transparent); }
.pill.bad, .pill.failed { color: var(--failed); background: color-mix(in srgb, var(--failed) 13%, transparent); }
.pill.running, .pill.deploying { color: var(--running); background: color-mix(in srgb, var(--running) 13%, transparent); }
.pill.degraded, .pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.empty { color: var(--muted); font-size: 13px; padding: 6px 0; }
.alerts li { border-left: 3px solid var(--failed); padding: 6px 10px; margin-bottom: 8px; background: color-mix(in srgb, var(--failed) 7%, transparent); border-radius: 0 8px 8px 0; }
.alerts .n { font-weight: 700; }
.alerts .d { font-size: 12px; color: var(--muted); }

/* gantt */
.gantt { position: relative; }
.g-row { display: grid; grid-template-columns: 190px 1fr; align-items: center; height: 30px; }
.g-label { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; display: flex; gap: 6px; align-items: center; }
.g-label .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--pending); }
.g-label .dot.running { background: var(--running); } .g-label .dot.done { background: var(--done); } .g-label .dot.failed { background: var(--failed); }
.g-track { position: relative; height: 100%; border-left: 1px solid var(--line); }
.g-plan { position: absolute; top: 7px; height: 16px; border-radius: 5px; background: var(--soft); border: 1px solid var(--line); }
.g-act { position: absolute; top: 10px; height: 10px; border-radius: 4px; background: var(--accent); transition: width .6s; }
.g-act.running { background: var(--running); background-image: linear-gradient(45deg, rgba(255,255,255,.25) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.25) 50%, rgba(255,255,255,.25) 75%, transparent 75%); background-size: 12px 12px; animation: stripes 1s linear infinite; }
.g-act.failed { background: var(--failed); }
.g-act.done { background: var(--done); }
@keyframes stripes { to { background-position: 12px 0; } }
.g-axis { display: grid; grid-template-columns: 190px 1fr; height: 22px; }
.g-ticks { position: relative; border-top: 1px solid var(--line); }
.g-ticks span { position: absolute; top: 3px; font-size: 11px; color: var(--muted); transform: translateX(-50%); font-variant-numeric: tabular-nums; }
.g-now { position: absolute; top: 0; bottom: 22px; width: 2px; background: var(--failed); z-index: 2; pointer-events: none; }
.g-now::before { content: attr(data-t); position: absolute; top: -2px; left: 4px; font-size: 10.5px; font-weight: 700; color: var(--failed); white-space: nowrap; }
.g-grid { position: absolute; top: 0; bottom: 22px; width: 1px; background: var(--line); opacity: .6; }

/* log */
.log { max-height: 520px; overflow-y: auto; font-size: 12.5px; }
.log li { display: grid; grid-template-columns: 62px 10px 1fr; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--soft); align-items: baseline; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log .lv { width: 8px; height: 8px; border-radius: 50%; background: var(--pending); align-self: center; }
.log .lv.success { background: var(--done); } .log .lv.error { background: var(--failed); } .log .lv.warn { background: var(--warn); } .log .lv.info { background: var(--running); }
.log .src { color: var(--muted); font-size: 11px; margin-left: 4px; }
.filter { font-size: 12px; color: var(--muted); display: flex; gap: 5px; align-items: center; }

/* phases (accordion) */
.phases { display: grid; gap: 6px; }
.phase { border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
.phase > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 12px; }
.phase > summary::-webkit-details-marker { display: none; }
.phase > summary:hover { background: var(--soft); }
.phase .no { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--soft); color: var(--muted); }
.phase.running .no { background: var(--running); color: #fff; } .phase.done .no { background: var(--done); color: #fff; } .phase.failed .no { background: var(--failed); color: #fff; }
.phase .tt { min-width: 0; }
.phase .tt b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phase .tt small { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.phase .pbar { height: 3px; background: var(--soft); border-radius: 9px; margin-top: 4px; overflow: hidden; }
.phase .pbar i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.phase.done .pbar i { background: var(--done); }
.phase .body { padding: 2px 14px 12px 48px; }
.phase .d { font-size: 12.5px; color: var(--muted); margin: 0 0 6px; }
.phase ul { list-style: none; padding: 0; margin: 0; }
.phase li { display: flex; gap: 7px; font-size: 12.5px; padding: 2px 0; align-items: start; }
.phase li .cb { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--pending); flex: none; margin-top: 2px; display: grid; place-items: center; font-size: 10px; color: #fff; }
.phase li.ok .cb { background: var(--done); border-color: var(--done); }
.phase li.ok span { color: var(--muted); }
.phase.admin li { cursor: pointer; }
.phase .note { font-size: 12px; margin-top: 6px; padding: 5px 8px; background: var(--soft); border-radius: 6px; }
.phase .acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* now card */
.now .lbl { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.now .cur { font-size: 18px; font-weight: 700; margin: 4px 0 2px; }
.now .meta2 { font-size: 12.5px; color: var(--muted); }
.now .big { height: 8px; background: var(--soft); border-radius: 9px; overflow: hidden; margin: 10px 0 8px; }
.now .big i { display: block; height: 100%; background: var(--running); border-radius: 9px; transition: width .6s; }
.now .next { font-size: 12.5px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; color: var(--muted); }
.now .next b { color: var(--ink); }
.now.done .big i { background: var(--done); }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--card); border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(0,0,0,.12); padding: 24px; transform: translateX(105%); transition: transform .25s; z-index: 30; overflow-y: auto; }
.drawer.open { transform: none; }
.drawer .close { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 26px; color: var(--muted); cursor: pointer; }
.drawer h3 { margin: 0 0 4px; font-size: 18px; }
.drawer .head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.drawer .head img { width: 56px; height: 56px; border-radius: 12px; }
.drawer dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; margin: 14px 0; }
.drawer dt { color: var(--muted); }
.drawer dd { margin: 0; word-break: break-word; }
.drawer p { color: var(--muted); font-size: 13px; }

.tooltip { position: fixed; pointer-events: none; background: var(--ink); color: var(--card); font-size: 12px; padding: 6px 9px; border-radius: 7px; opacity: 0; transition: opacity .12s; z-index: 40; max-width: 260px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 12px 16px 28px; }

@media (max-width: 1100px) {
  .grid.side, .grid.halves { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .clock { order: 3; }
  main { padding: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-row, .g-axis { grid-template-columns: 110px 1fr; }
}
