/* VaultForge Console — v0.3.0 */
* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg: #0e1116;
  --bg2: #151a21;
  --bg3: #1b222c;
  --line: #263040;
  --txt: #e8edf4;
  --muted: #93a1b3;
  --acc: #5b9dff;
  --acc2: #8b7bff;
  --ok: #3ecb84;
  --warn: #e3a545;
  --err: #e06060;
  --info: #55b8e5;
  --r: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 560px at 18% -12%, rgba(58, 92, 148, .22), transparent 60%),
    var(--bg);
  color: var(--txt);
  font: 14px/1.55 -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  min-height: 100vh;
}
a { color: var(--acc); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.link { color: var(--acc); cursor: pointer; }

/* ---- topbar ---- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 18px;
  background: rgba(14, 17, 22, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; font-weight: 700; color: var(--txt); }
.brand .logo { color: var(--acc); }
.brand .ver { color: var(--muted); font-size: 12px; font-weight: 400; }
#nav { display: flex; gap: 6px; flex: 1; }
#nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; font-size: 13px; }
#nav a:hover { color: var(--txt); background: var(--bg3); }
#nav a.active { color: var(--txt); background: var(--bg3); box-shadow: inset 0 -2px 0 var(--acc); }
.userbox { display: flex; gap: 10px; align-items: center; }
.user-name { color: var(--muted); font-size: 13px; }

/* ---- layout ---- */
.main { max-width: 1080px; margin: 0 auto; padding: 20px 18px 70px; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.view-title { margin: 0; font-size: 20px; }
.view-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.back { display: inline-block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { width: 220px; }
.toolbar-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.loading, .empty { color: var(--muted); padding: 26px; text-align: center; }
.error-box { color: #ff9b9b; background: #241416; border: 1px solid #4a2626; border-radius: 10px; padding: 12px 14px; margin: 10px 0; }

/* ---- buttons / inputs ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg3); color: var(--txt);
  cursor: pointer; font-size: 13px; font-family: inherit; transition: .15s;
}
.btn:hover { border-color: #3a4a63; transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--acc), var(--acc2)); border: none; color: #fff; font-weight: 600; }
.btn-danger { border-color: #5a2a2a; color: #ff9b9b; background: #2a1717; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.active { border-color: var(--acc); color: var(--acc); }
.icon-btn { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { color: var(--txt); background: var(--bg3); }
.input, .select, textarea.input {
  width: 100%; padding: 8px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: #10151c; color: var(--txt);
  font: inherit; outline: none;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(91, 157, 255, .13); }
.select { width: auto; }
textarea.input { resize: vertical; font-family: var(--mono); font-size: 13px; }
.field { margin-bottom: 12px; }
.field-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- cards ---- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.card + .card { margin-top: 14px; }
.card-title { font-weight: 600; }
.card-big { font-size: 26px; font-weight: 700; margin: 6px 0 2px; }
.card-sub { color: var(--muted); font-size: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

/* ---- status / badges ---- */
.pill { font-size: 11px; padding: 2px 8px; border-radius: 20px; border: 1px solid; }
.st-up { color: var(--ok); border-color: rgba(62, 203, 132, .4); background: rgba(62, 203, 132, .08); }
.st-warn { color: var(--warn); border-color: rgba(227, 165, 69, .4); background: rgba(227, 165, 69, .08); }
.st-down { color: var(--err); border-color: rgba(224, 96, 96, .4); background: rgba(224, 96, 96, .08); }
.st-unknown { color: var(--muted); border-color: var(--line); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--bg3); color: var(--muted); }
.t-ssh { color: #9db6ff; }
.t-file { color: #8fd8b0; }
.t-api { color: #e8c07d; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 20px; background: #202b3a; color: #a9bcd6; }
.stat-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.cb { width: 16px; height: 16px; accent-color: var(--acc); }

/* ---- list rows ---- */
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 14px; cursor: pointer; transition: .15s; }
.row:hover { border-color: #3a4a63; background: #171e27; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.row-actions { display: flex; gap: 6px; }
.actionbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; background: #14202e; border: 1px dashed #2f4a6b; border-radius: var(--r); margin-bottom: 12px; flex-wrap: wrap; }

/* ---- kv ---- */
.kv { display: flex; flex-direction: column; }
.kv-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #1d2734; }
.kv-row:last-child { border-bottom: none; }
.kv-key { width: 110px; flex: none; color: var(--muted); font-size: 12px; }
.kv-val { flex: 1; min-width: 0; word-break: break-all; font-family: var(--mono); font-size: 13px; }

/* ---- metrics ---- */
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.metric-card { text-align: center; }
canvas.ring { width: 100%; height: 112px; display: block; }
canvas.plot { width: 100%; height: 150px; display: block; }
.metric-cap { color: var(--muted); font-size: 12px; margin-top: 4px; }
.metric-figs { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 12px; }
.metric-figs b { color: var(--txt); font-weight: 600; }

/* ---- docker ---- */
.docker-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid #1d2734; flex-wrap: wrap; }
.docker-row:last-child { border-bottom: none; }
.docker-name { font-weight: 600; }

/* ---- terminal ---- */
.term-out { background: #0a0d11; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; min-height: 320px; max-height: 60vh; overflow: auto; font-family: var(--mono); font-size: 13px; }
.term-line { margin: 0 0 2px; white-space: pre-wrap; word-break: break-all; }
.term-line.cmd { color: #7fb2ff; }
.term-line.err { color: #ff8f8f; }
.term-line.muted { color: var(--muted); }
.term-form { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.term-prompt { color: var(--acc); font-family: var(--mono); }

/* ---- files ---- */
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; }
.crumb { color: var(--acc); cursor: pointer; }
.crumb-sep { color: var(--muted); }
.file-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid #1d2734; }
.file-row:hover { background: #171e27; }
.file-icon { width: 20px; text-align: center; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { width: 84px; text-align: right; }
.file-time { width: 150px; text-align: right; }
.file-actions { display: flex; gap: 6px; }

/* ---- modal ---- */
.modal-mask { position: fixed; inset: 0; background: rgba(5, 8, 12, .66); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 18px; }
.modal-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 520px; max-height: 86vh; display: flex; flex-direction: column; }
.modal-card.wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.modal-title { font-weight: 600; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }

/* ---- toast ---- */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 9px 14px; border-radius: 10px; background: #1c2532; border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: slidein .18s ease; font-size: 13px; max-width: 340px; }
.toast-ok { border-color: rgba(62, 203, 132, .5); }
.toast-err { border-color: rgba(224, 96, 96, .55); }
.toast-info { border-color: rgba(85, 184, 229, .5); }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- login ---- */
.login-wrap { display: flex; justify-content: center; padding: 8vh 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 26px; }
.login-title { margin: 0 0 4px; font-size: 22px; }
.login-sub { color: var(--muted); margin: 0 0 18px; font-size: 13px; }
.login-btn { width: 100%; justify-content: center; margin-top: 6px; }
.login-hint { margin-top: 14px; font-size: 13px; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  .file-time { display: none; }
  .file-size { width: 60px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  #topbar { gap: 8px; }
  #nav { order: 3; width: 100%; }
  .toolbar .input { width: 100%; }
}
