:root {
    --bg: #0f172a;
    --bg-2: #1e293b;
    --panel: #1e293b;
    --border: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --primary: #3b82f6;
    --primary-2: #2563eb;
    --danger: #ef4444;
    --ok: #10b981;
    --warn: #f59e0b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #0b1220; padding: 2px 6px; border-radius: 4px; color: #93c5fd; }
small { color: var(--muted); }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: var(--bg-2); border-bottom: 1px solid var(--border); }
.topbar .brand { font-size: 18px; font-weight: 600; }
.topbar .brand small { color: var(--muted); font-weight: normal; margin-left: 4px; }
.topbar .user { display: flex; gap: 12px; align-items: center; }
.btn-ghost { color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.btn-ghost:hover { background: var(--border); color: var(--text); }

.app { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 220px; background: var(--bg-2); border-right: 1px solid var(--border); padding: 16px 0; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--muted); }
.sidebar nav a.active, .sidebar nav a:hover { background: rgba(59,130,246,.1); color: var(--text); text-decoration: none; border-left: 3px solid var(--primary); padding-left: 17px; }
.sidebar .badge { margin-left: auto; background: var(--danger); color: white; font-size: 11px; padding: 2px 7px; border-radius: 999px; }

.content { flex: 1; padding: 24px; overflow-x: auto; }
.content h1 { margin: 0 0 20px; font-size: 24px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 12px; font-size: 16px; color: var(--text); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.card-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.card-value { font-size: 28px; font-weight: 600; margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: #0b1220; border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 6px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { font-family: 'Fira Code', Consolas, monospace; }
button { background: var(--primary); color: white; border: 0; padding: 9px 16px; border-radius: 6px; cursor: pointer; }
button:hover { background: var(--primary-2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: #475569; color: #fff; }
.btn-secondary:hover { background: #334155; }
.btn-small { padding: 4px 8px; font-size: 12px; }
.btn-group-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; }

.row-flex { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.row-flex input { flex: 1; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form-grid label input, .form-grid label select { color: var(--text); font-size: 14px; }
.form-actions { grid-column: 1 / -1; text-align: right; }

.list-clean { list-style: none; padding: 0; margin: 0; max-height: 400px; overflow-y: auto; }
.list-clean li { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); }
.list-clean li:last-child { border-bottom: 0; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 8px; background: #0b1220; color: var(--muted); border-bottom: 1px solid var(--border); font-weight: 600; }
.data-table td { padding: 8px; border-bottom: 1px solid var(--border); max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table tr:hover td { background: rgba(59,130,246,.05); }
.table-wrap { overflow-x: auto; }

.sql-history { list-style: none; padding: 0; margin: 0; }
.sql-history li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.sql-history code { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.alert-ok     { background: rgba(16,185,129,.12); color: #6ee7b7; border: 1px solid #10b981; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.alert-error  { background: rgba(239,68,68,.12);  color: #fca5a5; border: 1px solid var(--danger); padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.muted { color: var(--muted); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .3px; }
.pill-ok    { background: rgba(16,185,129,.18); color: #6ee7b7; }
.pill-info  { background: rgba(59,130,246,.18); color: #93c5fd; }
.pill-warn  { background: rgba(245,158,11,.18); color: #fcd34d; }
.pill-error { background: rgba(239,68,68,.18);  color: #fca5a5; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--panel); padding: 32px; border-radius: 10px; width: 360px; border: 1px solid var(--border); }
.login-card h1 { margin: 0 0 20px; font-size: 22px; text-align: center; }
.login-card h1 small { color: var(--muted); font-weight: normal; }
.login-card label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.login-card label input { margin-top: 4px; }
.login-card button { width: 100%; margin-top: 8px; }
