:root {
  --bg: #020617;
  --bg-soft: #030712;
  --bg-elevated: #020617;
  --accent: #22c55e;
  --accent-soft: rgba(34,197,94,0.1);
  --accent-strong: #16a34a;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,0.1);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-soft: 0 22px 55px rgba(0,0,0,0.65);
  --shadow-subtle: 0 14px 40px rgba(15,23,42,0.85);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif; background: radial-gradient(circle at top, #020617 0, #020617 35%, #000 100%); color: var(--text); }

body { min-height: 100vh; display: flex; flex-direction: column; }

.app-shell { display: flex; flex-direction: column; min-height: 100vh; max-width: 1360px; margin: 0 auto; padding: 18px 18px 28px; gap: 18px; }

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(15,23,42,0.92);
  border: 1px solid rgba(148,163,184,0.18);
  box-shadow: 0 18px 60px rgba(15,23,42,0.9);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 12px;
  z-index: 20;
}

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

.logo-orb {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: conic-gradient(from 210deg, #22c55e, #22c55e, #0ea5e9, #22c55e);
  position: relative;
  box-shadow: 0 0 0 1px rgba(15,23,42,0.9), 0 0 25px rgba(34,197,94,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.logo-orb-inner {
  width: 58%;
  height: 58%;
  border-radius: inherit;
  background: radial-gradient(circle at 30% 15%, #e5e7eb, #6b7280 38%, #020617 100%);
  box-shadow: inset 0 0 0 1px rgba(15,23,42,0.8);
}

.brand-title {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title span:nth-child(1) {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ca3af;
}

.brand-title span:nth-child(2) {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15,23,42,0.9);
  border: 1px solid rgba(148,163,184,0.4);
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34,197,94,0.18);
}

.btn {
  border-radius: 999px;
  border: none;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease-out;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #022c22;
  box-shadow: 0 14px 40px rgba(34,197,94,0.4);
}

.btn-primary:hover {
  transform: translateY(-1px) translateZ(0);
  box-shadow: 0 18px 50px rgba(34,197,94,0.45);
}

.btn-ghost {
  background: rgba(15,23,42,0.8);
  color: var(--muted);
  border: 1px solid rgba(148,163,184,0.4);
}

.btn-ghost:hover { background: rgba(15,23,42,1); color: #e5e7eb; }

/* Main layout */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: stretch;
}

@media (max-width: 960px) {
  .main-grid { grid-template-columns: minmax(0,1fr); }
  .topbar { border-radius: 16px; flex-wrap: wrap; gap: 8px 12px; }
}

/* Left: Template Liste & Filter */
.card {
  background: radial-gradient(circle at top left, rgba(34,197,94,0.12), transparent 50%),
              radial-gradient(circle at bottom right, rgba(59,130,246,0.12), transparent 55%),
              linear-gradient(145deg, #020617, #020617 55%, #020617);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(30,64,175,0.7);
  box-shadow: var(--shadow-soft);
  padding: 14px 14px 16px;
  position: relative;
  overflow: hidden;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-title span.sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(15,23,42,0.85);
  border: 1px solid rgba(55,65,81,0.9);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.16s ease-out;
}

.chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #4ade80;
}

.chip.active {
  background: rgba(34,197,94,0.16);
  color: #bbf7d0;
  border-color: rgba(34,197,94,0.75);
}

.chip:hover { border-color: rgba(148,163,184,1); color: #e5e7eb; }

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.input-shell {
  flex: 1;
  position: relative;
}

.input {
  width: 100%;
  background: rgba(15,23,42,0.95);
  border-radius: 999px;
  border: 1px solid rgba(55,65,81,0.9);
  padding: 7px 28px 7px 28px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: all 0.18s ease-out;
}

.input::placeholder { color: #6b7280; }

.input:focus {
  border-color: rgba(34,197,94,0.9);
  box-shadow: 0 0 0 1px rgba(34,197,94,0.5);
  background: #020617;
}

.input-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: #6b7280;
  pointer-events: none;
}

.input-badge {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #6b7280;
  background: rgba(15,23,42,0.95);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(55,65,81,0.9);
}

.template-list {
  margin-top: 6px;
  border-radius: 14px;
  background: radial-gradient(circle at top, rgba(15,23,42,0.85), #020617 52%, #000 100%);
  border: 1px solid rgba(31,41,55,0.9);
  max-height: calc(100vh - 210px);
  overflow: hidden auto;
  box-shadow: var(--shadow-subtle);
}

.template-item {
  display: flex;
  padding: 9px 11px;
  gap: 10px;
  border-bottom: 1px solid rgba(31,41,55,0.72);
  cursor: pointer;
  transition: background 0.15s ease-out, transform 0.12s ease-out;
}

.template-item:last-child { border-bottom: none; }

.template-item:hover {
  background: radial-gradient(circle at top left, rgba(34,197,94,0.12), rgba(15,23,42,0.9));
  transform: translateY(-1px);
}

.template-item.active {
  background: linear-gradient(135deg, rgba(34,197,94,0.18), rgba(15,23,42,0.95));
}

.template-logo {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 10%, #f9fafb, #6b7280 38%, #020617 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 12px 30px rgba(15,23,42,0.9);
  flex-shrink: 0;
}

.template-main { flex: 1; min-width: 0; }

.template-main-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 2px;
}

.template-title { font-size: 13px; font-weight: 600; }

.template-type-pill {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15,23,42,0.96);
  border: 1px solid rgba(55,65,81,0.9);
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.template-desc { font-size: 11px; color: #9ca3af; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.template-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  gap: 8px;
}

.template-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 70%;
}

.tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15,23,42,0.95);
  border: 1px solid rgba(55,65,81,0.8);
  color: #9ca3af;
}

.template-ports {
  font-size: 10px;
  color: #9ca3af;
}

.template-ports span {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(15,23,42,0.9);
  border: 1px solid rgba(55,65,81,0.85);
}

/* Right: Detail / Editor */
.detail-shell {
  position: relative;
  background: radial-gradient(circle at top right, rgba(34,197,94,0.12), transparent 60%),
              radial-gradient(circle at bottom left, rgba(59,130,246,0.16), transparent 60%),
              linear-gradient(150deg, #020617, #020617 65%, #000);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(30,64,175,0.85);
  box-shadow: var(--shadow-soft);
  padding: 14px 14px 16px;
  overflow: hidden;
}

.detail-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, rgba(15,23,42,0.7), transparent 60%);
  opacity: 0.9;
  pointer-events: none;
}

.detail-inner { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 10px; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.detail-header-left { display: flex; gap: 10px; align-items: center; }

.detail-logo {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: radial-gradient(circle at 30% 10%, #f9fafb, #6b7280 38%, #020617 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 14px 34px rgba(15,23,42,0.9);
  flex-shrink: 0;
}

.detail-title-block { display: flex; flex-direction: column; gap: 3px; }

.detail-title { font-size: 16px; font-weight: 650; }

.detail-subtitle { font-size: 12px; color: var(--muted); }

.detail-label-row { display: flex; flex-wrap: wrap; gap: 6px; }

.pill-soft {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(55,65,81,0.9);
  background: rgba(15,23,42,0.95);
  color: #9ca3af;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pill-soft span.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #22c55e;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0,1.15fr) minmax(0,0.85fr);
  gap: 10px;
}

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

.section {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15,23,42,0.92);
  border: 1px solid rgba(31,41,55,0.9);
  box-shadow: 0 12px 30px rgba(15,23,42,0.85);
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #9ca3af;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title span.badge-mini {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(55,65,81,0.9);
  color: #9ca3af;
  background: rgba(15,23,42,0.9);
}

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

.field-label {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.field-control {
  border-radius: 9px;
  border: 1px solid rgba(55,65,81,0.9);
  background: rgba(2,6,23,0.9);
  padding: 6px 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-value {
    color: #e5e7eb; 
    word-wrap: break-word;
    word-break: break-all;
    overflow-x: auto;
    max-width: 100%;
    min-height: 20px;
    padding: 2px 4px;
    font-size: 11px;
    line-height: 1.4;
    background: rgba(30,64,175,0.08);
    border-radius: 4px;
    border: 1px solid rgba(55,65,81,0.4);
}

.field-value.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 11px; }

.field-chip-row { display: flex; flex-wrap: wrap; gap: 3px; }

.field-chip {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(15,23,42,0.98);
  border: 1px solid rgba(55,65,81,0.9);
  color: #9ca3af;
}

.field-action-btn {
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 10px;
  border: 1px solid rgba(55,65,81,0.9);
  background: rgba(15,23,42,0.9);
  color: #9ca3af;
  cursor: pointer;
}

.field-action-btn:hover { border-color: rgba(148,163,184,1); color: #e5e7eb; }

.textarea-like {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  line-height: 1.45;
  max-height: 110px;
  overflow: auto;
  white-space: pre;
  word-wrap: normal;
}

.pill-row-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
  align-items: center;
}

.pill-row-footer-right { display: flex; gap: 8px; }

.btn-pill-soft {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  border: 1px solid rgba(55,65,81,0.9);
  background: rgba(15,23,42,0.9);
  color: #9ca3af;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-pill-soft span.dot-small {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #22c55e;
}

.btn-pill-soft.ghost-danger {
  border-color: rgba(248,113,113,0.8);
  color: #fecaca;
  background: rgba(127,29,29,0.4);
}

.btn-pill-soft.ghost-danger:hover { background: rgba(127,29,29,0.7); }

.json-preview {
  margin-top: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  background: radial-gradient(circle at top, rgba(15,23,42,0.92), #020617 60%, #000 100%);
  border: 1px solid rgba(31,41,55,0.95);
  box-shadow: 0 12px 30px rgba(15,23,42,0.95);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  color: #e5e7eb;
  max-height: 165px;
  overflow: auto;
}

.json-preview .json-key { color: #93c5fd; }
.json-preview .json-string { color: #bef264; }
.json-preview .json-number { color: #facc15; }
.json-preview .json-punc { color: #6b7280; }

.helper-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  color: #9ca3af;
}

.helper-pill {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(15,23,42,0.9);
  border: 1px dashed rgba(55,65,81,0.9);
}

.helper-pill code { font-size: 11px; }

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: #030712;
  border-radius: 18px;
  border: 1px solid rgba(30,64,175,0.85);
  box-shadow: 0 22px 55px rgba(0,0,0,0.65);
  padding: 20px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(31,41,55,0.9);
}

.modal-title {
  font-size: 18px;
  font-weight: 650;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}

.form-group {
  margin-bottom: 15px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid rgba(55,65,81,0.9);
  background: rgba(2,6,23,0.9);
  color: var(--text);
  font-size: 13px;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
}

.form-textarea {
  min-height: 100px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.btn-small {
  padding: 5px 12px;
  font-size: 12px;
}

/* Login Form */
.login-form {
  max-width: 400px;
  margin: 0 auto;
  padding: 30px;
  background: rgba(15,23,42,0.9);
  border-radius: 18px;
  border: 1px solid rgba(30,64,175,0.85);
  box-shadow: 0 22px 55px rgba(0,0,0,0.65);
}

.login-form h2 {
  text-align: center;
  margin-bottom: 20px;
  font-size: 20px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-btn {
  width: 100%;
}

/* Public view */
.public-view {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.public-view h1 {
  text-align: center;
  margin-bottom: 20px;
}