* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
  color: #0f172a;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 56px 1fr;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  color: #fff;
  background: linear-gradient(135deg, #0b1220 0%, #1e293b 100%);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.app-header.brand-merchant {
  background: linear-gradient(135deg, #064e3b 0%, #0b1220 100%);
  box-shadow: 0 4px 20px rgba(6,78,59,0.22);
}

.app-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.pill {
  background: rgba(255,255,255,0.15);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
}

.btn {
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  color: #fff;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.2); }

.btn.danger { background: rgba(244,63,94,0.35); border-color: rgba(244,63,94,0.35); }

.app-body {
  display: grid;
  grid-template-columns: 248px 1fr;
  gap: 16px;
  padding: 18px;
}

.sidebar {
  background: rgba(255,255,255,0.92);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 12px 10px;
  position: sticky;
  top: 74px;
  align-self: start;
}

.nav-group { margin: 8px 0 12px; }

.nav-title {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  margin: 2px 4px;
  border-radius: 12px;
  text-decoration: none;
  color: #475569;
  font-weight: 700;
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover { background: rgba(79,70,229,0.08); color: #3730a3; }

.nav-item.active {
  background: rgba(79,70,229,0.12);
  color: #3730a3;
}

.content {
  background: rgba(255,255,255,0.92);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  overflow: hidden;
  position: relative;
}

.frame-overlay + iframe {
  background: transparent;
}

.content iframe {
  width: 100%;
  height: calc(100vh - 56px - 36px);
  border: 0;
  display: block;
  background: #fff;
}

.shell-guest .sidebar { display: none; }
.shell-guest .app-body { grid-template-columns: 1fr; }
.shell-guest .content {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}
.shell-guest .content iframe { height: calc(100vh - 56px); }

.config-panel {
  height: calc(100vh - 56px - 36px);
  overflow: auto;
  background: #ffffff;
}

.frame-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(241,245,249,0.95), rgba(226,232,240,0.75));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.frame-overlay.hidden { opacity: 0; pointer-events: none; }

.frame-card {
  width: 360px;
  max-width: calc(100vw - 32px);
  background: rgba(255,255,255,0.94);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
  padding: 18px;
}

.frame-title { font-size: 13px; font-weight: 800; color: #0f172a; margin-bottom: 10px; }

.frame-bar { height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }

.frame-bar > div { height: 100%; width: 45%; background: linear-gradient(90deg, rgba(99,102,241,0.2), rgba(99,102,241,0.95), rgba(99,102,241,0.2)); background-size: 200% 100%; animation: frameMove 1.1s linear infinite; }

@keyframes frameMove { 0% { transform: translateX(-110%); } 100% { transform: translateX(240%); } }

.cfg-wrap { padding: 18px; }
.cfg-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.cfg-title { font-size: 16px; font-weight: 800; color: #0f172a; }
.cfg-sub { font-size: 12px; color: #64748b; margin-top: 6px; }
.cfg-actions { display: flex; align-items: center; gap: 10px; }
.cfg-badge { font-size: 12px; color: #0f172a; background: #e2e8f0; padding: 8px 10px; border-radius: 999px; }
.cfg-btn { border: 0; border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 700; cursor: pointer; background: #4f46e5; color: #fff; }
.cfg-btn:hover { background: #4338ca; }
.cfg-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cfg-btn.secondary { background: #eef2ff; color: #3730a3; }
.cfg-btn.secondary:hover { background: #e0e7ff; }
.cfg-grid { display: grid; grid-template-columns: 1fr 320px; gap: 14px; }
.cfg-main { min-width: 0; }
.cfg-side { position: sticky; top: 14px; height: calc(100vh - 56px - 36px - 18px - 18px); overflow: auto; }
.cfg-card { border: 1px solid #e2e8f0; border-radius: 14px; padding: 14px; margin-bottom: 12px; background: #fff; }
.cfg-row { display: grid; grid-template-columns: 1fr 360px; gap: 12px; align-items: start; }
.cfg-name { font-size: 13px; font-weight: 800; color: #0f172a; }
.cfg-key { font-size: 12px; color: #64748b; margin-top: 6px; }
.cfg-desc { font-size: 12px; color: #334155; margin-top: 8px; line-height: 1.45; }
.cfg-input { width: 100%; min-height: 42px; padding: 10px 12px; border-radius: 12px; border: 1px solid #cbd5e1; font-size: 13px; outline: none; }
.cfg-input:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.14); }
.cfg-input:disabled { background: #f1f5f9; color: #64748b; }
.cfg-err { margin-top: 8px; font-size: 12px; color: #ef4444; }
.cfg-side-card { border: 1px solid #e2e8f0; border-radius: 14px; padding: 14px; background: #fff; }
.cfg-side-title { font-size: 13px; font-weight: 800; color: #0f172a; margin-bottom: 10px; }
.cfg-side-ok { padding: 10px 12px; border-radius: 12px; background: rgba(16,185,129,0.12); color: #065f46; font-size: 12px; }
.cfg-side-warn { padding: 10px 12px; border-radius: 12px; background: rgba(245,158,11,0.12); color: #92400e; font-size: 12px; line-height: 1.5; }
.cfg-side-sub { margin-top: 12px; font-size: 12px; color: #64748b; }
.cfg-json { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: #0b1220; color: #e2e8f0; font-size: 12px; overflow: auto; max-height: 320px; }
.cfg-side-tip { margin-top: 10px; font-size: 12px; color: #64748b; }
.cfg-skeleton { height: 520px; border-radius: 14px; background: linear-gradient(90deg, #eef2ff, #ffffff, #eef2ff); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { 0% { background-position: 0% 0; } 100% { background-position: -200% 0; } }

.toast { position: fixed; top: 14px; right: 14px; z-index: 20000; padding: 10px 12px; border-radius: 12px; font-size: 13px; font-weight: 700; color: #0f172a; background: rgba(255,255,255,0.92); border: 1px solid #e2e8f0; box-shadow: 0 12px 32px rgba(0,0,0,0.12); transform: translateY(-8px); opacity: 0; transition: all 0.18s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { border-color: rgba(16,185,129,0.35); }
.toast-danger { border-color: rgba(239,68,68,0.35); }
.toast-info { border-color: rgba(99,102,241,0.35); }

@media (max-width: 1100px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: 0; }
  .content iframe { height: calc(100vh - 56px - 36px - 240px); }
}
