/* ===========================================
   SCOUT LIVE DASHBOARD — Refined Command Center
   Aesthetic: Matte dark, warm accent, editorial precision
   =========================================== */

/* --- Tokens --- */
:root {
  /* Surface palette — warm-tinted darks */
  --bg-0: #09090b;
  --bg-1: #0f0f12;
  --bg-2: #16161a;
  --bg-3: #1c1c21;
  --bg-4: #232329;
  --bg-hover: #27272e;

  /* Foreground palette */
  --fg: #ececef;
  --fg-2: #a9a9b2;
  --fg-3: #6e6e79;
  --fg-4: #44444d;

  /* Accent — warm amber-gold, not the overused teal/purple */
  --accent: #e8c872;
  --accent-fg: #09090b;
  --accent-dim: rgba(232, 200, 114, 0.12);
  --accent-glow: rgba(232, 200, 114, 0.25);

  /* Semantic */
  --green: #4ae08a;
  --green-dim: rgba(74, 224, 138, 0.12);
  --red: #f25c5c;
  --red-dim: rgba(242, 92, 92, 0.10);
  --amber: #f2a93b;
  --amber-dim: rgba(242, 169, 59, 0.10);
  --blue: #5ca0f2;
  --blue-dim: rgba(92, 160, 242, 0.10);

  /* Border */
  --border: #232329;
  --border-2: #2e2e36;
  --border-hover: #3a3a44;

  /* Typography */
  --font-display: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Sizing */
  --sidebar-w: 240px;
  --header-h: 64px;

  /* Transitions */
  --ease: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-display);
  background: var(--bg-0);
  color: var(--fg);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* --- Animations --- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===========================================
   AUTH VIEW
   =========================================== */

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(232, 200, 114, 0.04) 0%, transparent 70%),
    var(--bg-0);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px 36px;
  animation: fadeUp 0.5s var(--ease) both;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.logo-icon { color: var(--accent); display: flex; }
.logo-text {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--fg);
}
.logo-sm { font-size: 15px; }
.logo-dot { color: var(--accent); }

.auth-tagline {
  font-size: 13px;
  color: var(--fg-3);
  margin-bottom: 32px;
  letter-spacing: 0.01em;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 24px;
  background: var(--bg-0);
  padding: 3px;
  border-radius: var(--radius);
}
.auth-tab {
  flex: 1;
  padding: 8px 16px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-3);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.auth-tab:hover { color: var(--fg-2); }
.auth-tab.active {
  background: var(--bg-2);
  color: var(--fg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ===========================================
   FORMS
   =========================================== */

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.label-opt { font-weight: 400; color: var(--fg-4); text-transform: none; letter-spacing: 0; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
select {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--fg);
  background: var(--bg-0);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: all 0.15s var(--ease);
  width: 100%;
}
input::placeholder { color: var(--fg-4); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-icon-right {
  position: relative;
}
.input-icon-right input { padding-right: 40px; }

.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--fg-4);
  cursor: pointer;
  padding: 4px;
  display: flex;
}
.password-toggle:hover { color: var(--fg-2); }

.form-hint {
  font-size: 12px;
  color: var(--fg-4);
  line-height: 1.4;
}
.form-error {
  font-size: 13px;
  color: var(--red);
  font-family: var(--font-mono);
  min-height: 20px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-4);
}
.form-divider::before, .form-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===========================================
   BUTTONS
   =========================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 10px 18px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  border: none;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}
.btn svg { flex-shrink: 0; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-accent {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-accent:hover {
  filter: brightness(1.1);
  box-shadow: 0 2px 16px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-accent:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--fg-2);
  border: 1px solid var(--border-2);
}
.btn-outline:hover {
  border-color: var(--fg-3);
  color: var(--fg);
  background: var(--bg-3);
}

.btn-ghost {
  background: transparent;
  color: var(--fg-3);
  border: none;
  padding: 8px 12px;
}
.btn-ghost:hover { color: var(--fg); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

.btn-loader {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn.loading .btn-text { visibility: hidden; }
.btn.loading .btn-loader { display: block; }
.btn.loading svg { display: none; }

.btn-icon-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--fg-3);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.btn-icon-sm:hover {
  background: var(--bg-3);
  color: var(--fg);
  border-color: var(--border-2);
}
.btn-icon-sm.danger:hover {
  color: var(--red);
  border-color: rgba(242, 92, 92, 0.3);
  background: var(--red-dim);
}

.btn-copy {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-3);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.btn-copy:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.btn-copy.copied {
  color: var(--green);
  border-color: var(--green);
}

/* ===========================================
   SIDEBAR
   =========================================== */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  animation: fadeIn 0.3s var(--ease);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--fg-3);
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  color: var(--fg-2);
  background: var(--bg-2);
}
.nav-item.active {
  color: var(--fg);
  background: var(--bg-3);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item { position: relative; }

.nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-4);
  background: var(--bg-2);
  padding: 1px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}
.nav-item.active .nav-badge {
  color: var(--accent);
  background: var(--accent-dim);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-email-sidebar {
  font-size: 12px;
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===========================================
   MAIN CONTENT
   =========================================== */

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 36px 40px;
}

.content-section {
  display: none;
  animation: fadeUp 0.35s var(--ease) both;
}
.content-section.active { display: block; }

.section-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.section-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.page-desc {
  font-size: 14px;
  color: var(--fg-3);
  margin-top: 4px;
}

/* --- Filter select --- */
.filter-select select {
  font-size: 12px;
  padding: 7px 32px 7px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--fg-2);
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236e6e79' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all 0.15s var(--ease);
}
.filter-select select:hover { border-color: var(--border-hover); }
.filter-select select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Select wrapper for forms */
.select-wrap { position: relative; }
.select-wrap select {
  width: 100%;
  appearance: none;
  padding-right: 36px;
}
.select-wrap::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--fg-4);
  border-bottom: 1.5px solid var(--fg-4);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

/* ===========================================
   STATS GRID (Overview)
   =========================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.15s var(--ease);
  animation: fadeUp 0.4s var(--ease) both;
}
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:hover { border-color: var(--border-2); }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon-apps { background: var(--blue-dim); color: var(--blue); }
.stat-icon-keys { background: var(--accent-dim); color: var(--accent); }
.stat-icon-adapters { background: var(--green-dim); color: var(--green); }

.stat-info { display: flex; flex-direction: column; }
.stat-number {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 12px;
  color: var(--fg-3);
  margin-top: 4px;
}

/* ===========================================
   OVERVIEW PANELS
   =========================================== */

.overview-panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  animation: fadeUp 0.4s var(--ease) both;
  animation-delay: 0.2s;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-2);
}
.panel-body {
  padding: 8px;
}

/* Quick Actions */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 20px;
}
.quick-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg-3);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 500;
}
.quick-action-card:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-2px);
}

/* ===========================================
   LIST ITEMS — Shared for keys, apps, adapters
   =========================================== */

.keys-list, .apps-list, .adapters-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all 0.15s var(--ease);
  gap: 16px;
}
.list-card:hover {
  border-color: var(--border-2);
  background: var(--bg-3);
}

.list-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.list-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}
.list-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--fg-3);
  flex-wrap: wrap;
}
.list-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Tags */
.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tag-scope {
  background: var(--bg-4);
  color: var(--fg-3);
}
.tag-type {
  background: var(--bg-4);
  color: var(--fg-3);
}
.tag-platform {
  background: var(--accent-dim);
  color: var(--accent);
}
.tag-user {
  background: var(--bg-4);
  color: var(--fg-3);
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-available { color: var(--green); }
.status-available .status-dot { background: var(--green); box-shadow: 0 0 6px var(--green-dim); }
.status-error { color: var(--red); }
.status-error .status-dot { background: var(--red); }
.status-maintenance { color: var(--amber); }
.status-maintenance .status-dot { background: var(--amber); }
.status-disabled { color: var(--fg-4); }
.status-disabled .status-dot { background: var(--fg-4); }

/* Inline link */
.link-accent {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}
.link-accent:hover { text-decoration: underline; }

/* Prefix (for API key display) */
.mono-dim {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}

/* ===========================================
   APP CARDS — Expanded layout
   =========================================== */

.app-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s var(--ease);
}
.app-card:hover { border-color: var(--border-2); }

.app-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 16px;
}
.app-card-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}
.app-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
}
.app-card-url {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}
.app-card-url:hover { text-decoration: underline; }
.app-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11.5px;
  color: var(--fg-4);
  margin-top: 2px;
}

/* Port binding tags row */
.app-bindings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 20px 12px;
}
.binding-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  background: var(--bg-4);
  border-radius: 4px;
  color: var(--fg-3);
}

/* Expandable sections inside app cards */
.app-expand-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 20px;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-4);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.app-expand-trigger:hover { color: var(--fg-2); background: var(--bg-3); }
.app-expand-trigger svg {
  transition: transform 0.2s var(--ease);
}
.app-expand-trigger.open svg { transform: rotate(180deg); }

.app-expand-panel {
  display: none;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
}
.app-expand-panel.open { display: block; }

/* Port mapping controls (compact grid) */
.port-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.port-cell {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.port-cell label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-4);
}
.port-cell select {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.port-cell-actions {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

/* Env vars */
.env-var-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.env-var-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-2);
}
.env-var-key { color: var(--accent); font-weight: 500; min-width: 100px; }
.env-var-val { color: var(--fg-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-var-val.env-masked { color: var(--fg-4); letter-spacing: 2px; }
.env-empty, .env-loading { font-size: 12px; color: var(--fg-4); padding: 6px 0; }

.env-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.env-add-row input {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.env-key-input {
  width: 120px;
  max-width: 140px;
  flex-shrink: 0;
}
.env-val-input {
  flex: 2 1 200px;
  min-width: 150px;
}
.env-secret-label {
  font-size: 11px;
  color: var(--fg-4);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}

.env-redeploy-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--amber-dim);
  border: 1px solid rgba(242, 169, 59, 0.2);
  border-radius: var(--radius-sm);
}
.env-redeploy-hint {
  font-size: 12px;
  color: var(--amber);
}

/* ===========================================
   EMPTY STATES
   =========================================== */

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--fg-3);
}
.empty-state svg {
  width: 40px;
  height: 40px;
  color: var(--fg-4);
  margin-bottom: 12px;
}
.empty-state p {
  font-size: 13px;
  max-width: 300px;
  margin: 0 auto;
  line-height: 1.6;
}
.empty-state .btn {
  margin-top: 16px;
}

/* ===========================================
   MODALS
   =========================================== */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s var(--ease);
}
.modal.active { opacity: 1; visibility: visible; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.25s var(--ease);
}
.modal.active .modal-dialog {
  transform: translateY(0) scale(1);
}
.modal-lg { max-width: 560px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--fg-3);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.modal-close:hover { background: var(--bg-4); color: var(--fg); }

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-footer {
  display: flex;
  gap: 8px;
  padding: 0 24px 20px;
  justify-content: flex-end;
}

/* Scope picker in create key modal */
.scope-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.scope-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.scope-option:hover { border-color: var(--border-hover); }
.scope-option input { display: none; }
.scope-option input:checked + .scope-option-body { color: var(--fg); }
.scope-option input:checked ~ .scope-option-body::before {
  content: '';
}
.scope-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.scope-option-body { display: flex; flex-direction: column; gap: 1px; }
.scope-name { font-size: 13px; font-weight: 600; color: var(--fg-2); }
.scope-desc { font-size: 11px; color: var(--fg-4); }

/* Callout */
.callout {
  font-size: 13px;
  padding: 12px 14px;
  border-radius: var(--radius);
  line-height: 1.4;
}
.callout-warn {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(242, 169, 59, 0.2);
}

/* Key display box */
.key-display-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.key-display-box code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
  flex: 1;
}

/* File drop */
.file-drop {
  position: relative;
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.file-drop:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-drop-content { color: var(--fg-3); }
.file-drop-content svg { margin-bottom: 8px; color: var(--fg-4); }
.file-drop-content p { font-size: 13px; }
.file-drop-link { color: var(--accent); text-decoration: underline; }
.file-drop-hint { font-size: 11px; color: var(--fg-4); margin-top: 4px; }
.file-drop-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.file-drop-selected svg { color: var(--green); }
.file-drop-selected span { font-family: var(--font-mono); font-size: 13px; color: var(--fg); }

/* Input suffix */
.input-suffix-wrap { position: relative; }
.input-suffix-wrap input { padding-right: 130px; }
.input-suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
  pointer-events: none;
}

/* Adapter creds section */
.adapter-creds.hidden { display: none; }
.adapter-provider-fields.hidden { display: none; }
.adapter-provider-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Test result */
.test-result {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.test-result.hidden { display: none; }
.test-result.success {
  border-color: var(--green);
  background: var(--green-dim);
}
.test-result.success .test-result-icon::before {
  content: '\2713';
  color: var(--green);
  font-weight: bold;
}
.test-result.error {
  border-color: var(--red);
  background: var(--red-dim);
}
.test-result.error .test-result-icon::before {
  content: '\2717';
  color: var(--red);
  font-weight: bold;
}
.test-result.testing {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.test-result.testing .test-result-icon::before {
  content: '\2022';
  color: var(--accent);
  animation: pulse 1s infinite;
}
.test-result-message { color: var(--fg); line-height: 1.4; }

/* ===========================================
   TOAST NOTIFICATIONS
   =========================================== */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-left-width: 3px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--fg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toastSlideUp 0.3s var(--ease);
  max-width: 380px;
  opacity: 0;
  transform: translateY(8px);
}

@keyframes toastSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.toast-icon.spin {
  animation: toastSpin 1s linear infinite;
}
@keyframes toastSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.toast-message {
  flex: 1;
  line-height: 1.4;
}

/* Toast Types */
.toast.success { 
  border-left-color: var(--green);
  background: linear-gradient(135deg, var(--bg-2) 0%, rgba(34, 197, 94, 0.05) 100%);
}
.toast.success .toast-icon { color: var(--green); }

.toast.error { 
  border-left-color: var(--red);
  background: linear-gradient(135deg, var(--bg-2) 0%, rgba(239, 68, 68, 0.05) 100%);
}
.toast.error .toast-icon { color: var(--red); }
.toast.error { border-left-width: 4px; }

.toast.warning { 
  border-left-color: var(--amber);
  background: linear-gradient(135deg, var(--bg-2) 0%, rgba(251, 191, 36, 0.05) 100%);
}
.toast.warning .toast-icon { color: var(--amber); }

.toast.info { 
  border-left-color: var(--accent);
  background: linear-gradient(135deg, var(--bg-2) 0%, rgba(59, 130, 246, 0.05) 100%);
}
.toast.info .toast-icon { color: var(--accent); }

.toast.progress { 
  border-left-color: var(--fg-4);
}
.toast.progress .toast-icon { color: var(--fg-3); }

/* ===========================================
   SCROLLBAR
   =========================================== */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

::selection {
  background: var(--accent);
  color: var(--accent-fg);
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 900px) {
  .sidebar {
    width: 60px;
    --sidebar-w: 60px;
  }
  .sidebar-logo .logo-text,
  .nav-item span:not(.nav-badge),
  .user-email-sidebar {
    display: none;
  }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-badge { margin-left: 0; position: absolute; top: 4px; right: 4px; font-size: 9px; padding: 0 4px; }
  .sidebar-footer { justify-content: center; padding: 12px 8px; }
  .user-pill { justify-content: center; }
  .main-content { margin-left: 60px; padding: 24px 20px; }
  .stats-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .section-top { flex-direction: column; }
  .section-top-actions { width: 100%; }
  .form-row-2 { grid-template-columns: 1fr; }
  .port-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .modal-dialog { margin: 12px; }
}

/* Overview app mini-cards */
.mini-app-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius);
  transition: background 0.15s var(--ease);
  cursor: pointer;
}
.mini-app-card:hover { background: var(--bg-3); }
.mini-app-info { display: flex; flex-direction: column; gap: 1px; }
.mini-app-name { font-size: 13px; font-weight: 500; }
.mini-app-url { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); }
.mini-app-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--fg-4);
}

/* App card title row with status badge */
.app-card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-status-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Health grid layout */
.health-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-0);
  border-radius: var(--radius-sm);
}

.health-label {
  font-size: 12px;
  color: var(--fg-3);
  font-weight: 500;
}

.health-value {
  font-size: 13px;
  color: var(--fg);
}

/* Health error section */
.health-error-section {
  margin-top: 16px;
  padding: 14px;
  background: var(--red-dim);
  border: 1px solid rgba(242, 92, 92, 0.2);
  border-radius: var(--radius);
}

.health-error-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--red);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
}

.health-error-detail {
  font-size: 12px;
  color: var(--fg-2);
  margin-top: 4px;
}

.health-suggestions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(242, 92, 92, 0.2);
}

.health-suggestions-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  margin-bottom: 8px;
}

.health-suggestions-list {
  list-style: disc;
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--fg-2);
}

.health-suggestions-list li {
  margin: 4px 0;
}

/* Logs container */
.logs-container {
  max-height: 60vh;
  overflow-y: auto;
}

.logs-pre {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--fg-2);
  margin: 0;
}

.logs-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--fg-3);
  font-size: 13px;
}

.logs-error {
  padding: 16px;
  background: var(--red-dim);
  border: 1px solid rgba(242, 92, 92, 0.3);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 13px;
}

.logs-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-4);
  margin: 12px 0 8px 0;
}

.logs-section-label:first-child {
  margin-top: 0;
}

/* Modal actions row */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}
