:root {
  color-scheme: light;
  --bg: #f6f8fc;
  --panel: #ffffff;
  --panel-2: #f8faff;
  --panel-3: #edf3ff;
  --line: #d9e1ec;
  --line-soft: #e8edf4;
  --text: #17233a;
  --muted: #66758b;
  --accent: #2563d9;
  --accent-strong: #1e55bd;
  --accent-soft: #eaf1ff;
  --success: #16835c;
  --success-soft: #e8f7ef;
  --warning: #a66000;
  --warning-soft: #fff4da;
  --danger: #c93645;
  --danger-soft: #fff0f1;
  --shadow: 0 1px 2px rgba(25, 42, 70, 0.05), 0 8px 22px rgba(25, 42, 70, 0.04);
  --radius: 8px;
  --sidebar: 238px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
a { color: var(--accent-strong); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.boot,
.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.boot { gap: 12px; align-content: center; color: var(--muted); }

.spinner {
  width: 21px;
  height: 21px;
  display: inline-block;
  border: 2px solid #d9e2ef;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.auth-view { background: #f3f6fb; }

.auth-card {
  width: min(100%, 430px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 16px 45px rgba(31, 53, 86, 0.1);
}

.auth-card h1 { margin: 12px 0 6px; font-size: 25px; letter-spacing: -0.025em; }
.auth-card .form-grid { margin-top: 26px; }
.checker-card { width: min(100%, 650px); }
.checker-head { display: flex; align-items: center; gap: 12px; }
.checker-head div:last-child { min-width: 0; }
.checker-head h1 { margin: 0; }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.result-item { padding: 15px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--panel-2); }
.result-item span, .result-meta span { display: block; color: var(--muted); font-size: 11px; }
.result-item strong { display: block; margin-top: 7px; font-size: 20px; }
.result-meta { display: grid; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.result-meta p { display: flex; justify-content: space-between; gap: 12px; margin: 0; }
.result-meta strong { overflow-wrap: anywhere; text-align: right; }
.message { margin: 16px 0 0; color: var(--muted); }
.message.error { color: var(--danger); }
.auth-footnote { margin: 24px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid #cbd9f5;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 850;
  letter-spacing: -0.04em;
}

.brand-mark.small { width: 34px; height: 34px; border-radius: 8px; font-size: 12px; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: none; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.clipboard-helper { position: fixed; opacity: 0; pointer-events: none; }

.workspace { min-height: 100vh; }

.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand { display: flex; align-items: center; gap: 11px; min-height: 72px; padding: 18px 17px; border-bottom: 1px solid var(--line-soft); }
.brand strong, .brand span { display: block; }
.brand strong { color: var(--text); font-size: 14px; letter-spacing: -0.01em; }
.brand span { color: var(--muted); font-size: 11px; }

.nav-list { display: grid; gap: 3px; padding: 14px 11px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #53627a;
  cursor: pointer;
  text-align: left;
  transition: background-color 130ms ease, border-color 130ms ease, color 130ms ease;
}
.nav-item:hover { background: #f4f7fc; color: var(--text); }
.nav-item.active { border-color: #dce8ff; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.nav-icon { width: 20px; height: 20px; display: grid; place-items: center; color: currentColor; }
.nav-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 14px 15px;
  border-top: 1px solid var(--line-soft);
}
.identity { min-width: 0; display: flex; align-items: center; gap: 9px; flex: 1; }
.identity-copy { min-width: 0; }
.identity-copy strong, .identity-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-copy strong { color: var(--text); font-size: 12px; }
.identity-copy small { color: var(--muted); font-size: 11px; }
.avatar {
  width: 33px;
  height: 33px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #d1dcee;
  border-radius: 50%;
  background: #eef3ff;
  color: var(--accent-strong);
  font-weight: 800;
}

.app-shell { min-height: 100vh; margin-left: var(--sidebar); }
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  height: 70px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}
.topbar h1 { margin: 1px 0 0; color: var(--text); font-size: 15px; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.status-dot { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.status-dot i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(22, 131, 92, 0.1); }
.status-dot.error i { background: var(--danger); box-shadow: 0 0 0 3px rgba(201, 54, 69, 0.1); }
.mobile-menu { display: none !important; }

.content { width: min(100%, 1480px); margin: 0 auto; padding: 28px clamp(20px, 4vw, 48px) 64px; }
.view-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.view-head h2 { margin: 3px 0 0; color: #142039; font-size: 23px; letter-spacing: -0.03em; }
.view-head p { margin: 4px 0 0; }
.view-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-left: auto; }
.attention-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #f1d2a4;
  border-radius: var(--radius);
  background: #fff9ec;
  color: #74500e;
}
.attention-strip > div { min-width: 0; flex: 1 1 260px; display: grid; gap: 1px; }
.attention-strip strong { color: #69490e; font-size: 13px; }
.attention-strip span:not(.attention-icon) { color: #8d6822; font-size: 12px; }
.attention-strip .button { margin-left: auto; }
.attention-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f4b93f;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.stat-card { min-height: 116px; padding: 17px; }
.stat-card .label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.stat-card .value { display: block; margin-top: 15px; color: #142039; font-size: clamp(22px, 2vw, 28px); font-weight: 760; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.stat-card .hint { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.metric-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 7px; background: var(--accent-soft); color: var(--accent); }

.panel { margin-bottom: 16px; overflow: hidden; }
.panel-head { min-height: 58px; display: flex; align-items: center; gap: 12px; padding: 13px 17px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2, .panel-head h3 { margin: 0; color: var(--text); font-size: 14px; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.panel-head .panel-actions { display: flex; gap: 8px; margin-left: auto; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }
.split-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, 0.75fr); gap: 16px; }

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
}
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}
.button:hover { background: #1f57c2; box-shadow: 0 3px 8px rgba(37, 99, 217, 0.18); }
.button:active { background: #194ba8; }
.button.secondary { border-color: var(--line); background: #ffffff; color: #3f4e65; font-weight: 650; }
.button.secondary:hover { border-color: #bdcbe0; background: #f8faff; box-shadow: none; }
.button.ghost { border-color: transparent; background: transparent; color: var(--accent-strong); }
.button.ghost:hover { background: var(--accent-soft); box-shadow: none; }
.button.danger { border-color: #f2c7cc; background: var(--danger-soft); color: var(--danger); }
.button.danger:hover { border-color: #e7adb5; background: #fee4e6; box-shadow: none; }
.button.compact { min-height: 32px; padding: 0 10px; font-size: 12px; }
.button.block { width: 100%; }
.button:disabled, .icon-button:disabled { cursor: not-allowed; filter: grayscale(0.15); opacity: 0.52; box-shadow: none; }
.button .spinner { width: 14px; height: 14px; border-width: 2px; border-color: rgba(255, 255, 255, 0.48); border-top-color: #ffffff; }
.button.secondary .spinner { border-color: #d5deeb; border-top-color: var(--accent); }

.icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0; border-color: var(--line); background: #ffffff; color: #56657b; font-size: 17px; }
.icon-button:hover { border-color: #b8c6da; background: #f8faff; color: var(--text); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid.one { grid-template-columns: 1fr; }
.field { min-width: 0; display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { color: #394961; font-size: 12px; font-weight: 700; }
.field small { color: var(--muted); font-size: 11px; }
.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #ccd6e4;
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 9px 11px;
  outline: none;
  transition: border-color 130ms ease, box-shadow 130ms ease, background-color 130ms ease;
}
.input::placeholder, .textarea::placeholder { color: #8a98aa; }
.input:hover, .select:hover, .textarea:hover { border-color: #b6c4d8; }
.input:focus, .select:focus, .textarea:focus { border-color: #78a2f0; box-shadow: 0 0 0 3px rgba(37, 99, 217, 0.11); }
.input:disabled, .select:disabled { opacity: 0.62; cursor: not-allowed; }
.textarea { min-height: 90px; resize: vertical; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }
.auth-card .form-actions .button { width: 100%; }

.toolbar { display: grid; grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(130px, 0.35fr)) auto; gap: 9px; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); background: #fbfcfe; }
.toolbar.two { grid-template-columns: minmax(180px, 1fr) minmax(130px, 0.35fr) auto; }
.reconciliation-filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding: 16px; }
.reconciliation-filters .field { flex: 1 1 220px; min-width: 0; }
.reconciliation-stats .value { overflow-wrap: anywhere; font-size: clamp(20px, 1.8vw, 26px); }
.reconciliation-note { margin: 0 0 20px; color: var(--muted); font-size: 12px; }
.reconciliation-note p { margin: 6px 0; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th,
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
.data-table th { background: #f8faff; color: #66758b; font-size: 10px; font-weight: 800; letter-spacing: 0.045em; text-transform: uppercase; }
.data-table td { color: #40506a; font-size: 12px; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f5f8ff; }
.cell-main { display: block; color: var(--text); font-weight: 700; }
.cell-sub { display: block; max-width: 250px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; }
.actions { display: flex; align-items: center; gap: 6px; }

.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 23px; padding: 2px 8px; border: 1px solid #dce4ef; border-radius: 999px; background: #f4f6f9; color: #5f6e83; font-size: 10px; font-weight: 750; }
.badge::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.badge.success { border-color: #ccebd9; background: var(--success-soft); color: var(--success); }
.badge.warning { border-color: #f3dcab; background: var(--warning-soft); color: var(--warning); }
.badge.danger { border-color: #f3c8cd; background: var(--danger-soft); color: var(--danger); }
.badge.info { border-color: #cadbfd; background: var(--accent-soft); color: var(--accent-strong); }

.pagination { min-height: 57px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; }
.pagination-controls { display: flex; align-items: center; gap: 7px; }

.empty-state,
.error-state,
.loading-state { min-height: 230px; display: grid; place-items: center; align-content: center; gap: 8px; padding: 30px; color: var(--muted); text-align: center; }
.state-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #dbe4f1; border-radius: 10px; background: #f8faff; color: #64748a; font-size: 19px; }
.empty-state strong, .error-state strong { color: var(--text); }
.empty-state p, .error-state p { max-width: 420px; margin: 0; font-size: 12px; }
.error-state .state-icon { border-color: #f2c9cf; background: var(--danger-soft); color: var(--danger); }

.notice { padding: 13px 14px; border: 1px solid #dce4ef; border-radius: var(--radius); background: #f8faff; color: #526179; font-size: 12px; }
.notice.warning { border-color: #f1d9a6; background: #fff9e9; }
.notice.danger { border-color: #f0c5cb; background: var(--danger-soft); }
.notice strong { color: var(--text); }
#key-delete .notice { overflow-wrap: anywhere; }

.activity-list { display: grid; padding: 4px 0; }
.activity-item { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 11px; align-items: start; padding: 13px 17px; border-bottom: 1px solid var(--line-soft); }
.activity-item:last-child { border-bottom: 0; }
.activity-mark { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.activity-copy strong, .activity-copy small { display: block; }
.activity-copy strong { color: var(--text); font-size: 12px; }
.activity-copy small, .activity-time { color: var(--muted); font-size: 10px; }

.modal {
  width: min(calc(100% - 30px), 570px);
  max-height: min(88vh, 850px);
  padding: 0;
  border: 1px solid #cdd8e7;
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 20px 55px rgba(23, 43, 73, 0.2);
  overflow: hidden;
}
.modal::backdrop { background: rgba(31, 49, 77, 0.24); }
.modal-head { min-height: 68px; display: flex; align-items: center; gap: 10px; padding: 15px 19px; border-bottom: 1px solid var(--line-soft); background: #fbfcfe; }
.modal-head h2 { margin: 2px 0 0; font-size: 17px; }
.modal-head .icon-button { margin-left: auto; }
.modal-body { max-height: calc(88vh - 68px); padding: 20px; overflow-x: hidden; overflow-y: auto; }
.secret-box { display: grid; gap: 13px; }
.secret-value { position: relative; padding: 15px; border: 1px solid #cdddfb; border-radius: var(--radius); background: #f5f8ff; color: #1d4fae; font: 12px/1.65 "SFMono-Regular", Consolas, monospace; overflow-wrap: anywhere; user-select: all; }
.qr-placeholder { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8faff; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 9px; width: min(calc(100% - 36px), 360px); pointer-events: none; }
.toast { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; padding: 13px 14px; border: 1px solid #d5dfec; border-radius: var(--radius); background: #ffffff; box-shadow: 0 12px 30px rgba(22, 41, 70, 0.13); animation: toast-in 160ms ease both; pointer-events: auto; }
.toast.success { border-color: #c2e6d1; }
.toast.error { border-color: #efc4ca; }
.toast strong, .toast span { display: block; }
.toast strong { color: var(--text); font-size: 12px; }
.toast span { margin-top: 2px; color: var(--muted); font-size: 11px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

.nav-scrim { display: none; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  :root { --sidebar: 248px; }
  .sidebar { box-shadow: 12px 0 30px rgba(25, 43, 72, 0.13); transform: translateX(-101%); transition: transform 180ms ease; }
  .workspace.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim { position: fixed; z-index: 29; inset: 0; display: block; background: rgba(26, 42, 65, 0.28); opacity: 0; pointer-events: none; transition: opacity 180ms ease; }
  .workspace.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .app-shell { margin-left: 0; }
  .topbar { height: 64px; padding: 0 16px; }
  .mobile-menu { display: inline-grid !important; }
  .topbar .status-dot { display: none; }
  .content { padding: 22px 15px 48px; }
  .view-head { align-items: flex-start; flex-direction: column; }
  .view-actions { width: 100%; margin-left: 0; }
  .view-actions .button { flex: 1; }
  .attention-strip { align-items: flex-start; }
  .attention-strip .button { margin-left: 0; }
  .toolbar, .toolbar.two { grid-template-columns: 1fr; }
  .toolbar > :first-child { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-actions { grid-column: auto; }
  .auth-card { padding: 27px 21px; }
  .modal-body { padding: 17px; }
}

@media (max-width: 490px) {
  .result-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 108px; }
  .topbar-actions .button { width: 34px; padding: 0; font-size: 0; }
  .topbar-actions .button::after { content: "↻"; font-size: 17px; }
  .pagination { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
