:root {
    --bg: #f7f9f9;
    --ink: #0f1419;
    --muted: #536471;
    --line: #cfd9de;
    --panel: #ffffff;
    --accent: #1d9bf0;
    --accent-dark: #0f1419;
    --warn: #c8751a;
    --blue: #1d9bf0;
    --red: #b94040;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-box {
    width: min(100%, 380px);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 26px;
    background: var(--panel);
    box-shadow: 0 16px 36px rgba(25, 37, 60, 0.08);
}

.login-box h1 {
    margin-bottom: 18px;
    font-size: 24px;
}

.login-box input {
    width: 100%;
    height: 42px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    color: var(--ink);
    font-size: 15px;
}

.login-box .btn {
    width: 100%;
}

.login-error {
    margin-bottom: 12px;
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--red);
    background: #ffe7e7;
    font-size: 13px;
    font-weight: 700;
}

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

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

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

h1 {
    font-size: 30px;
    line-height: 1.2;
}

.top-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn {
    height: 38px;
    border: 0;
    border-radius: 999px;
    padding: 0 16px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.btn.secondary {
    background: #eff3f4;
    color: var(--ink);
}

.link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.broadcast {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 380px) auto;
    gap: 20px;
    align-items: stretch;
    padding: 22px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 20, 25, 0.06);
}

.broadcast .label {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.broadcast h2 {
    font-size: 22px;
    line-height: 1.55;
}

.today-hero {
    min-width: 0;
    display: grid;
    align-content: center;
    gap: 8px;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding: 0 22px;
}

.today-hero span {
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.today-hero strong {
    display: flex;
    align-items: baseline;
    gap: 6px;
    color: var(--accent-dark);
    line-height: 1;
}

.today-hero em {
    font-style: normal;
    font-size: 28px;
    font-weight: 900;
}

.today-hero b {
    overflow: hidden;
    font-size: 54px;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.today-hero small {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.broadcast-meta {
    min-width: 170px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    text-align: right;
}

.spend-status {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.spend-status {
    align-self: center;
}

.copy-tool {
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--panel);
}

.copy-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
    gap: 16px;
    padding: 18px;
}

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

.copy-form label {
    min-width: 0;
    display: grid;
    gap: 7px;
}

.copy-form label span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.copy-form input,
.copy-form select {
    width: 100%;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    color: var(--ink);
    background: #fff;
    font-size: 14px;
    font-weight: 700;
}

.copy-form input:focus,
.copy-form select:focus {
    border-color: var(--accent);
    outline: 2px solid rgba(29, 155, 240, 0.14);
}

.inline-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.mini-btn {
    height: 40px;
    border: 0;
    border-radius: 999px;
    padding: 0 14px;
    color: #fff;
    background: var(--accent);
    font-weight: 800;
    cursor: pointer;
}

.copy-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.copy-actions .btn {
    flex: 1 1 160px;
}

.copy-form .spend-status {
    grid-column: 1 / -1;
}

.copy-preview-wrap {
    min-width: 0;
    display: grid;
    grid-template-rows: auto 1fr;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #f7f9f9;
}

.copy-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 12px;
    background: #fff;
}

.copy-preview {
    min-height: 320px;
    margin: 0;
    overflow: auto;
    padding: 16px;
    color: var(--ink);
    font-family: "Microsoft YaHei", Consolas, monospace;
    font-size: 14px;
    line-height: 1.75;
    white-space: pre-wrap;
}

.range-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    background: var(--panel);
}

.range-toolbar span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.range-toolbar strong {
    font-size: 18px;
}

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

.range-btn {
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 14px;
    background: #fff;
    color: var(--ink);
    font-weight: 800;
    cursor: pointer;
}

.range-btn.active {
    border-color: var(--accent);
    background: #e8f5fe;
    color: #0c72b8;
}

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

.metric, .panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.metric {
    padding: 18px;
}

.metric span,
.metric small,
.panel-head span {
    color: var(--muted);
}

.metric span {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
}

.metric strong {
    display: block;
    margin-bottom: 8px;
    font-size: 28px;
    line-height: 1;
}

.metric small {
    font-size: 13px;
}

.grid.two {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
    gap: 14px;
    margin-bottom: 14px;
}

.grid.three {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.65fr) minmax(300px, 0.75fr);
    gap: 14px;
    margin-bottom: 14px;
}

.panel {
    min-width: 0;
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.panel-head h3 {
    font-size: 17px;
}

.panel-head span {
    font-size: 12px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 18px;
}

.summary-item {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 14px;
    background: #fbfcfe;
}

.summary-item span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.summary-item strong {
    display: block;
    overflow: hidden;
    margin-bottom: 8px;
    color: var(--ink);
    font-size: 24px;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.summary-item small {
    color: var(--muted);
    font-size: 12px;
}

.pay-list,
.stock-list {
    padding: 10px 18px 18px;
}

.pay-item,
.stock-item {
    display: grid;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.pay-item:last-child,
.stock-item:last-child {
    border-bottom: 0;
}

.pay-top,
.stock-top {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pay-top strong,
.stock-top strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pay-top span {
    color: var(--accent-dark);
    font-weight: 900;
    white-space: nowrap;
}

.pay-bar {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8edf4;
}

.pay-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}

.pay-item small,
.stock-item small {
    color: var(--muted);
    font-size: 12px;
}

.stock-top span {
    flex: 0 0 auto;
    min-width: 42px;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 900;
    text-align: center;
}

.stock-top span.ok {
    color: #0c72b8;
    background: #e8f5fe;
}

.stock-top span.warn {
    color: var(--warn);
    background: #fff0dc;
}

.stock-top span.danger {
    color: var(--red);
    background: #ffe7e7;
}

.bars {
    height: 260px;
    display: grid;
    grid-template-columns: repeat(24, minmax(14px, 1fr));
    gap: 7px;
    align-items: end;
    padding: 18px;
}

.bar {
    position: relative;
    min-width: 0;
    display: grid;
    align-items: end;
    gap: 7px;
    height: 100%;
}

.bar-fill {
    min-height: 4px;
    border-radius: 4px 4px 0 0;
    background: var(--blue);
}

.bar-tip {
    position: absolute;
    left: 50%;
    bottom: 24px;
    z-index: 5;
    min-width: 132px;
    display: grid;
    gap: 4px;
    border: 1px solid rgba(23, 32, 51, 0.12);
    border-radius: 7px;
    padding: 9px 10px;
    color: #fff;
    background: rgba(23, 32, 51, 0.94);
    box-shadow: 0 10px 24px rgba(25, 37, 60, 0.22);
    font-size: 12px;
    line-height: 1.35;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.bar-tip strong {
    font-size: 13px;
}

.bar-tip span {
    color: #edf3ff;
    font-size: 12px;
    text-align: left;
}

.bar:hover {
    z-index: 6;
}

.bar:hover .bar-fill {
    background: var(--accent);
}

.bar:hover .bar-tip {
    opacity: 1;
    transform: translate(-50%, 0);
}

.bar span {
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    text-align: center;
    white-space: nowrap;
}

.rank-list,
.history {
    padding: 10px 18px 18px;
}

.rank-item,
.history-item {
    min-width: 0;
    display: grid;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}

.rank-item:last-child,
.history-item:last-child {
    border-bottom: 0;
}

.rank-top,
.history-top {
    min-width: 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.rank-title,
.history-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-value {
    flex: 0 0 auto;
    color: var(--accent-dark);
    font-weight: 800;
    white-space: nowrap;
}

.rank-meta,
.history-text {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--line);
    padding: 12px 14px;
}

.pager button {
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    background: #fff;
    color: var(--ink);
    font-weight: 800;
    cursor: pointer;
}

.pager button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.pager span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

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

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 700;
    background: #fbfcfe;
}

td.money {
    color: var(--accent-dark);
    font-weight: 800;
    white-space: nowrap;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 9px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.tag.ok {
    color: #0c72b8;
    background: #e8f5fe;
}

.tag.wait {
    color: var(--warn);
    background: #fff0dc;
}

.tag.bad {
    color: var(--red);
    background: #ffe7e7;
}

.empty {
    padding: 20px 0;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 900px) {
    .shell {
        width: min(100% - 20px, 1280px);
        padding-top: 16px;
    }

    .topbar,
    .broadcast {
        grid-template-columns: 1fr;
    }

    .today-hero {
        border-left: 0;
        border-right: 0;
        border-top: 1px solid var(--line);
        border-bottom: 1px solid var(--line);
        padding: 16px 0;
    }

    .today-hero b {
        font-size: 44px;
    }

    .topbar {
        align-items: flex-start;
    }

    .top-actions {
        width: 100%;
        justify-content: stretch;
    }

    .btn {
        flex: 1;
    }

    .broadcast-meta {
        min-width: 0;
        text-align: left;
    }

    .copy-layout {
        grid-template-columns: 1fr;
    }

    .copy-form {
        grid-template-columns: 1fr;
    }

    .range-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .range-buttons {
        justify-content: stretch;
    }

    .range-btn {
        flex: 1 1 calc(50% - 8px);
    }

    .metrics,
    .grid.two,
    .grid.three {
        grid-template-columns: 1fr;
    }

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

    .bars {
        grid-template-columns: repeat(12, minmax(14px, 1fr));
        height: 220px;
        overflow: hidden;
    }

    .bar-tip {
        min-width: 118px;
    }

    .pager {
        justify-content: center;
    }
}

@media (max-width: 520px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }
}
