:root {
  --bg: #0a0f1a;
  --bg2: #0d1420;
  --panel: #111a2b;
  --panel2: #16202f;
  --border: #1f2b3d;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --green: #10b981;
  --green-dark: #059669;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --radius: 14px;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--green); text-decoration: none; }

/* icons */
.ic { width: 20px; height: 20px; display: inline-block; flex: 0 0 auto; }
.ic svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- login ---------------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(120% 120% at 50% 0%, #0f1f2e 0%, var(--bg) 60%); }
.login__card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 34px 30px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.login__sub { color: var(--muted); margin: 6px 0 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark { width: 42px; height: 42px; border-radius: 11px; background: var(--green); color: #04231a; font-weight: 800; font-size: 22px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.brand__text { font-size: 18px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.brand__text b { color: var(--green); }
label { display: block; color: var(--muted); font-size: 12.5px; margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=search] {
  width: 100%; background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 11px 13px; font-size: 14px; outline: none;
}
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); border-radius: 10px; padding: 10px 16px; font-size: 14px; cursor: pointer; font-family: inherit; transition: background .15s, transform .05s; }
.btn:hover { background: #1c2940; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--green); border-color: var(--green); color: #04231a; font-weight: 700; }
.btn--primary:hover { background: var(--green-dark); }
.btn--danger { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.4); color: #fca5a5; }
.btn--danger:hover { background: rgba(239,68,68,.22); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn--block { width: 100%; margin-top: 18px; }
.form-error { color: #fca5a5; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-size: 13px; }

/* ---------------- layout ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex: 0 0 auto; position: sticky; top: 0; height: 100vh; }
.brand--sidebar { padding: 20px 20px 14px; border-bottom: 1px solid var(--border); }
.nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav__item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 20px; background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; text-align: left; font-family: inherit; border-left: 3px solid transparent; }
.nav__item:hover { color: var(--text); background: rgba(255,255,255,.03); }
.nav__item.is-active { color: var(--green); background: rgba(16,185,129,.08); border-left-color: var(--green); }
.nav__ic { width: 20px; height: 20px; }
.nav__ic svg { width: 100%; height: 100%; }
.sidebar__foot { border-top: 1px solid var(--border); padding: 8px 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 22px; border-bottom: 1px solid var(--border); background: var(--bg2); position: sticky; top: 0; z-index: 20; }
.topbar__menu { display: none; background: none; border: none; color: var(--text); cursor: pointer; }
.topbar__menu .ic { width: 22px; height: 22px; }
.topbar__stats { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.chip b { color: var(--text); font-weight: 600; }
.chip--online { color: var(--green); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--green { background: var(--green); box-shadow: 0 0 0 0 rgba(16,185,129,.5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.5); } 70% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); } }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar__user { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.topbar__user::before { content: ""; width: 26px; height: 26px; border-radius: 50%; background: var(--green); display: inline-block; }

.content { padding: 24px; max-width: 1200px; width: 100%; }

.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 20px; }

/* ---------------- cards ---------------- */
.grid { display: grid; gap: 16px; }
.grid--stats { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card__label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.card__value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.card__sub { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.meter { height: 8px; background: var(--bg2); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.meter > span { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .4s ease; }
.meter > span.warn { background: var(--amber); }
.meter > span.danger { background: var(--red); }

.section { margin-top: 26px; }
.section h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; color: var(--text); }

/* ---------------- table ---------------- */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--bg2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill--green { background: rgba(16,185,129,.14); color: var(--green); }
.pill--red { background: rgba(239,68,68,.14); color: #fca5a5; }
.pill--amber { background: rgba(245,158,11,.14); color: #fbbf24; }
.pill--gray { background: rgba(148,163,184,.14); color: var(--muted); }

/* ---------------- files ---------------- */
.breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13.5px; }
.breadcrumb a { color: var(--green); cursor: pointer; }
.breadcrumb .sep { color: var(--muted); }
.file { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.file:hover { background: rgba(255,255,255,.03); }
.file:last-child { border-bottom: none; }
.file__ic { width: 22px; height: 22px; color: var(--muted); flex: 0 0 auto; }
.file__ic.folder { color: var(--amber); }
.file__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file__meta { color: var(--muted); font-size: 12px; display: flex; gap: 18px; flex: 0 0 auto; }
.filebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* editor / preview */
.preview { background: #0b1120; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; overflow: auto; max-height: 70vh; white-space: pre-wrap; word-break: break-word; }
.preview__line { color: var(--muted); }

/* ---------------- logs ---------------- */
.logbox { background: #0b1120; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; overflow: auto; max-height: 70vh; white-space: pre-wrap; word-break: break-word; color: #cbd5e1; }

/* ---------------- modal / toast ---------------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal__box { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 24px; max-width: 420px; width: 100%; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal__title { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.modal__msg { color: var(--muted); margin-bottom: 20px; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast { position: fixed; bottom: 22px; right: 22px; background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 12px; padding: 13px 18px; z-index: 200; box-shadow: 0 20px 50px rgba(0,0,0,.5); max-width: 360px; }
.toast.toast--err { border-left-color: var(--red); }

/* ---------------- responsive ---------------- */
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .sidebar.open { transform: translateX(0); }
  .topbar__menu { display: inline-flex; }
  .content { padding: 16px; }
  .file__meta { display: none; }
  .topbar__stats .chip { display: none; }
  .topbar__stats .chip--online { display: inline-flex; }
}
