:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e4e4e7;
  --border: #e4e4e7;
  --border-light: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #a1a1aa;

  --accent: #18181b;
  --accent-hover: #27272a;
  --accent-soft: rgba(24, 24, 27, 0.06);
  --accent-text: #3f3f46;

  --success: #166534;
  --success-soft: rgba(22, 101, 52, 0.08);
  --success-text: #166534;

  --warning: #92400e;
  --warning-soft: rgba(146, 64, 14, 0.08);
  --warning-text: #92400e;

  --danger: #991b1b;
  --danger-soft: rgba(153, 27, 27, 0.08);
  --danger-text: #991b1b;

  --info: #475569;
  --info-soft: rgba(71, 85, 105, 0.08);
  --info-text: #334155;

  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;
  --radius-pill: 9999px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "Cascadia Code", "Fira Code", Consolas, "Noto Sans SC", monospace;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.03);

  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

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

a { color: var(--accent-text); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 1000;
  font-weight: 500;
}
.skip-link:focus { top: 0; outline: none; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  color: var(--text);
  font-weight: 650;
  font-size: 15px;
  border-bottom: 1px solid transparent;
}
.sb-brand:hover { color: var(--text); text-decoration: none; }

.sb-mark {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.sb-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  color: var(--text-2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}
.sb-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sb-link.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.sb-link svg { flex-shrink: 0; }

.sb-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.sb-version { font-size: 12px; color: var(--text-3); }

.main-view {
  flex: 1;
  margin-left: 232px;
  padding: 28px 32px 40px;
  min-width: 0;
}

.main-content {
  width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
}

.page-title { font-size: 22px; font-weight: 650; color: var(--text); letter-spacing: -0.01em; }
.page-subtitle { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.page-subtitle .badge { margin-right: 6px; }

.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  color: var(--text);
  line-height: 1.4;
}
.btn svg { flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-light);
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-light);
  color: var(--text);
  text-decoration: none;
}
.btn-secondary:active { transform: translateY(1px); }

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover { background: #14532d; border-color: #14532d; color: #fff; text-decoration: none; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #7f1d1d; border-color: #7f1d1d; color: #fff; text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-body { padding: 20px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.tab {
  padding: 9px 14px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.field-label .req { color: var(--danger); }
.field-input, .field-textarea, .field-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: border var(--transition), box-shadow var(--transition);
  line-height: 1.4;
}
.field-input::placeholder, .field-textarea::placeholder { color: var(--text-3); }
.field-input:focus, .field-textarea:focus, .field-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.06);
}
.field-textarea { min-height: 100px; resize: vertical; }
.field-error { color: var(--danger-text); font-size: 12px; margin-top: 5px; }
.field-hint { color: var(--text-2); font-size: 12px; margin-top: 5px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: var(--surface-2); border-bottom: 1px solid var(--border); }
th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.5;
}
.badge-draft { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge-active { background: var(--success-soft); color: var(--success-text); }
.badge-inactive { background: var(--danger-soft); color: var(--danger-text); }
.badge-processing { background: var(--warning-soft); color: var(--warning-text); }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-failed { background: var(--danger-soft); color: var(--danger-text); }
.badge-pending { background: var(--warning-soft); color: var(--warning-text); }
.badge-approved { background: var(--success-soft); color: var(--success-text); }
.badge-rejected { background: var(--danger-soft); color: var(--danger-text); }
.badge-sensitive { background: var(--danger-soft); color: var(--danger-text); }

.highlight-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.5;
  background: rgba(245, 158, 11, 0.10);
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.20);
}

.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.search-input {
  padding: 7px 11px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  min-width: 200px;
  line-height: 1.4;
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.06); }

.filter-select {
  padding: 7px 11px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-2);
}
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; font-weight: 600; }
.empty-state p { font-size: 14px; margin-bottom: 18px; }
.empty-state-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 14px;
  color: var(--text-3);
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
}
.alert-info { background: var(--info-soft); color: var(--info-text); border-color: rgba(71, 85, 105, 0.14); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); border-color: rgba(146, 64, 14, 0.14); }
.alert-danger { background: var(--danger-soft); color: var(--danger-text); border-color: rgba(153, 27, 27, 0.14); }
.alert-success { background: var(--success-soft); color: var(--success-text); border-color: rgba(22, 101, 52, 0.14); }

.section-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.info-label { font-size: 12px; color: var(--text-2); margin-bottom: 3px; font-weight: 500; }
.info-value { font-size: 14px; color: var(--text); white-space: pre-wrap; }

.inline-editable {
  position: relative;
  border-radius: var(--radius-sm);
  cursor: default;
  min-height: 24px;
}
.inline-editable:hover { background: var(--surface-2); }
.inline-edit-trigger {
  position: absolute;
  top: 0;
  right: 0;
  padding: 1px 4px;
  opacity: 0;
  visibility: hidden;
  color: var(--text-3);
  cursor: pointer;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  font-size: 13px;
  line-height: 1;
  transition: opacity 120ms ease;
}
.inline-editable:hover .inline-edit-trigger { opacity: 1; visibility: visible; }
.inline-edit-trigger:hover { color: var(--text); background: var(--surface-3); }

.inline-editable .info-value,
.inline-editable .inline-textarea-value { min-height: 24px; padding: 3px 6px; }
.inline-edit-form { display: none; }
.inline-editable.editing .info-value,
.inline-editable.editing .inline-textarea-value { display: none; }
.inline-editable.editing .inline-edit-form { display: block; }
.inline-edit-form input,
.inline-edit-form textarea {
  width: 100%;
  font-size: 14px;
  font-family: var(--font);
  padding: 3px 6px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  resize: vertical;
}
.inline-edit-form textarea { min-height: 80px; }
.inline-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  justify-content: flex-end;
}
.inline-edit-actions .btn { font-size: 12px; padding: 2px 10px; }

.drawer-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 540px;
  max-width: 90vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer-overlay.open { transform: translateX(0); }

.drawer-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.drawer-title { font-size: 16px; font-weight: 650; color: var(--text); }
.drawer-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  transition: all var(--transition);
  font-size: 14px;
}
.drawer-close:hover { background: var(--surface-3); color: var(--text); }
.drawer-body { padding: 20px; }

.score-display {
  display: flex;
  align-items: center;
  gap: 12px;
}
.score-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--mono);
  letter-spacing: -0.02em;
}
.score-max { font-size: 15px; color: var(--text-3); }

.dimension-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
}
.dimension-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.dimension-name { font-weight: 600; color: var(--text); }
.dimension-score { font-family: var(--mono); font-weight: 700; color: var(--text); }
.dimension-reason { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.dimension-evidence {
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--border-light);
}

.hc-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border: 1px solid var(--border);
}
.hc-status {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
  margin-top: 1px;
}
.hc-pass { background: var(--success-soft); color: var(--success-text); }
.hc-fail { background: var(--danger-soft); color: var(--danger-text); }
.hc-pending { background: var(--warning-soft); color: var(--warning-text); }

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.weight-bar {
  width: 100%;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 5px;
}
.weight-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width var(--transition);
}

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.muted { color: var(--text-2); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-mono { font-family: var(--mono); }
.cursor-pointer { cursor: pointer; }

.markdown-body h1, .markdown-body h2, .markdown-body h3 { font-weight: 650; margin: 18px 0 10px; color: var(--text); }
.markdown-body h1 { font-size: 18px; }
.markdown-body h2 { font-size: 16px; }
.markdown-body h3 { font-size: 15px; }
.markdown-body p { margin-bottom: 10px; color: var(--text-2); }
.markdown-body ul { margin: 8px 0 12px 18px; color: var(--text-2); }
.markdown-body li { margin-bottom: 4px; }
.markdown-body strong { color: var(--text); font-weight: 600; }

.modal-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  background: var(--surface);
  margin: auto;
  outline: none;
}
.modal-dialog:focus { outline: none; }
.modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.25);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
  margin: 0;
}
.modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  max-height: calc(100vh - 130px);
}

@media (max-width: 1024px) {
  .sidebar { width: 60px; }
  .sidebar .sb-brand { padding: 18px 14px; justify-content: center; }
  .sidebar .sb-brand-name, .sidebar .sb-link span:not(.sb-mark) { display: none; }
  .sidebar .sb-link { justify-content: center; padding: 10px; }
  .sidebar .sb-footer { text-align: center; }
  .main-view { margin-left: 60px; padding: 20px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .main-view { padding: 16px; }
  .page-header { flex-direction: column; }
  .page-actions { width: 100%; }
  .btn { flex: 1; justify-content: center; }
  .search-bar .search-input, .search-bar .filter-select { width: 100%; }
}
