/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 13.5px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0b0b12;
  color: #c8c8d4;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: #7b9aff; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: rgba(99,130,255,.1); padding: 1px 5px; border-radius: 3px; font-size: 0.85em; color: #8fa4ff; }
ul { padding-left: 16px; }
ul li { margin-bottom: 3px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a3c; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a50; }

/* ===== AUTH SCREENS ===== */
.screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 30%, rgba(99,130,255,.04), transparent 60%);
}
.auth-card {
  background: #111119;
  border: 1px solid #1c1c2a;
  border-radius: 14px;
  padding: 32px 30px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.auth-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #6b8afd, #5046e5);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  margin-bottom: 14px;
  letter-spacing: -0.5px;
}
.auth-card h2 { font-size: 1.2rem; font-weight: 600; color: #e8e8f0; margin-bottom: 3px; }
.auth-sub { color: #6e6e82; font-size: 0.88rem; margin-bottom: 20px; }
.form-error { color: #f87171; font-size: 0.8rem; margin-top: 8px; min-height: 16px; }
.btn-link {
  background: none;
  border: none;
  color: #6e6e82;
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 12px;
}
.btn-link:hover { color: #a0a0b4; }

/* ===== LAYOUT ===== */
#app-shell { display: flex; min-height: 100vh; }

#sidebar {
  width: 200px;
  background: #0e0e16;
  border-right: 1px solid #1a1a28;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  margin-bottom: 22px;
}
.brand-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #6b8afd, #5046e5);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  flex-shrink: 0;
}
.brand-text { font-weight: 600; font-size: 0.88rem; color: #e0e0ea; }
.nav-links { flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: #78788e;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all .15s;
  border-left: 2px solid transparent;
}
.nav-link:hover { color: #b0b0c0; background: rgba(99,130,255,.04); text-decoration: none; }
.nav-link.active {
  color: #7b9aff;
  background: rgba(99,130,255,.07);
  border-left-color: #7b9aff;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer {
  padding: 12px 14px 0;
  border-top: 1px solid #1a1a28;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.session-status { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: #6e6e82; }
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online { background: #34d399; box-shadow: 0 0 5px rgba(52,211,153,.35); }
.status-dot.offline { background: #404054; }

#main-content {
  flex: 1;
  margin-left: 200px;
  padding: 22px 28px;
  max-width: 1050px;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.page-header h1 { font-size: 1.25rem; font-weight: 600; color: #e0e0ea; }
.page-actions { display: flex; gap: 6px; }

/* ===== CARDS ===== */
.card {
  background: #111119;
  border: 1px solid #1a1a28;
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.card h3 { font-size: 0.92rem; font-weight: 600; color: #d0d0dc; margin-bottom: 12px; }
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-header-row h3 { margin-bottom: 0; }
.card-filters { display: flex; gap: 6px; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 0.78rem; font-weight: 500; color: #78788e; }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-col { display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.flex-1 { flex: 1; min-width: 130px; }

input, select, textarea {
  background: #0b0b12;
  border: 1px solid #252538;
  border-radius: 7px;
  padding: 7px 10px;
  color: #c8c8d4;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: #6b8afd; }
input::placeholder { color: #404054; }
.input-sm { padding: 5px 8px; font-size: 0.8rem; width: 150px; }
.input-hint { font-size: 0.75rem; min-height: 14px; }
.input-hint.valid { color: #34d399; }
.input-hint.invalid { color: #f87171; }
.hint-text { color: #6e6e82; font-size: 0.82rem; margin-bottom: 12px; line-height: 1.5; }

select[multiple] { min-height: 56px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 16px;
  border: none;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: #6b8afd; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #5a79f0; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #bf2020; }
.btn-outline { background: transparent; border: 1px solid #252538; color: #9898ac; }
.btn-outline:hover { border-color: #6b8afd; color: #7b9aff; }
.btn-ghost { background: transparent; color: #78788e; padding: 5px 8px; }
.btn-ghost:hover { color: #c8c8d4; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-xs { padding: 3px 7px; font-size: 0.74rem; border-radius: 5px; }
.btn-full { width: 100%; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 0.74rem;
  font-weight: 600;
  color: #5e5e72;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 7px 10px;
  border-bottom: 1px solid #1a1a28;
}
tbody td {
  padding: 8px 10px;
  font-size: 0.85rem;
  border-bottom: 1px solid #131320;
  color: #a8a8bc;
}
tbody tr:hover { background: rgba(99,130,255,.03); }
.table-info { font-size: 0.75rem; color: #505064; margin-top: 8px; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: .01em;
}
.badge-green { background: rgba(52,211,153,.1); color: #34d399; }
.badge-red { background: rgba(248,113,113,.1); color: #f87171; }
.badge-blue { background: rgba(96,165,250,.1); color: #60a5fa; }
.badge-yellow { background: rgba(251,191,36,.1); color: #fbbf24; }
.badge-gray { background: rgba(136,136,160,.1); color: #78788e; }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  border-bottom: 1px solid #1a1a28;
  overflow-x: auto;
}
.tab {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #5e5e72;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.tab:hover { color: #9898ac; }
.tab.active { color: #7b9aff; border-bottom-color: #7b9aff; }

/* ===== SCRIPTS GRID ===== */
.scripts-grid { display: flex; flex-direction: column; gap: 6px; }
.script-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #0d0d15;
  border: 1px solid #181828;
  border-radius: 8px;
  transition: border-color .15s;
}
.script-item:hover { border-color: #252538; }
.script-info { display: flex; flex-direction: column; gap: 1px; }
.script-name { font-size: 0.88rem; font-weight: 500; color: #d0d0dc; }
.script-id { font-size: 0.72rem; color: #505064; font-family: monospace; }
.script-actions { display: flex; gap: 5px; align-items: center; }

/* ===== STEPS (Webhook Guide) ===== */
.steps { display: flex; flex-direction: column; gap: 16px; }
.step { display: flex; gap: 12px; }
.step-num {
  width: 26px;
  height: 26px;
  background: rgba(99,130,255,.1);
  color: #7b9aff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
}
.step div { flex: 1; }
.step strong { color: #d0d0dc; font-size: 0.88rem; }
.step p { color: #78788e; font-size: 0.82rem; margin-top: 3px; }
.code-block {
  background: #090910;
  border: 1px solid #181828;
  border-radius: 7px;
  padding: 10px 12px;
  margin-top: 6px;
  font-size: 0.8rem;
  color: #8fa4ff;
  overflow-x: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.code-block code { background: none; padding: 0; white-space: pre; display: block; }

/* ===== INFO ROWS (Security tab) ===== */
.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #181828;
}
.info-label { font-size: 0.8rem; color: #5e5e72; width: 72px; flex-shrink: 0; }
.info-value { font-size: 0.85rem; color: #a8a8bc; font-family: monospace; }

/* ===== STATUS INFO ===== */
.status-info {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 0.82rem;
}
.status-info.ok { background: rgba(52,211,153,.07); color: #34d399; }
.status-info.warn { background: rgba(251,191,36,.07); color: #fbbf24; }

/* ===== MINI TABLE (Stripe mappings) ===== */
.mini-table-wrap { margin-top: 10px; }
.mini-table { width: 100%; border-collapse: collapse; }
.mini-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: #505064;
  text-transform: uppercase;
  padding: 5px 8px;
  border-bottom: 1px solid #181828;
}
.mini-table td {
  padding: 6px 8px;
  font-size: 0.8rem;
  border-bottom: 1px solid #131320;
  color: #9898ac;
}

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1000;
}
.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  max-width: 320px;
  animation: slideIn .2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.toast.success { background: #0c3320; color: #86efac; border: 1px solid #14532d; }
.toast.error { background: #3a0808; color: #fca5a5; border: 1px solid #6f1d1d; }
.toast.info { background: #161340; color: #a5b4fc; border: 1px solid #2a2870; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== EMPTY / LOADING ===== */
.empty-msg { color: #505064; font-size: 0.85rem; text-align: center; padding: 22px 0; }
.loading-msg { color: #5e5e72; font-size: 0.82rem; text-align: center; padding: 16px 0; }

/* ===== SCRIPT MULTI-SELECT BUTTONS ===== */
.hint-small { font-size: 0.75rem; color: #505070; font-weight: 400; margin-left: 6px; }
.script-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 6px;
  min-height: 36px;
  align-items: flex-start;
}
.script-sel-btn {
  background: #17172a;
  border: 1px solid #2a2a3e;
  color: #9090b0;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.script-sel-btn:hover {
  border-color: #6b8afd;
  color: #b8c8ff;
  background: #1a1a30;
}
.script-sel-btn.active {
  background: rgba(107,138,253,0.18);
  border-color: #6b8afd;
  color: #a0b4ff;
  box-shadow: 0 0 0 1px rgba(107,138,253,0.25);
}

/* ===== EXTEND INLINE ===== */
.extend-inline {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
}
.extend-sel {
  background: #16162a;
  border: 1px solid #2a2a3e;
  color: #c8c8d4;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}
.extend-sel:focus { outline: none; border-color: #6b8afd; }
.revoke-btn { color: #f87171 !important; }

/* ===== PINE ID PREVIEW ===== */
.pine-preview {
  margin-top: 5px;
  font-size: 0.8rem;
  min-height: 18px;
}
.pine-preview .extracting { color: #7b9aff; }
.pine-preview .extract-ok { color: #86efac; }
.pine-preview .extract-err { color: #f87171; }

/* ===== SECURITY: API CONN INFO ===== */
.mono-small { font-family: monospace; font-size: 0.82rem; word-break: break-all; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #sidebar { width: 52px; padding: 10px 0; }
  .brand-text, .nav-link span, .session-status span:last-child { display: none; }
  .nav-link { justify-content: center; padding: 10px 0; border-left: none; border-bottom: 2px solid transparent; }
  .nav-link.active { border-bottom-color: #7b9aff; border-left: none; }
  #main-content { margin-left: 52px; padding: 16px 14px; }
  .form-row { flex-direction: column; }
  .flex-1 { min-width: 100%; }
  .input-sm { width: 100%; }
}
