:root {
  --bg0: #0c1210;
  --bg1: #121a17;
  --bg2: #1a2420;
  --line: #2a3a33;
  --text: #e6f0ea;
  --muted: #8aa397;
  --accent: #3dd68c;
  --accent-dim: #1f8f5a;
  --danger: #ff6b6b;
  --warn: #e6c07b;
  --ok: #3dd68c;
  --font-ui: "Syne", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1b3a2c 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1a2a40 0%, transparent 50%),
    linear-gradient(160deg, #0a100e, #101816 40%, #0c1210);
  min-height: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); min-height: 1.2em; }
code {
  font-family: var(--font-mono);
  background: var(--bg2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.brand {
  font-family: var(--font-ui);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent);
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-panel {
  width: min(420px, 100%);
  padding: 2rem;
  background: linear-gradient(180deg, rgba(26,36,32,0.95), rgba(12,18,16,0.98));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}
.login-panel h1 {
  margin: 0.4rem 0 0.35rem;
  font-size: 2rem;
  letter-spacing: -0.04em;
}
#login-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
#login-form input, .filename, .install-form input, .shell-form input, #pkg-input, #shell-input {
  width: 100%;
  background: var(--bg0);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  outline: none;
}
#login-form input:focus, .filename:focus, .install-form input:focus, .shell-form input:focus {
  border-color: var(--accent-dim);
}

.btn {
  font-family: var(--font-ui);
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--accent-dim); transform: translateY(-1px); }
.btn.primary, #login-form button {
  background: linear-gradient(180deg, #45e098, #2bb973);
  border-color: transparent;
  color: #04140c;
}
.btn.success { background: #1e3d2e; border-color: #2f6b4d; color: var(--ok); }
.btn.danger { background: #3a1c1c; border-color: #6b2f2f; color: var(--danger); }
.btn.danger.outline { background: transparent; }
.btn.ghost { background: transparent; width: 100%; }
.btn.small { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

/* App layout */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  animation: fadeIn 0.45s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(8,12,10,0.72);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1rem;
}
.sidebar-top { display: grid; gap: 0.85rem; }
.brand-block { display: grid; gap: 0.15rem; }
.brand-block .brand { font-size: 1.55rem; }
.domain { color: var(--muted); font-size: 0.78rem; font-family: var(--font-mono); }
.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
  display: grid;
  align-content: start;
  gap: 0.35rem;
}
.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 0.86rem;
}
.file-list li:hover { background: var(--bg2); }
.file-list li.active {
  background: #163226;
  border-color: #2f6b4d;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(61,214,140,0.7); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.main {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-width: 0;
  min-height: 100vh;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(12,18,16,0.55);
}
.file-meta { display: flex; align-items: center; gap: 0.65rem; min-width: 0; flex: 1; }
.filename { max-width: 320px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge.on {
  color: var(--ok);
  border-color: #2f6b4d;
  background: #143024;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid var(--line);
}
.tab {
  font-family: var(--font-ui);
  font-weight: 700;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.7rem 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-panel {
  display: none;
  min-height: 0;
  height: calc(100vh - 120px);
  padding: 0.75rem 1rem 1rem;
}
.tab-panel.active { display: flex; flex-direction: column; gap: 0.65rem; }

#editor {
  flex: 1;
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0a0f0d;
  color: #d7efe3;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 1rem;
  outline: none;
  tab-size: 4;
}

.panel-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
}
.output {
  flex: 1;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #070b09;
  color: #b8dcc9;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.45;
  padding: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.output.small { max-height: 180px; flex: 0 0 auto; }

.terminal {
  flex: 1;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.4rem;
  background: #050807;
  overflow: hidden;
}
.shell-fallback { display: grid; gap: 0.5rem; }
.shell-form, .install-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  width: 100%;
}
.packages-bar { align-items: stretch; }
.table-wrap {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(8,12,10,0.7);
}
table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 0.88rem; }
th, td { text-align: left; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: #101816; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { max-height: 34vh; border-right: none; border-bottom: 1px solid var(--line); }
  .tab-panel { height: calc(66vh - 40px); }
  .filename { max-width: 100%; }
}
