:root {
  --ink: #13201b;
  --muted: #5b6a63;
  --line: #d7ded8;
  --paper: #eef3ef;
  --panel: #ffffff;
  --sidebar: #10241c;
  --sidebar-text: #d7e6dd;
  --accent: #1a9b6f;
  --accent-2: #d9773a;
  --ok: #1a7f4b;
  --bad: #b42318;
  --warn: #9a6700;
  --shadow: 0 16px 40px rgba(16, 36, 28, 0.08);
  --radius: 14px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
}
.hidden { display: none !important; }
.brand { font-family: var(--display); font-weight: 700; letter-spacing: -0.03em; margin: 0; }
.brand span { color: var(--accent); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(900px 500px at 10% 0%, rgba(26,155,111,.16), transparent 55%),
    radial-gradient(700px 400px at 100% 10%, rgba(217,119,58,.12), transparent 50%),
    var(--paper);
}
.login-card {
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.login-card .sub { margin: 8px 0 22px; color: var(--muted); }
.login-card label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: 7px; }
.err { color: var(--bad); min-height: 1.2em; font-size: .9rem; }

input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 11px;
  padding: 11px 12px; font: inherit; background: #fbfcfb; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,155,111,.14);
}
textarea { min-height: 100px; font-family: var(--mono); font-size: .8rem; }

.btn {
  appearance: none; border: 0; border-radius: 11px; background: var(--ink);
  color: #fff; font: inherit; font-weight: 600; padding: 10px 14px; cursor: pointer;
}
.btn.primary { background: var(--accent); }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: rgba(26,155,111,.12); color: var(--accent); border: 0; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid rgba(180,35,24,.28); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { padding: 7px 10px; font-size: .84rem; border-radius: 9px; }
.full { width: 100%; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(215,230,221,.2); border-radius: 999px;
  padding: 7px 10px; font-size: .72rem; color: var(--sidebar-text);
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.app.preview-open { grid-template-columns: 240px 1fr 380px; }

.sidebar {
  background: linear-gradient(180deg, #123028, var(--sidebar));
  color: var(--sidebar-text);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand .brand { color: #fff; font-size: 1.7rem; }
.side-brand .brand span { color: #5ddea8; }
.side-tag { font-size: .78rem; opacity: .75; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav button {
  text-align: left; background: transparent; border: 0; color: inherit;
  font: inherit; font-weight: 600; padding: 11px 12px; border-radius: 11px; cursor: pointer;
}
.nav button:hover { background: rgba(255,255,255,.06); }
.nav button.active { background: rgba(93,222,168,.16); color: #fff; }
.side-foot { display: grid; gap: 10px; }

.main { padding: 22px 24px 48px; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-end;
  margin-bottom: 18px; flex-wrap: wrap;
}
.topbar h2 { margin: 0; font-family: var(--display); font-size: 1.55rem; letter-spacing: -.02em; }
.topbar .muted { margin: 4px 0 0; font-size: .92rem; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section { display: none; }
.section.active { display: block; animation: rise .28s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card b { display: block; font-family: var(--display); font-size: 1.55rem; letter-spacing: -.02em; }
.card span { color: var(--muted); font-size: .8rem; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px;
}
.panel-h {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap;
}
.panel-h h3 { margin: 0; font-size: 1rem; }
.panel-b { padding: 14px 16px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { max-width: 220px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; font-size: .9rem; }
.crumbs button {
  background: transparent; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 0;
}
.crumbs .sep { color: var(--muted); }

.drop {
  border: 1.5px dashed #b9c8be; border-radius: 16px; padding: 28px;
  text-align: center; background: #f7faf8; transition: .15s ease; margin-bottom: 12px;
}
.drop.drag { border-color: var(--accent); background: rgba(26,155,111,.08); }
.drop strong { display: block; margin-bottom: 4px; }

.fm-layout { display: grid; grid-template-columns: 220px 1fr; gap: 12px; min-height: 520px; }
@media (max-width: 900px) { .fm-layout { grid-template-columns: 1fr; } }
.tree {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fbfcfb;
  overflow: auto; max-height: 70vh;
}
.tree button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  font: inherit; padding: 7px 8px; border-radius: 8px; cursor: pointer; color: var(--ink);
}
.tree button:hover, .tree button.active { background: rgba(26,155,111,.12); }
.tree .nested { padding-left: 12px; }

.fm-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.fm-table th, .fm-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.fm-table th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.fm-table tr:hover td { background: #f6faf7; }
.fm-table tr.selected td { background: rgba(26,155,111,.08); }
.fm-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px;
}
.fm-tile {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; cursor: pointer;
}
.fm-tile.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(26,155,111,.18); }
.fm-tile .icon { font-size: 1.4rem; margin-bottom: 8px; }
.fm-tile .name { font-weight: 700; font-size: .86rem; word-break: break-all; }
.fm-tile .meta { color: var(--muted); font-size: .75rem; margin-top: 4px; }

.bulkbar {
  display: none; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: #f3f8f5; margin-bottom: 10px;
}
.bulkbar.show { display: flex; }

.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; padding: 4px 8px; border-radius: 999px;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.ready, .status.live { color: var(--ok); background: rgba(26,127,75,.1); }
.status.pending, .status.provisioning, .status.mismatch { color: var(--warn); background: rgba(154,103,0,.12); }
.status.error, .status.down { color: var(--bad); background: rgba(180,35,24,.1); }

.list { display: grid; gap: 10px; }
.item {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: linear-gradient(180deg,#fff,#fafcfb);
}
.item-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.item-title { font-weight: 700; word-break: break-all; }
.item-note { color: var(--muted); font-size: .84rem; margin-top: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.link-box {
  flex: 1; min-width: 140px; font-family: var(--mono); font-size: .74rem;
  padding: 8px 10px; border-radius: 9px; background: #eef3ef; border: 1px solid var(--line); word-break: break-all;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 700px) { .field-grid { grid-template-columns: 1fr; } }
.hint { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.empty {
  border: 1px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted);
}
.badge {
  display: inline-block; font-size: .7rem; font-weight: 700; padding: 3px 7px;
  border-radius: 999px; background: rgba(154,103,0,.14); color: var(--warn); margin-left: 6px;
}
.log {
  font-family: var(--mono); font-size: .75rem; background: #f0f5f1; border-radius: 10px;
  padding: 10px; max-height: 160px; overflow: auto; white-space: pre-wrap; color: var(--muted);
}
.preview {
  border-left: 1px solid var(--line); background: #fff; padding: 14px;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.preview-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.preview-body {
  font-family: var(--mono); font-size: .78rem; white-space: pre-wrap;
  background: #f7faf8; border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  min-height: 200px;
}
.toast {
  position: fixed; right: 16px; bottom: 16px; background: var(--ink); color: #fff;
  padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow); opacity: 0;
  transform: translateY(8px); transition: .2s; z-index: 80; max-width: min(420px, calc(100vw - 28px));
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

.guide { display: grid; gap: 14px; }
.guide-prose { line-height: 1.55; font-size: 0.95rem; }
.guide-prose p { margin: 0 0 12px; }
.guide-prose ul, .guide-prose ol { margin: 0 0 4px; padding-left: 1.25rem; }
.guide-prose li { margin: 0 0 8px; }
.guide-prose code {
  font-family: var(--mono); font-size: 0.84em;
  background: #f0f5f2; padding: 0.1em 0.35em; border-radius: 6px;
}

@media (max-width: 860px) {
  .app, .app.preview-open { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .preview { position: relative; height: auto; border-left: 0; border-top: 1px solid var(--line); }
}
