:root {
  color-scheme: dark;
  --bg: #0a0d0c;
  --surface: #111614;
  --surface-raised: #171d1a;
  --surface-soft: #1c2420;
  --border: #29332e;
  --border-strong: #3a4941;
  --text: #edf5f0;
  --muted: #8fa097;
  --accent: #67e08d;
  --accent-strong: #34c76a;
  --accent-ink: #07110a;
  --warning: #f4c95d;
  --danger: #ff7272;
  --info: #72b7ff;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(103, 224, 141, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 224, 141, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  font-family: var(--sans);
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button,
.file-name,
.breadcrumbs button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.muted {
  color: var(--muted);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 1.5rem;
  place-items: center;
}

.login-card {
  width: min(100%, 430px);
  padding: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(17, 22, 20, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--accent);
  border-radius: 12px;
  color: var(--accent);
  background: rgba(103, 224, 141, 0.08);
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  place-items: center;
}

.brand-mark.compact {
  width: 42px;
  height: 42px;
  margin: 0;
  border-radius: 9px;
  font-size: 0.85rem;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  letter-spacing: -0.04em;
}

.login-card > .muted {
  margin: 0.75rem 0 2rem;
}

.login-card label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
}

input,
textarea {
  color: var(--text);
  border: 1px solid var(--border-strong);
  background: var(--bg);
}

.login-card input {
  width: 100%;
  height: 48px;
  padding: 0 0.9rem;
  border-radius: 8px;
  font-family: var(--mono);
}

.form-error {
  min-height: 1.4em;
  margin: 0.5rem 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.security-note {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.primary,
.secondary,
.ghost {
  min-height: 38px;
  padding: 0.55rem 0.9rem;
  border-radius: 7px;
  font-weight: 750;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.primary {
  color: var(--accent-ink);
  background: var(--accent);
}

.primary:hover {
  background: #83eca3;
}

.secondary {
  color: var(--text);
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
}

.secondary:hover,
.ghost:hover {
  color: var(--text);
  border-color: #51645a;
  background: #212b26;
}

.ghost {
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
}

.small {
  min-height: 32px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.wide {
  width: 100%;
}

button:active {
  transform: translateY(1px);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 13, 12, 0.92);
  backdrop-filter: blur(18px);
}

.brand,
.topbar-actions,
.file-actions,
.dialog-actions,
.dialog-actions > div {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.file-actions,
.dialog-actions > div {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand .eyebrow {
  margin: 0;
  font-size: 0.62rem;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 30px;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.connection-pill.online {
  color: var(--accent);
  border-color: rgba(103, 224, 141, 0.32);
}

.connection-pill.offline {
  color: var(--danger);
  border-color: rgba(255, 114, 114, 0.3);
}

.connection-pill.connecting {
  color: var(--warning);
  border-color: rgba(244, 201, 93, 0.3);
}

main {
  width: min(1500px, 92vw);
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.hero-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.hero-row h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  letter-spacing: -0.045em;
}

.hero-row .muted {
  margin: 0.35rem 0 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.metric-card {
  min-height: 128px;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  letter-spacing: -0.06em;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.72rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(480px, 0.9fr);
  gap: 0.75rem;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h3,
.dialog-header h3 {
  margin: 0;
  font-size: 1rem;
}

.console-output {
  height: 520px;
  overflow: auto;
  padding: 1rem;
  color: #cbd8d0;
  background: #070a09;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.65;
  scrollbar-color: var(--border-strong) transparent;
}

.console-output p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.console-placeholder {
  color: #66736c;
}

.log-line {
  display: grid;
  grid-template-columns: 82px 58px 1fr;
  gap: 0.6rem;
}

.log-time {
  color: #59665f;
}

.log-level {
  color: var(--info);
  font-weight: 700;
}

.log-level.warning {
  color: var(--warning);
}

.log-level.severe {
  color: var(--danger);
}

.command-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  min-height: 66px;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-raised);
}

.command-form > span {
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 800;
}

.command-form input {
  min-width: 0;
  height: 40px;
  padding: 0 0.75rem;
  border: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.file-table-wrap {
  position: relative;
  height: 474px;
  overflow: auto;
  background: #0d110f;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0.5rem 1rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
  white-space: nowrap;
}

.breadcrumbs button {
  padding: 0.2rem 0.35rem;
  color: var(--muted);
  border-radius: 4px;
  background: transparent;
  font-family: var(--mono);
  font-size: 0.73rem;
}

.breadcrumbs button:hover {
  color: var(--accent);
  background: var(--surface-soft);
}

.breadcrumb-separator {
  color: #4d5a53;
  font-family: var(--mono);
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.76rem;
}

.file-table th {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 0.65rem 0.8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: #111614;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
}

.file-table th:first-child {
  width: 34%;
}

.file-table th:nth-child(2) {
  width: 14%;
}

.file-table th:nth-child(3) {
  width: 24%;
}

.file-table th:last-child {
  width: 28%;
  text-align: right;
}

.file-table td {
  height: 48px;
  padding: 0.45rem 0.8rem;
  overflow: hidden;
  color: var(--muted);
  border-bottom: 1px solid #1c231f;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-table tbody tr:hover {
  background: rgba(103, 224, 141, 0.035);
}

.file-table td:last-child {
  text-align: right;
}

.file-name {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 0.55rem;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background: transparent;
  font-family: var(--mono);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-icon {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.65rem;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
}

.row-actions button {
  min-height: 28px;
  padding: 0.2rem 0.4rem;
  color: var(--muted);
  border-radius: 4px;
  background: transparent;
  font-size: 0.68rem;
}

.row-actions button:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.row-actions .danger,
.dialog-actions .danger {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.38);
  background: rgba(255, 107, 107, 0.08);
}

.row-actions .danger:hover,
.dialog-actions .danger:hover {
  color: #ff9a9a;
  border-color: rgba(255, 107, 107, 0.65);
  background: rgba(255, 107, 107, 0.16);
}

.empty-state {
  margin: 4rem 1rem;
  color: var(--muted);
  text-align: center;
}

.panel-footer {
  display: flex;
  justify-content: space-between;
  min-height: 46px;
  padding: 0.75rem 1rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
}

.editor-dialog {
  width: min(1000px, 92vw);
  max-width: none;
  height: min(760px, 88vh);
  padding: 0;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.6);
}

.editor-dialog::backdrop {
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(3px);
}

.dialog-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.path-label {
  max-width: 70vw;
  margin: 0.2rem 0 0;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#editor-content {
  width: 100%;
  height: 100%;
  padding: 1.2rem;
  resize: none;
  border: 0;
  border-radius: 0;
  background: #070a09;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  tab-size: 2;
}

.dialog-actions {
  justify-content: space-between;
  min-height: 66px;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid var(--border);
}

.dialog-actions .muted {
  font-size: 0.72rem;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 1.25rem;
  bottom: 1.25rem;
  max-width: min(420px, calc(100vw - 2.5rem));
  padding: 0.85rem 1rem;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  background: #19211d;
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.5);
  font-size: 0.8rem;
}

.toast.error {
  border-left-color: var(--danger);
}

@media (max-width: 1100px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .file-table-wrap {
    height: 500px;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 1rem;
  }

  .brand > div:last-child {
    display: none;
  }

  main {
    width: calc(100% - 1.5rem);
    padding-top: 1.5rem;
  }

  .hero-row {
    align-items: start;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card {
    min-height: 108px;
  }

  .file-table th:nth-child(2),
  .file-table td:nth-child(2),
  .file-table th:nth-child(3),
  .file-table td:nth-child(3) {
    display: none;
  }

  .file-table th:first-child {
    width: 62%;
  }

  .file-table th:last-child {
    width: 38%;
  }

  .files-heading {
    align-items: start;
    gap: 1rem;
  }

  .file-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .console-output {
    height: 430px;
  }

  .log-line {
    grid-template-columns: 66px 48px 1fr;
    gap: 0.4rem;
  }

  .dialog-actions {
    align-items: flex-start;
    gap: 0.7rem;
  }

  .dialog-actions > span {
    display: none;
  }
}

@media (max-width: 460px) {
  .login-card {
    padding: 1.5rem;
  }

  .topbar-actions {
    gap: 0.25rem;
  }

  .connection-pill {
    max-width: 145px;
  }

  #connection-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .metrics {
    gap: 0.5rem;
  }

  .metric-card {
    padding: 0.9rem;
  }

  .hero-row .secondary {
    display: none;
  }

  .command-form {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .command-form .primary {
    grid-column: 1 / -1;
  }

  .panel-footer span:first-child {
    max-width: 65%;
  }
}
