:root {
    --ink: #17211f;
    --muted: #6a746f;
    --line: #dce4de;
    --paper: #f6f3ea;
    --panel: #fffdf7;
    --green: #0f8a68;
    --blue: #2357a6;
    --amber: #c7811b;
    --red: #b84c3f;
    --shadow: 0 18px 40px rgba(26, 35, 31, 0.11);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    letter-spacing: 0;
}

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

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 11px 12px;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(15, 138, 104, 0.14);
}

label span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 13px;
}

button {
    cursor: pointer;
    border: 0;
}

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

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

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

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

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

.eyebrow {
    margin: 0 0 6px;
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.primary-btn,
.secondary-btn,
.danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: 8px;
    padding: 0 18px;
    font-weight: 800;
    white-space: nowrap;
}

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

.secondary-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}

.danger-btn {
    background: #fff1ee;
    color: var(--red);
}

.compact {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.text-btn {
    background: transparent;
    color: var(--blue);
    padding: 0;
}

.ghost-link {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--muted);
}

.flash {
    border-left: 4px solid var(--green);
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: #f2fff9;
}

.flash.error {
    border-color: var(--red);
    background: #fff2f0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 10px;
    background: #eef2ee;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.status-pill.open,
.status-pill.confirmed,
.status-pill.published,
.status-pill.paid,
.status-pill.active,
.status-pill.converted,
.status-pill.done,
.status-pill.income {
    background: #e3f8ee;
    color: var(--green);
}

.status-pill.pending,
.status-pill.draft,
.status-pill.new,
.status-pill.followed,
.status-pill.todo,
.status-pill.doing {
    background: #fff4dc;
    color: var(--amber);
}

.status-pill.rejected,
.status-pill.paused,
.status-pill.closed,
.status-pill.inactive,
.status-pill.lost,
.status-pill.expense {
    background: #fff0ec;
    color: var(--red);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(15, 138, 104, 0.12), transparent 38%),
        linear-gradient(315deg, rgba(35, 87, 166, 0.14), transparent 34%),
        var(--paper);
}

.login-panel {
    width: min(960px, calc(100vw - 32px));
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 28px;
    align-items: stretch;
}

.login-copy,
.login-form,
.work-panel,
.metric-panel,
.tier-tile,
.mobile-section,
.project-detail,
.success-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.login-copy {
    padding: 48px;
}

.login-copy h1 {
    margin: 0 0 18px;
    font-size: 44px;
    line-height: 1.12;
}

.login-copy p:last-child {
    max-width: 520px;
    color: var(--muted);
    line-height: 1.8;
}

.login-form {
    display: grid;
    gap: 18px;
    padding: 32px;
}

.login-form h2 {
    margin: 0;
}

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px 1fr;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: #17211f;
    color: #fff;
    padding: 22px;
    overflow-y: auto;
}

.brand-block {
    display: flex;
    gap: 12px;
    align-items: center;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--green);
    font-weight: 900;
}

.brand-block span,
.side-footer span {
    display: block;
    color: rgba(255, 255, 255, 0.68);
    font-size: 12px;
    margin-top: 2px;
}

.side-nav {
    display: grid;
    gap: 6px;
    margin-top: 26px;
}

.side-nav a,
.side-footer a {
    border-radius: 8px;
    padding: 9px 11px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 14px;
}

.side-nav a.active,
.side-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.side-footer {
    margin-top: auto;
}

.admin-main {
    min-width: 0;
    padding: 28px;
}

.admin-topbar,
.panel-title,
.project-card-head,
.project-card-meta,
.project-detail-head,
.mobile-actions,
.batch-actions,
.form-actions,
.tile-actions,
.delete-row,
.filter-links {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.admin-topbar {
    margin-bottom: 22px;
}

.admin-topbar h1,
.panel-title h2,
.mobile-hero h1,
.project-detail h1,
.success-panel h1,
.mobile-section h1,
.mobile-section h2 {
    margin: 0;
}

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

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

.metric-panel {
    padding: 22px;
}

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

.metric-panel strong {
    display: block;
    margin-top: 10px;
    font-size: 30px;
}

.accent-green {
    border-top: 4px solid var(--green);
}

.accent-amber {
    border-top: 4px solid var(--amber);
}

.accent-red {
    border-top: 4px solid var(--red);
}

.accent-blue {
    border-top: 4px solid var(--blue);
}

.quick-grid,
.two-column,
.card-grid {
    display: grid;
    gap: 16px;
}

.quick-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.quick-card,
.info-tile {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.quick-card {
    display: block;
    padding: 18px;
}

.quick-card b,
.quick-card span {
    display: block;
}

.quick-card b {
    font-size: 16px;
}

.quick-card span {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.two-column {
    grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
    align-items: start;
}

.mini-list {
    display: grid;
    gap: 10px;
}

.mini-list.divided {
    border-top: 1px solid var(--line);
    margin-top: 16px;
    padding-top: 16px;
}

.mini-row {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.mini-row strong,
.mini-row small {
    display: block;
}

.mini-row small {
    margin-top: 3px;
    color: var(--muted);
}

.work-panel {
    margin-bottom: 18px;
    padding: 22px;
}

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

.inline-search,
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.inline-search input {
    min-width: 220px;
}

.filter-bar {
    margin-bottom: 16px;
}

.filter-bar input {
    max-width: 320px;
}

.filter-bar select {
    max-width: 180px;
}

.empty-cell,
.mobile-empty {
    color: var(--muted);
    text-align: center;
    padding: 28px;
}

.action-cell {
    min-width: 220px;
}

.action-cell a,
.action-cell form {
    display: inline-block;
    margin: 0 8px 7px 0;
}

.action-stack {
    min-width: 240px;
}

.action-stack form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-bottom: 8px;
}

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

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

.narrow-form {
    max-width: 520px;
    display: grid;
    gap: 18px;
}

.tier-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

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

.info-tile {
    display: grid;
    gap: 10px;
    padding: 16px;
}

.info-tile h3 {
    margin: 0;
}

.info-tile p,
.tile-copy {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.tile-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.report-progress {
    min-width: 120px;
    margin-bottom: 6px;
}

.settings-form {
    display: grid;
    gap: 14px;
}

.setting-row {
    display: grid;
    grid-template-columns: minmax(220px, 0.42fr) minmax(280px, 1fr);
    gap: 16px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 14px;
}

.setting-row strong,
.setting-row small {
    display: block;
}

.setting-row small {
    margin-top: 4px;
    color: var(--muted);
}

.tier-tile {
    display: grid;
    gap: 12px;
    padding: 18px;
}

.danger-zone {
    border-color: #f0c8c0;
}

.delete-row {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.batch-actions {
    justify-content: flex-end;
}

.amount-note {
    color: var(--muted);
    font-weight: 800;
}

.mobile-shell {
    background:
        linear-gradient(180deg, #eef7f0 0, transparent 260px),
        var(--paper);
}

.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    background: rgba(246, 243, 234, 0.92);
    backdrop-filter: blur(14px);
    padding: 14px 18px;
}

.mobile-brand {
    font-weight: 900;
}

.mobile-wrap {
    width: min(760px, calc(100vw - 28px));
    margin: 0 auto;
}

.mobile-hero {
    padding: 32px 0 18px;
}

.mobile-hero h1 {
    font-size: 34px;
    line-height: 1.18;
}

.mobile-hero p:last-child,
.project-detail p,
.success-panel p,
.right-row p,
.record-row p {
    color: var(--muted);
    line-height: 1.7;
}

.mobile-project-list,
.record-list,
.rights-list {
    display: grid;
    gap: 14px;
}

.project-card {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 18px;
    box-shadow: var(--shadow);
}

.project-card h2 {
    margin: 0;
    font-size: 22px;
}

.project-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.progress-line {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e3e8e4;
}

.progress-line span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--blue));
}

.project-card-meta {
    color: var(--muted);
    font-size: 13px;
}

.project-detail,
.mobile-section,
.success-panel {
    margin: 16px 0;
    padding: 20px;
}

.back-link {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--blue);
    font-weight: 800;
}

.project-detail h1 {
    margin-top: 12px;
    font-size: 30px;
    line-height: 1.2;
}

.detail-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.detail-metrics div,
.right-row,
.record-row,
.rights-preview,
.receipt-list div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 14px;
}

.detail-metrics span,
.receipt-list dt {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.detail-metrics strong {
    display: block;
    margin-top: 6px;
}

.mobile-section {
    display: grid;
    gap: 14px;
}

.mobile-form {
    display: grid;
    gap: 14px;
}

.rights-preview {
    color: var(--muted);
    line-height: 1.6;
}

.rights-preview strong {
    color: var(--green);
}

.mobile-submit {
    width: 100%;
}

.success-panel {
    margin-top: 24px;
}

.receipt-list {
    display: grid;
    gap: 10px;
    margin: 20px 0;
}

.receipt-list dt,
.receipt-list dd {
    margin: 0;
}

.receipt-list dd {
    margin-top: 4px;
    font-weight: 800;
}

.record-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.record-row p {
    margin: 4px 0 0;
}

.record-row b {
    display: block;
    margin-bottom: 7px;
    text-align: right;
}

.search-form {
    grid-template-columns: 1fr auto;
    align-items: end;
}

.search-form .mobile-submit {
    width: auto;
}

@media (max-width: 1000px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
        height: auto;
    }

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

    .side-footer {
        margin-top: 18px;
    }

    .metric-grid,
    .metric-grid.expanded,
    .tier-grid,
    .quick-grid,
    .card-grid,
    .two-column {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .login-panel,
    .form-grid,
    .metric-grid,
    .metric-grid.expanded,
    .quick-grid,
    .card-grid,
    .two-column,
    .tier-grid,
    .detail-metrics,
    .search-form,
    .setting-row {
        grid-template-columns: 1fr;
    }

    .login-copy {
        padding: 28px;
    }

    .login-copy h1,
    .mobile-hero h1 {
        font-size: 30px;
    }

    .admin-main {
        padding: 18px;
    }

    .admin-topbar,
    .panel-title,
    .record-row,
    .mobile-actions,
    .inline-search,
    .filter-bar,
    .mini-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .inline-search input,
    .filter-bar input,
    .filter-bar select {
        max-width: none;
        width: 100%;
    }

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

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

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

    .mobile-actions a,
    .search-form .mobile-submit {
        width: 100%;
    }
}
