:root {
    --primary: #4361ee;
    --primary-light: #4895ef;
    --secondary: #3a0ca3;
    --danger: #f72585;
    --warning: #f8961e;
    --dark: #212529;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    color-scheme: light;
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    color: var(--dark);
    background: #f5f7fa;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; padding: 28px 16px; }
body:has(dialog[open]) { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { outline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--primary-light); }
main { width: 100%; max-width: 1180px; margin: auto; background: #fff; border-radius: 16px; box-shadow: 0 4px 20px #00000014; overflow: hidden; }
.compact-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 26px; background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; }
h1 { font-size: 21px; letter-spacing: .5px; margin: 0 0 6px; }
.compact-header p { margin: 0; color: #ffffffd9; font-size: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark, .login-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #ffffff2b; }
.brand-mark svg, .login-mark svg { width: 26px; height: 26px; }
.header-button { background: #ffffff20; color: white; border: 1px solid #ffffff4d; }
.header-button:hover { background: #ffffff38; }
.content { background: #f8fafc; padding: 22px; }
[hidden] { display: none !important; }
section.card { background: white; border: 1px solid #eef0f4; border-radius: 12px; box-shadow: 0 2px 8px #0000000a; padding: 22px; margin: 0 0 20px; }
section.card:last-child { margin-bottom: 0; }
h2 { font-size: 17px; margin: 0; font-weight: 600; }
h3 { font-size: 15px; }
p { color: var(--gray); font-size: 13px; line-height: 1.7; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.section-head p { margin: 6px 0 0; }
button, .button { display: inline-flex; justify-content: center; align-items: center; gap: 6px; cursor: pointer; border: 0; border-radius: 8px; padding: 10px 16px; font-size: 13px; font-weight: 500; color: white; background: linear-gradient(135deg, var(--primary), var(--primary-light)); transition: transform .2s, box-shadow .2s; text-decoration: none; }
button:hover, .button:hover { box-shadow: 0 4px 12px #4361ee33; transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }
.secondary { background: #f8f9fa; border: 1px solid var(--gray-light); color: var(--dark); }
.danger { background: linear-gradient(135deg, #f72585, #b5179e); }
.icon-button { border: 0; padding: 4px 9px; font-size: 24px; line-height: 1; border-radius: 8px; color: #8993a2; background: transparent; }
input, select, textarea { border: 1px solid #dfe4ec; border-radius: 8px; padding: 10px 12px; width: 100%; max-width: 100%; color: var(--dark); background-color: #fff; font-size: 13px; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px #4895ef1a; }
select { min-height: 39px; }
label { display: grid; gap: 8px; font-size: 13px; color: #4b5563; }
textarea { resize: vertical; min-height: 86px; font-family: ui-monospace, Consolas, monospace; line-height: 1.6; }
input[type='checkbox'] { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); cursor: pointer; vertical-align: middle; box-shadow: none; }
.fields { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; }
.fields label { flex: 1 1 175px; min-width: 0; }
.fields > input { flex: 2 1 230px; width: auto; }
.fields > select { flex: 1 1 145px; width: auto; }
.fields button { align-self: end; }
.stack-form { display: grid; gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-radius: 12px; background: white; border: 1px solid #eef0f4; box-shadow: 0 2px 8px #00000006; }
.stat span { font-size: 12px; color: var(--gray); }
.stat strong { display: block; font-size: 28px; margin-top: 6px; color: var(--dark); }
.stat-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: var(--primary); background: #4361ee12; font-size: 18px; }
.stat[data-state='active'] .stat-icon { color: #10b981; background: #10b98112; }
.stat[data-state='disabled'] .stat-icon { color: #f72585; background: #f7258510; }
.stat[data-state='expired'] .stat-icon { color: #f8961e; background: #f8961e12; }
.bulk-toolbar { margin-top: 16px; padding-top: 16px; border-top: 1px solid #f0f2f5; }
.bulk-toolbar span { color: var(--gray); font-size: 12px; }
.table-wrap { overflow-x: auto; margin: 18px -6px 0; }
table { border-collapse: collapse; width: 100%; text-align: left; white-space: nowrap; }
th, td { padding: 14px 10px; border-bottom: 1px solid #f0f2f5; font-size: 12px; }
th { background: #f8fafc; color: #6b7280; font-weight: 500; }
tbody tr:hover { background: #fafbfe; }
code { font-family: ui-monospace, Consolas, monospace; color: #475569; font-size: 12px; }
.card-id { color: #94a3b8; display: block; margin-bottom: 5px; font-size: 11px; }
.badge { display: inline-block; border-radius: 20px; padding: 4px 9px; font-size: 11px; font-weight: 500; }
.badge-unused { color: #4361ee; background: #4361ee12; }
.badge-active { color: #059669; background: #10b98112; }
.badge-disabled { color: #e21d76; background: #f7258512; }
.badge-expired { color: #cc7914; background: #f8961e15; }
.device-info { color: #6b7280; }
.online { color: #059669; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.actions button { padding: 6px 10px; font-size: 12px; }
.pager { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; color: var(--gray); font-size: 12px; }
.pager a { color: var(--primary); text-decoration: none; padding: 5px 9px; border: 1px solid #e5e7eb; border-radius: 6px; }
.empty-state { padding: 40px 12px; text-align: center; color: #94a3b8; }
.login-shell { max-width: 440px; }
.login-shell .compact-header { padding: 24px; }
.login { max-width: 360px; margin: 0 auto; padding: 8px 0 12px; }
.login-mark { color: var(--primary); background: #4361ee0c; width: 60px; height: 60px; border-radius: 18px; margin: 6px auto 18px; }
.login h2 { text-align: center; margin-bottom: 8px; font-size: 20px; }
.login > p { text-align: center; margin-bottom: 25px; }
.login form { display: grid; gap: 20px; }
.notice { color: #047857; background: #ecfdf5; border: 1px solid #d1fae5; border-radius: 8px; padding: 11px 14px; margin: 0 0 18px; }
.notice.error { color: #be185d; background: #fff1f7; border-color: #fce1ee; }
.notice:empty { display: none; }
.toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #000000d9; color: white; padding: 12px 20px; border-radius: 8px; box-shadow: 0 8px 20px #00000026; backdrop-filter: blur(10px); text-align: center; max-width: min(80vw, 460px); pointer-events: none; z-index: 10000; font-size: 13px; }
details { border-top: 1px solid #eef0f4; padding-top: 16px; margin-top: 20px; }
summary { cursor: pointer; font-size: 13px; color: #4b5563; margin-bottom: 16px; }
dialog { width: min(490px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); border: 0; border-radius: 24px; padding: 0; box-shadow: 0 25px 50px -12px #00000040; overflow: auto; animation: slideIn .25s ease-out; }
dialog::backdrop { background: #00000080; backdrop-filter: blur(5px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 22px 24px 18px; border-bottom: 1px solid #f0f2f5; }
.dialog-body { padding: 22px 24px; }
.dialog-footer { display: flex; flex-wrap: wrap; justify-content: end; gap: 10px; padding: 16px 24px; border-top: 1px solid #f0f2f5; background: #fcfcfe; }
#generated-dialog { width: min(740px, calc(100vw - 32px)); }
#generated-keys { margin-top: 16px; min-height: 220px; background: #f8fafc; }
.result-badge { border-radius: 9px; padding: 14px; background: #4361ee0a; color: #536281; font-size: 12px; line-height: 1.7; }
.result-badge strong { color: var(--primary); }
#card-faces { display: none; }
@keyframes slideIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 700px) {
    body { padding: 12px 10px; }
    .compact-header { padding: 18px 16px; }
    h1 { font-size: 17px; }
    .brand-mark { display: none; }
    .content { padding: 14px; }
    section.card { padding: 16px; }
    .stats { gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat { padding: 14px 16px; }
    .stat strong { font-size: 24px; }
    .section-head { align-items: start; }
    .fields { gap: 12px; }
    .fields label { flex-basis: 100%; }
    .fields > input, .fields > select { width: 100%; flex-basis: 100%; }
    .dialog-head, .dialog-body, .dialog-footer { padding: 18px; }
    .dialog-footer button { flex: 1; }
}
@media print {
    body { background: white; padding: 0; }
    main { width: 100%; max-width: none; overflow: visible; box-shadow: none; }
    main > :not(.content) { display: none !important; }
    .content { padding: 0; background: white; }
    .content > :not(#generated-dialog) { display: none !important; }
    #generated-dialog { position: static; display: block; width: 100%; max-height: none; overflow: visible; border: 0; box-shadow: none; padding: 0; animation: none; }
    #generated-dialog::backdrop { display: none; }
    #generated-dialog > :not(#card-faces) { display: none !important; }
    #card-faces { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
    #card-faces article { border: 1px solid #8a9db7; border-radius: 12px; padding: 20px; break-inside: avoid; }
    #card-faces code { overflow-wrap: anywhere; white-space: normal; font-size: 14px; }
}

.header-actions, .menu-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.header-actions form { margin: 0; }
#password-dialog .fields { display: grid; }
#password-dialog .fields button { margin-top: 4px; }
@media (max-width: 700px) {
    .compact-header { align-items: flex-start; flex-direction: column; gap: 14px; }
    .header-actions { width: 100%; justify-content: flex-end; }
    .header-button { padding: 7px 10px; font-size: 12px; }
    .section-head { flex-direction: column; }
    .menu-actions { width: 100%; }
    .menu-actions button { flex: 1; padding: 9px 10px; }
}

.app-layout { display: grid; grid-template-columns: 214px minmax(0, 1fr); max-width: 1440px; min-height: calc(100vh - 56px); }
.workspace { min-width: 0; }
.sidebar { background: white; border-right: 1px solid #eef0f4; padding: 25px 16px 18px; display: flex; flex-direction: column; min-width: 0; }
.sidebar-brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 28px; }
.sidebar-brand strong { display: block; font-size: 17px; color: #273043; }
.sidebar-brand small { display: block; margin-top: 5px; font-size: 10px; color: #94a3b8; letter-spacing: 1px; }
.sidebar-symbol { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 10px; background: linear-gradient(135deg, #4361ee, #4895ef); color: white; font-size: 25px; }
.side-menu { display: grid; gap: 8px; }
.side-menu a { display: flex; align-items: center; gap: 12px; padding: 13px 16px; color: #64748b; text-decoration: none; font-size: 13px; border-radius: 9px; }
.side-menu a span { font-size: 18px; }
.side-menu a:hover { background: #f8fafc; }
.side-menu a.active { background: #4361ee0d; color: #4361ee; font-weight: 600; }
.login-log-card { margin-top: auto; padding: 16px 12px; border: 1px solid #eef0f4; border-radius: 12px; background: #fafbfe; }
.login-log-card h2 { font-size: 12px; margin-bottom: 12px; color: #475569; }
.login-log-entry { padding: 11px 0; border-top: 1px solid #edf0f5; }
.login-log-entry > div { display: flex; justify-content: space-between; gap: 5px; font-size: 10px; }
.login-log-entry strong { font-weight: 500; max-width: 75px; overflow: hidden; text-overflow: ellipsis; }
.login-log-entry time { display: block; margin-top: 7px; font-size: 10px; color: #94a3b8; }
.log-success { color: #059669; }
.log-failure { color: #e21d76; }
@media (max-width: 800px) {
    .app-layout { grid-template-columns: 160px minmax(0, 1fr); }
    .sidebar { padding: 20px 10px 14px; }
    .sidebar-brand { gap: 6px; padding-left: 2px; padding-right: 2px; }
    .sidebar-brand strong { font-size: 14px; }
    .sidebar-symbol { width: 30px; height: 30px; font-size: 21px; }
    .login-log-card { padding: 12px 9px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
    body { padding: 0; }
    .app-layout { grid-template-columns: 112px minmax(0, 1fr); min-height: 100vh; border-radius: 0; }
    .sidebar { padding: 18px 7px 12px; }
    .sidebar-brand { flex-direction: column; align-items: flex-start; padding-left: 9px; padding-bottom: 22px; }
    .sidebar-brand small { font-size: 9px; letter-spacing: 0; }
    .side-menu a { padding: 12px 9px; gap: 7px; font-size: 12px; }
    .side-menu a span { font-size: 15px; }
    .login-log-entry > div { flex-direction: column; gap: 5px; }
    .login-log-entry time { font-size: 9px; line-height: 1.6; }
    .compact-header { padding: 16px 12px; }
    h1 { font-size: 15px; }
    .compact-header p { font-size: 10px; }
    .header-actions { gap: 6px; justify-content: flex-start; }
    .header-button { padding: 7px 8px; font-size: 10px; }
    .content { padding: 12px 9px; }
    section.card { padding: 12px; }
    .stats { grid-template-columns: 1fr; }
    .login-shell { margin: 25px auto; width: calc(100% - 24px); }
}
@media print {
    .app-layout { display: block; min-height: 0; }
    .sidebar { display: none !important; }
    main > .workspace { display: block !important; }
    .workspace > :not(.content) { display: none !important; }
}

.app-layout { overflow: clip; }
.sidebar { position: sticky; top: 28px; height: calc(100vh - 56px); overflow-y: auto; align-self: start; }
@media (max-width: 700px) { .sidebar { top: 12px; height: calc(100dvh - 24px); } }
@media (max-width: 520px) { .sidebar { top: 0; height: 100dvh; } }

.login-log-list { max-height: min(550px, calc(100dvh - 310px)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #bac7e2 transparent; }
.login-log-list::-webkit-scrollbar { width: 4px; }
.login-log-list::-webkit-scrollbar-thumb { background: #bac7e2; border-radius: 5px; }
.login-log-entry { min-height: 55px; }
.login-log-card { flex-shrink: 0; }

.machine-code { display: block; min-width: 120px; max-width: 220px; white-space: normal; overflow-wrap: anywhere; user-select: text; }
.badge-unbound { color: #8055cc; background: #8055cc12; }
.stat[data-state='unbound'] .stat-icon { color: #8055cc; background: #8055cc12; }
@media (min-width: 801px) { .stats { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.card-key { display: block; min-width: 130px; max-width: 300px; white-space: normal; overflow-wrap: anywhere; user-select: text; }

.page-disabled { display: inline-block; padding: 5px 9px; border: 1px solid #edf0f5; border-radius: 6px; color: #b0b8c4; cursor: default; }
.page-size-form { margin-left: auto; }
.page-size-form label { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.page-size-form select { width: auto; min-width: 82px; padding: 6px 10px; min-height: 32px; }
@media (max-width: 700px) { .page-size-form { margin-left: 0; width: 100%; } }
