:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #eef4fb;
    --text: #162033;
    --muted: #667085;
    --line: #d9e2ef;
    --primary: #1768ac;
    --primary-strong: #0f4f86;
    --success: #12745f;
    --warning: #946200;
    --danger: #b42318;
    --radius: 8px;
    --shadow: 0 12px 28px rgba(22, 32, 51, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

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

a:hover {
    text-decoration: underline;
}

h1,
h2 {
    margin: 0;
    line-height: 1.2;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 20px;
}

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

code {
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--surface-2);
}

.page-shell {
    padding: 28px;
}

.topbar {
    max-width: 1180px;
    margin: 0 auto 22px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.front-grid,
.admin-grid {
    max-width: 1180px;
    margin: 0 auto;
    display: grid;
    gap: 18px;
}

.front-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

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

.install-wrap {
    max-width: 560px;
    margin: 7vh auto 0;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

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

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

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

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

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

.full,
.full-span {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 650;
}

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

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(23, 104, 172, 0.25);
    outline-offset: 2px;
}

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

.btn {
    min-height: 44px;
    border: 0;
    border-radius: var(--radius);
    padding: 10px 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

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

.btn.primary:hover:not(:disabled) {
    background: var(--primary-strong);
}

.btn.secondary {
    color: var(--primary-strong);
    background: #e3eef8;
}

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

.ghost-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.notice,
.result-box {
    border-radius: var(--radius);
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.notice {
    margin-bottom: 14px;
}

.result-box {
    margin-top: 16px;
    min-height: 52px;
}

.result-box:empty {
    display: none;
}

.result-box p {
    margin: 6px 0 0;
}

.success {
    color: var(--success);
    border-color: rgba(18, 116, 95, 0.28);
    background: #e9f7f2;
}

.warning {
    color: var(--warning);
    border-color: rgba(148, 98, 0, 0.28);
    background: #fff7e0;
}

.danger {
    color: var(--danger);
    border-color: rgba(180, 35, 24, 0.28);
    background: #fff0ee;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--primary-strong);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.status-pill.success {
    color: var(--success);
    background: #e9f7f2;
}

.status-pill.warning {
    color: var(--warning);
    background: #fff7e0;
}

.status-pill.danger {
    color: var(--danger);
    background: #fff0ee;
}

.card-meta {
    display: grid;
    gap: 10px;
}

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

.card-label {
    min-width: 72px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.card-value {
    font-weight: 650;
    color: var(--text);
}

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

.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}

.metric span {
    color: var(--muted);
    font-size: 13px;
}

.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 26px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background: #fff;
}

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

th {
    background: #f8fbfe;
    font-size: 13px;
    color: var(--muted);
}

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

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

.inline-filter select,
.row-form select,
.row-form input {
    width: auto;
    min-width: 120px;
}

.row-form input[placeholder] {
    min-width: 220px;
}

.check-row {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
    font-weight: 650;
}

.check-row input {
    width: 18px;
    min-height: 18px;
}

.check-row.compact {
    min-height: 44px;
}

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

.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(22, 32, 51, 0.46);
}

.modal-backdrop.open {
    display: flex;
}

.modal-panel {
    width: min(420px, 100%);
    padding: 24px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 24px 60px rgba(22, 32, 51, 0.22);
}

.modal-panel h2 {
    margin-bottom: 8px;
}

.modal-panel p {
    margin: 0 0 18px;
    color: var(--muted);
}

@media (max-width: 860px) {
    .page-shell {
        padding: 18px;
    }

    .topbar,
    .front-grid,
    .admin-grid,
    .form-grid,
    .metric-row {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
    }

    .front-grid {
        display: grid;
    }

    .admin-grid {
        display: grid;
    }

    .panel {
        padding: 18px;
    }

    .panel-head {
        display: grid;
    }

    .inline-filter,
    .row-form {
        align-items: stretch;
    }

    .inline-filter select,
    .inline-filter .btn,
    .row-form select,
    .row-form input,
    .row-form .btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
