:root {
  --bg: #12151b;
  --bg-2: #171b23;
  --panel: #1b2029;
  --panel-2: #212734;
  --line: #2b3240;
  --text: #e6eaf2;
  --muted: #8b95a7;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.xs { font-size: 11.5px; }
.mono { font-family: var(--mono); }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.error { color: var(--red); font-size: 12.5px; min-height: 16px; margin: 8px 0 0; }

/* ---------- boot ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 90; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px; }
.auth-brand { display: flex; gap: 13px; align-items: center; margin-bottom: 20px; }
.auth-card h1 { margin: 0; font-size: 19px; }
.auth-card p { margin: 2px 0 0; font-size: 12.5px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 10px 11px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.auth-alt { text-align: center; margin: 14px 0 0; font-size: 12.5px; }
.auth-alt a { color: var(--accent); text-decoration: none; }

/* ---------- buttons ---------- */
.btn {
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; transition: .12s; white-space: nowrap;
}
.btn:hover { background: #29313f; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.good { border-color: #1f6f43; color: #86efac; }
.btn.warn { border-color: #7a5312; color: #fcd34d; }
.btn.bad { border-color: #7f2b2b; color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: #29313f; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.side-head { display: flex; gap: 10px; align-items: center; padding: 15px 16px; border-bottom: 1px solid var(--line); }
.side-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-title strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.logo.sm { width: 32px; height: 32px; border-radius: 8px; font-size: 12px; }
.side-nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; background: transparent; border: 0; border-radius: 8px; color: var(--muted); font: inherit; text-align: left; cursor: pointer; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); font-weight: 500; }
.nav-item .ico { width: 16px; text-align: center; opacity: .9; }
.side-foot { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.who { display: flex; gap: 10px; align-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; }
.who-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.who-meta strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 18px; background: var(--bg-2); }
.crumb { font-weight: 600; font-size: 15px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill { display: flex; align-items: center; gap: 7px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.ok .dot { background: var(--green); box-shadow: 0 0 8px rgba(34,197,94,.7); }
.pill.ok { color: #a7f3d0; border-color: #1f6f43; }
.pill.off .dot { background: var(--red); }
.content { flex: 1; overflow: auto; padding: 20px; }
.view { max-width: 1200px; }

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 600; margin-top: 4px; line-height: 1.2; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

.meter { height: 7px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 9px; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.meter > i.g { background: var(--green); }
.meter > i.a { background: var(--amber); }
.meter > i.r { background: var(--red); }

.scard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; display: flex; flex-direction: column; gap: 11px; cursor: pointer; transition: .14s; }
.scard:hover { border-color: #3a4459; transform: translateY(-1px); }
.scard-head { display: flex; align-items: flex-start; gap: 10px; }
.scard h4 { margin: 0; font-size: 15px; }
.scard .sub { font-size: 12px; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-transform: capitalize; }
.status.running { color: #86efac; border-color: #1f6f43; background: rgba(34,197,94,.08); }
.status.exited { color: #fca5a5; border-color: #7f2b2b; background: rgba(239,68,68,.08); }
.status.paused { color: #fcd34d; border-color: #7a5312; }
.status .dot { width: 6px; height: 6px; }
.status.running .dot { background: var(--green); }

/* ---------- server view ---------- */
.sv-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.sv-head h2 { margin: 0; font-size: 20px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 14px; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }

.console { background: #0c0f14; border: 1px solid var(--line); border-radius: var(--radius); height: 460px; display: flex; flex-direction: column; overflow: hidden; }
.console-out { flex: 1; overflow: auto; padding: 12px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.console-out .warn { color: #fbbf24; }
.console-out .err { color: #f87171; }
.console-out .cmd { color: #7dd3fc; }
.console-in { display: flex; gap: 8px; padding: 9px; border-top: 1px solid var(--line); background: var(--panel); }
.console-in input { margin: 0; font-family: var(--mono); }
.console-in button { flex: none; }

/* ---------- files ---------- */
.files { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px; background: var(--bg-2); }
.crumbs a { color: var(--accent); text-decoration: none; cursor: pointer; }
.frow { display: grid; grid-template-columns: 1fr 110px 170px 116px; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.frow:hover { background: var(--panel-2); }
.frow:last-child { border-bottom: 0; }
.frow.head { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; background: var(--bg-2); }
.fname { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.fname span:hover { color: var(--accent); }
.fdir { color: #fbbf24; }
.fact { display: flex; gap: 4px; justify-content: flex-end; }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
tbody tr:hover { background: var(--panel-2); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 80; padding: 20px; }
.modal-box { width: 100%; max-width: 520px; max-height: 86vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.modal-box h3 { margin: 0 0 14px; font-size: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 95; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; font-size: 13px; max-width: 340px; animation: slide .2s ease; }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .big { font-size: 34px; opacity: .35; margin-bottom: 10px; }
.tpl { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 10px; }
.tpl-item { border: 1px solid var(--line); background: var(--bg-2); border-radius: 9px; padding: 12px; cursor: pointer; transition: .12s; }
.tpl-item:hover { border-color: #3a4459; }
.tpl-item.sel { border-color: var(--accent); background: rgba(59,130,246,.09); }
.tpl-item strong { display: block; font-size: 14px; margin-bottom: 3px; }
.tpl-item span { font-size: 12px; color: var(--muted); line-height: 1.4; display: block; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.only-mobile { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; z-index: 60; transform: translateX(-100%); transition: transform .18s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .only-mobile { display: grid; }
  .frow { grid-template-columns: 1fr 90px; }
  .frow > :nth-child(3), .frow > :nth-child(4) { display: none; }
  .split { grid-template-columns: 1fr; }
  .content { padding: 14px; }
}
