@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    --bg: #f8f9fc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --accent: #0ea5e9;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.03);
    --radius: 10px;
    --radius-sm: 6px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Navbar */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.92);
}

.nav-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-link:hover {
    color: var(--text);
    background: var(--bg);
}

.nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
}

/* Container */
.container {
    max-width: 860px;
    margin: 32px auto;
    padding: 0 20px;
}

/* Tabs */
.tab-content { display: none; }
.tab-content.active { display: block; }

h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
    letter-spacing: -0.3px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s ease;
    text-decoration: none;
    gap: 6px;
    line-height: 1.4;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); color: var(--text); }

.btn-danger {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--border);
}
.btn-danger:hover { background: var(--danger-light); border-color: var(--danger); }

.btn-copy {
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.9);
    border-color: rgba(255,255,255,0.2);
}
.btn-copy:hover { background: rgba(255,255,255,0.25); color: white; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 18px; }

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text);
    font-size: 13px;
}

.required { color: var(--danger); }

input[type="text"],
input[type="url"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

small {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

.checkbox-group {
    margin: 18px 0;
    padding: 12px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.checkbox-group label {
    display: inline;
    font-weight: 400;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* Info box */
.info-box {
    background: var(--primary-light);
    border: 1px solid #c7d2fe;
    padding: 16px;
    margin-bottom: 24px;
    border-radius: var(--radius);
}

.info-box h4 { color: var(--primary); margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.info-box p { font-size: 13px; margin-bottom: 4px; color: var(--text-secondary); }
.info-box p:last-child { margin-bottom: 0; }

/* Database list */
.database-list { display: flex; flex-direction: column; gap: 8px; }

.db-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.db-card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-md);
}

.db-info { min-width: 0; flex: 1; }
.db-info h3 { font-size: 14px; font-weight: 600; margin-bottom: 2px; color: var(--text); }
.db-info p { font-size: 12px; color: var(--text-secondary); margin: 1px 0; }
.db-info .mono { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 11px; color: var(--text-muted); }

.db-actions { display: flex; gap: 6px; flex-shrink: 0; margin-left: 16px; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

/* Success panel */
.success-panel {
    background: var(--success-light);
    border: 1px solid #a7f3d0;
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 24px;
}

.success-panel h3 { color: #065f46; margin-bottom: 8px; font-size: 15px; }
.success-panel p { font-size: 13px; color: #047857; }

/* SQL code block */
.sql-code {
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 12px 0;
    position: relative;
    overflow-x: auto;
}

.sql-code pre {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    margin: 0;
}

.sql-code .btn-copy {
    position: absolute;
    top: 8px;
    right: 8px;
}

/* Health results */
.health-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.health-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px;
    text-align: center;
}

.health-stat .count {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.health-stat .label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.health-stat.success { border-color: #a7f3d0; background: var(--success-light); }
.health-stat.success .count { color: var(--success); }

.health-stat.partial { border-color: #fde68a; background: var(--warning-light); }
.health-stat.partial .count { color: var(--warning); }

.health-stat.failure { border-color: #fecaca; background: var(--danger-light); }
.health-stat.failure .count { color: var(--danger); }

.health-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.15s ease;
}

.health-card:hover { border-color: #cbd5e1; }

.health-card .db-detail { min-width: 0; flex: 1; }
.health-card .db-detail strong { font-size: 14px; font-weight: 600; }
.health-card .db-detail .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.status-badge.success { background: #d1fae5; color: #065f46; }
.status-badge.partial { background: #fef3c7; color: #92400e; }
.status-badge.failure { background: #fee2e2; color: #991b1b; }
.status-badge.unknown { background: #f1f5f9; color: #64748b; }

.health-timestamp {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 18px;
    font-weight: 500;
}

.health-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 20px 0 8px 0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 28px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.modal-close:hover { color: var(--text); background: var(--bg); }

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Loading */
.loading { color: var(--text-muted); font-size: 13px; }

/* Password page */
.password-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.password-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 380px;
}

.password-card .logo {
    text-align: center;
    margin-bottom: 28px;
}

.password-card .logo h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.password-card .logo p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

.password-card .submit-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    padding: 11px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.15s ease;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3);
}

.password-card .submit-btn:hover { background: var(--primary-hover); }
.password-card .submit-btn:disabled { opacity: 0.5; }

.error-message {
    background: var(--danger-light);
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin: 14px 0;
    display: none;
    font-size: 13px;
}

.success-message {
    background: var(--success-light);
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin: 14px 0;
    display: none;
    font-size: 13px;
}

.security-info {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 12px 14px;
    margin-top: 20px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-muted);
}

.security-info h4 {
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 640px) {
    .navbar { padding: 0 16px; }
    .nav-links { gap: 2px; }
    .nav-link { padding: 6px 10px; font-size: 12px; }
    .container { margin: 20px auto; }
    .health-summary { grid-template-columns: 1fr; }
    .db-card { flex-direction: column; align-items: flex-start; gap: 12px; }
    .db-actions { margin-left: 0; }
}
