:root {
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1a1d26;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --border: #e5e7eb;
    --sidebar-bg: #111827;
    --sidebar-text: #9ca3af;
    --sidebar-active: #1e293b;
    --sidebar-hover: #1f2937;
    --success: #059669;
    --error: #dc2626;
    --warn: #d97706;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --sidebar-width: 240px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

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

/* ========== 侧边栏布局 ========== */
.admin-body { min-height: 100vh; }

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon { font-size: 1.6rem; }

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--sidebar-text);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-group-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #4b5563;
    padding: 12px 12px 6px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: 0.9rem;
    text-decoration: none;
    margin-bottom: 2px;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #e5e7eb;
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
    font-weight: 500;
}

.nav-item.logout { color: #f87171; }
.nav-item.logout:hover { background: rgba(248, 113, 113, 0.12); color: #fca5a5; }

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.asset-badge {
    display: inline-block;
    background: rgba(37, 99, 235, 0.2);
    color: #93c5fd;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    margin: 0 12px 10px;
}

/* ========== 右侧主区域 ========== */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.main-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.main-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text);
}

.main-content {
    flex: 1;
    padding: 24px 28px 40px;
}

/* ========== 内容组件 ========== */
h2 { font-size: 1.05rem; margin-bottom: 16px; font-weight: 600; }
.desc { color: var(--muted); margin-bottom: 20px; font-size: 0.9rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 12px; }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: box-shadow 0.15s;
}

.stat-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

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

form label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

form input[type="text"],
form input[type="number"],
form input[type="password"],
form textarea,
form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 14px;
    transition: border-color 0.15s;
    background: #fff;
}

form input:focus,
form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

form button,
button[type="submit"] {
    font-family: inherit;
}

form button,
button[type="submit"]:not(.btn) {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 500;
}

form button:hover,
button[type="submit"]:not(.btn):hover { background: var(--primary-hover); }

.inline-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.inline-form label { margin-bottom: 0; }
.inline-form input { margin-bottom: 0; width: 240px; }

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

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

th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    background: var(--bg);
    color: var(--muted);
}

.tag-ok { background: #ecfdf5; color: var(--success); }
.tag-warn { background: #fffbeb; color: var(--warn); }
.tag-info { background: #eff6ff; color: var(--primary); }

.badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.78rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-success { background: #ecfdf5; color: var(--success); border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }

.info-list { display: grid; grid-template-columns: 100px 1fr; gap: 8px 16px; }
.info-list dt { color: var(--muted); font-size: 0.875rem; }
.info-list dd { font-weight: 500; }
.info-list dd.highlight { color: var(--primary); font-size: 1.25rem; }

.info-list-wide { grid-template-columns: 120px 1fr; }

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.quick-links { list-style: none; }
.quick-links li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.quick-links li:last-child { border-bottom: none; }

.pagination {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.links { margin-top: 12px; }

.stat-warn { color: var(--warn); }

.inline-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
}

.hint-list {
    list-style: disc;
    padding-left: 20px;
    color: var(--muted);
    font-size: 0.9rem;
}

.hint-list li { margin-bottom: 8px; }

.plugin-fallback { margin-top: 12px; }

.feature-icon { margin-right: 6px; }

.feature-table .sub-row td {
    background: #fafbfc;
    font-size: 0.85rem;
}

.feature-table .sub-label {
    padding-left: 28px;
    color: var(--muted);
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.menu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.menu-card:hover {
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--primary);
}

.menu-card.live { border-left: 3px solid var(--success); }
.menu-card.pending { border-left: 3px solid var(--warn); opacity: 0.85; }

.menu-card-icon { font-size: 1.5rem; }
.menu-card-label { font-size: 0.85rem; font-weight: 500; text-align: center; }
.menu-card-status { font-size: 0.72rem; color: var(--muted); }

.search-form input[type="text"] { width: 280px; margin-bottom: 0; }

/* ========== 统一按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 0.8125rem;
    border-radius: 6px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
    text-decoration: none;
}

.btn-ghost {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: var(--text);
    text-decoration: none;
}

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

.btn-danger:hover {
    background: #b91c1c;
    color: #fff;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    padding: 0 4px;
    height: auto;
    min-height: 32px;
}

.btn-text:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}

.btn-text-danger {
    background: none;
    border: none;
    color: var(--error);
    padding: 0 4px;
    height: auto;
    min-height: 32px;
}

.btn-text-danger:hover {
    text-decoration: underline;
    color: #b91c1c;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 14px;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--muted);
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    line-height: 1;
}

.btn-link:hover {
    color: var(--primary);
    border-color: #cbd5e1;
    text-decoration: none;
}

/* ========== 列表面板（搜索 + 表格一体） ========== */
.list-panel {
    padding: 0;
    overflow: hidden;
}

.list-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px 16px;
}

.list-panel-title h2 {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-panel-desc {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.5;
}

.list-panel-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.toolbar-search {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex: 1;
    flex-wrap: wrap;
    min-width: 0;
}

.toolbar-search .field-group input,
.toolbar-search .field-group select {
    margin-bottom: 0;
    width: 100%;
}

.toolbar-search-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 1px;
}

.toolbar-batch {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    padding-bottom: 1px;
}

.batch-form-anchor {
    display: none;
}

.th-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    cursor: pointer;
    width: 100%;
}

.th-check input[type="checkbox"],
.col-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 10px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    border-radius: 6px;
    border: 1px solid #bfdbfe;
    background: #fff;
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-action:hover {
    background: var(--primary-light);
    border-color: #93c5fd;
    color: var(--primary-hover);
    text-decoration: none;
}

.btn-action-danger {
    border-color: #fecaca;
    color: var(--error);
    background: #fff;
}

.btn-action-danger:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 140px;
}

.field-group-wide {
    min-width: min(320px, 100%);
    flex: 1;
}

.field-group-sm {
    min-width: 110px;
}

.field-group label {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.field-group input,
.field-group select {
    height: 36px;
    padding: 0 12px;
    margin-bottom: 0;
    font-size: 0.875rem;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #fff;
}

.field-group input:focus,
.field-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.check-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 0.875rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    height: 32px;
}

.list-panel-body {
    padding: 0;
}

.list-panel-footer {
    margin: 0;
    padding: 14px 24px 18px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}

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

.empty-state p {
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.table-wrap-flat {
    border: none;
    border-radius: 0;
}

.table-wrap-flat .data-table th:first-child,
.table-wrap-flat .data-table td:first-child {
    padding-left: 24px;
}

.table-wrap-flat .data-table th:last-child,
.table-wrap-flat .data-table td:last-child {
    padding-right: 24px;
}

.col-check {
    width: 48px;
    text-align: center;
    vertical-align: middle;
}

.data-table th.col-check {
    padding-top: 10px;
    padding-bottom: 10px;
}

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

.nowrap { white-space: nowrap; }

.cell-result {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-info {
    font-size: 0.875rem;
    color: var(--muted);
}

.actions-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.actions-cell .inline-delete-form {
    display: inline-flex;
    margin: 0;
    align-items: center;
}

.data-table { font-size: 0.82rem; }
.data-table th { white-space: nowrap; }

.cell-address {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-sn { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-message { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.pagination span { font-size: 0.85rem; }

.tag-error { background: #fef2f2; color: var(--error); }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

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

body.modal-open { overflow: hidden; }

.modal-panel {
    background: var(--card);
    border-radius: 12px;
    width: min(720px, 100%);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    padding: 4px 8px;
}

.modal-body {
    padding: 20px;
    overflow: auto;
}

.detail-list {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px 16px;
    margin-bottom: 16px;
    font-size: 0.88rem;
}

.detail-list dt {
    color: var(--muted);
    margin: 0;
}

.detail-list dd {
    margin: 0;
    word-break: break-all;
}

.detail-subtitle {
    font-size: 0.92rem;
    margin: 0 0 8px;
}

.modal-pre {
    max-height: 320px;
    overflow: auto;
    margin: 0;
}

.code-block {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.78rem;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ========== 登录页 ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eff6ff 0%, #f0f2f5 100%);
}

.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
    text-align: center;
    color: var(--primary);
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.login-card .subtitle {
    text-align: center;
    color: var(--muted);
    margin-bottom: 28px;
}

.login-card button {
    width: 100%;
    padding: 12px;
    margin-top: 4px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    }

    .main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .grid-2 { grid-template-columns: 1fr; }
    .main-content { padding: 16px; }
    .list-panel-head,
    .list-panel-toolbar,
    .list-panel-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    .table-wrap-flat .data-table th:first-child,
    .table-wrap-flat .data-table td:first-child { padding-left: 16px; }
    .table-wrap-flat .data-table th:last-child,
    .table-wrap-flat .data-table td:last-child { padding-right: 16px; }
    .toolbar-batch { width: 100%; justify-content: flex-end; }
}
