:root {
  color-scheme: light;
  --ink: #192532;
  --muted: #637283;
  --line: rgba(35, 54, 73, 0.14);
  --paper: #f3f6f4;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --accent: #007d66;
  --accent-strong: #005846;
  --mint: #d9f4eb;
  --blue: #e7efff;
  --purple: #f0e4ff;
  --amber: #fff0cf;
  --danger: #fff3e8;
  --shadow: 0 18px 50px rgba(18, 40, 52, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(0, 90, 71, 0.18), rgba(125, 73, 155, 0.13)),
    radial-gradient(circle at 18% 14%, rgba(0, 125, 102, 0.16), transparent 30%),
    #eef3f1;
}

body::before {
  content: "";
  position: fixed;
  inset: 74px 0 0;
  z-index: -1;
  background:
    linear-gradient(rgba(12, 25, 30, 0.18), rgba(12, 25, 30, 0.18)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='800' viewBox='0 0 1200 800'%3E%3Crect width='1200' height='800' fill='%23e9f0ed'/%3E%3Cg opacity='.38'%3E%3Cpath d='M0 520 C180 450 260 610 420 530 S720 390 900 470 1080 620 1200 540 L1200 800 L0 800Z' fill='%23719b86'/%3E%3Cpath d='M0 610 C140 540 270 650 430 585 S720 505 900 585 1070 690 1200 615 L1200 800 L0 800Z' fill='%233b635b'/%3E%3Ccircle cx='190' cy='180' r='80' fill='%23bcd4c7'/%3E%3Cpath d='M720 120 L790 260 L650 260Z' fill='%2388a898'/%3E%3Cpath d='M870 90 L960 280 L780 280Z' fill='%235b8076'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
  filter: saturate(0.85);
}

body.auth-locked {
  overflow: hidden;
}

body.auth-locked .app-shell {
  visibility: hidden;
  pointer-events: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(7, 97, 79, 0.72), rgba(40, 44, 62, 0.64)),
    #eef3f1;
}

body.auth-locked .auth-gate {
  display: grid;
}

.auth-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.auth-card .brand-mark {
  color: white;
  background: var(--accent);
}

.auth-card h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.auth-card p {
  margin: -8px 0 4px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-error {
  min-height: 20px;
  color: #b43b2f;
  font-size: 13px;
  font-weight: 800;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 0 28px 32px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  min-height: 74px;
  margin: 0 -28px;
  padding: 0 28px;
  background: #07614f;
  color: white;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.16);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 25px;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.84);
  font-weight: 800;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  border-radius: 8px;
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 22px;
}

.auth-logout {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 13px;
  font-weight: 850;
}

.view-tabs {
  display: flex;
  gap: 8px;
  padding: 18px 0 8px;
}

.tab {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  border: 1px solid var(--line);
  font-weight: 850;
}

.tab.active {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.library-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  padding-top: 18px;
}

.filter-panel,
.panel,
.answer,
.card,
.file-card,
.ocr-panel,
.empty {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.filter-panel {
  position: sticky;
  top: 96px;
  align-self: start;
  display: grid;
  gap: 18px;
  padding: 24px;
}

.filter-row,
.filter-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.filter-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
}

.filter-title span {
  color: var(--accent);
  font-size: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: #314155;
  font-size: 14px;
  font-weight: 850;
}

textarea,
select,
input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(245, 248, 249, 0.9);
  color: var(--ink);
  outline: 0;
}

textarea:focus,
select:focus,
input:focus {
  border-color: rgba(0, 125, 102, 0.38);
  box-shadow: 0 0 0 3px rgba(0, 125, 102, 0.12);
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
  margin-bottom: 14px;
}

select,
input {
  min-height: 48px;
  padding: 0 12px;
}

select {
  appearance: auto;
  color: var(--ink);
  background-color: rgba(245, 248, 249, 0.96);
}

option {
  color: var(--ink);
  background: #ffffff;
}

.check-grid {
  display: grid;
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: var(--ink);
}

.check-row input {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  accent-color: var(--accent);
}

.library-results {
  min-width: 0;
}

.result-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding: 12px 4px;
  color: white;
}

.result-toolbar strong {
  display: block;
  font-size: 20px;
}

.result-toolbar span {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
}

.result-toolbar select {
  width: 170px;
  background: rgba(255, 255, 255, 0.9);
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.file-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 18px;
  min-height: 202px;
  padding: 26px;
}

.file-card.needs-ocr {
  box-shadow: 0 18px 50px rgba(130, 80, 28, 0.14);
}

.file-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: #f9fbfb;
  color: var(--accent);
  font-size: 27px;
  font-weight: 900;
}

.file-icon.ppt {
  color: #eb6b12;
}

.file-main {
  min-width: 0;
}

.file-card h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.file-name {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tag-row,
.file-facts,
.file-detail,
.file-actions,
.answer-grid,
.match-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-row {
  margin: 12px 0 10px;
}

.tag-row span,
.answer-grid span,
.match-tags span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.tag-row span.group-tag {
  background: #fff0bc;
  color: #8a5a00;
}

.tag-row span.area-tag {
  background: var(--mint);
  color: var(--accent-strong);
}

.tag-row span.room-tag {
  background: var(--blue);
  color: #275191;
}

.tag-row span.venue-tag,
.tag-row span.venue-area-tag {
  background: #e9ddff;
  color: #6d35b6;
}

.metrics span.metric-venue-area {
  border-color: #d8c5ff;
  background: #f4efff;
  color: #6d35b6;
}

.file-facts,
.file-detail {
  color: var(--muted);
  font-size: 13px;
}

.file-detail span {
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(246, 248, 249, 0.82);
}

.file-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.file-list a {
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  color: #43556a;
  font-size: 12px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.file-list a:hover {
  color: var(--accent-strong);
  background: #eef7f4;
}

.room-line {
  margin: 10px 0 0;
  color: #506172;
  font-size: 13px;
  line-height: 1.5;
}

.file-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.pill-button {
  display: inline-grid;
  place-items: center;
  min-width: 82px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #35475a;
  font-weight: 850;
  border: 1px solid rgba(37, 54, 72, 0.08);
}

.pill-button:hover {
  border-color: rgba(0, 125, 102, 0.24);
  color: var(--accent-strong);
}

.pill-button.disabled {
  opacity: 0.48;
  pointer-events: none;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 0;
}

.controls {
  position: sticky;
  top: 96px;
  align-self: start;
  padding: 18px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.button-row .wide {
  grid-column: 1 / -1;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 850;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button.secondary {
  background: #e9f0ef;
  color: var(--accent-strong);
}

.filter-actions .secondary {
  border: 1px solid rgba(0, 125, 102, 0.2);
  background: rgba(255, 255, 255, 0.78);
}

.model-status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef4f4;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 850;
}

.model-status.ok {
  background: #e8f5ed;
  color: #17643a;
}

.model-status.warn,
.inline-warning {
  background: #fff8ed;
  color: #744713;
  border: 1px solid #ecd5b7;
}

.inline-warning {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 8px;
  line-height: 1.6;
}

.results {
  min-width: 0;
}

.answer {
  padding: 18px;
  margin-bottom: 14px;
  background: var(--panel-solid);
}

.answer h2,
.ocr-card h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.answer p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.answer p + p {
  margin-top: 10px;
}

.model-line {
  margin-bottom: 12px !important;
}

.agent-answer,
.agent-answer p {
  color: var(--ink);
  line-height: 1.72;
}

.match-tags .ok {
  background: #e9f5f2;
  color: var(--accent-strong);
}

.match-tags .review {
  background: #fff5e7;
  color: #7d4d1c;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.card {
  padding: 16px;
  min-width: 0;
  background: var(--panel-solid);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.card-head p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.card h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.badge {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: #e9f5f2;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
}

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

.metrics span {
  padding: 10px;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metrics strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 16px;
  overflow-wrap: anywhere;
}

h4 {
  margin: 12px 0 6px;
  font-size: 14px;
}

ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

li + li {
  margin-top: 5px;
}

details {
  margin-top: 12px;
}

summary {
  cursor: pointer;
  color: #b66c21;
  font-weight: 850;
}

code {
  display: block;
  margin-top: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #f3f5f6;
  color: #41505e;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ocr-panel {
  margin-top: 18px;
  padding: 20px;
}

.ocr-panel .result-toolbar {
  color: var(--ink);
  margin-bottom: 18px;
}

.ocr-panel .result-toolbar span {
  color: var(--muted);
}

.ocr-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.ocr-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ocr-card img,
.ocr-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #eef2f2;
  border: 1px solid var(--line);
}

.ocr-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 850;
}

.ocr-card h3 {
  font-size: 16px;
}

.ocr-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.ocr-card span {
  display: inline-block;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--amber);
  color: #7c4c10;
  font-size: 12px;
  font-weight: 850;
}

.empty {
  padding: 28px;
  color: var(--muted);
  grid-column: 1 / -1;
  background: var(--panel-solid);
}

@media (max-width: 1180px) {
  .library-layout,
  .workspace,
  .file-grid,
  .ocr-grid,
  .cards {
    grid-template-columns: 1fr;
  }

  .filter-panel,
  .controls {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0 12px 22px;
  }

  .topbar {
    margin: 0 -12px;
    padding: 10px 12px;
    grid-template-columns: auto 1fr;
  }

  h1 {
    font-size: 21px;
  }

  .top-actions {
    grid-column: 1 / -1;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
  }

  .view-tabs,
  .row,
  .button-row,
  .metrics {
    grid-template-columns: 1fr;
  }

  .view-tabs {
    display: grid;
  }

  .library-layout {
    gap: 14px;
    padding-top: 10px;
  }

  .filter-panel {
    gap: 12px;
    padding: 16px;
  }

  .filter-row,
  .filter-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  label {
    gap: 6px;
    font-size: 13px;
  }

  select,
  input {
    min-height: 42px;
    padding: 0 9px;
    font-size: 14px;
  }

  .result-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
  }

  .result-toolbar select {
    width: 100%;
  }

  .file-card {
    grid-template-columns: 1fr;
    gap: 12px;
    min-height: 0;
    padding: 18px;
  }

  .file-actions {
    justify-content: flex-start;
  }

  .file-icon {
    width: 46px;
    height: 46px;
    font-size: 22px;
  }

  .file-card h3 {
    font-size: 17px;
  }
}
