*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: #0f1419;
    color: #e7ecf3;
    min-width: 1200px;
}

.header {
    padding: 1rem 2rem;
    background: #1a2332;
    border-bottom: 1px solid #2d3a4d;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.header-actions form {
    margin: 0;
}

.utc-clock {
    font-size: 0.875rem;
    color: #9fb0c7;
    font-variant-numeric: tabular-nums;
}

.main {
    padding: 1.5rem 2rem 3rem;
    max-width: 1400px;
    margin: 0 auto;
}

.filters,
.actions,
.table-section,
.chart-section {
    margin-bottom: 1.5rem;
}

.table-section {
    min-width: 0;
    overflow: hidden;
}

.filters h2,
.table-section h2,
.chart-section h2 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: #9fb0c7;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.filters-header h2 {
    margin: 0;
}

.filter-form {
    display: flex;
    gap: 1rem;
}

.filter-group {
    flex: 1;
    min-width: 180px;
    margin: 0;
    padding: 0.75rem;
    border: 1px solid #2d3a4d;
    border-radius: 6px;
    background: #1a2332;
}

.filter-group legend {
    padding: 0 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #9fb0c7;
}

.filter-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 8rem;
    overflow-y: auto;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #e7ecf3;
    cursor: pointer;
}

.filter-checkbox input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

.filter-checkbox span {
    line-height: 1.3;
}

select {
    min-width: 180px;
    padding: 0.5rem 0.75rem;
    background: #1a2332;
    color: #e7ecf3;
    border: 1px solid #2d3a4d;
    border-radius: 6px;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

.btn-primary {
    background: #3b82f6;
    color: #fff;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #2d3a4d;
    color: #e7ecf3;
}

.btn-secondary:hover:not(:disabled) {
    background: #3d4f66;
}

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

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

.status-text {
    font-size: 0.85rem;
    color: #9fb0c7;
}

.rates-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: #1a2332;
    border-radius: 8px;
    overflow: hidden;
}

#rates-table {
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.rates-table th,
.rates-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #2d3a4d;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rates-table th {
    background: #141c28;
    color: #9fb0c7;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rates-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.rates-table th.sortable:hover {
    color: #e7ecf3;
}

.rates-table th.sortable::after {
    content: " ⇅";
    opacity: 0.35;
    font-size: 0.7rem;
}

.rates-table th.sortable.sort-asc::after {
    content: " ↑";
    opacity: 1;
}

.rates-table th.sortable.sort-desc::after {
    content: " ↓";
    opacity: 1;
}

.rates-table .col-apy {
    font-variant-numeric: tabular-nums;
}

.rate-row {
    cursor: pointer;
    transition: background 0.15s;
}

.rate-row:hover {
    background: #243044;
}

.rate-row.selected {
    background: #1e3a5f;
}

.rate-row--stale {
    background: rgba(180, 83, 9, 0.08);
}

.rate-row--stale:hover {
    background: rgba(180, 83, 9, 0.14);
}

.rate-row--stale.selected {
    background: rgba(180, 83, 9, 0.22);
}

.stale-indicator {
    color: #f59e0b;
    font-size: 0.85rem;
}

.last-update--stale {
    color: #fbbf24;
}

.stale-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

.empty {
    color: #9fb0c7;
    text-align: center;
    padding: 2rem;
}

.rate-row--expanded {
    background: #1e3a5f;
}

.rate-row--expanded.rate-row--stale {
    background: rgba(180, 83, 9, 0.22);
}

.expand-chevron {
    display: inline-block;
    width: 0.65rem;
    margin-right: 0.4rem;
    color: #6b7d96;
    font-size: 0.65rem;
    vertical-align: middle;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.rate-row--expanded .expand-chevron {
    transform: rotate(90deg);
}

.rate-detail-row td {
    padding: 0 !important;
    background: #141c28;
    border-bottom: 1px solid #2d3a4d;
    overflow: hidden;
    width: 100%;
}

.rate-chart-slot {
    padding: 1rem 1.25rem 1.25rem;
    min-height: 360px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    contain: inline-size;
}

.chart-slot-placeholder {
    color: #6b7d96;
    text-align: center;
    padding: 2rem;
    margin: 0;
}

.rate-row--mock {
    background: rgba(59, 130, 246, 0.06);
}

.mock-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

.chart-panel {
    background: transparent;
    border-radius: 0;
    padding: 0;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.chart-canvas-wrap {
    position: relative;
    height: 300px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin-top: 0.5rem;
    overflow: hidden;
}

.chart-canvas-wrap > div {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
}

.chart-canvas-wrap canvas {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
}

.chart-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.chart-hint {
    font-size: 0.75rem;
    color: #6b7d96;
}

.chart-reset-btn {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
}

.chart-subtitle {
    font-size: 0.8rem;
    color: #9fb0c7;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.period-buttons {
    display: flex;
    gap: 0.5rem;
}

.period-btn {
    padding: 0.35rem 0.75rem;
    background: #2d3a4d;
    color: #e7ecf3;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.period-btn.active,
.period-btn:hover {
    background: #3b82f6;
}

.login-card {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
    background: #1a2332;
    border-radius: 8px;
}

.login-card h2 {
    margin: 0 0 1.5rem;
}

.login-card label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    color: #9fb0c7;
}

.login-card input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
    background: #0f1419;
    color: #e7ecf3;
    border: 1px solid #2d3a4d;
    border-radius: 6px;
}

.error {
    color: #f87171;
    margin-bottom: 1rem;
}

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    background: #1e3a5f;
    border-radius: 6px;
    font-size: 0.9rem;
    z-index: 1000;
}

.toast.hidden {
    display: none;
}

.header-nav {
    display: flex;
    gap: 0.75rem;
}

.nav-link {
    color: #9fb0c7;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.nav-link:hover {
    color: #e7ecf3;
    background: #243044;
}

.nav-link--active {
    color: #e7ecf3;
    background: #2d3a4d;
}

.alert-banner {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: #3d1f1f;
    border: 1px solid #ef4444;
    border-radius: 8px;
}

.alert-banner--test {
    border-color: #f59e0b;
    background: #3d2f1a;
}

.alert-banner__title {
    display: block;
    color: #fca5a5;
    margin-bottom: 0.5rem;
}

.alert-banner--test .alert-banner__title {
    color: #fcd34d;
}

.alert-banner__list {
    margin: 0 0 0.75rem;
    padding-left: 1.25rem;
    color: #fecaca;
}

.alert-banner--test .alert-banner__list {
    color: #fde68a;
}

.alert-banner__protocol {
    font-weight: 600;
}

.alert-banner__error {
    display: block;
    font-size: 0.85rem;
    color: #fca5a5;
    margin-top: 0.15rem;
}

.alert-banner__link {
    color: #93c5fd;
    font-size: 0.875rem;
}

.status-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge--ok {
    background: #14532d;
    color: #86efac;
}

.status-badge--empty {
    background: #78350f;
    color: #fcd34d;
}

.status-badge--failed {
    background: #7f1d1d;
    color: #fca5a5;
}

.status-badge--skipped {
    background: #1e293b;
    color: #94a3b8;
}

.status-badge--warning {
    background: #78350f;
    color: #fcd34d;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.admin-header__right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

.admin-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #9fb0c7;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-filter select {
    padding: 0.35rem 0.5rem;
    background: #1a2332;
    color: #e7ecf3;
    border: 1px solid #2d3a4d;
    border-radius: 6px;
}

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

.admin-table {
    font-size: 0.85rem;
}

.admin-table .mono {
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
}

.admin-table .muted {
    color: #6b7280;
    font-size: 0.8rem;
}

.error-cell {
    max-width: 200px;
    word-break: break-word;
    color: #fca5a5;
}

.details-cell {
    max-width: 240px;
}

.detail-tag {
    display: inline-block;
    margin: 0.1rem 0.2rem 0.1rem 0;
    padding: 0.1rem 0.35rem;
    background: #243044;
    border-radius: 3px;
    font-size: 0.75rem;
}

.empty-state {
    text-align: center;
    color: #6b7280;
    padding: 2rem;
}
