:root {
    --bg-deep: #020617;
    --bg-elevated: #0f172a;
    --bg-card: #111827;
    --bg-input: #1e293b;
    --fg-primary: #f8fafc;
    --fg-secondary: #cbd5e1;
    --fg-muted: #94a3b8;
    --accent-cyan: #06b6d4;
    --accent-cyan-glow: rgba(6, 182, 212, 0.25);
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.2);
    --accent-amber: #f59e0b;
    --accent-amber-glow: rgba(245, 158, 11, 0.2);
    --accent-red: #ef4444;
    --accent-pink: #ec4899;
    --accent-pink-glow: rgba(236, 72, 153, 0.2);
    --accent-violet: #8b5cf6;
    --accent-violet-glow: rgba(139, 92, 246, 0.2);
    --border-color: #1e293b;
    --border-light: #334155;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 4px 24px rgba(0,0,0,0.3), 0 1px 4px rgba(0,0,0,0.2);
    --transition: 200ms ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-deep);
    color: var(--fg-primary);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(236,72,153,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(139,92,246,0.04) 0%, transparent 50%);
}

.app-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 20px 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    flex-shrink: 0;
}

.app-header-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-violet));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-pink-glow);
}

.app-header h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--fg-primary), var(--fg-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header p {
    font-size: 13px;
    color: var(--fg-muted);
    margin-top: 2px;
}

.header-link {
    color: var(--fg-muted);
    text-decoration: none;
    font-size: 13px;
    transition: color var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.header-link:hover { color: var(--accent-pink); }

/* Section Card */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
    transition: border-color var(--transition);
    position: relative;
}

.section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(236,72,153,0.08) 0%, var(--bg-elevated) 60%);
    border-bottom: 1px solid var(--border-color);
    border-top: 2px solid rgba(236,72,153,0.25);
    border-radius: var(--radius) var(--radius) 0 0;
    position: relative;
}

.section-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--fg-primary);
}

.section-card-title i {
    color: var(--accent-pink);
    font-size: 20px;
}

.section-card-body {
    padding: 24px;
}

/* Tips */
.tips-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(236, 72, 153, 0.12);
    border: 1px solid rgba(236, 72, 153, 0.25);
    color: #ec4899;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.tips-btn:hover {
    background: rgba(236, 72, 153, 0.25);
    border-color: #ec4899;
    box-shadow: 0 0 12px rgba(236, 72, 153, 0.3);
    transform: scale(1.08);
}

.tips-btn:active { transform: scale(0.95); }

.tips-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 100;
}
.tips-backdrop.active { display: block; }

.tips-popover {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 600px;
    width: 600px;
    max-width: calc(100vw - 48px);
    resize: horizontal;
    overflow: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 200;
    animation: tipsEnter 250ms ease;
}
.tips-popover.active { display: block; }

.tips-popover::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 14px;
    height: 14px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    border-left: 1px solid var(--border-light);
    transform: rotate(45deg);
}

.tips-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}

.tips-popover-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--fg-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.tips-popover-title i { color: #ec4899; font-size: 15px; }

.tips-popover-close {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-input);
    color: var(--fg-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.tips-popover-close:hover { background: var(--accent-red); color: #fff; }

.tips-popover-body {
    padding: 18px;
    font-size: 12px;
    color: var(--fg-secondary);
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}
.tips-popover-body p { margin-bottom: 10px; }
.tips-popover-body p:last-child { margin-bottom: 0; }

.tips-placeholder {
    font-size: 12px;
    color: var(--fg-muted);
    line-height: 1.6;
    font-style: italic;
}

@keyframes tipsEnter {
    from { opacity: 0; transform: translateY(-8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Action Grid */
.action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.action-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.action-card:hover {
    border-color: var(--border-light);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.action-card--danger {
    border-left: 3px solid var(--accent-red);
}

.action-card--danger:hover {
    border-color: var(--accent-red);
    box-shadow: 0 2px 12px var(--accent-red-glow);
}

.action-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--fg-muted);
    flex-shrink: 0;
}

.action-card--danger .action-card-icon {
    background: rgba(239,68,68,0.12);
    color: var(--accent-red);
}

.action-card-info {
    flex: 1;
    min-width: 0;
}

.action-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--fg-primary);
    margin-bottom: 2px;
}

.action-card-desc {
    font-size: 12px;
    color: var(--fg-muted);
    line-height: 1.4;
}

.action-card .btn {
    flex-shrink: 0;
    width: 130px;
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
}

/* SQL Link Card */
.sql-link-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    text-decoration: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    cursor: pointer;
}

.sql-link-card:hover {
    border-color: var(--accent-violet);
    box-shadow: 0 4px 16px var(--accent-violet-glow);
}

.sql-link-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(236,72,153,0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--accent-violet);
    flex-shrink: 0;
}

.sql-link-info {
    flex: 1;
}

.sql-link-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--fg-primary);
    margin-bottom: 2px;
}

.sql-link-desc {
    font-size: 13px;
    color: var(--fg-muted);
}

.sql-link-arrow {
    color: var(--fg-muted);
    font-size: 14px;
    transition: color var(--transition), transform var(--transition);
}

.sql-link-card:hover .sql-link-arrow {
    color: var(--accent-violet);
    transform: translateX(3px);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    height: 42px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-red-glow);
}
.btn-danger:hover { box-shadow: 0 4px 20px var(--accent-red-glow); }

.btn-amber {
    background: linear-gradient(135deg, var(--accent-amber), #d97706);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-amber-glow);
}
.btn-amber:hover { box-shadow: 0 4px 20px var(--accent-amber-glow); }

.btn-violet {
    background: linear-gradient(135deg, var(--accent-violet), #7c3aed);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-violet-glow);
}
.btn-violet:hover { box-shadow: 0 4px 20px var(--accent-violet-glow); }

.btn-emerald {
    background: linear-gradient(135deg, var(--accent-emerald), #059669);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-emerald-glow);
}
.btn-emerald:hover { box-shadow: 0 4px 20px var(--accent-emerald-glow); }

.btn-cyan {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: #fff;
    box-shadow: 0 2px 12px rgba(6,182,212,0.25);
}
.btn-cyan:hover { box-shadow: 0 4px 20px rgba(6,182,212,0.35); }

.btn-ghost {
    background: var(--bg-input);
    color: var(--fg-secondary);
    border: 1px solid var(--border-color);
}
.btn-ghost:hover { background: var(--border-color); color: var(--fg-primary); }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 200ms ease;
}
.modal-overlay.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    width: 520px;
    max-width: 95vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: slideUp 250ms ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-input);
    color: var(--fg-muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--accent-red); color: #fff; }

.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.confirm-text {
    font-size: 15px;
    color: var(--fg-secondary);
    line-height: 1.6;
    text-align: center;
    padding: 8px 0;
}
.confirm-text strong { color: var(--accent-red); }

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.form-label i {
    margin-right: 4px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--fg-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    color-scheme: dark;
}

.form-input:focus {
    border-color: var(--accent-pink);
    box-shadow: 0 0 0 3px var(--accent-pink-glow);
}

.toggle-eye {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--fg-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    transition: color var(--transition);
}
.toggle-eye:hover {
    color: var(--fg-primary);
}



.tips-markdown {
    font-size: 12px;
    color: var(--fg-secondary);
    line-height: 1.6;
}

.tips-markdown h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-amber);
    margin: 0 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.tips-markdown h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin: 14px 0 8px 0;
}

.tips-markdown strong {
    color: var(--accent-amber);
    font-weight: 700;
}

.tips-markdown em {
    color: var(--fg-primary);
    font-style: italic;
}

.tips-markdown code {
    font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    background: var(--bg-deep);
    color: var(--accent-emerald);
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

/* Markdown Tables */
.tips-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 12px;
}

.tips-table tr:first-child {
    background: var(--bg-elevated);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 11px;
    color: var(--accent-amber);
}

.tips-table tr:first-child td {
    border-bottom: 2px solid var(--accent-amber);
    padding: 8px 12px;
}

.tips-table tr {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition);
}

.tips-table tr:hover {
    background: rgba(236, 72, 153, 0.04);
}

.tips-table tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.3);
}

.tips-table tr:nth-child(even):hover {
    background: rgba(236, 72, 153, 0.06);
}

.tips-table td {
    padding: 8px 12px;
    vertical-align: top;
    color: var(--fg-secondary);
}

.tips-table td:first-child {
    font-weight: 700;
    color: var(--fg-primary);
    width: 40px;
    text-align: center;
}

.tips-table tr:not(:first-child) td:nth-child(2) {
    font-weight: 600;
    color: var(--fg-primary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); }

/* Responsive */
@media (max-width: 768px) {
    .app-wrapper { padding: 20px 16px 40px; }
    .app-header { flex-direction: column; align-items: flex-start; gap: 14px; }
    .app-header-right { flex-wrap: wrap; }
    .action-grid { grid-template-columns: 1fr; }
    .action-card { flex-direction: column; align-items: flex-start; gap: 10px; }
    .action-card .btn { width: 100%; }
}

/* Toast */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--accent-emerald);
    border-left: 4px solid var(--accent-emerald);
    border-radius: var(--radius-sm);
    color: #6ee7b7;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    opacity: 0;
    transform: translateX(40px);
    transition: all 300ms ease;
}

.toast i { color: var(--accent-emerald); font-size: 16px; }

.toast-show {
    opacity: 1;
    transform: translateX(0);
}