*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242736;
  --border: #2e3248;
  --accent: #4f7cff;
  --accent-hover: #6b93ff;
  --danger: #e05252;
  --danger-hover: #ef6464;
  --text: #e2e4f0;
  --text-muted: #7b8197;
  --success: #3dba7d;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-muted); }

label { display: block; margin-bottom: 5px; font-size: 13px; color: var(--text-muted); font-weight: 500; }
.field { margin-bottom: 16px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
}
button:active, .btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; font-size: 13px; padding: 7px 12px; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface2); }
.btn-success { background: var(--success); color: #fff; font-size: 13px; padding: 7px 12px; }
.btn-success:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 12px; }

.error-box { background: rgba(224,82,82,.15); border: 1px solid var(--danger); border-radius: var(--radius); color: #f08080; padding: 10px 14px; font-size: 14px; margin-bottom: 16px; }

.header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; height: 58px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.header .logo { font-weight: 700; font-size: 17px; letter-spacing: -.3px; }
.header .logo span { color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-user { color: var(--text-muted); font-size: 13px; }

.main { padding: 28px 24px; max-width: 1100px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.toolbar h2 { font-size: 20px; flex: 1; }

.connections-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.conn-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.conn-card-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-card-meta { font-size: 13px; color: var(--text-muted); font-family: monospace; }
.conn-card-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 60px 24px; color: var(--text-muted); }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 14px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 100%; max-width: 480px; box-shadow: var(--shadow); }
.modal h2 { font-size: 18px; margin-bottom: 24px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; font-size: 14px; box-shadow: var(--shadow); animation: slide-in .2s ease; max-width: 320px; }
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .header { padding: 0 16px; }
  .main { padding: 20px 16px; }
  .login-card { padding: 28px 20px; }
  .modal { padding: 24px 18px; }
}
