:root {
  --brand: #0052d9;
  --brand-hover: #366ef4;
  --brand-light: #f2f3ff;
  --success: #2ba471;
  --success-bg: #c6f3d7;
  --warning: #d96c00;
  --warning-bg: #f3d7b5;
  --danger: #e34d59;
  --bg: #eeeeee;
  --card: #ffffff;
  --border: #dddddd;
  --border-light: #e8e8e8;
  --text: rgba(0, 0, 0, 0.9);
  --text-2: rgba(0, 0, 0, 0.66);
  --text-3: rgba(0, 0, 0, 0.55);
  --text-4: #939497;
  --radius-card: 6px;
  --radius-modal: 8px;
  --radius-btn: 4px;
  --sidebar-w: 232px;
  --sidebar-min: 64px;
  --ease: cubic-bezier(0.645, 0.045, 0.355, 1);
  --font: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body, #root {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 22px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { letter-spacing: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

/* ---------- 布局 ---------- */
.app-shell {
  display: flex;
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
}

/* ---------- 侧栏 ---------- */
.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex: 0 0 var(--sidebar-w);
  flex-direction: column;
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border-light);
  transition: width .28s var(--ease), flex-basis .28s var(--ease);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar--collapsed {
  flex-basis: var(--sidebar-min);
  width: var(--sidebar-min);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-light);
  overflow: hidden;
}

.sidebar__logo {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__logo svg { width: 15px; height: 15px; color: #fff; }

.sidebar__name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-menu {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 16px 8px;
  list-style: none;
  overflow-y: auto;
}

.side-menu__item {
  position: relative;
  display: flex;
  flex: 0 0 36px;
  align-items: center;
  width: 100%;
  height: 36px;
  padding: 0 10px 0 16px;
  overflow: hidden;
  color: var(--text-3);
  background: transparent;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
  transition: background-color .28s var(--ease), color .28s var(--ease);
}

.side-menu__item:hover:not(.is-active) { background: #eee; }
.side-menu__item.is-active { color: var(--brand); background: var(--brand-light); font-weight: 500; }
.side-menu__item svg { flex: 0 0 18px; width: 18px; height: 18px; margin-right: 10px; }

.side-menu__label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

.sidebar--collapsed .side-menu__item { padding: 0 0 0 15px; }
.sidebar--collapsed .side-menu__label { display: none; }
.sidebar--collapsed .sidebar__name { display: none; }
.sidebar--collapsed .sidebar__brand { padding: 0 19px; justify-content: center; }

.side-menu__operations {
  padding: 12px 8px 16px;
  border-top: 1px solid var(--border-light);
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 34px;
  color: var(--text-3);
  background: transparent;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}

.icon-button:hover { background: #eee; color: var(--text); }
.icon-button svg { width: 18px; height: 18px; }

/* ---------- 内容区 ---------- */
.content {
  flex: 1;
  min-width: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 100%;
}

.content__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 2px;
}

.content__title { margin: 0; font-size: 20px; font-weight: 500; line-height: 28px; }
.content__sub { font-size: 13px; color: var(--text-3); }

/* ---------- 卡片 ---------- */
.card {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.card__header h1, .card__header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 22px;
}

.card__body { padding: 16px; }

.card__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  font-size: 12px;
  line-height: 20px;
  color: var(--success);
  background: var(--success-bg);
  border-radius: 10px;
}

.card__badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

/* ---------- 公告 ---------- */
.notice-list { margin: 0; padding-left: 18px; color: var(--text-2); }
.notice-list li { margin-bottom: 8px; line-height: 1.75; font-size: 13px; }
.notice-list li:last-child { margin-bottom: 0; }

/* ---------- 表单 ---------- */
.parse-form { display: flex; flex-direction: column; gap: 16px; }

.form-field { display: flex; flex-direction: column; gap: 8px; }

.form-field__label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-2);
}

.form-field.is-required .form-field__label::after {
  content: "*";
  color: var(--danger);
}

.form-field__control textarea,
.form-field__control input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 22px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  outline: 0;
  transition: border-color .2s, box-shadow .2s;
  resize: vertical;
}

.form-field__control textarea { min-height: 88px; }

.form-field__control textarea:focus,
.form-field__control input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(0, 82, 217, 0.1);
}

.form-field__control textarea::placeholder,
.form-field__control input::placeholder { color: var(--text-4); }

.form-field.has-error .form-field__control textarea,
.form-field.has-error .form-field__control input { border-color: var(--danger); }

.field-error {
  font-size: 12px;
  line-height: 20px;
  color: var(--danger);
}

.field-hint {
  font-size: 12px;
  line-height: 20px;
  color: var(--text-4);
}

.form-row { display: flex; gap: 16px; }
.form-row > .form-field { flex: 1; }

.form-actions { display: flex; gap: 12px; align-items: center; }

/* ---------- 按钮 ---------- */
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 20px;
  font-size: 14px;
  line-height: 22px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background-color .2s, border-color .2s;
}

.primary-button {
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
}

.primary-button:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }

.secondary-button {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
}

.secondary-button:hover:not(:disabled) { background: #f5f5f5; }

.primary-button:disabled,
.secondary-button:disabled { opacity: .5; cursor: not-allowed; }

.button-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ---------- 结果 ---------- */
.query-result { margin-top: 16px; }

.result-block {
  padding: 14px 16px;
  background: #f8f9fb;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
}

.result-block__row {
  display: flex;
  gap: 12px;
  padding: 5px 0;
  font-size: 13px;
}

.result-block__row dt { flex: 0 0 88px; color: var(--text-3); margin: 0; }
.result-block__row dd { flex: 1; margin: 0; word-break: break-all; }

.code-chip {
  display: inline-block;
  padding: 0 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--brand);
  background: var(--brand-light);
  border-radius: 3px;
}

.status-alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 22px;
  border-radius: var(--radius-card);
}

.status-alert--warn { color: #8a4b00; background: #fdf3e6; border: 1px solid var(--warning-bg); }
.status-alert--info { color: #0b3f8f; background: #eef4ff; border: 1px solid #cfe0fb; }
.status-alert--error { color: #8d2830; background: #fdeced; border: 1px solid #f6c9cc; }
.status-alert--ok { color: #1c6b4c; background: #eaf7f1; border: 1px solid #bfe6d5; cursor: pointer; }
.status-alert--ok:hover { background: #e0f3ea; }

/* ---------- 空态 ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 16px;
  color: var(--text-4);
  font-size: 13px;
}

.empty-state svg { width: 44px; height: 44px; opacity: .45; }

/* ---------- 弹窗 ---------- */
.welcome-notice,
.access-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.56);
  animation: fade-in .18s ease-out;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.welcome-notice__dialog {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100dvh - 40px);
  padding: 30px;
  overflow-y: auto;
  background: #fff;
  border-radius: var(--radius-modal);
  box-shadow: 0 24px 64px rgba(15, 23, 42, .3);
  animation: modal-in .2s ease-out;
}

.access-modal__dialog {
  width: min(400px, 100%);
  padding: 28px 24px 24px;
  background: #fff;
  border-radius: var(--radius-modal);
  box-shadow: 0 16px 48px rgba(15, 23, 42, .24);
  text-align: center;
  animation: modal-in .18s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.welcome-notice__close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--text-3);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.welcome-notice__close:hover { background: #eee; color: var(--text); }
.welcome-notice__close svg { width: 18px; height: 18px; }

.welcome-notice__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand);
}

.welcome-notice__eyebrow svg { width: 16px; height: 16px; }

.welcome-notice__dialog h2 {
  margin: 0 42px 16px 0;
  font-size: 22px;
  font-weight: 500;
  line-height: 30px;
}

.welcome-notice__content { color: var(--text-2); line-height: 1.8; font-size: 13.5px; }
.welcome-notice__content p { margin: 0 0 10px; }
.welcome-notice__content strong { color: var(--brand); font-weight: 500; }
.welcome-notice__lead { color: var(--text); font-size: 15px; font-weight: 500; margin-bottom: 12px !important; }
.welcome-notice__footnote {
  padding-top: 12px;
  margin-top: 4px;
  color: var(--text-3);
  border-top: 1px solid var(--border-light);
  font-size: 12.5px;
}

.welcome-notice__actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
  margin-top: 22px;
}

.welcome-notice__secondary,
.welcome-notice__primary,
.access-modal__secondary,
.access-modal__primary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  text-align: center;
  font-size: 14px;
}

.welcome-notice__secondary,
.access-modal__secondary {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
}

.welcome-notice__secondary:hover,
.access-modal__secondary:hover { background: #f5f5f5; }

.welcome-notice__primary,
.access-modal__primary {
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
}

.welcome-notice__primary:hover,
.access-modal__primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }

.access-modal__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  color: var(--brand);
  background: var(--brand-light);
  border-radius: 50%;
}

.access-modal__icon svg { width: 24px; height: 24px; }
.access-modal__dialog h2 { margin: 0 0 8px; font-size: 17px; font-weight: 500; }
.access-modal__dialog p { margin: 0 0 20px; color: var(--text-2); font-size: 13.5px; line-height: 1.7; }
.access-modal__actions { display: flex; gap: 10px; }
.access-modal__actions > * { flex: 1; }
.access-modal__actions--single > * { flex: 1; }
.access-modal__hint { margin: 14px 0 0 !important; font-size: 12px !important; color: var(--text-4) !important; }

/* ---------- 解析结果弹窗 ---------- */
.result-dialog {
  width: min(440px, 100%);
  padding: 28px 24px 20px;
}

.result-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  color: #fff;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 8px rgba(43, 164, 113, .1);
}

.result-hero svg { width: 26px; height: 26px; }

.result-dialog h2 { margin: 0 0 6px !important; font-size: 18px !important; }
.result-dialog > p { margin: 0 0 18px !important; font-size: 13px !important; color: var(--text-3) !important; }

.result-list {
  max-height: 46vh;
  overflow-y: auto;
  text-align: left;
}

.result-item {
  padding: 14px 16px;
  background: #f8f9fb;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  margin-bottom: 10px;
}

.result-item:last-child { margin-bottom: 0; }

.result-item__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.result-item__tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 9px;
  font-size: 12px;
  line-height: 20px;
  color: var(--brand);
  background: var(--brand-light);
  border-radius: 10px;
}

.result-item__tag--warn { color: var(--warning); background: #fdf3e6; }

.result-code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 4px;
  margin-bottom: 10px;
}

.result-code-box dt { font-size: 12px; color: var(--text-3); margin: 0 0 2px; }
.result-code-box dd { margin: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 20px; font-weight: 500; letter-spacing: 2px; color: var(--brand); }

.copy-btn {
  flex: 0 0 auto;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--brand);
  background: #fff;
  border: 1px solid #c3d4f5;
  border-radius: 4px;
  cursor: pointer;
}

.copy-btn:hover { background: var(--brand-light); }

.result-row {
  display: flex;
  gap: 10px;
  font-size: 12.5px;
  line-height: 20px;
  padding: 2px 0;
}

.result-row dt { flex: 0 0 58px; color: var(--text-3); margin: 0; }
.result-row dd { flex: 1; margin: 0; color: var(--text-2); word-break: break-all; }

.result-dialog .access-modal__actions { margin-top: 18px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  font-size: 13.5px;
  color: #fff;
  background: #2b2b2b;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  transform: translateX(-50%);
  animation: toast-in .2s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.toast svg { width: 16px; height: 16px; flex: 0 0 16px; }
.toast--warning { background: #8a4b00; }
.toast--error { background: #a32d2d; }

/* ---------- 卡密结果 ---------- */
.query-card__body { padding: 16px; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  margin-top: 14px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.kv-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: #fff;
}

.kv-grid dt { font-size: 12px; color: var(--text-3); margin: 0; }
.kv-grid dd { margin: 0; font-size: 14px; color: var(--text); font-weight: 500; }

/* ---------- 移动端 ---------- */
.sidebar-toggle-mobile { display: none; }

@media (max-width: 768px) {
  .content { padding: 16px; }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform .28s var(--ease);
    box-shadow: 4px 0 24px rgba(0, 0, 0, .12);
    flex-basis: var(--sidebar-w);
    width: var(--sidebar-w);
  }
  .sidebar.is-open { transform: none; }
  .sidebar--collapsed { flex-basis: var(--sidebar-w); width: var(--sidebar-w); }
  .sidebar--collapsed .side-menu__label { display: block; }
  .sidebar--collapsed .side-menu__item { padding: 0 10px 0 16px; }
  .sidebar-toggle-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-right: 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
  }
  .sidebar-toggle-mobile svg { width: 18px; height: 18px; }
  .mobile-bar {
    display: flex;
    align-items: center;
    margin: -4px -4px 4px;
  }
  .welcome-notice { align-items: flex-end; padding: 0; }
  .welcome-notice__dialog {
    width: 100%;
    max-height: calc(100dvh - 24px);
    padding: 26px 20px calc(20px + env(safe-area-inset-bottom));
    border-radius: 8px 8px 0 0;
  }
  .welcome-notice__dialog h2 { font-size: 19px; }
  .form-row { flex-direction: column; gap: 16px; }
  .form-actions { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .content__title { font-size: 17px; }
  .welcome-notice__actions { grid-template-columns: 1fr; }
  .access-modal__actions { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
