:root {
  color-scheme: dark;
  --bg: #101417;
  --panel: #171d21;
  --panel-2: #20282d;
  --line: #334047;
  --text: #edf2f4;
  --muted: #aab6bc;
  --accent: #e36d3f;
  --accent-2: #68b98f;
  --warn: #d9aa4b;
  --danger: #d76565;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

input:disabled,
select:disabled {
  opacity: .72;
  cursor: not-allowed;
}

.locked-input {
  color: #f1d08b;
  border-color: rgba(217, 170, 75, .5);
  background: rgba(217, 170, 75, .08);
}

button {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

button.secondary {
  background: #263238;
  border-color: #425058;
}

button.ghost,
.icon-btn {
  background: transparent;
  border-color: #425058;
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(227, 109, 63, .14), transparent 42%),
    linear-gradient(300deg, rgba(104, 185, 143, .12), transparent 45%),
    var(--bg);
}

.pin-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 20px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .34);
}

.pin-box h1,
.topbar h1,
.workspace-head h2,
.logs h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #43515a;
  background: #11171a;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
}

.error {
  min-height: 20px;
  margin: 0;
  color: #ff9c9c;
}

.app {
  min-height: 100vh;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.topbar,
.command-strip,
.summary,
.editor-shell,
.backup-shell,
.console-shell,
.logs {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.active-view {
  border-color: rgba(227, 109, 63, .85) !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px;
}

.status-row,
.command-strip,
.save-tools,
.logs-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  background: #303a40;
  color: var(--muted);
  font-weight: 700;
}

.chip.ok {
  background: rgba(104, 185, 143, .18);
  color: #a7e7c4;
}

.chip.warn {
  background: rgba(217, 170, 75, .18);
  color: #f1d08b;
}

.chip.bad {
  background: rgba(215, 101, 101, .18);
  color: #f1aaaa;
}

.command-strip {
  padding: 12px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
}

.summary div {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 4px;
}

.summary div:last-child {
  border-right: 0;
}

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

.summary strong {
  overflow-wrap: anywhere;
}

.editor-shell {
  min-height: 520px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #13191d;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.categories {
  display: grid;
  gap: 4px;
}

.category-btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.category-btn.active {
  background: #253038;
  color: #fff;
  border-color: #40505a;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

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

.dirty {
  color: var(--warn);
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid #28343a;
  padding: 10px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #253038;
  text-align: left;
  z-index: 1;
}

th:nth-child(1) { width: 24%; }
th:nth-child(2) { width: 20%; }
th:nth-child(3) { width: 36%; }
th:nth-child(4) { width: 20%; }

td {
  color: #dce4e8;
}

td small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

tr.changed {
  background: rgba(227, 109, 63, .08);
}

.value-input {
  min-width: 0;
}

.logs {
  min-height: 220px;
  overflow: hidden;
}

.backup-shell {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.console-shell {
  overflow: hidden;
}

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

.console-tools,
.quick-commands,
.console-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.quick-commands {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.quick-command {
  background: #263238;
  border-color: #425058;
}

.console-form {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.console-form input {
  flex: 1;
  min-width: min(440px, 100%);
}

.console-output {
  max-height: 520px;
}

.backup-head,
.backup-create {
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.backup-create {
  align-items: end;
  justify-content: start;
  flex-wrap: wrap;
}

.backup-create label {
  min-width: min(360px, 100%);
  flex: 1;
}

.backup-meta {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
}

.backup-meta span,
.backup-card span {
  color: var(--muted);
  font-size: 12px;
}

.backup-meta strong {
  overflow-wrap: anywhere;
}

.backup-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.backup-card {
  border: 1px solid #303c43;
  background: #141a1e;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.backup-card h3 {
  margin: 0;
  font-size: 18px;
}

.backup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.backup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.danger {
  background: var(--danger);
}

pre {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  background: #0d1113;
  color: #d6dee2;
  font: 12px Consolas, monospace;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #263238;
  border: 1px solid #485760;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}

@media (max-width: 900px) {
  .topbar,
  .workspace-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .summary div {
    border-bottom: 1px solid var(--line);
  }

  .editor-shell {
    grid-template-columns: 1fr;
  }

  .backup-head,
  .backup-create,
  .console-head,
  .console-form {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  th:nth-child(3),
  td:nth-child(3),
  th:nth-child(4),
  td:nth-child(4) {
    display: none;
  }

  th:nth-child(1),
  th:nth-child(2) {
    width: 50%;
  }
}
