/* 生产 ERP 前端样式（SERP-FE-SHELL）
   设计：左窄深蓝导航 + 浅灰工作区 + 青绿主色；清爽、可读、键盘可用、无外部字体/图标。 */

:root {
  --navy-900: #0d2136;
  --navy-800: #12304b;
  --navy-700: #1b4063;
  --navy-text: #d8e4f0;
  --navy-text-dim: #9db3c8;
  --teal-600: #0f8f8f;
  --teal-700: #0b7575;
  --teal-100: #e2f4f2;
  --ink: #1b2733;
  --ink-2: #45566a;
  --muted: #6b7c8f;
  --line: #d8dee6;
  --line-soft: #e6ebf1;
  --surface: #ffffff;
  --workspace: #f2f4f7;
  --success: #1f7a4d;
  --success-bg: #e8f5ee;
  --warn: #a4681a;
  --warn-bg: #fdf3e2;
  --danger: #b4322b;
  --danger-bg: #fdecea;
  --info-bg: #eef3f9;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 35, 54, 0.08), 0 6px 20px rgba(16, 35, 54, 0.06);
  --focus: 0 0 0 3px rgba(15, 143, 143, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB",
    "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Cascadia Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--workspace);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0 0 6px;
  line-height: 1.3;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

p {
  margin: 0 0 8px;
}

a {
  color: var(--teal-700);
}

code,
pre {
  font-family: var(--mono);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

/* HTML hidden 属性必须始终生效：作者样式里的 .stack/.grid/.row/.toolbar/.button 等
   display 规则会覆盖浏览器默认的 [hidden] 规则，导致面板、已创建结果区收起失效。
   本文件不涉及 hidden="until-found"，因此统一用 display:none 处理。 */
[hidden] {
  display: none !important;
}

.visually-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 40;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--teal-700);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: top 0.15s ease-in;
}

.skip-link:focus {
  top: 12px;
}

/* ---------------------------------------------------------------- 布局 */

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.side-nav {
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-800) 100%);
  color: var(--navy-text);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px 18px;
  min-height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 12px;
  border-bottom: 1px solid rgba(216, 228, 240, 0.16);
}

.brand-mark {
  margin: 0;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--teal-600);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  display: grid;
  place-items: center;
}

.brand-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--navy-text);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: rgba(216, 228, 240, 0.1);
  color: #fff;
}

.nav-link[aria-current="page"] {
  background: rgba(15, 143, 143, 0.22);
  border-left-color: #37c2bb;
  color: #fff;
}

.nav-link-title {
  display: block;
  font-weight: 600;
  font-size: 14.5px;
}

.nav-link-summary {
  display: block;
  font-size: 12px;
  color: var(--navy-text-dim);
  margin-top: 2px;
}

.nav-link[aria-current="page"] .nav-link-summary {
  color: #cfe6ef;
}

.nav-foot {
  margin: auto 6px 0;
  font-size: 12px;
  color: var(--navy-text-dim);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px 24px 32px;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar-title {
  min-width: 140px;
  flex: 1 1 180px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.user-chip {
  display: flex;
  flex-direction: column;
  padding: 4px 10px;
  border-left: 1px solid var(--line);
  min-width: 120px;
}

.user-principal {
  font-weight: 600;
  font-family: var(--mono);
  font-size: 13px;
}

.user-meta {
  font-size: 11.5px;
}

/* 仅窄屏显示：必须带 .topbar 前缀，否则会被后面的 .button 显示规则覆盖。 */
.topbar .nav-toggle {
  display: none;
}

/* ---------------------------------------------------------------- 页面区 */

.page-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.page-area:focus {
  outline: none;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-header h2 {
  font-size: 19px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.row-between {
  justify-content: space-between;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- 表单 */

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 160px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: 38px;
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: #f5f7f9;
  color: var(--muted);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

/* 三个按钮类共享尺寸/字体/圆角/禁用与焦点表现：页面只用 button-secondary 或
   button-danger（不带 button）时，也必须是同一套按钮外观，而不是浏览器原生小按钮。 */
.button,
.button-secondary,
.button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  min-height: 38px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.button:focus-visible,
.button-secondary:focus-visible,
.button-danger:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.button {
  color: #fff;
  background: var(--teal-600);
  border-color: var(--teal-600);
}

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

.button:disabled,
.button-secondary:disabled,
.button-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button-secondary {
  color: var(--ink-2);
  background: #fff;
  border-color: var(--line);
}

.button-secondary:hover:not(:disabled) {
  background: #f4f7f9;
  border-color: #c3ccd6;
  color: var(--ink);
}

.button-danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.button-danger:hover:not(:disabled) {
  background: #99261f;
  border-color: #99261f;
}

/* ---------------------------------------------------------------- 数据展示 */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 520px;
}

.data-table caption {
  text-align: left;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

.data-table thead th {
  background: #f7f9fb;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--info-bg);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: #bfe2cf;
}

.badge-pending {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: #f0d9b0;
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #f2c4c0;
}

.badge-count {
  min-width: 22px;
  justify-content: center;
  background: var(--teal-100);
  color: var(--teal-700);
  border-color: #b9e2de;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.metric {
  background: #f7f9fb;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.metric .metric-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.metric .metric-value {
  display: block;
  font-size: 19px;
  font-weight: 700;
  font-family: var(--mono);
}

.empty-state {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  padding: 22px 18px;
  background: #fafbfc;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
}

/* ---------------------------------------------------------------- 提示 */

.notice-region {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notice-region:empty {
  display: none;
}

.notice {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 11px 44px 11px 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.notice-body {
  min-width: 0;
  flex: 1;
}

.notice-title {
  margin: 0 0 2px;
  font-weight: 700;
  font-size: 14.5px;
}

.notice-detail {
  margin: 0 0 6px;
  font-size: 13.5px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.notice-actions {
  margin-top: 6px;
}

.notice-close {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  font-size: 12.5px;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.notice-info {
  border-left-color: #6f8bab;
  background: var(--info-bg);
}

.notice-success {
  border-left-color: var(--success);
  background: var(--success-bg);
}

.notice-error {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.notice-pending {
  border-left-color: #c98a2b;
  background: var(--warn-bg);
}

.original-ref {
  margin: 2px 0 4px;
  overflow-wrap: anywhere;
}

.code-inline {
  padding: 1px 6px;
  background: #eef2f7;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  font-size: 12.5px;
}

.code-block {
  max-height: 260px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 10px;
  background: #0f1c2b;
  color: #d7e3ef;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tech-detail {
  margin-top: 6px;
  font-size: 13px;
}

.tech-detail > summary {
  cursor: pointer;
  color: var(--ink-2);
}

/* ---------------------------------------------------------------- 未决原号中心 */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(460px, 100vw);
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(16, 35, 54, 0.16);
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.drawer[hidden] {
  display: none;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.drawer-body {
  padding: 14px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pending-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pending-item {
  border: 1px solid var(--line);
  border-left: 4px solid #c98a2b;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fffdf8;
}

.pending-item p {
  margin: 2px 0;
}

.has-pending {
  border-color: #e0b877;
  background: var(--warn-bg);
}

/* ---------------------------------------------------------------- 登录 */

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: center;
  gap: 40px;
  padding: 40px clamp(20px, 6vw, 90px);
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 55%, #12595c 100%);
}

.login-brand {
  color: #eaf2f8;
}

.login-brand .eyebrow {
  color: #9fd8d3;
}

.login-brand h2 {
  font-size: 26px;
  margin-bottom: 10px;
}

.login-brand .muted {
  color: #b9cde0;
  max-width: 46ch;
}

.login-card {
  width: 100%;
}

.login-card h1 {
  margin-bottom: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.login-submit {
  min-width: 140px;
}

.login-error:not(:empty) {
  padding: 8px 10px;
  border: 1px solid #f2c4c0;
  border-left: 4px solid var(--danger);
  background: var(--danger-bg);
  color: #7d241e;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: 264px;
    z-index: 35;
    transform: translateX(-102%);
    transition: transform 0.18s ease-out;
    box-shadow: 8px 0 24px rgba(16, 35, 54, 0.2);
  }

  body[data-nav="open"] .side-nav {
    transform: translateX(0);
  }

  .topbar .nav-toggle {
    display: inline-flex;
  }

  .workspace {
    padding: 12px 14px 26px;
  }

  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .login-screen {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    padding: 28px 18px;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  .user-chip {
    border-left: 0;
    padding-left: 0;
  }

  .data-table {
    min-width: 420px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  .side-nav,
  .topbar,
  .notice-region,
  .drawer,
  .button {
    display: none !important;
  }

  .workspace {
    padding: 0;
  }

  .card {
    box-shadow: none;
  }
}
