@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;700&display=swap');

:root {
  --bg: #f2efe8;
  --panel: #fbf8f2;
  --panel-strong: #14211a;
  --panel-muted: #efe7d9;
  --ink: #172019;
  --ink-soft: #576259;
  --line: rgba(23, 32, 25, 0.12);
  --accent: #0e8f5b;
  --accent-soft: rgba(14, 143, 91, 0.12);
  --danger: #b64f3a;
  --shadow: 0 22px 48px rgba(28, 35, 29, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: 'Space Grotesk', 'Trebuchet MS', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(14, 143, 91, 0.12), transparent 35%),
    linear-gradient(180deg, #f6f3ed 0%, var(--bg) 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  padding: 28px 22px;
  background: rgba(20, 33, 26, 0.96);
  color: #eef4ee;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand h1,
.workspace-header h2,
.panel-header h3 {
  margin: 0;
  line-height: 1;
}

.brand h1 {
  font-size: clamp(2rem, 5vw, 2.8rem);
  letter-spacing: -0.06em;
  margin-bottom: 12px;
}

.workspace-header h2,
.panel-header h3 {
  font-size: 1.5rem;
  letter-spacing: -0.05em;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.72rem;
  opacity: 0.72;
}

.muted {
  margin: 0;
  color: rgba(238, 244, 238, 0.74);
  line-height: 1.5;
}

.sidebar-section {
  margin-top: 28px;
}

.section-title-row,
.workspace-header,
.panel-header,
.database-item-top,
.credential-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title-row h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.04em;
}

.database-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.database-item {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  border-radius: 18px;
  padding: 16px;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.database-item:hover,
.database-item.is-active {
  transform: translateY(-1px);
  border-color: rgba(14, 143, 91, 0.52);
  background: rgba(14, 143, 91, 0.14);
}

.database-name {
  font-size: 1rem;
  letter-spacing: -0.04em;
}

.database-status,
.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.database-meta {
  display: block;
  margin-top: 10px;
  color: rgba(238, 244, 238, 0.7);
  font-size: 0.88rem;
}

.workspace {
  padding: 28px;
}

.status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pill {
  background: var(--panel);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.status-pill.ok {
  color: var(--accent);
  border-color: rgba(14, 143, 91, 0.24);
  background: var(--accent-soft);
}

.status-pill.error {
  color: var(--danger);
  border-color: rgba(182, 79, 58, 0.24);
  background: rgba(182, 79, 58, 0.08);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(300px, 440px) minmax(0, 1fr);
  gap: 22px;
  margin-top: 22px;
}

.panel {
  border-radius: 28px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.form-panel {
  align-self: start;
}

.flash-message {
  margin-top: 18px;
  border-radius: 18px;
  padding: 12px 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
}

.flash-message.success {
  color: var(--accent);
  border-color: rgba(14, 143, 91, 0.24);
  background: var(--accent-soft);
}

.flash-message.error {
  color: var(--danger);
  border-color: rgba(182, 79, 58, 0.24);
  background: rgba(182, 79, 58, 0.08);
}

.flash-message.warning {
  color: #9a5b14;
  border-color: rgba(154, 91, 20, 0.24);
  background: rgba(209, 154, 66, 0.12);
}

.create-form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.create-form label {
  display: grid;
  gap: 8px;
  font-size: 0.94rem;
  color: var(--ink-soft);
}

.create-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.create-form input:focus {
  border-color: rgba(14, 143, 91, 0.48);
  box-shadow: 0 0 0 4px rgba(14, 143, 91, 0.12);
}

.double-field {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toggle-row {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 12px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.primary-button,
.ghost-button,
.copy-button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease;
}

.primary-button {
  background: var(--panel-strong);
  color: #fff;
}

.primary-button:hover,
.ghost-button:hover,
.copy-button:hover {
  transform: translateY(-1px);
}

.ghost-button,
.copy-button {
  background: var(--panel-muted);
  color: var(--ink);
}

.details-empty,
.credentials-stack {
  margin-top: 18px;
}

.details-empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: 24px;
  padding: 24px;
}

.details-card {
  display: grid;
  gap: 18px;
}

.details-header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.details-header h4 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.05em;
}

.details-header p {
  margin: 10px 0 0;
  color: var(--ink-soft);
}

.credentials-stack {
  display: grid;
  gap: 18px;
}

.credential-group {
  border-radius: 22px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
}

.credential-group h5 {
  margin: 0 0 12px;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}

.credential-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.credential-group-header h5 {
  margin: 0;
}

.n8n-sync-button {
  padding: 8px 12px;
}

.credential-row {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.credential-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.credential-label {
  color: var(--ink-soft);
}

.credential-value {
  max-width: 60%;
  text-align: right;
  font-family: 'IBM Plex Mono', monospace;
  word-break: break-all;
}

.hidden {
  display: none !important;
}

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

  .workspace {
    padding-top: 16px;
  }

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

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .double-field {
    grid-template-columns: 1fr;
  }

  .workspace-header,
  .panel-header,
  .section-title-row,
  .credential-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .credential-value {
    max-width: 100%;
    text-align: left;
  }
}
