:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-soft: #fbfbfd;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.12);
  --line-soft: rgba(0, 0, 0, 0.07);
  --blue: #0071e3;
  --blue-strong: #005bbd;
  --green: #248a3d;
  --orange: #b85c00;
  --red: #bf1d3a;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fbfbfd 0%, #f5f5f7 42%, #ffffff 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Hiragino Sans", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

.hidden {
  display: none !important;
}

.login-body {
  min-height: 100vh;
}

.login-shell {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 28px;
}

.login-panel {
  background: var(--surface-solid);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 430px;
  padding: 34px;
  width: 100%;
}

.login-panel h1 {
  font-size: 44px;
  margin-bottom: 8px;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.login-message {
  color: var(--muted);
  font-size: 14px;
  margin: 16px 0 0;
  min-height: 20px;
}

.login-message.error {
  color: var(--red);
}

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

.topbar {
  align-items: center;
  backdrop-filter: saturate(180%) blur(22px);
  background: rgba(251, 251, 253, 0.78);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px clamp(18px, 5vw, 56px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 12px;
}

.role-switcher {
  align-items: center;
  display: flex;
  gap: 8px;
}

.role-switcher span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.role-switcher select {
  min-height: 36px;
  min-width: 172px;
  padding: 7px 10px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 3px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 23px;
  font-weight: 650;
  line-height: 1.16;
}

h2 {
  font-size: 28px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.15;
}

.status-pill {
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 13px;
  white-space: nowrap;
}

.status-pill.health-error {
  border-color: rgba(191, 29, 58, 0.22);
  color: var(--red);
}

.shell {
  margin: 0 auto;
  max-width: 1280px;
  padding: 28px clamp(16px, 4vw, 48px) 60px;
}

.tabs {
  backdrop-filter: saturate(180%) blur(18px);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  margin-bottom: 34px;
  padding: 6px;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 560;
  min-height: 42px;
  padding: 8px 10px;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.tab:hover {
  background: rgba(0, 0, 0, 0.04);
}

.tab.active {
  background: var(--text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 28px;
}

.compact-metrics {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.metric {
  background: var(--surface-solid);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  min-height: 132px;
  padding: 22px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 560;
  line-height: 1.45;
  margin-bottom: 16px;
}

.metric strong {
  color: var(--text);
  font-size: 38px;
  font-weight: 680;
  letter-spacing: 0;
}

.metric.warn strong {
  color: var(--orange);
}

.metric.risk strong {
  color: var(--red);
}

.panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

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

.filters {
  display: flex;
  gap: 8px;
}

.filter-panel {
  background: var(--surface-solid);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 18px;
}

.filter-search {
  grid-column: span 3;
}

.filter-clear {
  align-self: end;
  width: 100%;
}

.primary-button,
.ghost-button {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  min-height: 42px;
  padding: 10px 16px;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.primary-button {
  background: var(--blue);
  border: 1px solid var(--blue);
  color: white;
}

.primary-button:hover {
  background: var(--blue-strong);
  border-color: var(--blue-strong);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line-soft);
  color: var(--blue);
}

.ghost-button:hover {
  background: white;
  border-color: rgba(0, 113, 227, 0.28);
}

.form-grid {
  background: var(--surface-solid);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 22px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.full,
.full {
  grid-column: 1 / -1;
}

.tax-breakdown {
  background: #f5f5f7;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 14px;
}

.tax-breakdown input[readonly] {
  background: #ffffff;
  color: var(--text);
  font-weight: 650;
}

.tax-breakdown .muted {
  margin: 0;
}

.ocr-panel {
  background: #f5f5f7;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 16px;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.panel-head.compact h2 {
  font-size: 18px;
}

.panel-head.compact .muted {
  margin: 6px 0 0;
}

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

.ocr-summary,
.ocr-item {
  background: white;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  min-height: 68px;
  padding: 11px;
}

.ocr-summary {
  border-color: rgba(36, 138, 61, 0.24);
}

.ocr-summary.warn {
  border-color: rgba(184, 92, 0, 0.28);
}

.ocr-summary strong,
.ocr-item strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.ocr-summary span,
.ocr-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
  outline: none;
}

textarea {
  resize: vertical;
}

.receipt-list {
  display: grid;
  gap: 12px;
}

.receipt-table-wrap {
  background: var(--surface-solid);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  overflow-x: auto;
}

.receipt-table {
  border-collapse: collapse;
  min-width: 1280px;
  width: 100%;
}

.receipt-table th,
.receipt-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

.receipt-table th {
  background: #f5f5f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  position: sticky;
  top: 0;
  z-index: 1;
}

.receipt-table td {
  font-size: 13px;
}

.receipt-table td > span,
.table-note-box span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.35;
  margin-top: 4px;
}

.receipt-table select {
  min-height: 36px;
  min-width: 150px;
  padding: 7px 9px;
}

.table-note-box {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(120px, 1fr) 38px;
  min-width: 190px;
}

.table-note-box span {
  grid-column: 1 / -1;
  margin-top: 0;
}

.table-note-box input {
  min-height: 36px;
  padding: 7px 9px;
}

.table-add-note,
.table-detail {
  min-height: 36px;
  padding: 7px 10px;
}

.receipt-card {
  align-items: center;
  background: var(--surface-solid);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 18px;
}

.user-admin-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  margin-top: 14px;
}

.user-admin-grid label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 560;
  gap: 5px;
}

.user-reason-field {
  grid-column: 1 / -1;
}

.user-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  min-width: 290px;
}

.user-audit-list {
  margin-top: 14px;
}

.review-task-list {
  display: grid;
  gap: 12px;
}

.review-task-card {
  align-items: center;
  background: var(--surface-solid);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 16px;
}

.review-task-card.overdue {
  border-color: rgba(191, 29, 58, 0.28);
}

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

.active-segment {
  background: var(--text);
  color: white;
}

.receipt-title {
  font-size: 17px;
  font-weight: 650;
  margin-bottom: 5px;
}

.receipt-meta,
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.classification-info {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.classification-info span {
  background: #f5f5f7;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  font-weight: 560;
  padding: 5px 9px;
}

.classification-reason {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 8px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.tag {
  background: rgba(0, 113, 227, 0.1);
  border-radius: 999px;
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 560;
  padding: 5px 9px;
}

.tag.risk {
  background: rgba(191, 29, 58, 0.1);
  color: var(--red);
}

.tag.warn {
  background: rgba(184, 92, 0, 0.11);
  color: var(--orange);
}

.receipt-edit-panel {
  background: #f5f5f7;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
  padding: 14px;
}

.receipt-edit-panel .save-edit {
  align-self: end;
}

.note-panel {
  border-top: 1px solid var(--line-soft);
  margin-top: 14px;
  padding-top: 12px;
}

.note-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 8px;
}

.note-list {
  display: grid;
  gap: 8px;
}

.note-item {
  align-items: start;
  background: #fbfbfd;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px;
}

.note-item strong {
  font-size: 12px;
}

.note-item span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 2px;
}

.note-item p {
  margin: 7px 0 0;
}

.delete-note {
  background: transparent;
  border: 0;
  color: var(--red);
  cursor: pointer;
  font-size: 12px;
  padding: 4px;
}

.note-compose {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 10px;
}

.receipt-side {
  align-items: end;
  display: grid;
  gap: 10px;
  min-width: 220px;
}

.detail-button {
  width: 100%;
}

.receipt-amount {
  font-size: 20px;
  font-weight: 680;
  text-align: right;
}

.detail-dialog {
  background: transparent;
  border: 0;
  max-height: min(88vh, 980px);
  max-width: min(1120px, calc(100vw - 28px));
  padding: 0;
  width: 100%;
}

.detail-dialog::backdrop {
  backdrop-filter: blur(20px);
  background: rgba(0, 0, 0, 0.32);
}

.detail-shell {
  background: rgba(251, 251, 253, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.detail-head {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 20px 22px;
}

.detail-layout {
  display: grid;
  gap: 0;
  grid-template-columns: minmax(320px, 0.78fr) minmax(0, 1fr);
  max-height: calc(88vh - 94px);
  overflow: auto;
}

.detail-preview {
  background: #f5f5f7;
  border-right: 1px solid var(--line-soft);
  display: grid;
  gap: 12px;
  min-height: 520px;
  padding: 18px;
}

.detail-preview-media {
  align-self: stretch;
  background: white;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  height: 100%;
  min-height: 420px;
  object-fit: contain;
  width: 100%;
}

.detail-pdf {
  object-fit: initial;
}

.detail-file-link {
  color: var(--blue);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.detail-main {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.detail-lock {
  align-items: center;
  background: #fff8f1;
  border: 1px solid rgba(184, 92, 0, 0.2);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px;
}

.detail-lock strong {
  display: block;
  font-size: 14px;
  margin-bottom: 5px;
}

.detail-lock p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

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

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

.detail-item,
.detail-block,
.detail-note {
  background: var(--surface-solid);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.detail-item {
  display: grid;
  gap: 5px;
  min-height: 76px;
  padding: 12px;
}

.detail-item span,
.detail-note span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.detail-item strong {
  font-size: 14px;
  font-weight: 620;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.detail-block {
  padding: 14px;
}

.detail-block h3 {
  font-size: 14px;
  margin: 0 0 8px;
}

.detail-block p {
  line-height: 1.55;
  margin: 0;
}

.detail-notes {
  display: grid;
  gap: 8px;
}

.detail-note {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.detail-note p {
  margin-top: 4px;
}

.timeline-list {
  display: grid;
  gap: 8px;
}

.timeline-item {
  border-left: 3px solid var(--blue);
  display: grid;
  gap: 3px;
  padding: 6px 0 6px 10px;
}

.timeline-item span,
.timeline-item p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.timeline-item strong {
  font-size: 14px;
}

.detail-empty {
  align-content: center;
  background: white;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 420px;
  padding: 22px;
  text-align: center;
}

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

.two-column .panel,
#audit .panel,
#taxReview .panel,
#export .panel {
  background: transparent;
}

.plain-list {
  background: var(--surface-solid);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  line-height: 1.8;
  margin: 14px 0 0;
  padding: 18px 18px 18px 38px;
}

.audit-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.audit-card {
  align-items: center;
  background: var(--surface-solid);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 18px;
}

.audit-card code {
  background: #f5f5f7;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  max-width: 280px;
  overflow: hidden;
  padding: 7px 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ocr-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-search {
    grid-column: 1 / -1;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-lock {
    grid-template-columns: 1fr;
  }

  .detail-preview {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    min-height: 360px;
  }

  .detail-preview-media,
  .detail-empty {
    min-height: 320px;
  }
}

@media (max-width: 620px) {
  h1 {
    font-size: 20px;
  }

  h2 {
    font-size: 24px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .top-actions,
  .role-switcher {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs,
  .metric-grid,
  .form-grid,
  .two-column,
  .filter-panel,
  .detail-grid,
  .detail-ocr-grid,
  .ocr-grid,
  .tax-breakdown,
  .receipt-edit-panel,
  .note-compose,
  .note-item,
  .audit-card,
  .user-admin-grid,
  .receipt-card {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .receipt-side {
    align-items: stretch;
    min-width: 0;
  }

  .user-actions {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .receipt-amount {
    text-align: left;
  }

  .detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-layout {
    max-height: calc(88vh - 150px);
  }
}
