:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #637083;
    --line: #dde4ee;
    --primary: #225ea8;
    --primary-dark: #184a86;
    --danger: #b93838;
    --review-row: #fff6df;
    --review-border: #d89a13;
    --approved-row: #eaf7ef;
    --approved-border: #23965a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

body,
input,
select,
textarea,
button {
    -webkit-text-size-adjust: 100%;
}

a {
    color: var(--primary);
    text-decoration: none;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 10px 12px;
    outline: none;
    min-height: 42px;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #637083 50%),
        linear-gradient(135deg, #637083 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% + 1px),
        calc(100% - 12px) calc(50% + 1px);
    background-repeat: no-repeat;
    background-size: 6px 6px, 6px 6px;
    line-height: 1.35;
    padding-right: 38px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(34, 94, 168, 0.12);
}

button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 0;
    border-radius: 6px;
    padding: 0 14px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}

.primary-button {
    background: var(--primary);
    color: #fff;
}

.primary-button:hover {
    background: var(--primary-dark);
}

.secondary-button {
    background: #edf2f8;
    color: #24364e;
}

.ghost-button {
    background: #fff;
    border: 1px solid var(--line);
    color: #27384f;
}

.danger-button {
    background: #fff0f0;
    color: var(--danger);
}

.compact {
    min-height: 32px;
    padding: 0 10px;
}

.full {
    width: 100%;
}

.login-body {
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(34, 94, 168, 0.12), rgba(35, 150, 90, 0.10)),
        var(--bg);
}

.login-shell {
    width: min(440px, calc(100vw - 32px));
}

.login-panel,
.form-panel,
.table-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 16px 36px rgba(32, 45, 67, 0.08);
}

.login-panel {
    padding: 34px;
}

.brand-block {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    font-size: 22px;
}

.brand-mark.small {
    width: 38px;
    height: 38px;
    font-size: 18px;
}

.brand-block h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.brand-block p,
.page-head p,
.topbar-title span {
    margin: 0;
    color: var(--muted);
}

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

label span {
    display: block;
    margin-bottom: 8px;
    color: #34445c;
    font-weight: 600;
}

label {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 70px;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title strong {
    display: block;
    font-size: 16px;
}

.menu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu a,
.menu button {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 6px;
    background: transparent;
    color: #2d3c52;
}

.menu a.active {
    background: #e9f0f8;
    color: var(--primary);
    font-weight: 700;
}

.page {
    width: min(1400px, calc(100vw - 40px));
    margin: 28px auto 42px;
}

.page.narrow {
    width: min(920px, calc(100vw - 40px));
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
    margin-bottom: 18px;
}

.page-head h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

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

.search-panel {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(32, 45, 67, 0.06);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.provider-stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
    min-height: 116px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 10px 24px rgba(32, 45, 67, 0.07);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 14px;
    font-size: 34px;
    line-height: 1;
}

.stat-card.primary {
    border-color: #b8d0ec;
}

.stat-card.primary strong {
    color: var(--primary);
}

.stat-card.reviewing {
    background: #fff8e8;
    border-color: #ecd49c;
}

.stat-card.reviewing strong {
    color: #8b5f00;
}

.stat-card.approved,
.stat-card.listed {
    background: #ecf8f1;
    border-color: #bde6cc;
}

.stat-card.approved strong,
.stat-card.listed strong {
    color: #146c3f;
}

.stat-card.voided {
    background: #f7f8fa;
}

.stat-card.voided strong {
    color: #687386;
}

.stats-section {
    margin-top: 18px;
}

.stats-section h2 {
    margin: 0 0 12px;
    font-size: 20px;
}

.status-stat-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.status-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 58px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.status-stat-row span {
    color: #34445c;
    font-weight: 700;
}

.status-stat-row strong {
    font-size: 22px;
}

.stat-reviewing {
    background: #fff8e8;
    border-color: #ecd49c;
}

.stat-approved,
.stat-appstore,
.stat-listed {
    background: #ecf8f1;
    border-color: #bde6cc;
}

.stat-voided {
    background: #f7f8fa;
}

.provider-stat-table {
    min-width: 720px;
}

.table-card {
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 920px;
}

.admin-table {
    min-width: 1420px;
}

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

.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f9fbfe;
    color: #42526a;
    font-size: 13px;
    font-weight: 700;
}

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

.row-reviewing {
    background: var(--review-row);
}

.row-approved {
    background: var(--approved-row);
}

.admin-row-reviewing {
    background: #fff5d8;
}

.admin-row-approved {
    background: #e6f7ed;
}

.admin-row-appstore {
    background: #eaf2ff;
}

.admin-row-listed {
    background: #e7f8df;
}

.admin-row-voided {
    background: #f3f1f6;
    color: #626b78;
}

.status-pill,
.legend {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    font-weight: 700;
    border: 1px solid transparent;
}

.legend {
    min-height: 36px;
    min-width: 132px;
    opacity: 0.72;
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

.legend.selected {
    opacity: 1;
    border-width: 2px;
    box-shadow: 0 8px 18px rgba(32, 45, 67, 0.18), 0 0 0 3px rgba(34, 94, 168, 0.18);
}

.legend:active {
    transform: scale(0.98);
}

.provider-reviewing,
.legend.reviewing {
    color: #8b5f00;
    background: #fff0bf;
    border-color: var(--review-border);
}

.provider-approved,
.legend.approved {
    color: #146c3f;
    background: #dff4e7;
    border-color: var(--approved-border);
}

.legend.reviewing.selected {
    color: #fff;
    background: #b47700;
    border-color: #8b5f00;
}

.legend.approved.selected {
    color: #fff;
    background: #16824b;
    border-color: #0f6539;
}

.status-legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.remark-form input {
    min-width: 220px;
}

.status-form select {
    min-width: 150px;
    padding: 8px 38px 8px 10px;
}

.status-menu {
    position: relative;
    width: 170px;
}

.status-menu summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 8px 12px;
    cursor: pointer;
    list-style: none;
}

.status-menu summary::-webkit-details-marker {
    display: none;
}

.status-menu summary::after {
    content: "";
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg) translateY(-2px);
    flex: 0 0 9px;
}

.status-menu[open] summary {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(34, 94, 168, 0.12);
}

.status-menu-reviewing summary {
    background: #fff0bf;
    border-color: #d89a13;
    color: #8b5f00;
}

.status-menu-approved summary {
    background: #dff4e7;
    border-color: #23965a;
    color: #146c3f;
}

.status-menu-appstore summary {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1d4ed8;
}

.status-menu-listed summary {
    background: #dcfce7;
    border-color: #22c55e;
    color: #15803d;
}

.status-menu-voided summary {
    background: #eceff3;
    border-color: #94a3b8;
    color: #475569;
}

.status-menu-appstore[open] summary {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.status-menu-listed[open] summary {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
}

.status-menu-voided[open] summary {
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.16);
}

.status-menu-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    width: 190px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 28px rgba(32, 45, 67, 0.18);
}

.status-menu-list form {
    margin: 0;
}

.status-menu-list button {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    min-height: 36px;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 0 10px;
}

.status-menu-list button:hover,
.status-menu-list button.selected {
    background: var(--primary);
    color: #fff;
}

.actions {
    width: 1%;
    white-space: nowrap;
}

.multi-actions {
    display: flex;
    gap: 8px;
}

.remark-cell {
    max-width: 220px;
    white-space: normal;
}

.time-cell {
    min-width: 128px;
    white-space: nowrap;
}

.locked-note {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    border-radius: 6px;
    padding: 0 10px;
    background: #f2f4f7;
    color: #687386;
    font-weight: 700;
}

.mono {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.empty {
    height: 110px;
    text-align: center;
    color: var(--muted);
}

.alert {
    margin-bottom: 14px;
    border-radius: 8px;
    padding: 12px 14px;
}

.alert.success {
    background: #e9f8ef;
    color: #146c3f;
    border: 1px solid #bfe8cf;
}

.alert.danger {
    background: #fff1f1;
    color: var(--danger);
    border: 1px solid #f0c5c5;
}

.form-panel {
    padding: 24px;
}

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

.password-form {
    display: grid;
    gap: 18px;
}

.span-2 {
    grid-column: span 2;
}

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

@media (max-width: 760px) {
    body {
        font-size: 15px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .topbar,
    .page-head {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        gap: 12px;
        min-height: auto;
        padding: 12px 14px;
    }

    .topbar-title {
        min-width: 0;
    }

    .brand-mark.small {
        width: 34px;
        height: 34px;
        flex: 0 0 34px;
        font-size: 16px;
    }

    .topbar-title strong {
        font-size: 15px;
    }

    .topbar-title span {
        font-size: 13px;
    }

    .menu {
        display: grid;
        grid-template-columns: 1fr 1fr;
        flex-wrap: wrap;
        gap: 8px;
    }

    .menu form {
        margin: 0;
    }

    .menu a,
    .menu button {
        width: 100%;
        min-height: 40px;
        background: #f3f6fa;
    }

    .page {
        width: 100%;
        margin: 0;
        padding: 14px 12px 28px;
    }

    .page.narrow {
        width: 100%;
    }

    .page-head {
        gap: 12px;
        margin-bottom: 14px;
    }

    .page-head h1 {
        margin-bottom: 4px;
        font-size: 22px;
    }

    .page-head .primary-button {
        width: 100%;
        min-height: 44px;
    }

    .page-actions {
        display: grid;
        grid-template-columns: 1fr;
        justify-content: stretch;
        gap: 10px;
    }

    .search-panel {
        grid-template-columns: 1fr auto;
        gap: 8px;
        margin-bottom: 12px;
        padding: 10px;
    }

    .search-panel input {
        grid-column: 1 / -1;
    }

    .search-panel .primary-button,
    .search-panel .ghost-button {
        width: 100%;
        min-height: 42px;
    }

    .stat-grid,
    .provider-stat-grid,
    .status-stat-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-card {
        min-height: 92px;
        padding: 15px;
    }

    .stat-card strong {
        margin-top: 10px;
        font-size: 30px;
    }

    .stats-section h2 {
        font-size: 18px;
    }

    .login-panel {
        padding: 22px;
    }

    .login-body {
        align-items: start;
        padding-top: 36px;
    }

    .login-shell {
        width: min(100vw - 24px, 440px);
    }

    .brand-block {
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 22px;
    }

    .brand-block h1 {
        font-size: 21px;
    }

    .brand-block p {
        font-size: 13px;
        line-height: 1.5;
    }

    .table-card {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .data-table,
    .admin-table,
    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .data-table th,
    .data-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .data-table {
        border-collapse: collapse;
    }

    .data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .data-table tbody {
        display: grid;
        gap: 12px;
    }

    .data-table tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        overflow: visible;
        box-shadow: 0 8px 22px rgba(32, 45, 67, 0.08);
    }

    .data-table td {
        display: grid;
        grid-template-columns: 82px minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        min-height: 48px;
        padding: 12px;
        border-bottom: 1px solid rgba(221, 228, 238, 0.82);
        word-break: break-word;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 13px;
        font-weight: 700;
        line-height: 1.7;
    }

    .data-table tr:last-child td,
    .data-table td:last-child {
        border-bottom: 0;
    }

    .data-table .empty {
        display: block;
        height: auto;
        padding: 28px 12px;
        text-align: center;
    }

    .data-table .empty::before {
        content: "";
    }

    .inline-form,
    .remark-form,
    .status-form,
    .multi-actions {
        width: 100%;
    }

    .remark-form {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 70px;
        align-items: stretch;
    }

    .remark-form input {
        min-width: 0;
    }

    .status-form select {
        width: 100%;
        min-width: 0;
    }

    .status-menu {
        width: 100%;
    }

    .status-menu summary {
        min-height: 44px;
        padding: 10px 12px;
    }

    .status-menu-list {
        position: static;
        width: 100%;
        margin-top: 8px;
        box-shadow: none;
    }

    .status-menu-list button {
        min-height: 42px;
    }

    .actions {
        width: 100%;
        white-space: normal;
    }

    .actions form,
    .actions .primary-button,
    .actions .secondary-button,
    .actions .ghost-button,
    .actions .danger-button,
    .locked-note {
        width: 100%;
    }

    .multi-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .compact,
    .primary-button,
    .secondary-button,
    .ghost-button,
    .danger-button {
        min-height: 42px;
    }

    .status-legend {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .legend {
        justify-content: center;
        min-height: 34px;
        padding: 0 8px;
        font-size: 13px;
    }

    .status-pill {
        min-height: 30px;
    }

    .remark-cell {
        max-width: none;
    }

    .account-form {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .span-2 {
        grid-column: span 1;
    }

    .form-panel {
        padding: 16px;
    }

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

@media (max-width: 380px) {
    .data-table td {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .remark-form,
    .multi-actions,
    .status-legend,
    .form-actions,
    .search-panel {
        grid-template-columns: 1fr;
    }

    .search-panel input {
        grid-column: auto;
    }
}
