:root {
    --bg-1: #0f172a;
    --bg-2: #1e293b;
    --surface: rgba(248, 250, 252, 0.94);
    --surface-strong: #ffffff;
    --text: #0f172a;
    --muted: #475569;
    --accent: #0ea5a4;
    --accent-2: #f59e0b;
    --danger: #dc2626;
    --border: #d9e2ec;
    --highlight: #ecfeff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: 'Source Sans 3', sans-serif;
    background: radial-gradient(circle at 10% 10%, #1d4ed8 0%, transparent 35%),
        radial-gradient(circle at 90% 80%, #ea580c 0%, transparent 30%),
        linear-gradient(145deg, var(--bg-1), var(--bg-2));
}

.background-shape {
    position: fixed;
    inset: 0;
    background-image: linear-gradient(120deg, rgba(255, 255, 255, 0.06) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0.06) 75%, transparent 75%, transparent);
    background-size: 72px 72px;
    opacity: 0.24;
    pointer-events: none;
}

.shell {
    width: min(1180px, 94vw);
    margin: 32px auto;
    display: grid;
    gap: 18px;
    position: relative;
    z-index: 1;
}

.hero {
    background: linear-gradient(120deg, rgba(15, 23, 42, 0.82), rgba(30, 41, 59, 0.82));
    color: #f8fafc;
    border-radius: 18px;
    border: 1px solid rgba(248, 250, 252, 0.2);
    padding: 24px;
    animation: reveal 360ms ease-out;
}

.hero h1 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 0.2px;
    font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.hero p {
    margin: 8px 0 0;
    color: #dbeafe;
}

.card {
    background: var(--surface);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.15);
    animation: reveal 460ms ease-out;
}

h2,
h3 {
    margin: 0 0 10px;
    font-family: 'Space Grotesk', sans-serif;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field span {
    color: var(--muted);
    font-weight: 600;
}

select,
.btn {
    min-height: 44px;
    border-radius: 10px;
    font-size: 0.98rem;
}

select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
}

.actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    border: none;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn.primary {
    color: #f8fafc;
    background: linear-gradient(135deg, #0891b2, #0f766e);
}

.btn.secondary {
    color: #111827;
    background: linear-gradient(135deg, #fde68a, #f59e0b);
}

.btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

.status {
    min-height: 22px;
    margin: 10px 0 0;
    font-weight: 600;
}

.status.error {
    color: var(--danger);
}

.status.ok {
    color: #047857;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-strong);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

th,
td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #edf2f7;
    vertical-align: top;
}

th {
    background: #e2e8f0;
    color: #1e293b;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
}

.sort-btn {
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.sort-btn.active {
    color: #0f766e;
}

.sort-btn::after {
    content: ' \2195';
    font-size: 0.8rem;
    opacity: 0.7;
}

.sort-btn.active.asc::after {
    content: ' \2191';
}

.sort-btn.active.desc::after {
    content: ' \2193';
}

tbody tr:nth-child(even) {
    background: #f8fafc;
}

tr.selected {
    background: var(--highlight) !important;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 18px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.meta-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
}

.meta-item .k {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

.meta-item .v {
    font-weight: 700;
    word-break: break-word;
}

.subsection {
    margin-top: 8px;
}

.loader {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    color: #f8fafc;
    font-family: 'Space Grotesk', sans-serif;
}

.loader.hidden {
    display: none;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 255, 255, 0.35);
    border-top-color: #f8fafc;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 840px) {
    .shell {
        width: min(96vw, 1180px);
        margin: 16px auto 20px;
    }

    .control-grid {
        grid-template-columns: 1fr;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}