/* Ru 发卡后台：与门禁共享月相、切角和数据刻度，不改管理交互。 */
:root {
  color-scheme: dark;
  --luna-ink-950: oklch(0.145 0.025 285);
  --luna-ink-900: oklch(0.195 0.035 285);
  --luna-paper: oklch(0.96 0.018 320);
  --luna-muted: oklch(0.77 0.025 300);
  --luna-pink: #ef2d5e;
  --luna-blue: #4f5af0;
  --luna-mint: #34d399;
  --luna-amber: #fbbf24;
  --luna-red: #f87171;
  --luna-yellow: #ffe71e;
  --page: var(--luna-ink-950);
  --surface: oklch(0.2 0.035 285 / 0.92);
  --surface-solid: var(--luna-ink-900);
  --surface-blue: oklch(0.24 0.045 295);
  --line: oklch(0.38 0.055 300 / 0.72);
  --line-strong: oklch(0.54 0.09 330);
  --text: var(--luna-paper);
  --muted: var(--luna-muted);
  --blue: var(--luna-pink);
  --blue-deep: oklch(0.75 0.16 350);
  --blue-pale: oklch(0.29 0.08 345);
  --pink: oklch(0.28 0.075 10);
  --pink-deep: var(--luna-red);
  --green: oklch(0.26 0.06 165);
  --green-deep: var(--luna-mint);
  --yellow: oklch(0.28 0.065 85);
  --yellow-deep: var(--luna-amber);
  --shadow: 0 26px 80px oklch(0.07 0.02 285 / 0.56);
  --shadow-soft: 0 16px 40px oklch(0.08 0.02 285 / 0.36);
  --radius-lg: 0;
  --radius-md: 12px;
  --radius-sm: 7px;
  --font-data: "Cascadia Mono", "JetBrains Mono", "Microsoft YaHei", monospace;
  --cut: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

html { background: var(--page); }
body {
  min-height: 100dvh;
  background: var(--page);
  color: var(--text);
  font-size: 16px;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 3px, oklch(0.9 0.02 320 / 0.016) 3px 4px);
}
.cloud-background::after {
  background: linear-gradient(90deg, oklch(0.13 0.025 285 / 0.97), oklch(0.14 0.025 285 / 0.86) 48%, oklch(0.13 0.03 300 / 0.64));
}
.cloud-background video { opacity: 0.68; object-position: 58% center; }
::selection { background: var(--luna-pink); color: var(--luna-paper); }
:focus-visible { outline: 2px solid var(--luna-yellow); outline-offset: 3px; }
.skip-link { z-index: 100; background: var(--surface-solid); box-shadow: var(--shadow-soft); }
.muted { color: var(--muted); }
.eyebrow, .section-kicker { color: var(--luna-pink); font-family: var(--font-data); font-size: 10px; letter-spacing: 0.2em; }

.button, .icon-button, .day-option {
  border: 1px solid var(--line);
  border-radius: 7px;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  background: oklch(0.25 0.04 285);
  color: var(--text);
  font-weight: 650;
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1), background-color 160ms ease-out, border-color 160ms ease-out;
}
.button:hover:not(:disabled), .icon-button:hover:not(:disabled), .day-option:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--luna-pink); background: oklch(0.31 0.06 320); box-shadow: none; }
.button:active:not(:disabled), .day-option:active:not(:disabled) { transform: scale(0.98); }
.button.primary { border-color: oklch(0.75 0.18 350); background: var(--luna-pink); color: oklch(0.985 0.005 350); box-shadow: none; }
.button.primary:hover:not(:disabled) { background: oklch(0.64 0.235 355); }
.button.secondary { background: transparent; color: var(--text); }
.button.danger { border-color: oklch(0.65 0.19 20 / 0.72); background: transparent; color: var(--luna-red); }
.button:disabled, .day-option:disabled { opacity: 0.48; }
.field > span:first-child, .days-fieldset legend { color: var(--text); }
.field input, .password-control input, .input-with-unit input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: oklch(0.15 0.025 285 / 0.96);
  color: var(--text);
  font-size: 16px;
}
.field input::placeholder { color: oklch(0.66 0.025 300); }
.field input:focus { border-color: var(--luna-pink); box-shadow: 0 0 0 3px oklch(0.6 0.22 350 / 0.18); }
.field-help { color: var(--muted); }
.form-message { color: var(--luna-red); }
.form-message.success { color: var(--luna-mint); }

/* 管理员登录：左侧任务简报，右侧唯一操作面板。 */
.login-shell { min-height: 100dvh; padding: clamp(20px, 5vw, 72px); }
.login-card {
  width: min(1120px, 100%);
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 28px) 0, 100% 28px, 100% 100%, 28px 100%, 0 calc(100% - 28px));
  background: oklch(0.18 0.03 285 / 0.93);
  box-shadow: var(--shadow);
}
.login-art {
  position: relative;
  min-height: 620px;
  padding: 34px 38px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(circle at 56% 54%, oklch(0.6 0.21 350 / 0.26), transparent 40%),
    oklch(0.16 0.03 285 / 0.7);
}
.login-art::before {
  content: "";
  position: absolute;
  top: 120px;
  left: 50%;
  width: 380px;
  height: 380px;
  border: 1px solid oklch(0.65 0.19 350 / 0.35);
  border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 38px, oklch(0.7 0.16 350 / 0.08) 39px 40px);
  transform: translateX(-50%);
}
.brand-lockup { position: relative; z-index: 2; font-family: var(--font-data); letter-spacing: 0.08em; }
.brand-lockup img { width: 50px; height: 50px; object-fit: contain; }
.brand-lockup small { color: var(--muted); font-size: 9px; letter-spacing: 0.16em; }
.login-art-copy { position: relative; z-index: 2; margin-top: 60px; }
.login-art-copy h2 { max-width: 13ch; color: var(--text); font-size: clamp(30px, 3.5vw, 46px); line-height: 1.28; letter-spacing: -0.04em; }
.login-art-copy p { max-width: 28rem; color: var(--muted); font-size: 16px; }
.login-mascot { position: absolute; z-index: 1; right: -24px; bottom: -20px; width: 340px; filter: drop-shadow(0 20px 32px oklch(0.08 0.03 285 / 0.5)); }
.art-note { position: absolute; z-index: 2; bottom: 26px; left: 38px; padding: 0; border: 0; border-radius: 0; background: none; color: var(--muted); font-family: var(--font-data); font-size: 10px; letter-spacing: 0.08em; }
.login-form-wrap { padding: 54px 46px; background: oklch(0.19 0.03 285 / 0.88); }
.login-form-wrap h1 { font-size: 34px; }
.security-note { color: var(--muted); font-family: var(--font-data); }
.security-note span { color: var(--luna-mint); }
.password-control .icon-button { color: var(--muted); background: transparent; }

/* 后台：窄轨道导航 + 宽工作区。 */
.admin-layout { grid-template-columns: 224px minmax(0, 1fr); gap: 28px; width: min(1580px, 100%); padding: 24px; }
.sidebar {
  top: 24px;
  height: calc(100dvh - 48px);
  padding: 24px 14px 18px;
  border: 1px solid var(--line);
  border-radius: 0;
  clip-path: var(--cut);
  background: oklch(0.18 0.03 285 / 0.94);
  box-shadow: var(--shadow-soft);
}
.sidebar-brand { padding: 4px 8px 22px; border-color: var(--line); }
.sidebar-brand img { width: 48px; height: 48px; object-fit: contain; }
.sidebar-brand strong { font-size: 23px; }
.sidebar-brand small { color: var(--muted); font-family: var(--font-data); letter-spacing: 0.12em; }
.side-nav { gap: 4px; margin-top: 28px; }
.nav-link { min-height: 50px; gap: 10px; padding: 11px 12px; border: 0; border-radius: 6px; color: var(--muted); font-size: 14px; }
.nav-link > span { width: 20px; height: 20px; color: var(--muted); font-family: var(--font-data); font-size: 17px; }
.nav-link:hover, .nav-link.active { border: 0; background: oklch(0.29 0.07 335); color: var(--text); }
.nav-link.active > span { color: var(--luna-pink); }
.sidebar-bottom p { color: var(--muted); font-family: var(--font-data); font-size: 10px; letter-spacing: 0.08em; }
.workspace { padding: 10px 0 24px; }
.workspace-header { padding: 14px 2px 28px; border-bottom: 1px solid var(--line); }
.workspace-header h1 { font-size: clamp(30px, 3vw, 42px); }
.workspace-header p { color: var(--muted); }
.session-chip, .soft-badge { border: 1px solid var(--line); border-radius: 6px; background: oklch(0.21 0.035 285); color: var(--text); font-family: var(--font-data); }
.online-dot { background: var(--luna-mint); box-shadow: 0 0 0 4px oklch(0.65 0.17 165 / 0.12), 0 0 12px oklch(0.65 0.17 165 / 0.5); }
.section-block { margin-top: 24px; }
.section-heading { margin: 0 0 14px; }
.stats-grid { gap: 10px; }
.stat-card {
  position: relative;
  min-height: 112px;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 0;
  clip-path: var(--cut);
  background: var(--surface);
  box-shadow: none;
}
.stat-total, .stat-active, .stat-unused, .stat-revoked { background: var(--surface); }
.stat-card::after { content: ""; position: absolute; top: 10px; right: 10px; width: 5px; height: 5px; border-radius: 50%; background: var(--luna-pink); }
.stat-active::after { background: var(--luna-mint); }
.stat-unused::after { background: var(--luna-amber); }
.stat-revoked::after { background: var(--luna-red); }
.stat-card span:not(.stat-icon) { color: var(--muted); font-family: var(--font-data); }
.stat-card strong { color: var(--text); font-family: var(--font-data); font-size: 34px; font-variant-numeric: tabular-nums; }
.stat-icon, .stat-total .stat-icon, .stat-active .stat-icon, .stat-unused .stat-icon, .stat-revoked .stat-icon { width: 24px; height: 24px; border-radius: 0; background: transparent; color: var(--muted); font-family: var(--font-data); font-size: 20px; }
.stat-active .stat-icon { color: var(--luna-mint); }
.stat-unused .stat-icon { color: var(--luna-amber); }
.stat-revoked .stat-icon { color: var(--luna-red); }
.dashboard-grid { grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.65fr); gap: 12px; margin-top: 20px; }
.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 0;
  clip-path: var(--cut);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.flow-panel { background: var(--surface); }
.soft-badge { background: oklch(0.28 0.07 340); color: var(--text); }
.day-options { gap: 7px; }
.day-option { border-color: var(--line); background: oklch(0.16 0.025 285); color: var(--muted); }
.day-option.selected { border-color: var(--luna-pink); background: var(--luna-pink); color: var(--luna-paper); box-shadow: none; }
.flow-list li:not(:last-child)::after { background: var(--line); }
.flow-list li > span { border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface-solid); color: var(--luna-pink); font-family: var(--font-data); }
.flow-list p { color: var(--muted); }
.cards-panel { margin-top: 12px; }
.cards-heading { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.cards-list { gap: 10px; }
.license-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: oklch(0.17 0.028 285 / 0.86);
  box-shadow: none;
}
.license-card:hover { border-color: var(--line-strong); box-shadow: none; }
.license-card-header { border-color: var(--line); }
.license-hint { color: var(--luna-yellow); font-family: var(--font-data); }
.status-badge { border: 1px solid var(--line); border-radius: 5px; font-family: var(--font-data); }
.status-active { border-color: oklch(0.55 0.14 165 / 0.5); background: var(--green); color: var(--green-deep); }
.status-unused { border-color: oklch(0.62 0.14 85 / 0.5); background: var(--yellow); color: var(--yellow-deep); }
.status-revoked, .status-expired { border-color: oklch(0.62 0.18 20 / 0.5); background: var(--pink); color: var(--pink-deep); }
.license-meta dt { color: var(--muted); }
.license-meta dd { color: var(--text); font-family: var(--font-data); }
.license-actions { border-color: var(--line); }
.loading-state, .empty-state { color: var(--muted); }
.loading-dot { background: var(--luna-pink); }
.password-panel { margin-top: 12px; }
.password-intro { border-color: var(--line); }
.password-intro p { color: var(--muted); }
.workspace-footer { color: var(--muted); font-family: var(--font-data); font-size: 11px; }

.dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: oklch(0.185 0.032 285 / 0.99);
  color: var(--text);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: oklch(0.08 0.02 285 / 0.78); backdrop-filter: blur(5px); }
.dialog p { color: var(--muted); }
.dialog-decoration, .confirm-symbol { border-color: var(--line-strong); background: oklch(0.28 0.08 345); color: var(--luna-pink); }
.generated-card { border: 1px dashed var(--line-strong); border-radius: 7px; background: oklch(0.14 0.025 285); color: var(--luna-yellow); font-family: var(--font-data); }
.toast { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-soft); }
.toast.success { border-color: oklch(0.55 0.14 165 / 0.65); }
.toast.error { border-color: oklch(0.62 0.18 20 / 0.65); }

@media (max-width: 1100px) {
  .admin-layout { grid-template-columns: 190px minmax(0, 1fr); gap: 20px; padding: 18px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .login-card { grid-template-columns: minmax(0, 1fr) minmax(340px, 0.9fr); }
  .login-mascot { width: 290px; }
}

@media (max-width: 800px) {
  .login-shell { padding: 20px; }
  .login-card { grid-template-columns: 1fr; }
  .login-art { min-height: 280px; padding: 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .login-art-copy { margin-top: 26px; }
  .login-art-copy h2 { font-size: 30px; }
  .login-art-copy p { max-width: 55%; }
  .login-mascot { right: 0; bottom: -54px; width: 230px; }
  .login-art::before { top: 10px; left: 76%; width: 250px; height: 250px; }
  .art-note { bottom: 18px; left: 24px; }
  .login-form-wrap { padding: 34px 28px; }
  .admin-layout { display: block; padding: 12px; }
  .sidebar { position: relative; top: 0; width: 100%; height: auto; margin-bottom: 16px; padding: 14px; clip-path: none; }
  .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 0 12px; }
  .sidebar-brand img { width: 40px; height: 40px; }
  .side-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
  .nav-link { justify-content: center; min-height: 46px; padding: 8px; text-align: center; }
  .sidebar-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
  .sidebar-bottom p { margin: 0; text-align: left; }
  .sidebar-bottom .button { width: auto; }
  .workspace-header { align-items: flex-start; }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .login-shell { padding: 10px; }
  .login-card { clip-path: none; }
  .login-art { min-height: 236px; padding: 18px; }
  .brand-lockup img { width: 42px; height: 42px; }
  .login-art-copy { margin-top: 18px; }
  .login-art-copy h2 { font-size: 25px; }
  .login-art-copy p { max-width: 62%; font-size: 14px; }
  .login-mascot { right: -10px; bottom: -28px; width: 160px; }
  .art-note { display: none; }
  .login-form-wrap { padding: 28px 20px; }
  .login-form-wrap h1 { font-size: 29px; }
  .admin-layout { padding: 8px; }
  .sidebar { padding: 12px; }
  .nav-link { gap: 4px; font-size: 12px; }
  .nav-link > span { display: none; }
  .sidebar-bottom p { display: none; }
  .sidebar-bottom .button { width: 100%; }
  .workspace-header { display: grid; gap: 16px; padding: 12px 4px 22px; }
  .header-actions { flex-wrap: wrap; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-card { min-height: 106px; padding: 14px; }
  .stat-card strong { font-size: 29px; }
  .stat-icon { display: none; }
  .panel { padding: 18px 14px; clip-path: none; }
  .panel-heading { align-items: flex-start; }
  .soft-badge { max-width: 120px; white-space: normal; }
  .day-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .generate-row { grid-template-columns: 1fr; }
  .custom-days { max-width: none; }
  .generate-row .button { width: 100%; }
  .license-card-header { align-items: flex-start; }
  .license-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .license-actions { display: grid; grid-template-columns: 1fr; }
  .license-actions .button { width: 100%; }
  .password-panel { display: block; }
  .password-intro { padding-bottom: 18px; }
  .dialog { width: calc(100% - 24px); padding: 22px 18px; }
  .dialog-actions { display: grid; grid-template-columns: 1fr; }
  .dialog-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .cloud-background video { display: none; }
  .cloud-background { background: var(--page) url("custom/background-poster.jpg") center / cover; }
}


/* 卡密摘要优先，时间记录按需展开，避免管理列表在手机端无限拉长。 */
.license-details { border-top: 1px solid var(--line); }
.license-details > summary {
  min-height: 42px;
  padding: 11px 16px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.license-details[open] > summary { color: var(--text); }
.license-meta-secondary { padding-top: 0; }
.generated-card { overflow-wrap: anywhere; word-break: break-all; }

@media (max-width: 520px) {
  .login-art { min-height: 132px; padding: 16px 18px; }
  .login-art-copy { margin-top: 12px; }
  .login-art-copy h2, .login-art-copy p { display: none; }
  .login-mascot { right: 2px; bottom: -32px; width: 116px; }
  .login-art::before { top: -74px; left: 78%; width: 210px; height: 210px; }
  .login-form-wrap { padding: 24px 20px; }
  .login-form-wrap h1 { font-size: 27px; }
  .license-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .license-actions .button { min-width: 0; padding-inline: 8px; }
  .license-details > summary { min-height: 44px; }
  .generated-card { font-size: clamp(13px, 4vw, 17px); }
}

/* ---- 卡密管理：完整卡密 / 折叠 / 搜索 ---- */
.cards-toolbar { margin: 10px 0 14px; }
.cards-search { width: 100%; padding: 10px 12px; font-size: 14px; color: #141413; background: #fff; border: 1px solid #141413; border-radius: 0; }
.license-card.collapsed .license-meta,
.license-card.collapsed .license-actions,
.license-card.collapsed .license-full { display: none; }
.license-card-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.license-toggle { margin-left: auto; }
.license-full { margin: 10px 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.license-full .license-key { font-family: "Menlo", "Consolas", monospace; font-size: 14px; word-break: break-all; background: #f5f5f5; border: 1px solid #8b8b88; padding: 8px 10px; }
