:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --primary: #1f7a5c;
  --primary-dark: #176249;
  --secondary: #2f5e9e;
  --danger: #b42318;
  --warning-bg: #fff4df;
  --pass-bg: #e6f4ef;
  --fail-bg: #fff0ee;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

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

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
}

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  text-decoration: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

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

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

.secondary {
  border-color: #c8d7eb;
  background: #eef5ff;
  color: var(--secondary);
}

.ghost {
  border-color: var(--line);
  background: white;
  color: var(--text);
}

.danger {
  border-color: #f0b4ad;
  background: #fff0ee;
  color: var(--danger);
}

.danger:hover {
  background: #ffe5e1;
}

.icon-button {
  width: 38px;
  padding: 0;
  border-color: var(--line);
  background: white;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

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

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(20, 35, 55, 0.08);
}

.login-panel h1,
.topbar h1,
.section h2,
dialog h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.brand-name {
  font-size: 22px;
  line-height: 1.35;
  font-weight: 800;
}

.login-panel h1,
.topbar h1 {
  font-size: 20px;
  line-height: 1.35;
}

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

.login-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 22px;
}

.login-mode-tabs button {
  border-color: var(--line);
  background: white;
  color: var(--muted);
}

.login-mode-tabs button.active {
  border-color: #c8d7eb;
  background: #eef5ff;
  color: var(--secondary);
}

.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-content: end;
  min-height: 62px;
}

.checkbox-field input {
  width: auto;
  min-height: 0;
}

.photo-field {
  display: grid;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.photo-upload-section {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

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

textarea {
  resize: vertical;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.section-head,
.actions,
.user-box,
.tabs {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0;
}

.user-box,
.actions {
  gap: 10px;
  flex-wrap: wrap;
}

.tabs {
  gap: 8px;
  margin: 10px 0 16px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  border-radius: 6px 6px 0 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.tabs button.active {
  border-color: var(--line);
  border-bottom-color: white;
  background: white;
  color: var(--text);
}

.user-box button.active {
  border-color: #c8d7eb;
  background: #eef5ff;
  color: var(--secondary);
}

.section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.landing-page {
  min-height: 240px;
}

.section-head {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

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

.filters,
.inline-form {
  display: grid;
  grid-template-columns: repeat(9, minmax(112px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.inline-form {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #344054;
  font-size: 13px;
}

tbody tr:hover {
  background: #f9fbfd;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.badge.pass {
  background: var(--pass-bg);
  color: #16624a;
}

.badge.fail {
  background: var(--fail-bg);
  color: var(--danger);
}

.badge.neutral {
  background: #eef2f6;
  color: #475467;
}

dialog {
  width: min(920px, calc(100vw - 24px));
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(12, 20, 30, 0.24);
}

.small-dialog {
  width: min(460px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgba(12, 20, 30, 0.38);
}

.dialog-body {
  padding: 22px;
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

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

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

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

.detail-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.detail-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.pending-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

.pending-photo-tile {
  display: grid;
  gap: 6px;
}

.pending-photo-tile img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f6;
}

.pending-photo-tile button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.photo-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.photo-section {
  display: grid;
  gap: 10px;
}

.photo-section h3 {
  margin: 0;
  color: #344054;
  font-size: 14px;
}

.photo-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.photo-tile {
  display: grid;
  gap: 8px;
}

.photo-tile img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f6;
}

.photo-name {
  min-height: 30px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17202a;
  color: white;
  box-shadow: 0 12px 40px rgba(12, 20, 30, 0.2);
}

@media (max-width: 980px) {
  .filters,
  .inline-form {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .section-head,
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .app {
    padding: 14px;
  }

  .section,
  .login-panel,
  .dialog-body {
    padding: 16px;
  }

  .filters,
  .inline-form,
  .code-row,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
