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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    color: #333;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: #2c3e50;
}

.form-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.form-box h2 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.form-box input {
    width: 100%;
    padding: 12px;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-box button {
    width: 100%;
    padding: 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.form-box button:hover {
    background: #2980b9;
}

.error-message {
    color: #e74c3c;
    margin-top: 1rem;
    display: none;
}

.error-message.show {
    display: block;
}

/* Main Layout */
.layout {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 280px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.5rem;
    background: #34495e;
    border-bottom: 1px solid #1a252f;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.logout-btn {
    padding: 8px 16px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.logout-btn:hover {
    background: #c0392b;
}

.nav-menu {
    padding: 1rem;
    border-bottom: 1px solid #1a252f;
}

.nav-item {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 0.5rem;
    background: transparent;
    color: white;
    border: none;
    border-radius: 4px;
    text-align: left;
    cursor: pointer;
    transition: background 0.3s;
}

.nav-item:hover {
    background: #34495e;
}

.nav-item.active {
    background: #3498db;
}

.db-tree {
    padding: 1rem;
    flex: 1;
}

.db-tree h3 {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    opacity: 0.7;
    text-transform: uppercase;
}

#database-list {
    font-size: 0.9rem;
}

.db-item {
    padding: 8px 12px;
    margin-bottom: 4px;
    background: #34495e;
    border-radius: 4px;
    cursor: pointer;
}

.db-item:hover {
    background: #3d566e;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: #f5f5f5;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.main-content h2 {
    margin-bottom: 2rem;
    color: #2c3e50;
}

.section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.section h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.section button,
.create-section button {
    padding: 10px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.section button:hover,
.create-section button:hover {
    background: #2980b9;
}

.section label,
.create-section label {
    margin-right: 1rem;
}

.section select,
.create-section select,
.create-section input[type="text"],
.create-section input[type="password"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
    margin-right: 0.5rem;
}

.data-grid {
    margin-top: 1rem;
    overflow-x: auto;
}

.data-grid table {
    width: 100%;
    border-collapse: collapse;
}

.data-grid th,
.data-grid td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.data-grid th {
    background: #ecf0f1;
    font-weight: 600;
    color: #2c3e50;
}

.data-grid tr:hover {
    background: #f8f9fa;
}

.data-grid button {
    padding: 6px 12px;
    margin-right: 0.5rem;
    font-size: 0.85rem;
}

.table-actions {
    margin-bottom: 1rem;
}

.pagination {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* SQL View */
#sql-editor {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.result-box {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 1rem;
}

.result-success {
    color: #27ae60;
    padding: 1rem;
    background: #d5f4e6;
    border-radius: 4px;
}

.result-error {
    color: #e74c3c;
    padding: 1rem;
    background: #fadbd8;
    border-radius: 4px;
}

/* Create View */
.create-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.create-section h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.create-section input[type="text"],
.create-section input[type="password"] {
    width: 100%;
    max-width: 400px;
}

.column-row {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr auto auto auto auto;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.column-row input,
.column-row select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.column-row button {
    padding: 8px 12px;
}

/* Settings View */
.settings-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.settings-section h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

#2fa-qr img {
    margin: 1rem 0;
}

#2fa-secret {
    background: #ecf0f1;
    padding: 8px 12px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 1rem;
}

.modal-content input[type="file"] {
    margin: 1rem 0;
}

.modal-content button {
    padding: 10px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 0.5rem;
}

.modal-content button:hover {
    background: #2980b9;
}

.close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #000;
}

.form-row {
    margin-bottom: 1rem;
}

.form-row label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
    }

    .db-tree {
        display: none;
    }

    .column-row {
        grid-template-columns: 1fr;
    }
}
