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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #1a1a1a;
    background: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

/* Login */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: #f5f5f5;
}
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 360px;
    text-align: center;
}
.login-box h1 { margin-bottom: 8px; font-size: 24px; }
.login-box p { color: #666; margin-bottom: 24px; }
.login-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 12px;
}
.login-box button {
    width: 100%;
    padding: 10px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}
.login-box button:hover { background: #1d4ed8; }

/* Layout */
#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
#sidebar {
    width: 260px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
}
.sidebar-header h2 { font-size: 16px; }
.sidebar-header button {
    padding: 6px 12px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}
.sidebar-header button:hover { background: #1d4ed8; }
#table-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
#table-list li {
    padding: 10px 16px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.1s;
}
#table-list li:hover { background: #f0f4ff; }
#table-list li.active {
    background: #eff6ff;
    border-left-color: #2563eb;
    font-weight: 500;
}
#table-list li .table-meta {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
}
.sidebar-footer button {
    width: 100%;
    padding: 8px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #666;
    cursor: pointer;
    font-size: 13px;
}
.sidebar-footer button:hover { background: #f5f5f5; }

/* Main */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 16px;
}

/* Table view */
#table-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 8px;
}
.table-header h2 { font-size: 18px; }
.table-actions { display: flex; gap: 8px; }
.table-actions button {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
}
.table-actions button:hover { background: #f5f5f5; }
.table-info {
    padding: 0 20px 12px;
    color: #888;
    font-size: 12px;
    display: flex;
    gap: 16px;
}

/* Grid */
.grid-wrapper {
    flex: 1;
    overflow: auto;
    padding: 0 20px;
}
#data-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
#data-grid th {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: #555;
    white-space: nowrap;
    z-index: 1;
}
#data-grid td {
    border: 1px solid #e0e0e0;
    padding: 0;
    max-width: 300px;
    height: 36px;
}
#data-grid td.cell-checkbox {
    width: 36px;
    text-align: center;
    padding: 8px;
}
#data-grid td .cell-display {
    padding: 8px 12px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 20px;
}
#data-grid td .cell-display:hover { background: #f0f4ff; }
#data-grid td input.cell-edit {
    width: 100%;
    height: 100%;
    padding: 8px 12px;
    border: 2px solid #2563eb;
    outline: none;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
}
#data-grid tr.new-row td { background: #f0fff4; }
#data-grid th.col-id { width: 60px; }

/* Table footer */
.table-footer {
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
}
.table-footer button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
}
.table-footer button:hover { background: #f5f5f5; }

/* Danger button */
.btn-danger { color: #dc2626 !important; border-color: #fca5a5 !important; }
.btn-danger:hover { background: #fef2f2 !important; }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-content {
    background: #fff;
    border-radius: 8px;
    width: 480px;
    max-width: 90vw;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}
.modal-header h3 { font-size: 16px; }
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #999;
    padding: 0 4px;
}
.modal-close:hover { color: #333; }
.form-group {
    padding: 16px 20px 0;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #555;
}
.form-group input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 20px;
}
.form-actions button {
    padding: 8px 20px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}
.form-actions button[type="button"] {
    background: #fff;
    border: 1px solid #ddd;
    color: #333;
}
.form-actions button[type="submit"] {
    background: #2563eb;
    border: none;
    color: #fff;
}
.form-actions button[type="submit"]:hover { background: #1d4ed8; }

/* Drop zone */
.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 6px;
    padding: 30px;
    text-align: center;
    color: #999;
    cursor: pointer;
    transition: border-color 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: #2563eb;
    color: #2563eb;
}
.file-name {
    padding: 8px 0 0;
    font-size: 13px;
    color: #2563eb;
}

/* Error */
.error {
    color: #dc2626;
    font-size: 13px;
    padding: 12px 20px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }
