:root {
    --bg: #0f1419;
    --panel: #171e27;
    --panel-2: #1d2631;
    --line: #2a3544;
    --text: #e8eef6;
    --muted: #93a1b3;
    --accent: #3d9cf0;
    --accent-2: #1f6feb;
    --danger: #f07178;
    --ok: #7fd99a;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: radial-gradient(1200px 600px at 10% -10%, #1a2a3d 0%, var(--bg) 45%);
    color: var(--text);
}

.app { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
    background: rgba(20, 27, 36, 0.95);
    border-right: 1px solid var(--line);
    padding: 18px 12px;
    overflow: auto;
}
.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    color: inherit;
    text-decoration: none;
    padding: 8px 8px 18px;
}
.logo {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    font-weight: 800;
    letter-spacing: 0.04em;
}
.brand small { display: block; color: var(--muted); font-size: 12px; }
.side-label {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 8px;
}
.side-empty { color: var(--muted); padding: 8px; line-height: 1.5; }
.table-nav { display: flex; flex-direction: column; gap: 4px; }
.table-link {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
}
.table-link:hover, .table-link.active { background: var(--panel-2); }
.t-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-count { color: var(--muted); font-size: 12px; }

.main { padding: 22px 28px 40px; min-width: 0; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: 28px; font-weight: 700; }

.btn {
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-weight: 600;
}
.btn.primary {
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    border-color: transparent;
}
.btn.danger { border-color: #5a2a32; color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.export {
    background: #1b7a48;
    border-color: transparent;
    justify-content: center;
}
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.card, .upload-card, .stats article, .table-card {
    background: rgba(23, 30, 39, 0.9);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.upload-card { padding: 24px; }
.dropzone {
    border: 1.5px dashed #3b4d63;
    border-radius: 16px;
    padding: 48px 20px;
    text-align: center;
    position: relative;
}
.dropzone.drag { border-color: var(--accent); background: rgba(61, 156, 240, 0.08); }
.dropzone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.drop-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #223246;
    font-size: 28px;
}
.dropzone h2 { margin: 0 0 8px; }
.dropzone p { color: var(--muted); }
.hidden { display: none !important; }
.progress-wrap { margin-top: 22px; }
.progress-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.bar {
    height: 12px;
    background: #223246;
    border-radius: 999px;
    overflow: hidden;
}
.bar span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--ok));
    transition: width 0.2s ease;
}
.help { margin-top: 28px; color: var(--muted); }
.help ol { line-height: 1.8; }
code {
    background: #223246;
    padding: 2px 6px;
    border-radius: 6px;
    color: #d7e6ff;
}
.muted { color: var(--muted); }

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
.stats article { padding: 16px 18px; }
.stats small { color: var(--muted); }
.stats strong { display: block; margin-top: 6px; font-size: 22px; overflow-wrap: anywhere; }

.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.table-card {
    padding: 18px;
    color: inherit;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.table-card:hover { border-color: var(--accent); }
.table-card .card-main {
    color: inherit;
    text-decoration: none;
}
.table-card h3 { margin: 0 0 8px; overflow-wrap: anywhere; }
.table-card p { margin: 0; color: var(--muted); }
.table-card .btn.export { align-self: flex-start; padding: 8px 12px; font-size: 13px; }

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.search { display: flex; gap: 8px; }
.search input {
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    min-width: 280px;
}
.grid-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(23, 30, 39, 0.9);
}
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data th, table.data td {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
    white-space: pre-wrap;
    max-width: 420px;
}
table.data th {
    position: sticky;
    top: 0;
    background: #202a36;
    z-index: 1;
}
.row-num { color: var(--muted); width: 48px; }
td.null { color: #6f7f93; font-style: italic; }
.pager {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
}

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 280px; }
    .stats { grid-template-columns: 1fr 1fr; }
    .search input { min-width: 160px; }
}
