/* 平台端共享样式：变量、按钮、表单、表格、分页、Toast、抽屉。
   后台与社区各自再加载自己的布局样式。 */

:root {
    --bg: #e8f1fb;
    --bg-deep: #d6e7fa;
    --surface: #ffffff;
    --surface-soft: #f6f9fe;
    --border: #d5dfea;
    --text: #1f2d3d;
    --muted: #6b7a8c;
    --primary: #2a7de1;
    --primary-strong: #1d63b8;
    --primary-soft: #dbeafe;
    --danger: #c0392b;
    --danger-soft: #fde8e6;
    --success: #1f9d55;
    --warning: #b7791f;
    --radius: 8px;
    --shadow: 0 6px 22px rgba(31, 45, 61, .10);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 10px; font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- 平台壳层：顶栏 / 侧栏 / 页面布局 ---------- */
.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 56px;
    padding: 0 22px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(31, 45, 61, .05);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-topbar .brand {
    color: var(--primary-strong);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: .04em;
}
.app-topbar .brand a { color: inherit; text-decoration: none; }
.app-topbar .who {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.app-layout {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    width: min(1600px, 100%);
    margin: 0 auto;
    padding: 16px 20px 24px;
}

.app-nav {
    flex: 0 0 158px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(31, 45, 61, .05);
    position: sticky;
    top: 72px;
}
.app-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    transition: background-color .15s, color .15s;
}
.app-nav a:hover { background: var(--surface-soft); color: var(--primary); }
.app-nav a.active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 700; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary-strong);
    font: inherit;
    cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s, transform .05s;
    white-space: nowrap;
}
.btn:hover { background: #cfe4fd; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-strong); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #a93226; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--surface-soft); }
.btn.sm { min-height: 28px; padding: 3px 10px; font-size: 13px; }
.btn.block { width: 100%; }

/* ---------- 表单 ---------- */
input[type="text"], input[type="password"], input[type="number"],
input[type="search"], select, textarea {
    width: 100%;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(42, 125, 225, .15);
}
textarea { resize: vertical; min-height: 80px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
label { color: var(--muted); font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .readonly-value {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface-soft);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 16px; }

/* ---------- 卡片 / 筛选区 ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(31, 45, 61, .04);
}
.card-pad { padding: 16px; }
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.filters .field { min-width: 130px; }
.filters .field.grow { flex: 1; min-width: 200px; }
.filters .actions { display: flex; gap: 8px; margin-left: auto; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

/* ---------- 表格 ---------- */
.table-wrap {
    width: 100%;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eef4fd;
    color: #41536a;
    font-weight: 700;
    text-align: left;
}
.data-table th, .data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #edf1f6;
}
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: #f2f7ff; }
.data-table tbody tr.is-selected { background: #e3efff; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.check, .data-table td.check { width: 38px; text-align: center; }
.data-table .nowrap { white-space: nowrap; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    line-height: 20px;
}
.badge.ok { background: #e3f6ec; color: var(--success); }
.badge.warn { background: #fdf3e0; color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--primary-soft); color: var(--primary-strong); }

.empty {
    padding: 36px 16px;
    color: var(--muted);
    text-align: center;
}
.table-loading { padding: 26px 16px; text-align: center; color: var(--muted); }

/* ---------- 分页 ---------- */
.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 12px 0 2px;
    font-size: 13px;
}
.pager-btn {
    min-width: 32px;
    height: 30px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font: inherit;
}
.pager-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager-btn.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-btn:disabled { opacity: .45; cursor: default; }
.pager-gap { padding: 0 4px; color: var(--muted); }
.pager-info { color: var(--muted); }

/* ---------- 加载遮罩 ---------- */
.loading-mask {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(15, 23, 42, .42);
    color: #fff;
    font-size: 16px;
}
.loading-mask.is-visible { display: flex; }
.loading-mask img { max-width: 260px; max-height: 260px; border-radius: 12px; }

/* ---------- Toast ---------- */
.toast-host {
    position: fixed;
    top: 18px;
    left: 50%;
    z-index: 9500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transform: translateX(-50%);
    pointer-events: none;
}
.toast {
    min-width: 220px;
    max-width: 520px;
    padding: 9px 16px;
    border-radius: 8px;
    background: rgba(31, 45, 61, .92);
    color: #fff;
    box-shadow: var(--shadow);
    animation: toast-in .18s ease-out;
    word-break: break-word;
}
.toast-success { background: rgba(31, 157, 85, .95); }
.toast-error { background: rgba(192, 57, 43, .95); }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- 确认气泡 ---------- */
.popconfirm-mask {
    position: fixed;
    inset: 0;
    z-index: 9200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, .4);
}
.popconfirm {
    width: min(440px, 100%);
    padding: 18px 20px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 12px 36px rgba(0, 0, 0, .28);
}
.popconfirm-text { line-height: 1.7; white-space: pre-line; }
.popconfirm-input { width: 100%; min-height: 96px; margin-top: 10px; resize: vertical; }
.popconfirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- 抽屉表单 ---------- */
.drawer-mask {
    position: fixed;
    inset: 0;
    z-index: 9100;
    display: flex;
    justify-content: flex-end;
    background: rgba(15, 23, 42, .38);
}
.drawer {
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    height: 100%;
    background: var(--surface);
    box-shadow: -10px 0 34px rgba(0, 0, 0, .18);
    animation: drawer-in .18s ease-out;
}
@keyframes drawer-in {
    from { transform: translateX(30px); opacity: .6; }
    to { transform: translateX(0); opacity: 1; }
}
.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.drawer-head h3 { margin: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.drawer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-soft);
}
.drawer .section-title {
    margin: 18px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border);
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .08em;
}
.drawer .section-title:first-child { margin-top: 0; }

/* ---------- 通用头像 ---------- */
.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}

@media (max-width: 720px) {
    .filters .actions { margin-left: 0; width: 100%; }
    .drawer { width: 100%; }
}
