﻿:root {
    --bg: #f5f7fa;
    --card: #ffffff;
    --text: #1f2a37;
    --muted: #6b7a90;
    --border: #d9e0ea;
    --primary: #1f6fd6;
    --primary-hover: #1a5db3;
    --danger: #d92d20;
    --danger-bg: #fff5f4;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

.topbar {
    min-height: 64px;
    background: #154a95;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    gap: 12px;
}

.kicker {
    font-size: 12px;
    opacity: 0.85;
}

.topbar h1 {
    font-size: 20px;
    font-weight: 600;
    white-space: nowrap;
}

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

.page {
    width: min(1320px, 100%);
    margin: 0 auto;
    padding: 24px;
    display: grid;
    gap: 24px;
}

.toolbar,
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.toolbar {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.toolbar input,
.toolbar select {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px;
    font-size: 14px;
}

#search-input {
    min-width: 300px;
}

.panel {
    padding: 16px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.panel-head h2 {
    font-size: 18px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 950px;
}

th,
td {
    border-bottom: 1px solid #edf1f6;
    text-align: left;
    padding: 10px 8px;
    font-size: 13px;
}

th {
    color: #44546c;
    background: #fafcff;
}

.placeholder {
    text-align: center;
    color: var(--muted);
    padding: 24px;
}

.role-tag,
.status-tag {
    display: inline-block;
    border-radius: 99px;
    font-size: 12px;
    padding: 3px 8px;
}

.role-admin {
    background: #e8f1ff;
    color: #1453a4;
}

.role-user {
    background: #eff4f8;
    color: #5c6d83;
}

.status-on {
    background: #eaf8ef;
    color: #1f8f56;
}

.status-off {
    background: #f2f4f7;
    color: #7a889b;
}

.row-actions {
    display: flex;
    gap: 6px;
}

button,
.link-btn {
    border-radius: 8px;
    border: 1px solid transparent;
    min-height: 40px;
    padding: 0 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

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

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

.secondary-btn,
.link-btn {
    background: #fff;
    color: #2b4f78;
    border-color: #b9c8db;
}

.secondary-btn:hover,
.link-btn:hover {
    background: #edf3fc;
}

.danger-btn {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #efb1ac;
}

.danger-outline {
    background: #fff;
    color: var(--danger);
    border-color: #efb1ac;
}

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

.pagination button:disabled {
    background: #f3f5f8;
    border-color: #dfe6ef;
    color: #9ba8b7;
    cursor: not-allowed;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(18, 31, 50, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.open {
    display: flex;
}

.modal-card {
    width: min(680px, 100%);
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.modal-card h3 {
    margin-bottom: 12px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    color: #44546c;
}

label input,
label select {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 10px;
}

.full-row {
    grid-column: 1 / -1;
}

.form-error {
    color: var(--danger);
    min-height: 20px;
    margin-top: 8px;
    font-size: 13px;
}

.modal-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 800px) {
    .page {
        padding: 12px;
        gap: 12px;
    }

    .topbar {
        padding: 12px;
        position: sticky;
        top: 0;
        z-index: 40;
        flex-wrap: nowrap;
    }

    .topbar > div:first-child {
        min-width: 0;
    }

    .topbar h1 {
        font-size: 18px;
    }

    .top-actions {
        width: auto;
        margin-left: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .top-actions .link-btn,
    .top-actions .danger-btn {
        min-height: 36px;
        padding: 0 12px;
        font-size: 14px;
        white-space: nowrap;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

    .toolbar-left {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
    }

    #search-input {
        min-width: 160px;
        flex: 1;
    }

    .toolbar input,
    .toolbar select,
    button,
    .link-btn,
    label input,
    label select {
        min-height: 44px;
        font-size: 16px;
    }

    #search-btn,
    #refresh-btn,
    #create-btn {
        flex: 1;
        min-width: 110px;
    }

    .panel {
        padding: 12px;
    }

    .panel-head {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    .row-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .row-actions button {
        flex: 1;
    }

    .pagination {
        justify-content: space-between;
        gap: 8px;
    }

    .pagination button {
        flex: 1;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .modal-card {
        width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 88vh;
        padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
    }

    .modal-actions {
        position: sticky;
        bottom: 0;
        background: #fff;
        padding-top: 10px;
    }
}

@media (max-width: 520px) {
    .topbar {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .kicker {
        display: none;
    }

    .top-actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
    }

    .top-actions .link-btn,
    .top-actions .danger-btn {
        flex: 1;
    }
}

@media (max-width: 680px) {
    table {
        min-width: 100%;
    }

    thead {
        display: none;
    }

    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    tbody tr {
        border: 1px solid #e5ebf2;
        border-radius: 10px;
        background: #fff;
        padding: 6px 10px;
        margin-bottom: 10px;
    }

    tbody td {
        border-bottom: 1px dashed #edf1f6;
        padding: 9px 0;
        font-size: 14px;
        display: flex;
        gap: 10px;
        align-items: center;
        justify-content: space-between;
        min-height: 40px;
    }

    tbody td:last-child {
        border-bottom: none;
        padding-bottom: 4px;
    }

    tbody td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        flex-shrink: 0;
        margin-right: 10px;
    }

    .row-actions {
        width: 100%;
    }

    .placeholder-row td {
        display: block;
        border: none;
        text-align: center;
    }

    .placeholder-row td::before {
        content: none;
    }
}

@media (max-width: 680px) and (orientation: landscape) {
    .topbar {
        position: static;
    }

    .page {
        padding: 10px;
    }

    .modal-card {
        max-height: 94vh;
    }
}

@media (max-width: 400px) {
    .top-actions,
    .toolbar-left {
        gap: 8px;
    }

    #search-input,
    #search-btn,
    #refresh-btn,
    #create-btn {
        width: 100%;
        flex: none;
    }

    .pagination {
        flex-wrap: wrap;
    }
}
