:root {
  --bg: #0a1120;
  --bg-2: #0d1627;
  --panel: #111c30;
  --panel-2: #15223a;
  --line: #22314f;
  --text: #e8effc;
  --muted: #93a6c7;
  --accent: #4f8cff;
  --accent-2: #38d0c4;
  --ok: #35d07f;
  --warn: #f2b544;
  --danger: #ff5f70;
  --radius: 12px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { height: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(1200px 600px at 20% -10%, #14294a 0%, transparent 55%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { margin-left: auto; }

/* ------------------------------------------------------------ login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.login-brand strong { display: block; font-size: 18px; }
.login-brand small { color: var(--muted); }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #2f6bda);
  color: #fff; font-weight: 800; letter-spacing: .5px;
}
.login label { color: var(--muted); font-size: 13px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.check input { width: auto; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0; }

/* ------------------------------------------------------------ layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px;
  background: rgba(10, 17, 32, .78);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand-text strong { display: block; letter-spacing: .4px; }
.brand-text small { color: var(--muted); font-size: 12px; }
#nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; gap: 10px; align-items: center;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font: inherit; text-align: left;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-item span { width: 18px; text-align: center; opacity: .85; }
.nav-item:hover { background: rgba(79, 140, 255, .08); color: var(--text); }
.nav-item.active { background: rgba(79, 140, 255, .16); border-color: rgba(79, 140, 255, .35); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-status { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.topbar { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -.3px; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

/* ------------------------------------------------------------ components */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 12px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 13px;
  transition: border-color .15s, background .15s, transform .05s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: #33507f; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #4f8cff, #2f6bda); border-color: #3f7cf0; color: #fff; }
.btn.danger { border-color: rgba(255, 95, 112, .5); color: #ffb3bb; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

input, textarea, select {
  width: 100%; background: #0b1526; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(79, 140, 255, .35); border-color: #3d6fbf; }
textarea { resize: vertical; min-height: 120px; }
label { font-size: 13px; color: var(--muted); }

.card {
  background: linear-gradient(180deg, rgba(21, 34, 58, .9), rgba(17, 28, 48, .9));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: .2px; color: #cddcf7; }
.metric { font-size: 26px; font-weight: 700; letter-spacing: -.5px; overflow-wrap: anywhere; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed rgba(34, 49, 79, .7); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; word-break: break-word; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); background: #0d1729; }
.badge.ok { color: #b8ffd9; border-color: rgba(53, 208, 127, .4); background: rgba(53, 208, 127, .1); }
.badge.warn { color: #ffe2ad; border-color: rgba(242, 181, 68, .4); background: rgba(242, 181, 68, .1); }
.badge.err { color: #ffc0c6; border-color: rgba(255, 95, 112, .45); background: rgba(255, 95, 112, .1); }

.bar { height: 6px; background: #0a1424; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid rgba(34, 49, 79, .65); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:hover td { background: rgba(79, 140, 255, .04); }
td.actions-cell { text-align: right; white-space: nowrap; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.crumbs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.crumbs button { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.file-row { cursor: pointer; }
.file-row .icon { width: 20px; display: inline-block; text-align: center; opacity: .9; }
.type-dir { color: var(--accent-2); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 12px; cursor: pointer; font: inherit; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

pre.log {
  margin: 0; background: #060d18; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; max-height: 46vh; overflow: auto; font-size: 12px; line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}

/* ------------------------------------------------------------ modal */
.modal { position: fixed; inset: 0; background: rgba(3, 8, 16, .72); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-box { width: min(760px, 100%); max-height: 92vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head .btn { margin-left: auto; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.modal-body textarea.code { min-height: 42vh; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ------------------------------------------------------------ toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 9px; padding: 10px 12px; font-size: 13px; box-shadow: var(--shadow); max-width: 380px; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }

.notice { border: 1px solid rgba(242, 181, 68, .35); background: rgba(242, 181, 68, .08); color: #ffe2ad; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.notice.info { border-color: rgba(79, 140, 255, .35); background: rgba(79, 140, 255, .08); color: #cfe0ff; }
.steps { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.steps li { margin: 4px 0; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 12px; gap: 12px; scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand { padding: 0; }
  .brand-text { display: none; }
  #nav { flex-direction: row; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 8px 10px; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .side-status { display: none; }
  .main { padding: 16px; }
  .actions { margin-left: 0; }
}
