:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --primary: #1890ff;
  --primary-dark: #096dd9;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #e5e7eb;
  --sidebar: #1f2937;
  --sidebar-active: #111827;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  border-radius: 6px;
  height: 36px;
  padding: 0 16px;
  cursor: pointer;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover { background: var(--primary-dark); }

.secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

label {
  display: grid;
  gap: 8px;
  color: #374151;
  margin-bottom: 16px;
}

input, textarea, select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input, select {
  height: 36px;
  padding: 0 12px;
}

textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  padding: 12px;
  line-height: 1.65;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 20px 12px;
}

.brand {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 20px;
  font-weight: 700;
}

.nav-item {
  width: 100%;
  height: 42px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  margin-top: 8px;
}

.nav-item.active, .nav-item:hover {
  background: var(--sidebar-active);
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar span {
  margin-left: 12px;
  color: var(--muted);
  font-size: 14px;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  padding: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.card h2 {
  margin: 0;
  font-size: 18px;
}

.upload-row, .actions, .filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.upload-row {
  justify-content: space-between;
  margin-top: 12px;
}

.result-card {
  min-height: 430px;
}

.note-preview {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 340px;
  padding: 18px;
  line-height: 1.75;
  white-space: pre-wrap;
  background: #fff;
  overflow: auto;
}

.note-preview.empty {
  color: var(--muted);
  display: grid;
  place-items: center;
}

.table-card {
  grid-column: 1 / -1;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  background: #fafafa;
  color: #374151;
  font-weight: 600;
}

td button {
  height: 30px;
  padding: 0 10px;
  margin-right: 6px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 12px;
}

.settings-panel {
  padding: 16px;
  max-width: 760px;
}

.settings-form {
  max-width: 620px;
}

.message {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.message.error { color: #cf1322; }
.message.success { color: #237804; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
  }
  .brand { min-width: 100px; }
  .nav-item { width: auto; min-width: 112px; text-align: center; }
  .panel-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .compose-card, .table-card, .card-head .actions { display: none !important; }
  .app-shell, .panel-grid { display: block; }
  .card, .note-preview { border: 0; padding: 0; }
}
