:root {
  --brand-dark: #1C1633;
  --brand-blue: #15127C;
  --brand-periwinkle: #585EE9;
  --brand-sky: #789EE2;
  --brand-light: #F5F5F5;
  --border: #E2E8F0;
  --text: #1C1633;
  --text-muted: #5b5670;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(28, 22, 51, .12);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--brand-light);
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78em;
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85em;
  background: rgba(28,22,51,.06);
  padding: 2px 5px;
  border-radius: 5px;
}

/* ======================= LOCK ======================= */
.lock {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(88,94,233,.35), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(120,158,226,.28), transparent 55%),
    var(--brand-dark);
  z-index: 50;
}

.lock-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px 28px;
  text-align: center;
}

.lock-logo { width: 150px; height: auto; margin: 0 auto 18px; display: block; }
.lock-card h1 { font-size: 1.35rem; margin: 0 0 4px; letter-spacing: -.01em; }
.lock-sub { margin: 0 0 22px; color: var(--text-muted); font-size: .9rem; }

.lock-field {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.lock-field input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 1rem;
  font-family: inherit;
}
.lock-field input:focus,
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand-periwinkle);
  box-shadow: 0 0 0 3px rgba(88,94,233,.18);
}

.lock-error { color: #ba1a1a; font-size: .85rem; margin: 12px 0 0; }
.lock-foot { color: rgba(255,255,255,.6); font-size: .78rem; margin: 0; }

/* ======================= BUTTONS ======================= */
.primary-btn, .secondary-btn, .ghost-btn {
  font-family: inherit;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
.primary-btn {
  background: var(--brand-periwinkle);
  color: #fff;
  border: 1px solid var(--brand-periwinkle);
  padding: 12px 18px;
  font-size: .98rem;
}
.primary-btn:hover { background: #4a50e0; }
.primary-btn:active { transform: translateY(1px); }
.primary-btn.block { width: 100%; }

.secondary-btn {
  background: #fff;
  color: var(--brand-dark);
  border: 1px solid var(--border);
  padding: 10px 14px;
  font-size: .9rem;
}
.secondary-btn:hover { border-color: var(--brand-periwinkle); color: var(--brand-periwinkle); }

.ghost-btn {
  background: transparent;
  color: var(--brand-dark);
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: .86rem;
}
.ghost-btn.light { color: #fff; border-color: rgba(255,255,255,.35); }
.ghost-btn.light:hover { background: rgba(255,255,255,.1); }

/* ======================= APP ======================= */
.app { min-height: 100vh; }

.topbar {
  background: var(--brand-dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar-logo { height: 34px; width: auto; }
.topbar-titles { display: flex; flex-direction: column; line-height: 1.25; margin-right: auto; }
.topbar-titles strong { font-size: 1rem; }
.topbar-titles span { font-size: .78rem; color: rgba(255,255,255,.68); }

.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 22px 60px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 2px 10px rgba(28,22,51,.04);
}
.panel h2 { margin: 0 0 4px; font-size: 1.1rem; }
.help { margin: 0 0 18px; color: var(--text-muted); font-size: .85rem; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 6px; color: #3c3752; }
.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
.field small { display: block; color: var(--text-muted); font-size: .74rem; margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.advanced { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 14px; }
.advanced summary { cursor: pointer; font-weight: 600; font-size: .86rem; color: var(--brand-periwinkle); }
.advanced[open] summary { margin-bottom: 14px; }

.check { display: flex; align-items: flex-start; gap: 9px; font-size: .85rem; color: #3c3752; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand-periwinkle); }
.check.small { font-size: .8rem; color: var(--text-muted); margin-top: 12px; }

/* ======================= PREVIEW ======================= */
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.preview-head h2 { margin: 0; }

.mode-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.mode-switch button {
  font-family: inherit; font-size: .8rem; font-weight: 600;
  border: 0; background: #fff; color: var(--text-muted);
  padding: 7px 14px; cursor: pointer;
}
.mode-switch button.active { background: var(--brand-dark); color: #fff; }

.preview-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 26px;
  overflow: auto;
  transition: background .2s ease;
}
.preview-wrap.light { background: #fff; }
.preview-wrap.dark { background: #12101d; }
.preview-wrap iframe {
  width: 100%;
  height: 250px;
  border: 0;
  display: block;
  background: transparent;
}

.actions { margin-top: 18px; }
.hint { font-size: .8rem; color: var(--text-muted); margin: 10px 0 0; line-height: 1.5; }
.actions-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.actions-row .secondary-btn { flex: 1 1 auto; }

/* ======================= CLIENT TABS ======================= */
.clients { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 20px; }
.clients h3 { font-size: .95rem; margin: 0 0 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  cursor: pointer;
}
.tab.active { background: var(--brand-dark); color: #fff; border-color: var(--brand-dark); }
.tab-panel { display: none; margin: 0; padding-left: 18px; font-size: .85rem; color: #3c3752; line-height: 1.65; }
.tab-panel.active { display: block; }
.tab-panel li { margin-bottom: 6px; }

/* ======================= TOAST ======================= */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--brand-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ======================= RESPONSIVE ======================= */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .grid-2 { grid-template-columns: 1fr; }
  .tab-panel { padding-left: 16px; }
  .topbar-titles span { display: none; }
}
