/*
 * RRC admin portal. Hand-written, no build step and no external requests, so it works as-is on a VPS.
 * White is the main colour; the page is a barely-there off-white so that white cards separate by a thin line, not by shadow.
 * One accent (deep sea blue). Up / down / warning use their own colours so "green" never means "brand".
 */

:root {
    --bg: #fafbfb;
    --surface: #ffffff;
    --surface-2: #f2f5f5;
    --line: #e2e8e8;
    --line-strong: #c9d2d2;

    --ink: #14201f;
    --ink-2: #3f4e55;
    --ink-3: #5f6f75;

    --accent: #0a6a86;
    --accent-hover: #085873;
    --accent-soft: #e6f2f6;

    --good: #167a43;
    --good-soft: #e6f4ec;
    --bad: #c4261d;
    --bad-soft: #fdeceb;
    --warn: #8a5200;
    --warn-soft: #fff4de;
    --warn-line: #efd08d;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(20, 32, 31, 0.05);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner, .page { max-width: 1180px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.page { padding-top: 24px; padding-bottom: 64px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; letter-spacing: -0.02em; }

.topbar-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.topbar-actions a, .linklike { color: var(--ink-2); }
.linklike { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.topbar-actions a, .linklike { display: inline-flex; align-items: center; min-height: 32px; }
.linklike:hover, .topbar-actions a:hover { color: var(--accent); text-decoration: none; }

.lang { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.lang a { display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; font-size: 13px; color: var(--ink-2); }
.lang a:hover { text-decoration: none; background: var(--surface-2); }
.lang a.is-active { background: var(--ink); color: #fff; }

.tokenbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.tokenbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 13px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- building blocks ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card + .card, .section + .section { margin-top: 20px; }
/* Cards sitting side by side in a grid are spaced by the grid's gap, not by the stacking rule above. */
.grid > .card, .grid > .card + .card { margin-top: 0; }
.card-head { margin-bottom: 16px; }
.card-title { font-size: 17px; font-weight: 650; }
.card-sub { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.card.is-warn { border-color: var(--warn-line); }

.section { margin-top: 28px; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }

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

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.page-title .sym { color: var(--ink-3); font-weight: 600; margin-left: 6px; }
.addr { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; color: var(--ink-3); font-size: 13px; max-width: 100%; }
.addr .mono { overflow-wrap: anywhere; }
.addr > span:first-child { white-space: nowrap; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--ink-3); letter-spacing: 0.02em; }
.stat-value { margin-top: 6px; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; }
/* The unit is never split from its number: if there is no room it moves down as a whole. */
.stat-value .unit { font-size: 13px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.stat-sub { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); }
.stat.small-stat .stat-value { font-size: 18px; }

.bar { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.up { background: var(--good-soft); color: var(--good); }
.badge.down { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.up-text { color: var(--good); }
.down-text { color: var(--bad); }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; margin-bottom: 16px; font-size: 14px; }
.alert.success { background: var(--good-soft); border-color: #b7dfc7; color: #0f5b31; }
.alert.error { background: var(--bad-soft); border-color: #f2bcb8; color: #8f1d17; }
.alert.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.alert .mono { overflow-wrap: anywhere; }

/* ---------- forms ---------- */

.field { margin-bottom: 14px; }
.field label, .label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.input, textarea.input, select.input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink); font: inherit; font-size: 14.5px;
}
.input::placeholder { color: #8a9899; }
.input:hover { border-color: #a9b6b6; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 106, 134, 0.15); }
.input.mono { font-family: var(--mono); font-size: 13.5px; }
textarea.input { resize: vertical; min-height: 96px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 4px 0 20px; font-size: 14px; color: var(--ink-2); }
.checks label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.checks input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-sm);
    border: 1px solid transparent; font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2;
    white-space: nowrap; /* a two-character Chinese label must never break into two lines */
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-warn { background: var(--surface); border-color: var(--warn-line); color: var(--warn); }
.btn-warn:hover { background: var(--warn-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn[disabled], .btn.is-busy { opacity: 0.6; cursor: not-allowed; }

.busy { display: none; align-items: center; gap: 8px; margin-top: 12px; color: var(--ink-3); font-size: 13px; }
.busy.is-on { display: flex; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 9px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table th:first-child { border-top-left-radius: var(--radius-sm); }
.table th:last-child { border-top-right-radius: var(--radius-sm); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
/* Links inside tables get a taller hit area without making the rows taller. */
.table td a { display: inline-block; padding: 6px 2px; margin: -6px 0; }
.table .empty { text-align: center; color: var(--ink-3); padding: 28px 10px; }
.table .num { text-align: right; }
.table th.num { text-align: right; }

/* ---------- price chart ---------- */

.range { display: inline-flex; gap: 6px; }
.range button { padding: 7px 13px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.range button:hover { border-color: var(--accent); color: var(--accent); }
.range button.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chart-box { position: relative; height: 300px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; font-size: 12.5px; color: var(--ink-3); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---------- login ---------- */

.auth { max-width: 400px; margin: 56px auto 0; }
.auth .card { padding: 28px; }

/* ---------- small screens ---------- */

@media (max-width: 960px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .card { padding: 18px; }
    .page { padding-top: 18px; }
    .chart-box { height: 260px; }
}

@media (max-width: 520px) {
    .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-value { font-size: 20px; }
    .topbar-actions { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2.4s; }
}
