:root {
  color-scheme: light;
  --page: #f4f6f1;
  --panel: #ffffff;
  --ink: #182024;
  --muted: #65717a;
  --line: #d8ded5;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --terminal: #0c0f14;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(100%, 380px);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(24, 32, 36, 0.08);
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand,
.brand-row,
.section-heading {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  min-height: 32px;
  font-size: 18px;
  font-weight: 700;
}

.brand-row,
.section-heading {
  justify-content: space-between;
  gap: 12px;
}

.section-heading {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.brand-mark {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: 6px 6px 0 #f59e0b;
}

.ghost-button,
.toolbar-button,
.host-row-actions button,
.modal-actions button[type="button"],
.icon-button {
  background: #f6f7f4;
  border-color: var(--line);
  color: var(--muted);
}

#loginButton,
#addHostButton,
.modal-actions button[type="submit"] {
  background: var(--accent);
  color: #ffffff;
}

#loginButton:hover,
#addHostButton:hover,
.modal-actions button[type="submit"]:hover {
  background: var(--accent-strong);
}

.host-list {
  display: grid;
  gap: 10px;
}

.host-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.host-details {
  display: grid;
  gap: 4px;
  width: 100%;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.host-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.empty-hosts,
.empty-terminal {
  display: grid;
  place-items: center;
  min-height: 140px;
  color: #87919c;
  text-align: center;
}

.terminal-panel {
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background: var(--terminal);
}

.terminal-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 0 10px;
  color: #d6dde4;
  border-bottom: 1px solid #1d2630;
  font-size: 13px;
}

.terminal-tabs {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
}

.terminal-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  max-width: 220px;
  height: 32px;
  padding: 0 8px;
  background: #151b22;
  border-color: #27313b;
  color: #cbd5df;
}

.terminal-tab.active {
  background: #22312f;
  border-color: #2f7d73;
  color: #ffffff;
}

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

.tab-close {
  color: #9ca8b4;
  font-weight: 800;
}

.terminal-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.status-dot,
.tab-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #87919c;
}

.status-dot[data-state="pending"],
.tab-dot[data-state="pending"] {
  background: #f59e0b;
}

.status-dot[data-state="online"],
.tab-dot[data-state="online"] {
  background: #22c55e;
}

.status-dot[data-state="offline"],
.tab-dot[data-state="offline"] {
  background: #87919c;
}

.terminal-stack {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.terminal-pane {
  display: none;
  width: 100%;
  height: 100%;
  padding: 10px;
}

.terminal-pane.active {
  display: block;
}

.terminal-target {
  width: 100%;
  height: 100%;
}

.xterm {
  height: 100%;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 150px;
  padding: 10px 11px;
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", "Liberation Mono", monospace;
  font-size: 13px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.form-row {
  display: grid;
  grid-template-columns: minmax(84px, 0.65fr) minmax(0, 1fr);
  gap: 10px;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.modal {
  width: min(92vw, 520px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(24, 32, 36, 0.24);
}

.modal::backdrop {
  background: rgba(12, 15, 20, 0.48);
}

.modal-form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
}

.connect-summary {
  min-height: 34px;
  padding: 8px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f7f4;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 4px;
}

@media (max-width: 860px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(460px, 1fr);
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .sidebar,
  .login-panel,
  .modal-form {
    padding: 16px;
  }

  .form-row,
  .modal-actions,
  .host-row-actions {
    grid-template-columns: 1fr;
  }

  .terminal-toolbar {
    grid-template-columns: 1fr;
    grid-template-rows: 36px 36px;
    height: 76px;
  }

  .terminal-panel {
    grid-template-rows: 76px minmax(0, 1fr);
  }
}
