:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --ink: #1f2d3d;
    --muted: #6b7a8d;
    --line: #e3e8ef;
    --brand: #2c5fe0;
    --brand-ink: #ffffff;
    --sidebar: #1f2a44;
    --sidebar-ink: #cdd6e6;
    --danger: #d93838;
    --warn: #d98a00;
    --ok: #1e9e5a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
}

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: var(--sidebar);
    color: var(--sidebar-ink);
    padding: 18px 0;
    flex-shrink: 0;
}

.sidebar .logo {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    padding: 0 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    margin-bottom: 12px;
}

.sidebar a {
    display: block;
    color: var(--sidebar-ink);
    text-decoration: none;
    padding: 10px 20px;
    font-size: 14px;
}

.sidebar a:hover, .sidebar a.active {
    background: rgba(255,255,255,.08);
    color: #fff;
    border-left: 3px solid var(--brand);
}

.main { flex: 1; padding: 22px 28px; overflow-x: auto; }

.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 18px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 8px; align-items: center; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 18px;
}

table.grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    font-size: 13px;
}

table.grid th, table.grid td {
    border: 1px solid var(--line);
    padding: 8px 10px;
    text-align: left;
    white-space: nowrap;
}

table.grid th { background: #f0f3f8; font-weight: 600; }
table.grid tr:hover td { background: #fafbfe; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.danger { color: var(--danger); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }

.btn {
    display: inline-block;
    background: var(--brand);
    color: var(--brand-ink);
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    text-decoration: none;
    font-size: 13px;
}
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: #eef1f6; color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 14px 22px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 600; color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea {
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: var(--ink);
}
.field.full { grid-column: 1 / -1; }
.att-list { list-style: none; margin: 4px 0 0; padding: 0; }
.att-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.att-list li:last-child { border-bottom: none; }
.att-meta { color: var(--muted); font-size: 12px; }
.att-del { color: #c0392b; font-size: 12px; }
.field-hint { font-size: 11px; color: var(--muted); opacity: .8; }
.field-hint::before { content: "· "; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
}
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 22px; font-weight: 700; margin-top: 4px; }

.legend { display: inline-block; padding: 2px 8px; border-radius: 10px; background: #eef1f6; font-size: 12px; color: var(--muted); }

.fk-row { display: flex; gap: 6px; align-items: center; }
.fk-row select { flex: 1; }
.btn-mini {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border: 1px solid var(--line);
    background: #eef1f6;
    color: var(--brand);
    border-radius: 6px;
    font-size: 18px; line-height: 1;
    cursor: pointer;
}
.btn-mini:hover { background: var(--brand); color: #fff; }

.modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(20, 30, 50, .45);
    align-items: center; justify-content: center;
    z-index: 50;
}
.modal-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px 20px;
    width: 360px; max-width: 92vw;
    box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.modal-box .field { margin-bottom: 10px; }

/* ---- 登录页 ---- */
.login-body { background: linear-gradient(160deg, #eef2f8, #dfe7f3); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(30,50,90,.12); padding: 34px 38px; width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-logo { font-size: 22px; font-weight: 800; text-align: center; }
.login-sub { color: var(--muted); text-align: center; margin-bottom: 6px; }
.login-error { background: #fdecec; color: #c0392b; border: 1px solid #f5c6c6; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 6px; }
.login-btn { width: 100%; margin-top: 4px; }
.login-hint { color: var(--muted); font-size: 12px; text-align: center; opacity: .85; }

/* ---- 侧边栏用户区 ---- */
.sidebar-user { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.15); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-user span { font-size: 12px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { background: none; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 6px; font-size: 12px; padding: 3px 10px; cursor: pointer; }
.logout-btn:hover { background: rgba(255,255,255,.15); }
.sidebar { display: flex; flex-direction: column; }
