:root {
  --bg: #f6f7fb;
  --text: #111;
  --muted: #555;
  --border: #e2e4ea;
  --border2: #f0f1f5;
  --primary: #2563eb;
  --danger: #dc2626;
  --card: #ffffff;
  --pill-bg: #f3f4f6;
  --shadow: 0 4px 12px rgba(16, 24, 40, 0.03), 0 12px 32px rgba(16, 24, 40, 0.04);
  --sidebar-bg: #f8f9fa;
  --sidebar-item-bg: transparent;
  --sidebar-item-border: transparent;
  --sidebar-item-hover-bg: #f1f3f5;
  --sidebar-item-hover-border: transparent;
}

* {
  box-sizing: border-box;
}

/* HTML `hidden` must win over author `display` (e.g. .btn, .side-item), or auth/nav toggles break. */
[hidden] {
  display: none !important;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-brand {
  padding: 10px 10px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fbfbfd;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--sidebar-item-border);
  color: #1f2a37;
  text-decoration: none;
  font-size: 14px;
  background: var(--sidebar-item-bg);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.06);
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease,
    transform 120ms ease;
}

.side-item:hover {
  background: var(--sidebar-item-hover-bg);
  border-color: var(--sidebar-item-hover-border);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.12);
  transform: translateY(-1px);
  text-decoration: none;
}

.side-item.active {
  background: #f0f7ff;
  color: var(--primary);
  border-color: #d6e4ff;
  font-weight: 600;
}

.side-item.active .muted {
  color: rgba(255, 255, 255, 0.8);
}

.side-label {
  font-weight: 650;
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px 10px;
  border-top: 1px solid var(--border);
}

.main {
  padding: 22px 22px 26px;
}

.main-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-title {
  margin: 0;
  font-size: 20px;
}

.main-body {
  max-width: 1280px;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.brand {
  font-weight: 750;
  font-size: 18px;
}

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

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.nav-item {
  color: var(--primary);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d6e4ff;
  background: #f3f7ff;
  font-size: 13px;
}
.nav-item.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.05), 0 16px 48px rgba(16, 24, 40, 0.06);
}

.card + .card {
  margin-top: 16px;
}

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

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

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.k {
  font-size: 13px;
  color: #666;
}

.v {
  font-size: 26px;
  font-weight: 750;
  margin-top: 8px;
}

.v-sm {
  font-size: 16px;
  font-weight: 650;
}

.form-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
}

input,
textarea {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid #cfcfcf;
  font: inherit;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.btn:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  text-decoration: none;
}

.btn.secondary {
  border-color: #d1d5db;
  background: white;
  color: #374151;
}
.btn.secondary:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.btn.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}
.btn.danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

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

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

.table th {
  font-size: 13px;
  color: #444;
}

code {
  background: var(--pill-bg);
  padding: 2px 6px;
  border-radius: 6px;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  margin-right: 6px;
  margin-top: 4px;
}

.status {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ok {
  color: #0a7d2a;
}

.bad {
  color: var(--danger);
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.filters input {
  flex: 1;
  min-width: 160px;
}

/* 双栏 Master-Detail 布局 (Notes 页面专用) */
.workspace-2col {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 14px;
  align-items: start;
  height: calc(100vh - 80px);
}

.list-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.new-note-box {
  margin-bottom: 10px;
}

/* 覆盖默认的 listbox 行为，使其在 flex 容器中滚动 */
.list-panel .listbox {
  flex: 1;
  overflow-y: auto;
  border-top: 1px solid var(--border2);
  margin-top: 10px;
}

@media (max-width: 900px) {
  .workspace-2col {
    grid-template-columns: 1fr;
    height: auto;
  }
  .list-panel, .detail-panel {
    height: auto;
    max-height: 80vh; /* 移动端限制高度 */
  }
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr 420px;
  gap: 14px;
  align-items: start;
}

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

.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fcfcfd;
}

.panel-body {
  padding: 16px 20px;
}

@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

.listbox {
  display: flex;
  flex-direction: column;
}

.list-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border2);
  cursor: pointer;
}

.list-item:hover {
  background: #fbfbff;
}

.list-item.active {
  background: #f3f7ff;
  outline: 1px solid #d6e4ff;
}

.list-title {
  font-weight: 700;
}

.list-meta {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.detail-title {
  font-weight: 750;
  font-size: 16px;
  margin: 0 0 8px;
}

.detail-text {
  white-space: pre-wrap;
  line-height: 1.55;
  color: #1f2a37;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 10px;
  background: #fbfbfd;
  max-height: 520px;
  overflow: auto;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 0;
}

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

.list {
  margin: 0;
  padding-left: 18px;
}
.list li {
  margin: 6px 0;
}

@media (max-width: 900px) {
  .cards {
    grid-template-columns: 1fr;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .workspace {
    grid-template-columns: 1fr;
  }
}

/* 首页入口列表样式优化 */
.entry-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-item {
  display: block;
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.entry-item:hover {
  background: linear-gradient(90deg, #e3f2fd, #f0f7ff);
  color: var(--primary);
  transform: translateX(4px);
  text-decoration: none;
}

/* --- Split View for Note Detail --- */
.split-view {
  display: flex;
  height: calc(100vh - 80px); /* Adjust based on header height */
  gap: 16px;
  padding: 0 16px 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.left-panel {
  flex: 3;
}

.right-panel {
  flex: 2;
  min-width: 300px;
}

.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafafa;
}

.panel-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

/* --- PDF Viewer --- */
.pdf-container {
  flex: 1;
  background: #525659; /* Standard PDF viewer bg color */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
}

.pdf-placeholder {
  color: rgba(255,255,255,0.7);
  text-align: center;
}

.pdf-placeholder .msg {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 8px;
}

.pdf-placeholder .sub {
  font-size: 13px;
  opacity: 0.8;
}

/* --- Form & Metadata --- */
.scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.section {
  margin-bottom: 16px;
}

.section.half {
  flex: 1;
}

.form-row {
  display: flex;
  gap: 12px;
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.input, .textarea, .select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.input:focus, .textarea:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

.textarea {
  resize: vertical;
}

.code-font {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  background: #eee;
  color: #555;
}

.badge.success {
  background: #e6fffa;
  color: #047481;
}

.tags-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.tag {
  background: var(--pill-bg);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tag .x {
  cursor: pointer;
  color: #999;
}

.tag .x:hover {
  color: var(--danger);
}

.tag-input {
  border: none;
  outline: none;
  font-size: 13px;
  flex: 1;
  min-width: 60px;
}

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

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

.flex-between .label {
  margin-bottom: 0;
}

/* --- Upload Area --- */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  background: #fafafa;
  transition: all 0.2s;
  cursor: pointer;
}

.upload-area:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}

.upload-icon {
  font-size: 32px;
  margin-bottom: 12px;
  color: var(--primary);
}

.upload-hint {
  color: var(--muted);
  font-size: 14px;
}

/* Modal Styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fffdf2; /* Pale yellow background */
  border: 1px solid #dcd3b8; /* Light brown border */
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(130, 92, 0, 0.15); /* Warmer shadow */
  width: 400px;
  max-width: 90vw;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #efe8d4;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #4a3e20; /* Darker brown text */
}

.modal-body {
  padding: 20px;
  font-size: 15px;
  color: #3b3117;
}

.modal-body p {
  margin: 0;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #efe8d4;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(255, 255, 255, 0.4); /* Slightly lighter footer */
}

/* Warning Modal */
.warning-modal-content {
  background: #fffdf2;
  border: 1px solid #dcd3b8;
}
.warning-modal-header {
  border-bottom: 1px solid #efe8d4;
}
.warning-modal-body {
  color: #3b3117;
}
.warning-modal-footer {
  border-top: 1px solid #efe8d4;
  background: rgba(255, 255, 255, 0.4);
}

/* Chart Styles */
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 240px;
  overflow: hidden;
  padding-top: 10px;
}
.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-point {
  fill: white;
  stroke: var(--primary);
  stroke-width: 2;
  cursor: pointer;
  transition: r 0.2s;
}
.chart-point:hover {
  r: 6;
  fill: var(--primary);
}
.chart-label-x {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: middle;
}
.chart-label-y {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: end;
}
.chart-grid-line {
  fill: none;
  stroke: var(--border2);
  stroke-width: 1;
}
.chart-tooltip {
  fill: #1f2a37;
  font-size: 12px;
  font-weight: 600;
  text-anchor: middle;
}
.chart-empty {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

/* Flag Pills & Buttons */
.flag-pill {
  font-weight: 600;
}
.flag-pill.pinned {
  background: #fff4cc;
  border-color: #ffe7a6;
  color: #825c00;
}
.flag-pill.favorite {
  background: #ffe3e3;
  border-color: #ffc9c9;
  color: #c92a2a;
}
.btn.active-flag {
  background: #f6f8fa;
  border-color: #cfcfcf;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

/* View Filter Bar */
.view-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border2);
  padding-bottom: 12px;
}

#clearFilters:hover {
  background: #fbfbfd;
  color: var(--text);
}

/* Notes State Hint */
.notes-state-hint {
  font-size: 13px;
  color: var(--muted);
  background: #fcfcfc;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px dashed var(--border2);
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.notes-state-chip {
  display: inline-flex;
  align-items: center;
  background: #f3f7ff;
  border: 1px solid #d6e4ff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--primary);
}

.notes-state-chip-label {
  margin-right: 4px;
}

.notes-state-chip-remove {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: transparent;
  color: #999;
  font-size: 14px;
  line-height: 1;
}

.notes-state-chip-remove:hover {
  background: #d6e4ff;
  color: var(--danger);
}

.view-btn {
  background: none;
  border: 1px solid transparent;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 20px;
  transition: all 0.2s ease;
}

.view-btn:hover {
  background: var(--pill-bg);
  color: var(--text);
}

.view-btn.active {
  background: var(--text);
  color: white;
  border-color: transparent;
}
.existing-tags-list {
  margin-top: 8px;
  padding: 8px;
  background: #fbfbfd;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.existing-tag-pill {
  cursor: pointer;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  transition: all 0.15s;
}
.existing-tag-pill:hover {
  background: #f0f7ff;
  border-color: var(--primary);
  color: var(--primary);
}
.existing-tag-pill.added {
  background: #f6f8fa;
  border-color: #eee;
  color: #aaa;
  cursor: not-allowed;
}
.existing-tag-pill.added:hover {
  background: #f6f8fa;
  border-color: #eee;
  color: #aaa;
}
.warning-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 14px;
  background: #fffdf2; /* Pale yellow background */
  border: 1px solid #dcd3b8; /* Light brown border */
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(130, 92, 0, 0.08);
}

.warning-icon {
  font-size: 16px;
  line-height: 1.4;
}

.warning-text {
  font-size: 13px;
  color: #4a3e20;
  line-height: 1.4;
  word-break: break-word;
}

/* Document Analysis & QA Card */
.document-analysis-card {
  background: #fbfbfd;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 20px;
}

.qa-answer {
  font-size: 14px;
  color: var(--text);
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  line-height: 1.5;
}

.qa-evidence-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qa-evidence-item {
  font-size: 12px;
  color: var(--muted);
  background: #f4f5f8;
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--border2);
  line-height: 1.4;
}

