:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --brand-soft: #eff6ff;
    --green: #15803d;
    --green-soft: #dcfce7;
    --red: #b91c1c;
    --red-soft: #fee2e2;
    --orange: #b45309;
    --orange-soft: #fef3c7;
    --amber: #92400e;
    --amber-soft: #ffedd5;
    --gray: #475569;
    --gray-soft: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -16px rgba(15, 23, 42, .25);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

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

.container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 28px;
    height: 60px;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: .2px;
    white-space: nowrap;
}

.brand:hover { text-decoration: none; }
.brand span {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    padding-left: 8px;
    border-left: 1px solid var(--line);
}

.topnav { display: flex; gap: 6px; flex: 1; }
.topnav a {
    padding: 7px 12px;
    border-radius: 8px;
    color: var(--ink-2);
    font-weight: 500;
}
.topnav a:hover { background: #f8fafc; text-decoration: none; }
.topnav a.active { background: var(--brand-soft); color: var(--brand-dark); }

.topuser {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--muted);
}
.topuser form { margin: 0; }
.topuser .link-btn {
    background: none;
    border: 0;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 2px;
}
.topuser .link-btn:hover { color: var(--red); }

/* ---------------- 主体 ---------------- */
main.container { padding-top: 24px; padding-bottom: 48px; }

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

.page-head h1 {
    margin: 0 0 4px;
    font-size: 22px;
    letter-spacing: .3px;
}

.page-head .sub { color: var(--muted); font-size: 13px; }

.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------- 统计卡 ---------------- */
.stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: var(--ink);
    box-shadow: var(--shadow);
    transition: border-color .15s, transform .15s;
}
.stat:hover { text-decoration: none; border-color: #cbd5e1; transform: translateY(-1px); }
.stat .k { font-size: 12.5px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 700; line-height: 1.3; letter-spacing: .5px; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat.is-alert .v { color: var(--red); }
.stat.is-warn .v { color: var(--orange); }
.stat.is-on { border-color: #bfdbfe; background: linear-gradient(180deg, #f8fbff, #fff); }

/* ---------------- 卡片/表格 ---------------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card + .card { margin-top: 16px; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.card-body { padding: 18px; }

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: #fcfdff;
}
.filters .grow { flex: 1 1 240px; }
.filters input[type=text], .filters select { height: 36px; }

table.list {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.list th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    font-size: 12.5px;
    letter-spacing: .3px;
    background: #f8fafc;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

table.list td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

table.list tbody tr:hover { background: #fbfdff; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list .num { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list .who { font-weight: 600; color: var(--ink); }
table.list .meta { color: var(--muted); font-size: 12.5px; }
table.list .cell-strong { font-weight: 600; font-variant-numeric: tabular-nums; }
table.list .days { display: block; font-size: 12px; color: var(--muted); }
table.list .days.red { color: var(--red); }
table.list .days.orange { color: var(--orange); }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; white-space: nowrap; }

/* ---------------- 徽章 ---------------- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.7;
    white-space: nowrap;
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.blue { background: var(--brand-soft); color: var(--brand-dark); }
.badge.gray { background: var(--gray-soft); color: var(--gray); }

/* ---------------- 按钮 ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 15px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-2);
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 0 2px; height: auto; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------- 表单 ---------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 22px;
}
.form-grid .full { grid-column: 1 / -1; }

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 6px;
}
.field label .req { color: var(--red); margin-left: 2px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.field .err { color: var(--red); font-size: 12.5px; margin-top: 5px; }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    padding: 8px 11px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
textarea { resize: vertical; min-height: 84px; }

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: var(--ink-2);
    cursor: pointer;
}
.checkbox input { width: 16px; height: 16px; }

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 16px 18px;
    border-top: 1px solid var(--line);
    background: #fcfdff;
}

/* ---------------- 提示 ---------------- */
.flash {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 13.5px;
    border: 1px solid transparent;
}
.flash.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash.info { background: var(--brand-soft); border-color: #bfdbfe; color: var(--brand-dark); }

/* ---------------- 详情页 ---------------- */
.detail-grid {
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 16px;
    align-items: start;
}

.kv {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 22px;
}
.kv .item .k { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.kv .item .v { font-size: 14px; color: var(--ink); font-weight: 500; word-break: break-all; }
.kv .item.full { grid-column: 1 / -1; }

.license-box {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
    max-height: 190px;
    overflow: auto;
    white-space: pre-wrap;
}
.license-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; align-items: center; }

.table-plain { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-plain td { padding: 8px 0; border-bottom: 1px dashed #eef2f7; vertical-align: top; }
.table-plain tr:last-child td { border-bottom: 0; }
.table-plain td.k { color: var(--muted); width: 132px; white-space: nowrap; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
    display: flex;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px dashed #eef2f7;
    font-size: 13px;
}
.timeline li:last-child { border-bottom: 0; }
.timeline .time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12.5px; }
.timeline .what { color: var(--ink-2); }

/* ---------------- 空状态 / 分页 ---------------- */
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--ink-2); font-weight: 600; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

.pager {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 14px;
    border-top: 1px solid var(--line);
    font-size: 13px;
    color: var(--muted);
}
.pager a, .pager span.cur {
    display: inline-block;
    min-width: 32px;
    text-align: center;
    padding: 4px 9px;
    border-radius: 7px;
    border: 1px solid var(--line);
    color: var(--ink-2);
}
.pager span.cur { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pager a:hover { background: #f8fafc; text-decoration: none; }

footer.site {
    padding: 22px 0 34px;
    text-align: center;
    color: #94a3b8;
    font-size: 12.5px;
}

/* ---------------- 登录 ---------------- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(1200px 500px at 50% -10%, #dbeafe 0%, #f1f5f9 55%, #f1f5f9 100%);
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 390px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 24px 60px -30px rgba(15, 23, 42, .35);
    padding: 30px 28px 26px;
}
.login-card .logo {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.login-card h1 { margin: 0 0 4px; font-size: 19px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; height: 40px; font-size: 14px; margin-top: 6px; }
.login-foot { text-align: center; color: #94a3b8; font-size: 12px; margin-top: 18px; }

@media (max-width: 1080px) {
    .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .topbar-inner { gap: 14px; }
    .brand span { display: none; }
    .topnav { gap: 2px; }
    .topnav a { padding: 6px 9px; font-size: 13px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; }
    table.list { display: block; overflow-x: auto; white-space: nowrap; }
    .filters .grow { flex-basis: 100%; }
}
