:root {
  --page: #f2f5f8;
  --surface: #ffffff;
  --surface-muted: #f7f9fb;
  --surface-strong: #0f172a;
  --text: #172033;
  --muted: #667085;
  --line: #d6dee8;
  --primary: #145bd7;
  --primary-dark: #0f3f9b;
  --accent: #0f8f75;
  --warning: #b7791f;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 20px rgba(15, 23, 42, 0.05);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(242, 245, 248, 0.96) 260px),
    var(--page);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  pointer-events: none;
}

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

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 2.2vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.98rem;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.app-header,
.panel,
.result-card,
.login-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: end;
  padding: 24px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 8px;
  padding: 0 9px;
  border: 1px solid rgba(20, 91, 215, 0.16);
  border-radius: 999px;
  background: rgba(20, 91, 215, 0.07);
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-header p,
.result-card p,
.login-card p,
.empty-state p {
  color: var(--muted);
}

.app-header p {
  max-width: 720px;
  margin-top: 8px;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.status-line {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(15, 143, 117, 0.2);
  border-radius: 999px;
  background: rgba(15, 143, 117, 0.08);
  color: #0b6958;
  font-size: 0.88rem;
  font-weight: 700;
}

.status-line strong {
  color: var(--text);
}

.header-actions,
.result-actions,
.table-actions,
.user-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.header-actions {
  margin-top: 16px;
}

.nav-tabs {
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 5px;
  border: 1px solid #dce3ec;
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}

.nav-tabs .primary-button,
.nav-tabs .secondary-button {
  min-height: 34px;
  padding: 0 12px;
  box-shadow: none;
}

.nav-tabs .secondary-button {
  border-color: transparent;
  background: transparent;
}

.nav-tabs .is-active {
  border-color: #cdd6e1;
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.08);
}

.header-actions form,
.result-actions form,
.user-actions form {
  margin: 0;
}

.header-count {
  min-width: 148px;
  padding: 14px 16px;
  border: 1px solid #cfe0f7;
  border-radius: var(--radius-md);
  background: #f6f9fe;
  text-align: left;
}

.header-count strong,
.header-count span {
  display: block;
}

.header-count strong {
  color: var(--primary-dark);
  font-size: 1.35rem;
  line-height: 1.15;
}

.header-count span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
}

.alert {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(180, 35, 24, 0.2);
  border-radius: var(--radius-md);
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
  font-weight: 700;
}

.alert-success {
  border-color: rgba(15, 143, 117, 0.22);
  background: rgba(15, 143, 117, 0.08);
  color: var(--accent);
}

.capture-form,
.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.capture-form {
  margin-top: 18px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf1f6;
}

.panel-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid #dce3ec;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-weight: 700;
}

label span {
  color: #344054;
  font-size: 0.9rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cdd6e1;
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(20, 91, 215, 0.55);
  box-shadow: 0 0 0 4px rgba(20, 91, 215, 0.1);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px;
}

.photo-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid #dce3ec;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.photo-card.has-photo {
  border-color: rgba(15, 143, 117, 0.34);
  background: #f5fbf9;
  box-shadow: inset 0 0 0 1px rgba(15, 143, 117, 0.06);
}

.photo-card-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  align-items: start;
}

.photo-card-head > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #bfdbfe;
  background: #eaf2ff;
  color: var(--primary-dark);
  font-weight: 800;
}

.photo-card p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.88rem;
}

.photo-picker {
  position: relative;
  min-height: 184px;
  border: 1px dashed #9fbce6;
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(239, 246, 255, 0.82)),
    #f3f7fc;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-picker input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  padding: 0;
}

.picker-text {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(20, 91, 215, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--primary-dark);
  box-shadow: var(--shadow-soft);
  font-weight: 800;
}

.has-photo .picker-text {
  position: absolute;
  right: 10px;
  bottom: 10px;
}

.photo-picker img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-picker img[hidden] {
  display: none;
}

.photo-card small {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.84rem;
  word-break: break-all;
}

.submit-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  padding: 14px 0 0;
  background: linear-gradient(180deg, rgba(242, 245, 248, 0), var(--page) 45%);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

button.primary-button,
button.secondary-button {
  appearance: none;
}

.primary-button {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 24px rgba(20, 91, 215, 0.18);
}

.secondary-button {
  border-color: #cdd6e1;
  background: #fff;
  color: var(--primary-dark);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

.result-shell,
.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.result-card,
.login-card {
  width: min(720px, 100%);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card {
  width: min(460px, 100%);
}

.result-card h1,
.login-card h1 {
  margin-bottom: 10px;
}

.login-form {
  margin-top: 20px;
}

.login-hint {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #dce3ec;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.9rem;
}

.login-hint strong {
  color: var(--text);
}

.result-card strong {
  color: var(--text);
  word-break: break-all;
}

.result-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.result-meta div {
  padding: 13px;
  border: 1px solid #dce3ec;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.result-meta dt,
.result-meta dd {
  margin: 0;
}

.result-meta dt {
  color: var(--muted);
  font-size: 0.86rem;
}

.result-meta dd {
  margin-top: 5px;
  font-weight: 800;
  word-break: break-word;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  text-align: center;
  font-weight: 700;
}

.toast[hidden] {
  display: none;
}

.list-panel {
  margin-top: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.record-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.record-table th,
.record-table td {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: middle;
}

.record-table th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 0.86rem;
  font-weight: 800;
}

.record-table tbody tr:hover {
  background: #f9fbff;
}

.filename-cell {
  max-width: 280px;
  color: var(--muted);
  word-break: break-all;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 20px 0;
}

.user-create-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
}

.status-pill.is-active {
  background: rgba(15, 143, 117, 0.1);
  color: var(--accent);
}

.status-pill.is-disabled {
  background: rgba(180, 35, 24, 0.09);
  color: var(--danger);
}

.reset-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reset-form input {
  width: 150px;
  min-height: 34px;
  padding: 7px 10px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.detail-meta {
  align-self: start;
}

.detail-list {
  grid-template-columns: 1fr;
  margin: 0;
}

.pdf-panel {
  min-height: 760px;
  padding: 10px;
}

.pdf-panel iframe {
  width: 100%;
  height: 760px;
  border: 0;
  border-radius: var(--radius-md);
  background: #f8fafc;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 18px, 100%);
    padding-top: 12px;
  }

  .app-header {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .header-count {
    width: 100%;
  }

  .field-grid,
  .photo-grid,
  .result-meta,
  .detail-layout,
  .user-create-form {
    grid-template-columns: 1fr;
  }

  .panel,
  .result-card,
  .login-card {
    padding: 16px;
  }

  .photo-picker {
    min-height: 220px;
  }

  .submit-bar,
  .result-actions,
  .header-actions,
  .user-actions,
  .reset-form {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .nav-tabs {
    width: 100%;
  }

  .pdf-panel {
    min-height: 520px;
  }

  .pdf-panel iframe {
    height: 520px;
  }
}
