:root {
    --bg: #f5efe6;
    --panel: rgba(255, 252, 248, 0.88);
    --panel-strong: #fffaf2;
    --text: #1f1a17;
    --muted: #6e6258;
    --line: rgba(63, 42, 27, 0.12);
    --accent: #0f766e;
    --accent-strong: #115e59;
    --warn: #b45309;
    --success: #15803d;
    --danger: #b91c1c;
    --shadow: 0 20px 60px rgba(45, 26, 6, 0.09);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "PingFang SC", "Noto Sans SC", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 30%),
        radial-gradient(circle at bottom right, rgba(180, 83, 9, 0.16), transparent 25%),
        linear-gradient(135deg, #f8f3eb 0%, #efe6da 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.auth-page-shell {
    padding: 24px 0 40px;
}

.topbar,
.hero-card,
.strategy-card,
.empty-card,
.detail-card,
.auth-card,
.gradient-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 24px;
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 20px 24px;
    margin-bottom: 20px;
}

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

.server-time-block {
    display: grid;
    gap: 2px;
    padding: 8px 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.5);
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 12px;
    color: var(--muted);
}

h1, h2, h3, p {
    margin-top: 0;
}

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

.ghost-link,
.ghost-button,
.primary-link,
.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    transition: transform 0.2s ease, background 0.2s ease;
}

.ghost-button {
    background: transparent;
    cursor: pointer;
}

.primary-link,
.primary-button {
    border: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: white;
    cursor: pointer;
}

.ghost-link:hover,
.ghost-button:hover,
.primary-link:hover,
.primary-button:hover {
    transform: translateY(-1px);
}

.message-stack {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.message {
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
}

.message-success {
    border-color: rgba(21, 128, 61, 0.2);
}

.auth-layout {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(320px, 520px);
    justify-content: center;
    gap: 24px;
    align-items: center;
}

.auth-card,
.gradient-panel {
    padding: 32px;
}

.gradient-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: end;
    color: white;
    background:
        linear-gradient(180deg, rgba(11, 78, 73, 0.3), rgba(11, 78, 73, 0.92)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='rgba(255,255,255,0.16)'%3E%3Cpath d='M0 40h160M0 80h160M0 120h160'/%3E%3Cpath d='M40 0v160M80 0v160M120 0v160'/%3E%3C/g%3E%3C/svg%3E");
    background-size: cover;
}

.stack-form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 8px;
}

.field input,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    border-radius: 16px;
    padding: 12px 14px;
}

.password-input-wrap {
    display: grid;
    align-items: center;
}

.password-input-wrap input {
    grid-area: 1 / 1;
    padding-right: 52px;
}

.captcha-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
}

.captcha-image {
    width: 178px;
    height: 56px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
}

.captcha-refresh {
    white-space: nowrap;
}

.password-toggle {
    appearance: none;
    -webkit-appearance: none;
    grid-area: 1 / 1;
    justify-self: end;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    border: 1px solid rgba(63, 42, 27, 0.08);
    background: rgba(255, 255, 255, 0.78);
    color: #6c6259;
    border-radius: 12px;
    padding: 0;
    margin: 0;
    line-height: 0;
    font-size: 0;
    overflow: hidden;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    z-index: 2;
    margin-right: 10px;
}

.password-toggle:hover {
    background: rgba(255, 250, 242, 0.96);
    color: var(--accent-strong);
}

.password-toggle:active {
    transform: scale(0.98);
}

.password-icon {
    display: block;
    flex: none;
    width: 18px;
    height: 18px;
}

.password-icon-eye-off {
    display: none !important;
}

.password-toggle.is-visible .password-icon-eye {
    display: none !important;
}

.password-toggle.is-visible .password-icon-eye-off {
    display: block !important;
}

.secondary-action {
    margin-top: 22px;
    width: 100%;
}

.toggle-block {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.inline-toggle-form {
    margin-bottom: 18px;
}

.toggle-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

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

.dashboard-layout,
.detail-layout {
    display: grid;
    gap: 20px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.hero-card,
.strategy-card,
.empty-card,
.detail-card {
    padding: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
}

.card-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.terminal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
    align-items: start;
}

.terminal-status-panel {
    display: grid;
    gap: 16px;
    align-content: start;
}

.heartbeat-row {
    display: flex;
    align-items: center;
    min-height: 34px;
}

.heartbeat-copy {
    display: grid;
    gap: 8px;
}

.reverse-repo-form {
    display: grid;
    gap: 12px;
    max-width: 460px;
    justify-self: stretch;
    width: 100%;
}

.reverse-repo-form .field input {
    max-width: 180px;
}

.reverse-repo-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.reverse-repo-actions .ghost-button,
.reverse-repo-actions .primary-button {
    justify-self: start;
}

.pill {
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    background: rgba(17, 94, 89, 0.08);
}

.pill-live {
    color: var(--success);
}

.pill-muted {
    color: var(--warn);
}

.info-list {
    display: grid;
    gap: 14px;
    margin: 18px 0 24px;
}

.info-list.two-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.snapshot-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.statistics-card {
    display: grid;
    gap: 22px;
}

.statistics-header {
    align-items: center;
}

.statistics-metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 22px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.48);
}

.statistics-metrics > div {
    display: grid;
    gap: 6px;
    padding: 18px 20px;
    border-right: 1px solid var(--line);
    min-width: 0;
}

.statistics-metrics > div:last-child {
    border-right: 0;
}

.statistics-metrics strong {
    font-size: clamp(24px, 2.2vw, 32px);
    line-height: 1.08;
    color: var(--accent-strong);
    max-width: 100%;
    overflow-wrap: anywhere;
    letter-spacing: -0.03em;
}

.statistics-metrics span {
    color: var(--muted);
}

.statistics-controls {
    display: grid;
    grid-template-columns: 180px 180px minmax(0, 1fr);
    gap: 14px;
    align-items: end;
}

.statistics-range-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.statistics-chart {
    width: 100%;
    min-height: 520px;
}

.statistics-empty {
    padding: 14px 16px;
    border: 1px solid rgba(180, 83, 9, 0.2);
    border-radius: 16px;
    color: var(--warn);
    background: rgba(180, 83, 9, 0.08);
}

.info-list dt {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 4px;
}

.info-list dd {
    margin: 0;
    font-weight: 600;
}

.status-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-top: 3px;
    flex: 0 0 auto;
}

.status-online {
    background: var(--success);
    box-shadow: 0 0 0 8px rgba(21, 128, 61, 0.14);
}

.status-offline {
    background: var(--danger);
    box-shadow: 0 0 0 8px rgba(185, 28, 28, 0.14);
}

.status-not-logged-in {
    background: var(--warn);
    box-shadow: 0 0 0 8px rgba(180, 83, 9, 0.14);
}

.detail-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
    align-items: start;
}

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

.table-sort-button {
    appearance: none;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sort-indicator {
    display: inline-grid;
    gap: 2px;
    align-items: center;
    justify-items: center;
    width: 10px;
}

.sort-triangle {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.38;
}

.sort-triangle-up {
    border-bottom: 5px solid var(--muted);
}

.sort-triangle-down {
    border-top: 5px solid var(--muted);
}

.table-sort-button.is-asc .sort-triangle-up {
    border-bottom-color: var(--accent-strong);
    opacity: 1;
}

.table-sort-button.is-desc .sort-triangle-down {
    border-top-color: var(--accent-strong);
    opacity: 1;
}

.settings-table-wrap {
    margin-top: 18px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.56);
}

.settings-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.settings-table th,
.settings-table td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.settings-table thead th {
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    background: rgba(255, 250, 242, 0.92);
}

.settings-table tbody tr:last-child td {
    border-bottom: 0;
}

.settings-table-index {
    width: 88px;
    font-weight: 700;
    color: var(--accent-strong);
}

.settings-table-name {
    min-width: 220px;
    font-weight: 600;
}

.settings-table-desc {
    color: var(--muted);
}

.settings-table-action {
    width: 180px;
}

.download-bundle-box {
    display: grid;
    gap: 10px;
    margin-top: 18px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.5);
}

.password-card {
    max-width: 760px;
}

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

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

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

.rebalance-dialog {
    width: min(760px, calc(100vw - 24px));
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow);
    background: var(--panel-strong);
}

.secret-dialog {
    width: min(680px, calc(100vw - 24px));
}

.secret-copy-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin: 18px 0;
    align-items: center;
}

.secret-input {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    border-radius: 16px;
    padding: 12px 14px;
}

.token-input-wrap {
    min-width: 0;
}

.secret-help {
    display: grid;
    gap: 8px;
}

.secret-example {
    margin: 8px 0 0;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(31, 26, 23, 0.04);
    overflow-x: auto;
}

.rebalance-dialog::backdrop {
    background: rgba(31, 26, 23, 0.35);
}

.dialog-close-row,
.dialog-actions {
    display: flex;
    justify-content: end;
    margin-bottom: 12px;
}

.site-footer {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 22px;
    color: var(--muted);
    font-size: 13px;
}

.site-footer a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

@media (max-width: 900px) {
    .auth-layout,
    .detail-layout {
        grid-template-columns: 1fr;
    }

    .topbar,
    .card-header,
    .heartbeat-row {
        flex-direction: column;
    }

    .captcha-row {
        grid-template-columns: 1fr;
        justify-items: start;
    }

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

    .reverse-repo-form {
        justify-self: stretch;
        max-width: none;
    }

    .snapshot-summary {
        grid-template-columns: 1fr 1fr;
    }

    .statistics-metrics,
    .statistics-controls {
        grid-template-columns: 1fr;
    }

    .statistics-metrics > div {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .statistics-metrics > div:last-child {
        border-bottom: 0;
    }

    .statistics-range-actions {
        justify-content: flex-start;
    }

    .statistics-chart {
        min-height: 420px;
    }
}
