:root {
  --bg: #0b0f17;
  --bg-soft: #131a26;
  --panel: #111827;
  --panel-2: #182132;
  --line: #253145;
  --line-strong: #35507a;
  --text: #e5ecf8;
  --text-soft: #9fb0cb;
  --text-muted: #6f7f99;
  --primary: #5ea0ff;
  --primary-2: #3578f6;
  --success: #4fd18b;
  --warning: #f8b84e;
  --danger: #ff6b6b;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: radial-gradient(circle at top, rgba(53, 120, 246, 0.12), transparent 25%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select {
  font: inherit;
}

.page-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(11, 15, 23, 0.8);
  border-bottom: 1px solid rgba(53, 80, 122, 0.5);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.brand small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-pill, .role-pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(19, 26, 38, 0.8);
  color: var(--text-soft);
  font-size: 12px;
}

.badge.success { color: var(--success); border-color: rgba(79, 209, 139, 0.35); }
.badge.warning { color: var(--warning); border-color: rgba(248, 184, 78, 0.35); }
.badge.danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); }
.badge.primary { color: var(--primary); border-color: rgba(94, 160, 255, 0.35); }

.card {
  background: linear-gradient(180deg, rgba(24, 33, 50, 0.9), rgba(17, 24, 39, 0.96));
  border: 1px solid rgba(53, 80, 122, 0.45);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section {
  padding: 24px;
}

.section + .section {
  margin-top: 20px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-title h1,
.section-title h2,
.section-title h3,
.section-title h4,
.title {
  margin: 0;
  color: #fff;
}

.subtle {
  color: var(--text-muted);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat-card {
  padding: 18px;
  border-radius: 14px;
  background: rgba(11, 15, 23, 0.42);
  border: 1px solid rgba(53, 80, 122, 0.45);
}

.stat-label {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 10px 24px rgba(53, 120, 246, 0.28);
}

.btn-success { background: rgba(79, 209, 139, 0.14); border-color: rgba(79, 209, 139, 0.28); color: var(--success); }
.btn-danger { background: rgba(255, 107, 107, 0.14); border-color: rgba(255, 107, 107, 0.28); color: var(--danger); }
.btn-warning { background: rgba(248, 184, 78, 0.14); border-color: rgba(248, 184, 78, 0.28); color: var(--warning); }
.btn-ghost { border-color: rgba(53, 80, 122, 0.55); background: rgba(11, 15, 23, 0.34); color: var(--text-soft); }
.btn-sm { padding: 8px 12px; font-size: 12px; border-radius: 10px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field.full { grid-column: 1 / -1; }

label {
  color: var(--text-soft);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  background: rgba(11, 15, 23, 0.62);
  border: 1px solid rgba(53, 80, 122, 0.55);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.7;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(94, 160, 255, 0.14);
}

.notice, .alert {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(53, 80, 122, 0.45);
  font-size: 14px;
  line-height: 1.6;
}

.notice.info, .alert.info { background: rgba(53, 120, 246, 0.12); color: #b8d2ff; }
.notice.success, .alert.success { background: rgba(79, 209, 139, 0.12); color: #b8f3d6; }
.notice.warning, .alert.warning { background: rgba(248, 184, 78, 0.12); color: #ffe1aa; }
.notice.danger, .alert.danger { background: rgba(255, 107, 107, 0.12); color: #ffcbcb; }

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid rgba(53, 80, 122, 0.45);
  background: rgba(11, 15, 23, 0.3);
  color: var(--text-soft);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
}

.tab-btn.active {
  background: rgba(53, 120, 246, 0.18);
  border-color: rgba(94, 160, 255, 0.45);
  color: #fff;
}

.table-wrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(53, 80, 122, 0.45);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(53, 80, 122, 0.22);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--text-soft);
  background: rgba(17, 24, 39, 0.92);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.data-table tr:hover td {
  background: rgba(94, 160, 255, 0.04);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
}

.split-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
}

.compare-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.compare-panel,
.annotated-box,
.review-editor-box {
  padding: 18px;
  border-radius: 16px;
  background: rgba(11, 15, 23, 0.42);
  border: 1px solid rgba(53, 80, 122, 0.4);
}

.line-block {
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 10px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.line-block.red { background: rgba(255, 107, 107, 0.12); border-left: 4px solid var(--danger); }
.line-block.yellow { background: rgba(248, 184, 78, 0.12); border-left: 4px solid var(--warning); }
.line-block.green { background: rgba(79, 209, 139, 0.12); border-left: 4px solid var(--success); }
.line-comment { margin-top: 10px; color: var(--text-soft); font-size: 13px; }

.chip-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid rgba(53, 80, 122, 0.45);
  color: var(--text-soft);
  font-size: 12px;
}

.chip button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.96);
  border: 1px solid rgba(53, 80, 122, 0.5);
  box-shadow: var(--shadow);
  transition: 0.22s ease;
  z-index: 60;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { color: #b8f3d6; }
.toast.warning { color: #ffe1aa; }
.toast.danger { color: #ffcbcb; }
.toast.info { color: #cfe1ff; }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 23, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 70;
}

.modal-mask.show { display: flex; }

.modal {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: linear-gradient(180deg, rgba(24, 33, 50, 0.98), rgba(17, 24, 39, 0.98));
  border-radius: 18px;
  border: 1px solid rgba(53, 80, 122, 0.55);
  box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-header { border-bottom: 1px solid rgba(53, 80, 122, 0.35); }
.modal-footer { border-top: 1px solid rgba(53, 80, 122, 0.35); }
.modal-body { padding: 20px; }

.loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
}

.loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(94, 160, 255, 0.3);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-layout, .compare-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .page-shell { padding: 16px; }
  .topbar-inner { padding: 12px 16px; }
  .form-grid, .grid-3, .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .section { padding: 18px; }
}
