:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d9e0ea;
  --line-strong: #b8c4d3;
  --text: #172033;
  --muted: #65748b;
  --blue: #1264f6;
  --blue-soft: #e8f0ff;
  --green: #18a058;
  --green-soft: #e8f8ef;
  --red: #d92d20;
  --red-soft: #fff0ed;
  --amber: #b7791f;
  --amber-soft: #fff7df;
  --shadow: 0 12px 30px rgba(19, 32, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(140deg, #f9fbff 0%, #eef4ff 48%, #f7fbf8 100%);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, #09c6c0, #1264f6);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.login-card h1,
.panel-title h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.login-card p,
.panel-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form {
  margin-top: 24px;
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: #354155;
  font-size: 13px;
  font-weight: 700;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.input:focus,
.textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(18, 100, 246, 0.12);
}

.textarea {
  min-height: 360px;
  resize: vertical;
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 7px;
  padding: 8px 12px;
  color: var(--text);
  background: #edf1f7;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn:hover {
  background: #e4eaf3;
}

.btn.primary {
  color: #fff;
  background: var(--blue);
}

.btn.primary:hover {
  background: #0d55d9;
}

.btn.danger {
  color: var(--red);
  background: var(--red-soft);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
}

.btn.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.error {
  padding: 10px 12px;
  border: 1px solid #ffd2ca;
  color: var(--red);
  background: var(--red-soft);
  border-radius: 7px;
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: #fff;
}

.side-head {
  padding: 20px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.side-search {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.side-nav {
  display: grid;
  gap: 7px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.nav-btn {
  width: 100%;
  min-height: 34px;
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.nav-btn:hover,
.nav-btn.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.container-list {
  overflow: auto;
  padding: 8px;
}

.container-item {
  display: grid;
  gap: 5px;
  width: 100%;
  text-align: left;
  padding: 10px;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
}

.container-item:hover,
.container-item.active {
  background: var(--blue-soft);
}

.container-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.container-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

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

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: 0 0 auto;
}

.status-dot.running {
  background: var(--green);
}

.status-dot.exited {
  background: var(--red);
}

.main {
  min-width: 0;
  padding: 18px 20px 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.metric small {
  display: block;
  min-height: 18px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.bar {
  display: block;
  height: 7px;
  overflow: hidden;
  margin-top: 9px;
  border-radius: 999px;
  background: #edf1f7;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #09c6c0, #1264f6);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(420px, 1.35fr);
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(19, 32, 52, 0.04);
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 14px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.kv {
  display: grid;
  gap: 8px;
}

.kv-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid #edf0f5;
}

.kv-row:last-child {
  border-bottom: 0;
}

.kv-row span {
  color: var(--muted);
  font-size: 13px;
}

.kv-row strong,
.mono {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab-btn {
  border-radius: 7px;
  padding: 7px 10px;
  color: var(--muted);
  background: transparent;
}

.tab-btn.active {
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 800;
}

.log-box {
  min-height: 540px;
  max-height: 68vh;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  color: #d8e2f0;
  background: #0e1726;
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.file-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.file-toolbar .input {
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.file-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.file-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 130px 80px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  background: #fff;
  border-bottom: 1px solid #edf0f5;
}

.file-row:hover {
  background: var(--surface-soft);
}

.file-row:last-child {
  border-bottom: 0;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.file-subtle {
  color: var(--muted);
  font-size: 12px;
}

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 12px 0 8px;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
}

.small-empty {
  min-height: 110px;
  padding: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
  gap: 14px;
  align-items: start;
}

.compact-form {
  margin-top: 0;
}

.small-textarea {
  min-height: 210px;
}

.notice {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.audit-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.audit-table th,
.audit-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.audit-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 800;
}

.audit-table tr:last-child td {
  border-bottom: 0;
}

.table-empty {
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #172033;
  box-shadow: var(--shadow);
}

.toast.error {
  color: #fff;
  background: var(--red);
  border: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  background: #eef2f7;
  color: var(--muted);
}

.badge.running {
  color: var(--green);
  background: var(--green-soft);
}

.badge.exited {
  color: var(--red);
  background: var(--red-soft);
}

.badge.paused {
  color: var(--amber);
  background: var(--amber-soft);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: 0;
    max-height: 44vh;
  }

  .main {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .file-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
