:root {
  --bg: #0d1017;
  --bg-2: #11161f;
  --card: #151b26;
  --line: #232c3f;
  --line-soft: #1c2333;
  --text: #e6ebf4;
  --muted: #8b94a9;
  --muted-2: #6b7488;
  --accent: #4c8bf5;
  --accent-hover: #3b78e0;
  --green: #3fb68b;
  --red: #e5484d;
  --amber: #e0a63b;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; font-size: 14px; }
.brand img { width: 26px; height: 26px; border-radius: 6px; }
.brand .sep { color: var(--muted-2); font-weight: 400; }
.env-tag {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  background: #5865f2;
  padding: 3px 9px;
  border-radius: 20px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.user img { width: 24px; height: 24px; border-radius: 50%; }

/* layout */
.wrap { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 24px 40px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line-soft); }
.page-head h1 { margin: 0 0 4px 0; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

.layout { display: grid; grid-template-columns: 210px 1fr; gap: 20px; align-items: start; }

/* sidebar */
.side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 10px;
  cursor: pointer;
}
.side-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.side-link:hover { background: var(--card); color: var(--text); }
.side-link.active { background: var(--card); color: var(--text); }
.side-section { border-top: 1px solid var(--line-soft); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.side-label { font-size: 11px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted-2); }
.meter { height: 6px; background: var(--card); border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); }
.side-note { margin: 0; font-size: 12.5px; color: var(--muted); }
.srv-rows { display: flex; flex-direction: column; }
.srv-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.srv-row:last-child { border-bottom: 0; }
.srv-row span { color: var(--muted); }
.srv-row strong { font-weight: 600; font-variant-numeric: tabular-nums; }

/* modal */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 13, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-back[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 380px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.modal h3 { margin: 0 0 14px 0; font-size: 15px; font-weight: 650; }
.modal .input { width: 100%; }
.modal-err { margin: 8px 0 0 0; font-size: 12.5px; color: var(--red); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* processes */
.proc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.proc-head h3 { margin: 0 !important; }
.section-label { font-size: 11px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted-2); }

/* buttons + inputs */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 550;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.btn img, .btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--muted-2); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.input {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  outline: none;
  font-family: inherit;
}
.input::placeholder { color: var(--muted-2); }
.input:focus { border-color: var(--accent); }
.search-wrap { position: relative; color: var(--muted-2); }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; }
.search-wrap .input { padding-left: 32px; width: 220px; }

/* panels */
.panels { min-width: 0; }
.panel { display: none; flex-direction: column; gap: 16px; }
.panel.active { display: flex; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.panel-head .hint { font-size: 12.5px; color: var(--muted-2); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* cards */
.card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.card { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; }
.card-label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.card-value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.card-sub { font-size: 12.5px; color: var(--muted-2); margin-top: 2px; }
.two-col { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; }
.box { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px; }
.box h3 { margin: 0 0 12px 0; font-size: 13px; font-weight: 650; }
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.activity li { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); color: var(--muted); }
.activity li:last-child { border-bottom: 0; }
.activity li span:last-child { color: var(--muted-2); font-size: 12px; flex-shrink: 0; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.box .note { font-size: 12.5px; color: var(--muted-2); margin: 10px 0 0 0; }

/* files */
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.crumb { background: transparent; border: 0; padding: 2px 4px; margin: -2px -4px; font-size: 13px; color: var(--muted); cursor: pointer; border-radius: 4px; font-family: inherit; }
.crumb:hover { color: var(--text); background: var(--card); }
.crumb.current { color: var(--text); font-weight: 600; cursor: default; }
.crumb.current:hover { background: transparent; }
.crumbs .csep { color: var(--muted-2); }
.table-box { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
table.files { width: 100%; border-collapse: collapse; font-size: 13px; }
table.files th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted-2); padding: 10px 16px; border-bottom: 1px solid var(--line-soft); background: var(--bg-2); }
table.files td { padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
table.files tr:last-child td { border-bottom: 0; }
table.files tbody tr:hover { background: rgba(255,255,255,0.015); }
.fname { display: flex; align-items: center; gap: 11px; font-weight: 500; }
.fname img.icon { width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0; }
.fname svg.ui { width: 17px; height: 17px; color: var(--muted); flex-shrink: 0; }
.muted { color: var(--muted); }
.num { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-actions { text-align: right; }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px; cursor: pointer; display: inline-flex; color: var(--muted); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--card); border-color: var(--line); color: var(--text); }
.drop-hint { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); background: var(--bg-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; }
.drop-hint svg { width: 16px; height: 16px; flex-shrink: 0; }
.drop-hint strong { color: var(--text); font-weight: 550; }
.drop-hint.over { border-color: var(--accent); }

/* editor */
.editor { display: grid; grid-template-columns: 210px 1fr; background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; min-height: 400px; }
.tree { border-right: 1px solid var(--line-soft); padding: 8px; display: flex; flex-direction: column; gap: 1px; }
.tree-item { display: flex; align-items: center; gap: 9px; font-size: 13px; padding: 7px 9px; border-radius: 6px; color: var(--muted); cursor: pointer; }
.tree-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.tree-item img.badge { width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; }
.tree-item:hover { background: var(--card); color: var(--text); }
.tree-item.active { background: var(--card); color: var(--text); }
.editor-main { display: flex; flex-direction: column; min-width: 0; }
.editor-tabs { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--line-soft); padding: 0 8px; }
.tab { font-family: inherit; font-size: 12.5px; padding: 9px 12px; color: var(--muted); border: 0; border-bottom: 2px solid transparent; background: transparent; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
#editorHost { height: 380px; min-height: 330px; background: #0b0e14; }
#editorHost .monaco-editor, #editorHost .monaco-editor-background { background: #0b0e14; }
#editorFallback {
  flex: 1;
  min-height: 330px;
  background: #0b0e14;
  color: #c9d4e3;
  border: 0;
  padding: 16px 18px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  resize: vertical;
  outline: none;
}
.editor-status { display: flex; justify-content: space-between; padding: 8px 16px; font-size: 12px; color: var(--muted-2); border-top: 1px solid var(--line-soft); }

/* terminal */
.term { background: #0b0e14; border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.term-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; color: var(--muted); }
.term-body { padding: 14px 16px; min-height: 230px; max-height: 360px; overflow-y: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.7; }
.term-line.dim { color: var(--muted-2); }
.term-line.cmd { color: var(--text); }
.term-input-row { display: flex; gap: 9px; align-items: center; padding: 11px 16px; border-top: 1px solid var(--line-soft); }
.term-input-row .prompt { color: var(--accent); font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
#termInput { flex: 1; background: transparent; border: 0; color: var(--text); font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; outline: none; }

/* apps */
.apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.app { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.app-top { display: flex; align-items: center; gap: 9px; }
.app-top strong { font-size: 13.5px; font-weight: 600; }
.app-top svg { width: 17px; height: 17px; color: var(--muted); flex-shrink: 0; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot.on { background: var(--green); }
.dot.off { background: var(--red); }
.pill { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--card); border: 1px solid var(--line); padding: 2px 8px; border-radius: 20px; }
.app-desc { font-size: 12.5px; color: var(--muted); }
.app-actions { display: flex; gap: 6px; padding-top: 2px; }
.logs { background: #0b0e14; border: 1px solid var(--line-soft); border-radius: 6px; padding: 12px 14px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.7; color: #93a1b8; overflow-x: auto; margin: 0; white-space: pre-wrap; }

footer { border-top: 1px solid var(--line-soft); padding: 18px 24px; text-align: center; color: var(--muted-2); font-size: 12.5px; }
footer p { margin: 0; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c2333;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* logout */
.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  padding: 6px;
  cursor: pointer;
}
.logout-btn:hover { background: var(--card); border-color: var(--line); color: var(--text); }

/* login */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 32px 28px 24px;
  text-align: center;
}
.login-logo { width: 52px; height: 52px; border-radius: 12px; margin: 0 auto 14px; }
.login-card h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.login-sub { margin: 4px 0 20px 0; font-size: 13px; color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .input { width: 100%; }
.login-btn { width: 100%; justify-content: center; margin-top: 4px; padding: 9px 14px; }
.login-error { margin: 0; font-size: 12.5px; color: var(--red); }
.login-hint { margin: 18px 0 0 0; font-size: 12.5px; color: var(--muted-2); }
.login-hint code {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .side-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; }
  .tree { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .apps-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 16px; }
  .wrap { padding: 20px 16px 32px; }
  .card-grid { grid-template-columns: 1fr; }
  .side-nav { grid-template-columns: 1fr 1fr; }
}
