:root {
    --ui-bg: #f8f9fa;
    --ui-card: #ffffff;
    --ui-text: #1a1d21;
    --ui-muted: #64748b;
    --ui-border: #e2e8f0;
    --ui-accent: #2563eb;
    --ui-accent-hover: #1d4ed8;
    --ui-success: #16a34a;
    --ui-danger: #dc2626;
    --ui-header: #f1f5f9;
    --ui-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    --ui-shadow-soft: 0 4px 12px rgba(15, 23, 42, 0.05);
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--ui-bg);
    color: var(--ui-text);
}

.navbar,
.header,
.topbar,
.header-nav {
    background: var(--ui-card);
    border-bottom: 1px solid var(--ui-border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.navbar,
.header,
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo,
.topbar-brand,
.page-brand,
.title {
    font-weight: 800;
    letter-spacing: -0.01em;
}

.controls,
.nav-links,
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.nav-link,
.home-link,
.secondary-link {
    color: var(--ui-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: color 0.15s ease;
}

.nav-link:hover,
.home-link:hover,
.secondary-link:hover {
    color: var(--ui-accent);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--ui-card);
    border-bottom: 1px solid var(--ui-border);
    box-shadow: var(--ui-shadow);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header-main {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.app-title-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.app-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ui-text);
    margin: 0;
    white-space: nowrap;
}

.app-subtitle {
    font-size: 12px;
    color: var(--ui-muted);
    margin: 0;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.app-header-links {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.app-user {
    font-size: 13px;
    color: var(--ui-muted);
}

.app-link {
    color: var(--ui-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.app-link:hover {
    color: var(--ui-accent);
}

.app-page {
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
    padding: 12px;
}

.app-page.compact {
    padding: 8px;
}

.app-page.fill {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.app-page.narrow {
    max-width: 720px;
}

.app-page.standard {
    max-width: 1600px;
}

.app-page.wide {
    max-width: 1680px;
}

.app-card {
    background: var(--ui-card);
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    box-shadow: var(--ui-shadow);
    padding: 12px;
    box-sizing: border-box;
}

.app-card.soft {
    box-shadow: var(--ui-shadow-soft);
}

.app-layout-split {
    flex: 1;
    min-height: 0;
    display: flex;
}

.app-layout-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
}

.app-layout-sidebar {
    flex: 0 0 220px;
    min-width: 0;
    border-left: 1px solid var(--ui-border);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 12px 10px;
    overflow-y: auto;
}

.app-section {
    margin-bottom: 12px;
}

.app-section:last-child {
    margin-bottom: 0;
}

.app-button {
    border: 1px solid var(--ui-border);
    background: var(--ui-card);
    color: var(--ui-text);
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.app-button:hover {
    border-color: var(--ui-accent);
}

.app-button.primary {
    background: var(--ui-accent);
    border-color: var(--ui-accent);
    color: #fff;
}

.app-button.primary:hover {
    background: var(--ui-accent-hover);
    border-color: var(--ui-accent-hover);
}

.app-button.danger {
    background: var(--ui-danger);
    border-color: var(--ui-danger);
    color: #fff;
}

.app-button.ghost {
    background: transparent;
}

.app-select,
.app-input {
    border: 1px solid var(--ui-border);
    background: #fff;
    color: var(--ui-text);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
}

.app-select:hover,
.app-input:hover,
.app-select:focus,
.app-input:focus {
    border-color: var(--ui-accent);
    outline: none;
}

.app-statusbar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--ui-muted);
    background: var(--ui-card);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    padding: 6px 10px;
}

.app-statusbar.compact {
    width: fit-content;
}

.app-status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.strategy-card {
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
    animation: fadeIn 0.4s ease-out;
}

.strategy-header {
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ui-header);
    border-bottom: 1px solid var(--ui-border);
    cursor: pointer;
    user-select: none;
}

.strategy-header:hover {
    background-color: #e2e8f0;
}

.strategy-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.strategy-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ui-text);
}

.strategy-summary {
    font-size: 0.8125rem;
    color: var(--ui-muted);
    display: flex;
    gap: 1.25rem;
}

.strategy-body {
    padding: 1rem;
    display: none;
}

.strategy-card.expanded .strategy-body {
    display: block;
}

.strategy-card.expanded .toggle-icon {
    transform: rotate(180deg);
}

.toggle-icon {
    transition: transform 0.2s;
    color: var(--ui-muted);
}

.section-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ui-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 0 0.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--ui-border);
}

.section-content {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid var(--ui-border);
    margin-bottom: 1rem;
}

.table-shell {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table-shell th {
    background-color: var(--ui-header);
    color: var(--ui-muted);
    font-weight: 600;
    padding: 6px 8px;
    border-bottom: 1px solid var(--ui-border);
    white-space: nowrap;
    text-align: right;
}

.table-shell td {
    padding: 6px 8px;
    border-bottom: 1px solid #f1f5f9;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.table-shell tr:last-child td {
    border-bottom: none;
}

.table-shell td:first-child,
.table-shell th:first-child {
    text-align: left;
}

.table-shell tbody tr:hover td {
    background: #f8fafc;
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 0.75rem;
}

.grid-card {
    background: var(--ui-card);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    padding: 0.75rem;
}

.grid-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--ui-text);
    margin-bottom: 0.65rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.4rem;
}

.heatmap-table {
    border-spacing: 0;
    border-collapse: collapse;
}

.heatmap-table th {
    background: var(--ui-header);
    border: 1px solid var(--ui-border);
    padding: 4px 5px;
    font-size: 0.65rem;
    text-align: center;
}

.heatmap-table td {
    border: 1px solid var(--ui-border);
    padding: 6px 4px;
    font-size: 0.75rem;
    text-align: center;
    min-width: 65px;
}

.toggle-container {
    display: flex;
    align-items: center;
}

.toggle-label {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    gap: 8px;
}

.toggle-label input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background-color: #cbd5e1;
    border-radius: 20px;
    transition: 0.4s;
}

.toggle-switch:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: 0.4s;
}

input:checked + .toggle-switch {
    background-color: var(--ui-accent);
}

input:checked + .toggle-switch:before {
    transform: translateX(16px);
}

.toggle-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--ui-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #94a3b8;
    display: inline-block;
}

.status-dot.active {
    background: #22c55e;
    box-shadow: 0 0 5px rgba(34, 197, 94, 0.4);
}

.empty-state {
    text-align: center;
    color: var(--ui-muted);
    padding: 3rem 1rem;
}

.dashboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dashboard-list li + li {
    border-top: 1px solid var(--ui-border);
}

.dashboard-link {
    display: block;
    padding: 12px 6px;
    color: var(--ui-text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s ease, color 0.15s ease;
}

.dashboard-link:hover {
    background: var(--ui-header);
    color: var(--ui-accent);
}

.dashboard-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--ui-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ui-border);
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: linear-gradient(180deg, #eef4ff 0%, #f8fafc 100%);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--ui-card);
    border: 1px solid var(--ui-border);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
    padding: 24px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 18px;
}

.auth-brand .page-brand {
    display: block;
    font-size: 22px;
    margin-bottom: 4px;
}

.auth-brand .app-subtitle {
    display: block;
}

@media (max-width: 900px) {
    .app-header {
        align-items: flex-start;
    }

    .app-header,
    .app-header-main,
    .app-header-actions {
        flex-direction: column;
    }

    .app-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}
