:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: #0b1017;
  --panel-2: #111824;
  --panel-3: #081019;
  --border: #1f2b3a;
  --border-soft: rgba(31, 43, 58, 0.55);
  --text: #d6deeb;
  --muted: #7b8fa8;
  --accent: #7ee787;
  --warn: #ff7b72;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Consolas, "Cascadia Mono", monospace;
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none;
}

.login-screen {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at top, #101722 0%, #05070a 72%);
}

.login-card {
  width: min(360px, 100%);
  padding: 20px;
  border: 1px solid var(--border);
  background: rgba(11, 16, 23, 0.96);
  display: grid;
  gap: 12px;
}

.login-brand {
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.login-card input,
.login-card button,
.actions button,
.mobile-tab,
.terminal-actions button {
  border: 1px solid var(--border);
  background: #091019;
  color: var(--text);
  padding: 10px 12px;
}

.login-card button,
.actions button,
.mobile-tab,
.terminal-actions button {
  cursor: pointer;
}

.login-status,
.statusbar,
.meta,
.item-meta {
  color: var(--muted);
  font-size: 12px;
}

.shell {
  height: 100%;
  display: grid;
  grid-template-columns: 220px 300px minmax(0, 1fr);
  background: var(--bg);
}

.mobile-tabs {
  display: none;
}

.nodes,
.sessions {
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.pane-title,
.actions,
.terminal-header,
.statusbar {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.pane-title {
  text-transform: lowercase;
  letter-spacing: 0.05em;
}

.actions {
  display: flex;
  gap: 8px;
  background: var(--panel);
}

.actions button {
  flex: 1;
}

.list {
  height: calc(100% - 44px);
  overflow: auto;
}

.sessions .list {
  height: calc(100% - 49px);
}

.item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}

.item.active {
  background: rgba(126, 231, 135, 0.12);
  outline: 1px solid rgba(126, 231, 135, 0.6);
  outline-offset: -1px;
}

.item-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.item-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-status {
  color: var(--accent);
}

.item-status.offline {
  color: var(--warn);
}

.terminal-pane {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #070b10;
}

.terminal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  background: var(--panel-3);
}

.title {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.terminal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.terminal-actions button {
  min-width: 0;
}

.terminal-actions .danger {
  border-color: rgba(255, 123, 114, 0.45);
  color: var(--warn);
}

.terminal-host {
  min-height: 0;
  padding: 6px;
}

.terminal-stage,
.xterm {
  width: 100%;
  height: 100%;
}

.statusbar {
  background: var(--panel-3);
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--border);
    background: var(--panel);
  }

  .mobile-tab {
    border-width: 0 1px 0 0;
    padding: 12px 10px;
    text-transform: lowercase;
  }

  .mobile-tab:last-child {
    border-right: 0;
  }

  .mobile-tab.active {
    color: var(--accent);
    background: rgba(126, 231, 135, 0.08);
  }

  .nodes,
  .sessions,
  .terminal-pane {
    display: none;
    height: calc(100vh - 49px);
    border-right: 0;
  }

  .nodes.active-pane,
  .sessions.active-pane,
  .terminal-pane.active-pane {
    display: grid;
  }

  .nodes.active-pane,
  .sessions.active-pane {
    grid-template-rows: auto 1fr;
  }

  .terminal-pane.active-pane {
    grid-template-rows: auto 1fr auto;
  }

  .terminal-header {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .actions {
    position: sticky;
    top: 0;
    z-index: 2;
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 16px;
  }

  .pane-title,
  .actions,
  .terminal-header,
  .statusbar {
    padding: 10px;
  }

  .terminal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .terminal-host {
    padding: 4px;
  }

  .xterm {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}
