/* ============================================
   安全经费计提工具 - 91ehs.cn 风格
   色彩体系：深蓝主色 + 左侧边框卡片
   ============================================ */

:root {
  /* 主色调 - 91ehs 深蓝 */
  --primary: #1e5ba8;
  --primary-hover: #184a8f;
  --primary-light: #e8f0fa;
  --primary-lighter: #f3f8ff;
  --primary-deep: #0f3d7a;
  
  /* 背景色系 */
  --bg: #f3f6fb;
  --bg-soft: #f8fafd;
  --bg-dark: #e6ecf5;
  
  /* 表面色 */
  --surface: #ffffff;
  --surface-hover: #fafbfe;
  --surface-2: #f0f4fa;
  
  /* 文字颜色 */
  --text: #1f2d3d;
  --text-secondary: #4a5568;
  --text-muted: #7a8799;
  --text-disabled: #b5bfcc;
  
  /* 强调色 - 橙红警示 */
  --accent: #e67e22;
  --accent-hover: #d35400;
  --accent-light: #fef5e7;
  --accent-deep: #a04000;
  
  /* 状态色 */
  --ok: #eafaf1;
  --ok-border: #27ae60;
  --ok-text: #1e8449;
  --review: #fef9e7;
  --review-border: #f39c12;
  --review-text: #b7950b;
  --danger: #fdecea;
  --danger-border: #e74c3c;
  --danger-text: #c0392b;
  
  /* 边框 */
  --line: #e1e8f0;
  --line-light: #ecf0f5;
  --line-strong: #c5d1e0;
  
  /* 阴影层次 */
  --shadow-sm: 0 1px 2px rgba(30, 91, 168, 0.04);
  --shadow: 0 2px 8px rgba(30, 91, 168, 0.08);
  --shadow-md: 0 4px 16px rgba(30, 91, 168, 0.1);
  --shadow-lg: 0 8px 24px rgba(30, 91, 168, 0.12);
  --shadow-xl: 0 12px 32px rgba(30, 91, 168, 0.15);
  
  /* 圆角 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* 过渡 */
  --transition-fast: 150ms ease;
  --transition: 200ms ease;
}

/* 基础重置 */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
}

/* 顶部深蓝导航条 */
body {
  border-top: 4px solid var(--primary);
}

/* 容器 */
.prototype-main {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

/* 顶部标签 */
.page-step,
.section-kicker {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* 页面标题区域 */
.page-head {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line-light);
}

.page-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-head-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.page-head-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(30, 91, 168, 0.3);
}

.page-head-icon svg {
  width: 26px;
  height: 26px;
}

.page-head h1 {
  margin: 4px 0 0;
  font-size: clamp(26px, 3.5vw, 36px);
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 700;
  color: var(--primary-deep);
}

.library-entry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(30, 91, 168, 0.18);
  background: rgba(255, 255, 255, 0.88);
  color: var(--primary-deep);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.library-entry-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: rgba(30, 91, 168, 0.35);
}

.page-summary {
  margin: 12px 0 0;
  max-width: 680px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.tool-entitlement-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  padding: 16px 18px;
  border: 1px solid rgba(30, 91, 168, 0.14);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(30, 91, 168, 0.07), rgba(255, 255, 255, 0.98));
  box-shadow: var(--shadow-sm);
}

.tool-entitlement-copy {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.tool-entitlement-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: rgba(30, 91, 168, 0.12);
  color: var(--primary-deep);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tool-entitlement-text {
  display: grid;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.tool-entitlement-text strong {
  color: var(--primary-deep);
  font-size: 14px;
  line-height: 1.6;
}

.tool-entitlement-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tool-entitlement-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(30, 91, 168, 0.12);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.tool-entitlement-bind {
  min-height: 20px;
  color: var(--accent-deep);
  font-size: 13px;
  line-height: 1.6;
  font-weight: 600;
}

.tool-entitlement-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Tab 导航 */
.tab-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 24px 0 20px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0;
}

.tab-chip {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 12px 24px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: all var(--transition-fast);
  position: relative;
  bottom: -2px;
}

.tab-chip:hover {
  color: var(--primary);
  background: var(--primary-lighter);
}

.tab-chip.is-active {
  color: var(--primary);
  background: var(--surface);
  border: 2px solid var(--line);
  border-bottom-color: var(--surface);
  font-weight: 600;
  bottom: -2px;
}

/* Tab 面板切换 */
.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease;
}

.tab-panel.is-active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 区块标题 */
.section-head {
  margin: 0 0 20px;
  padding-left: 12px;
  border-left: 3px solid var(--primary);
}

.section-head h2 {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--text);
}

/* 网格布局 */
.layout-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.layout-grid-wide {
  grid-template-columns: 1.1fr 0.9fr;
}

/* 卡片样式 - 左侧边框风格 */
.surface-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: box-shadow var(--transition), transform var(--transition);
}

.surface-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* 卡片头部 */
.card-head,
.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.card-head h3,
.result-head h3 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.field-tip {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* 表单网格 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid label,
.full-textarea {
  display: grid;
  gap: 6px;
}

.form-grid label span,
.full-textarea span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

/* 输入框样式 */
.form-grid input,
.form-grid select,
.form-grid textarea,
.full-textarea textarea,
.upload-box input {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.full-textarea textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 91, 168, 0.12);
}

.form-grid textarea,
.full-textarea textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
}

.span-2 {
  grid-column: span 2;
}

/* 自动规则卡片 */
.auto-rule-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--primary-lighter);
  border-left: 4px solid var(--primary);
}

.auto-rule-card div {
  display: grid;
  gap: 4px;
}

.auto-rule-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.auto-rule-card strong {
  color: var(--primary);
  line-height: 1.4;
  font-size: 14px;
}

/* 法规提示卡片 */
.legal-card {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--accent-light);
  border-radius: var(--radius-md);
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
}

.legal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.legal-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.legal-head strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-deep);
}

.legal-summary,
.legal-rate {
  margin: 0;
  line-height: 1.6;
  font-size: 14px;
}

.legal-summary {
  color: var(--text-secondary);
}

.legal-excerpt {
  margin-top: 12px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: rgba(255, 255, 255, 0.7);
}

.legal-caption {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.legal-rate {
  font-weight: 500;
  color: var(--text);
}

/* 按钮样式 - 91ehs 风格 */
.primary-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 10px 22px;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.primary-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(30, 91, 168, 0.3);
}

.ghost-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-secondary);
  padding: 8px 16px;
  font-weight: 500;
  font-size: 13px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ghost-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-lighter);
}

.ghost-btn.is-small {
  padding: 6px 14px;
  font-size: 12px;
}

.ghost-btn.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-lighter);
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 状态标签 */
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: var(--primary-lighter);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

/* 指标网格 */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.compact-metrics {
  margin-bottom: 16px;
}

.metric-box {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #fff 0%, var(--bg-soft) 100%);
}

.metric-box span {
  color: var(--text-muted);
  font-size: 13px;
}

.metric-box strong {
  font-size: 22px;
  line-height: 1.2;
  color: var(--primary);
}

/* 摘要面板 */
.summary-panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.summary-panel.compact {
  margin-top: 16px;
}

.summary-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.summary-copy {
  margin: 0;
  line-height: 1.6;
  color: var(--text);
  font-size: 14px;
}

.breakdown-list {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 13px;
}

/* 月度分配 */
.month-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.month-strip li {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.month-strip li:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.month-strip span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.month-strip strong {
  font-size: 14px;
  color: var(--text);
}

.month-strip em {
  color: var(--text-muted);
  font-style: normal;
  font-size: 12px;
}

/* 状态框 */
.status-box {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}

.status-box.ok {
  background: var(--ok);
  border-color: var(--ok-border);
  border-left: 4px solid var(--ok-border);
}

.status-box.review {
  background: var(--review);
  border-color: var(--review-border);
  border-left: 4px solid var(--review-border);
}

.status-box.danger {
  background: var(--danger);
  border-color: var(--danger-border);
  border-left: 4px solid var(--danger-border);
}

.status-label {
  display: inline-flex;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.status-box.ok .status-label {
  color: var(--ok-text);
}

.status-box.review .status-label {
  color: var(--review-text);
}

.status-box.danger .status-label {
  color: var(--danger-text);
}

.status-box p {
  margin: 0;
  line-height: 1.6;
  font-size: 14px;
}

/* 上传区域 */
.upload-box {
  margin-bottom: 12px;
}

/* 表格 */
.table-wrap {
  overflow-x: auto;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
}

.preview-table th,
.preview-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.preview-table th {
  color: var(--text-secondary);
  font-weight: 600;
  background: var(--bg-soft);
}

.empty-cell {
  color: var(--text-muted);
  text-align: center;
}

/* 响应式 - 平板 */
@media (max-width: 1024px) {
  .prototype-main {
    width: min(100% - 32px, 1200px);
    padding-top: 24px;
  }

  .layout-grid,
  .layout-grid-wide {
    grid-template-columns: 1fr;
  }

  .month-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* 响应式 - 手机横屏 */
@media (max-width: 768px) {
  .prototype-main {
    width: min(100% - 24px, 100%);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .card-head,
  .result-head,
  .legal-head {
    flex-direction: column;
    align-items: stretch;
  }

  .auto-rule-card {
    grid-template-columns: 1fr;
  }

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

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

  .tool-entitlement-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .tool-entitlement-copy {
    flex-direction: column;
  }

  .tool-entitlement-actions {
    width: 100%;
  }
}

/* 响应式 - 手机竖屏 */
@media (max-width: 480px) {
  .page-head-top {
    gap: 12px;
    align-items: flex-start;
  }

  .page-head-icon {
    width: 42px;
    height: 42px;
  }

  .page-head-icon svg {
    width: 20px;
    height: 20px;
  }

  .page-head h1 {
    font-size: 22px;
  }

  .page-head-main {
    gap: 12px;
  }

  .page-summary {
    font-size: 13px;
  }

  .surface-card {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .month-strip {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .tab-strip {
    overflow-x: auto;
    flex-wrap: nowrap;
    border-bottom: 2px solid var(--line);
  }

  .tab-chip,
  .primary-btn,
  .ghost-btn {
    white-space: nowrap;
  }

  .tool-entitlement-bar {
    padding: 16px;
  }

  .tool-entitlement-meta {
    flex-direction: column;
  }

  .tool-entitlement-actions {
    flex-direction: column;
  }

  .tool-entitlement-actions .primary-btn,
  .tool-entitlement-actions .ghost-btn {
    width: 100%;
    justify-content: center;
  }

  .library-entry-btn {
    width: 100%;
  }
}
