:root {
  --bg: #0b0f17;
  --bg-soft: #111725;
  --panel: #131a29;
  --panel-2: #172033;
  --line: #22304a;
  --line-soft: #1b2436;
  --text: #e6edf7;
  --muted: #8b9bb4;
  --muted-2: #5f7085;
  --accent: #2f8cf5;
  --accent-2: #38d6c4;
  --green: #38d68a;
  --yellow: #f2c14e;
  --red: #f25f6b;
  --purple: #a583f7;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(1200px 800px at 10% -10%, #14203a 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #0e1522 0%, #0b111c 100%);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 18px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121f; font-weight: 800; letter-spacing: 0.5px;
}
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--muted-2); font-size: 11px; margin-top: 2px; }

#nav { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: transparent; border: none; color: var(--muted);
  font-size: 13.5px; cursor: pointer; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: #16203366; color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, #1d2f4d, #16233a); color: #fff; box-shadow: inset 0 0 0 1px #2a3f5f; }
.nav-ico { width: 18px; opacity: 0.85; }
.nav-badge {
  margin-left: auto; background: #1e2c44; color: var(--muted);
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
}

.sidebar-foot { margin-top: auto; padding: 16px; border-top: 1px solid var(--line-soft); }
.engine-pill {
  display: flex; align-items: center; gap: 8px;
  background: #0f1a2a; border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px; font-size: 12px; color: var(--muted);
}
.engine-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }
.engine-pill.ok .dot { background: var(--green); box-shadow: 0 0 8px #38d68a88; }
.engine-pill.demo .dot { background: var(--purple); box-shadow: 0 0 8px #a583f788; }
.engine-pill.err .dot { background: var(--red); }
.meta-line { font-size: 11px; color: var(--muted-2); margin-top: 8px; line-height: 1.5; word-break: break-all; }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }

.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
h1 { font-size: 24px; margin: 0; font-weight: 650; letter-spacing: -0.3px; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.live { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 9px 15px; border-radius: 10px; font-size: 13px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { border-color: #33507c; background: #1b2740; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #2f8cf5, #2569c4); border-color: #2f8cf5; color: #fff; font-weight: 600; }
.btn.primary:hover { background: linear-gradient(135deg, #3d97ff, #2b74d3); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #4a2430; }
.btn.danger:hover { background: #2a1620; }
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.view.hidden { display: none; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card {
  background: linear-gradient(170deg, #141d2e, #101724);
  border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px 18px;
}
.stat-card header { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; }
.stat-ico { opacity: 0.5; }
.stat-value { font-size: 32px; font-weight: 680; margin: 8px 0 12px; letter-spacing: -0.5px; }
.stat-value small { font-size: 14px; color: var(--muted); margin-left: 3px; font-weight: 500; }
.stat-value.small { font-size: 20px; line-height: 1.5; }
.bar { height: 6px; background: #1b2536; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width 0.5s ease; }
.stat-card footer { margin-top: 10px; font-size: 11.5px; color: var(--muted-2); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }

.panel { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.lg.cpu::before { background: var(--accent); }
.lg.mem::before { background: var(--accent-2); }
canvas { width: 100%; display: block; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 9px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); word-break: break-all; }
.link { color: var(--accent); font-size: 12.5px; cursor: pointer; text-decoration: none; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted-2); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:hover { background: #14203355; }
.table .right { text-align: right; }
.table .mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.table .empty-cell { color: var(--muted-2); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.state.running .dot { background: var(--green); box-shadow: 0 0 6px #38d68a77; }
.state.exited .dot { background: var(--red); }
.state.paused .dot { background: var(--yellow); }
.state.created .dot { background: var(--muted-2); }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar-title { font-size: 14px; font-weight: 600; color: var(--muted); }
.input {
  background: #0f1626; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 13px; outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: #2f8cf5; }
.input.search { min-width: 280px; }
.input.tiny { width: 84px; padding: 6px 9px; }
.input.select { padding: 7px 10px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--accent); }

.segmented { display: flex; background: #0f1626; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented button { background: transparent; border: none; color: var(--muted); padding: 6px 13px; border-radius: 8px; cursor: pointer; font-size: 12.5px; }
.segmented button.active { background: #1d2c46; color: #fff; }

.empty { text-align: center; padding: 40px; color: var(--muted-2); }

.hint { font-size: 11.5px; color: var(--muted-2); }

.compose-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; }
.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-card {
  border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px;
  background: #101827; display: flex; flex-direction: column; gap: 8px;
}
.project-card .p-head { display: flex; justify-content: space-between; align-items: center; }
.project-card .p-name { font-weight: 600; }
.project-card .p-meta { font-size: 11.5px; color: var(--muted-2); }
.project-card .p-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.compose-editor { display: flex; flex-direction: column; gap: 10px; }
textarea.code {
  width: 100%; min-height: 380px; resize: vertical;
  background: #0c1320; color: #cfe0ff; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; font-family: var(--mono); font-size: 12.5px;
  line-height: 1.65; outline: none; tab-size: 2;
}
textarea.code:focus { border-color: #2f8cf5; }
.compose-actions { display: flex; justify-content: space-between; align-items: center; }

.code-block {
  background: #0c1320; border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 12px; font-family: var(--mono); font-size: 12px; color: #a9c0e0;
  max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}

.container-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.sum-card {
  border: 1px solid var(--line-soft); border-radius: 12px; padding: 13px 14px;
  background: #101827; display: flex; flex-direction: column; gap: 7px; cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.sum-card:hover { border-color: #2c4a72; transform: translateY(-1px); }
.sum-card .s-name { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.sum-card .s-image { font-size: 11.5px; color: var(--muted-2); font-family: var(--mono); }
.sum-card .s-meta { font-size: 11.5px; color: var(--muted); }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #1b2740; color: var(--muted); }
.badge.green { background: #123122; color: #6fe0a8; }
.badge.red { background: #33161d; color: #f5999f; }
.badge.yellow { background: #332a12; color: #f0cf85; }
.badge.purple { background: #241a38; color: #c3aaf9; }

.drawer-backdrop, .modal-backdrop { position: fixed; inset: 0; background: #05080ecc; backdrop-filter: blur(2px); z-index: 60; }
.drawer-backdrop.hidden, .modal-backdrop.hidden, .drawer.hidden { display: none; }
.drawer-backdrop { z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(760px, 92vw);
  background: #0d1420; border-left: 1px solid var(--line); z-index: 50;
  display: flex; flex-direction: column; animation: slideIn 0.22s ease;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.drawer-head h2 { font-size: 16px; margin: 0; }
.drawer-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; font-family: var(--mono); }
.icon-btn { background: transparent; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: #1a2438; color: var(--text); }
.drawer-body { flex: 1; overflow: auto; padding: 16px 20px 30px; }
.drawer-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.drawer-tabs button { background: transparent; border: 1px solid var(--line-soft); color: var(--muted); padding: 7px 14px; border-radius: 9px; cursor: pointer; font-size: 13px; }
.drawer-tabs button.active { background: #1d2c46; color: #fff; border-color: #2c4a72; }
.drawer-pane.hidden { display: none; }

.stat-grid.mini { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.mini-card { background: #101827; border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.mini-card span { font-size: 11px; color: var(--muted-2); }
.mini-card b { font-size: 15px; font-weight: 600; }
.section-title { font-size: 13px; color: var(--muted); margin: 18px 0 10px; font-weight: 600; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 12px; background: #101827; border: 1px solid var(--line-soft); border-radius: 8px; padding: 6px 10px; color: #a9c0e0; font-family: var(--mono); }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.log-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.logs {
  background: #060b13; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-family: var(--mono); font-size: 12px; line-height: 1.6;
  height: calc(100vh - 260px); overflow: auto; white-space: pre-wrap; word-break: break-all;
  color: #b7c8de; margin: 0;
}

.terminal-shell { background: #060b13; border: 1px solid var(--line); border-radius: 10px; padding: 10px; height: calc(100vh - 320px); }
#terminal-host { width: 100%; height: 100%; }
.xterm .xterm-viewport { background: transparent !important; }

.modal-backdrop { display: grid; place-items: center; z-index: 70; }
.modal { width: min(640px, 92vw); max-height: 88vh; background: #0d1420; border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; animation: slideIn 0.18s ease; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 10px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--muted); }
.field .input, .field select { width: 100%; }
.field .input[type="checkbox"] { width: auto; }
.form-note { font-size: 11.5px; color: var(--muted-2); margin-top: 8px; line-height: 1.6; }

.toast-wrap { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast {
  background: #111c2c; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 11px 16px; font-size: 13px; min-width: 240px; max-width: 380px;
  box-shadow: 0 12px 30px #0008; animation: toastIn 0.2s ease;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.spinner { width: 14px; height: 14px; border: 2px solid #ffffff33; border-top-color: #fff; border-radius: 50%; display: inline-block; animation: spin 0.7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.terminal-badge { font-size: 10px; background: #213a5c; color: #a9c8f0; padding: 1px 6px; border-radius: 5px; margin-left: 6px; }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .compose-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .main { padding: 18px; }
  .stat-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
