:root {
  color-scheme: light;
  --bg: #eef3f1;
  --panel: #ffffff;
  --ink: #17211f;
  --muted: #64716d;
  --line: #d9e2df;
  --soft: #f6f9f8;
  --deep: #153b36;
  --green: #167263;
  --green-2: #e3f4ef;
  --amber: #c97919;
  --red: #bd3b36;
  --blue: #2467a6;
  --shadow: 0 18px 50px rgb(21 59 54 / 12%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root.dark {
  color-scheme: dark;
  --bg: #111817;
  --panel: #1b2422;
  --ink: #eef5f2;
  --muted: #a7b5b0;
  --line: #33413e;
  --soft: #16201e;
  --deep: #8ee0cf;
  --green: #59c4ae;
  --green-2: #1e3b36;
  --amber: #f0b15b;
  --red: #ef7770;
  --blue: #8cbff0;
  --shadow: 0 18px 50px rgb(0 0 0 / 25%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

.login-screen {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgb(21 59 54 / 10%), transparent 40%),
    var(--bg);
}

.login-screen.is-closed {
  display: none !important;
}

.app-shell.is-open {
  display: block !important;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: clamp(22px, 6vw, 34px);
  box-shadow: var(--shadow);
}

.login-mark {
  width: 52px;
  height: 52px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.login-card .eyebrow {
  margin-top: 4px;
}

.login-card .primary-button {
  width: 100%;
}

.login-error {
  min-height: 22px;
  color: var(--red) !important;
  font-weight: 760;
}

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

button {
  cursor: pointer;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  padding: 14px clamp(16px, 4vw, 34px);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--deep);
  color: #ffffff;
}

:root.dark .brand-mark {
  color: #10201d;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 1.02rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.82rem;
}

.header-actions,
.tool-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.staff-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
}

.view-tabs {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 4px;
  box-shadow: 0 10px 30px rgb(21 59 54 / 7%);
}

.tab-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-weight: 840;
}

.tab-button.is-active {
  background: var(--green);
  color: #ffffff;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 10px 30px rgb(21 59 54 / 7%);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  line-height: 1;
}

.metric.alert strong {
  color: var(--amber);
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(0, 1.5fr);
  gap: 16px;
  align-items: start;
}

.view-panel {
  display: none;
}

.view-panel.is-active {
  display: grid;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.form-panel,
.list-panel {
  padding: clamp(16px, 3vw, 22px);
}

.form-panel {
  position: sticky;
  top: 86px;
}

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

.list-head {
  align-items: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.16;
}

h1,
h2 {
  font-size: clamp(1.2rem, 2.4vw, 1.65rem);
}

h3 {
  font-size: 1.02rem;
}

.source-form {
  display: grid;
  gap: 14px;
}

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

.field-row.thirds {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 780;
}

.field-help {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 16%, transparent);
}

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

.image-chip {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  aspect-ratio: 4 / 3;
}

.image-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-chip button {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 60%);
  border-radius: 8px;
  background: rgb(0 0 0 / 54%);
  color: #ffffff;
  padding: 0;
}

.card-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.card-images img {
  width: 58px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
}

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

.check-grid label {
  display: flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 9px 10px;
  color: var(--ink);
  font-weight: 740;
}

.check-grid input {
  width: 18px;
  min-height: 18px;
  margin: 0 8px 0 0;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 820;
  text-decoration: none;
}

.primary-button {
  flex: 1;
  border: 1px solid var(--green);
  background: var(--green);
  color: #ffffff;
  padding: 10px 14px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  padding: 10px 13px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--green);
  padding: 8px;
}

.icon-button {
  width: 42px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
}

.import-label {
  position: relative;
  overflow: hidden;
}

.import-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.duplicate-box {
  margin-bottom: 14px;
  border: 1px solid color-mix(in srgb, var(--amber) 60%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--amber) 12%, var(--panel));
  padding: 12px;
}

.duplicate-box strong {
  color: var(--amber);
}

.duplicate-box p {
  margin: 5px 0 0;
  color: var(--muted);
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(120px, 0.7fr));
  gap: 10px;
  margin-bottom: 12px;
}

.bulk-note {
  margin-bottom: 14px;
  border-radius: 8px;
  background: var(--green-2);
  color: var(--deep);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 720;
}

.source-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 28px;
  text-align: center;
}

.empty-state strong {
  display: block;
  font-size: 1.08rem;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
}

.source-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px;
}

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

.source-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.source-title h3 {
  min-width: 0;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--green-2);
  color: var(--deep);
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 850;
}

.badge.hot {
  background: color-mix(in srgb, var(--amber) 18%, var(--panel));
  color: var(--amber);
}

.badge.bad {
  background: color-mix(in srgb, var(--red) 14%, var(--panel));
  color: var(--red);
}

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.meta-grid span {
  border-radius: 6px;
  background: var(--panel);
  padding: 5px 8px;
}

.source-note {
  margin: 10px 0 0;
  color: var(--muted);
}

.card-actions {
  display: flex;
  align-items: start;
  gap: 8px;
}

.mini-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 7px 9px;
  font-size: 0.86rem;
  font-weight: 820;
}

.mini-button.danger {
  color: var(--red);
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

#detailContent {
  padding: 16px;
}

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

.detail-images img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

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

.detail-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 11px;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 820;
}

.detail-item strong {
  display: block;
  margin-top: 4px;
}

.staff-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.staff-editor {
  display: grid;
  gap: 10px;
}

.staff-editor label {
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 8px;
  background: var(--deep);
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  pointer-events: none;
}

:root.dark .toast {
  color: #10201d;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .dashboard {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .form-panel {
    position: static;
  }

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

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

@media (max-width: 720px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: space-between;
  }

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

  .view-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .field-row,
  .field-row.thirds,
  .filters,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .check-grid {
    grid-template-columns: 1fr;
  }

  .image-preview-grid,
  .detail-images {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-head,
  .source-card {
    grid-template-columns: 1fr;
  }

  .list-head {
    align-items: stretch;
  }

  .tool-actions,
  .form-actions,
  .card-actions {
    flex-wrap: wrap;
  }

  .staff-editor label {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button,
  .mini-button {
    flex: 1;
  }
}

@media (max-width: 420px) {
  main {
    padding: 12px;
  }

  .dashboard {
    gap: 8px;
  }

  .metric {
    padding: 12px;
  }
}

[hidden] {
  display: none !important;
}
