:root {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --text: #172033;
    --muted: #64748b;
    --border: #dfe5ed;
    --primary: #2563eb;
    --sidebar: #111c30;
    --input: #ffffff;
    --hover: #f8fafc;
}

[data-theme="dark"] {
    --bg: #0b1120;
    --panel: #131e30;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #2d3b50;
    --primary: #3b82f6;
    --input: #0f172a;
    --hover: #1e293b;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.sidebar {
    width: 245px;
    position: fixed;
    inset: 0 auto 0 0;
    background: var(--sidebar);
    color: white;
    padding: 24px 16px;
    overflow-y: auto;
}

.logo {
    font-weight: 800;
    font-size: 22px;
    padding: 0 10px;
}

.subtitle {
    font-size: 11px;
    color: #94a3b8;
    padding: 0 10px;
    margin-bottom: 35px;
}

.nav-link {
    display: block;
    color: #b7c5d9;
    padding: 12px 15px;
    margin: 5px 0;
    border-radius: 8px;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background: #233654;
    color: white;
}

.main {
    margin-left: 245px;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--panel);
    padding: 15px 28px;
    border-bottom: 1px solid var(--border);
}

.content {
    padding: 28px;
    max-width: 1800px;
    margin: auto;
}

h1 {
    font-size: 27px;
    margin: 0 0 5px;
}

h2 {
    font-size: 18px;
    margin: 0 0 18px;
}

.muted, small {
    color: var(--muted);
}

.page-title {
    margin-bottom: 25px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    min-width: 0;
}

.grid .card {
    margin: 0;
}

.metric {
    font-size: 32px;
    font-weight: 750;
    margin: 8px 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border: 0;
    padding: 9px 15px;
    border-radius: 7px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(1.1);
}

.btn-secondary {
    background: var(--hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-sm {
    font-size: 12px;
    padding: 7px 10px;
}

input, select {
    background: var(--input);
    color: var(--text);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font: inherit;
    max-width: 100%;
}

input:not([type="checkbox"]):not([type="file"]),
select {
    width: 100%;
}

input:focus, select:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

label {
    font-weight: 600;
    display: block;
    margin-bottom: 7px;
}

.field {
    margin-bottom: 20px;
}

.actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
}

.actions form {
    margin: 0;
}

.between {
    justify-content: space-between;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    background: var(--hover);
}

tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: var(--hover);
}

.nowrap {
    white-space: nowrap;
}

.badge {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 650;
    background: #e2e8f0;
    color: #334155;
}

.success {
    background: #dcfce7;
    color: #166534;
}

.failed, .danger {
    background: #fee2e2;
    color: #991b1b;
}

.running {
    background: #dbeafe;
    color: #1e40af;
}

.queued {
    background: #fef3c7;
    color: #92400e;
}

.alert {
    padding: 14px 18px;
    border-radius: 9px;
    margin-bottom: 20px;
    overflow-wrap: anywhere;
}

.login-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-card {
    max-width: 420px;
    width: 100%;
    padding: 35px;
}

.progress {
    height: 9px;
    background: var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin: 7px 0 18px;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
}

.search-form {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.price {
    font-weight: 700;
    white-space: nowrap;
}

.form-box {
    max-width: 800px;
}

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

.source-grid .card {
    margin: 0;
}

.error-text {
    max-width: 350px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    font-size: 12px;
}

@media (max-width: 1100px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 760px) {
    .sidebar {
        position: static;
        width: 100%;
        padding: 15px;
    }

    .subtitle {
        margin-bottom: 15px;
    }

    .sidebar nav {
        display: flex;
        flex-wrap: wrap;
    }

    .nav-link {
        padding: 8px 10px;
    }

    .main {
        margin-left: 0;
    }

    .content {
        padding: 15px;
    }

    .topbar {
        padding: 12px 15px;
    }

    .source-grid,
    .search-form {
        grid-template-columns: 1fr;
    }

    .metric {
        font-size: 25px;
    }
}
