:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --green: #0e9f6e;
  --green-dark: #087f5b;
  --amber: #b7791f;
  --red: #c2410c;
  --blue: #2563eb;
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
}

.title-row {
  display: flex;
  align-items: end;
  gap: 18px;
  flex-wrap: wrap;
}

.title-row p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

h2 {
  font-size: 22px;
}

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

.sync-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  padding: 0 18px;
  background: var(--green);
  color: white;
}

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

.ghost-button {
  padding: 0 16px;
  background: white;
  border-color: var(--line);
  color: var(--text);
}

.icon-button {
  width: 40px;
  background: white;
  border-color: var(--line);
  color: var(--text);
  font-size: 20px;
}

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

.stat-card {
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.stat-card strong {
  font-size: 36px;
  line-height: 1;
}

.toolbar {
  display: grid;
  grid-template-columns: 140px 140px 140px 170px 1fr;
  gap: 10px;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

input,
select {
  height: 40px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  padding: 10px;
}

.table-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.editor-panel {
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.field-title {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.paste-drop {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f9fafb;
  color: var(--muted);
  text-align: center;
  outline: none;
  overflow: hidden;
}

.paste-drop:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(14, 159, 110, 0.14);
}

.paste-drop.has-image {
  border-style: solid;
}

.paste-drop p {
  margin: 0;
  font-weight: 700;
}

.paste-drop img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
}

#screenshotFile {
  height: auto;
  margin-top: 10px;
  padding: 9px;
}

.local-preview-wrap {
  margin-top: 14px;
}

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

.section-head .eyebrow {
  margin-bottom: 4px;
}

.manager-toolbar {
  min-width: 1040px;
  display: grid;
  grid-template-columns: 150px 180px 1fr;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f9fafb;
}

.muted-text {
  color: var(--muted);
  font-size: 12px;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
}

th:nth-child(1),
td:nth-child(1) {
  width: 74px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 112px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 70px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 70px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 84px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 132px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 100px;
}

.mobile-cards {
  display: none;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafb;
  color: #475467;
  font-size: 13px;
}

td {
  font-size: 14px;
}

td:nth-child(6) {
  line-height: 1.45;
  overflow-wrap: anywhere;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

.badge.inventory {
  background: #e7f7ef;
  color: var(--green-dark);
}

.badge.restock {
  background: #eef2ff;
  color: #4338ca;
}

.badge.ad {
  background: #eaf1ff;
  color: var(--blue);
}

.badge.listing {
  background: #f5f0ff;
  color: #6d28d9;
}

.badge.new {
  background: #fff7ed;
  color: var(--red);
}

.badge.notified {
  background: #fffbeb;
  color: var(--amber);
}

.badge.done {
  background: #ecfdf3;
  color: var(--green-dark);
}

.status-button {
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

.status-button:focus-visible {
  outline: 3px solid rgba(14, 159, 110, 0.2);
  outline-offset: 3px;
}

.badge.waiting {
  background: #fff7ed;
  color: var(--red);
}

.badge.confirmed {
  background: #fffbeb;
  color: var(--amber);
}

.badge.fixed {
  background: #ecfdf3;
  color: var(--green-dark);
}

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

.small-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
}

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

.screenshot-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.screenshot-field input[type="file"] {
  grid-column: 1 / -1;
  height: auto;
  padding: 9px;
}

.screenshot-preview {
  min-height: 96px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f9fafb;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  outline: none;
}

.screenshot-preview:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(14, 159, 110, 0.14);
}

.screenshot-preview img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  display: block;
}

.screenshot-thumb {
  width: 78px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
}

.thumb-button {
  padding: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
}

.image-viewer {
  position: relative;
  min-height: min(88vh, 980px);
  display: grid;
  place-items: center;
  padding: 12px;
  background: #0f172a;
  border-radius: 8px;
}

.image-viewer img {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(96vw - 24px);
  max-height: calc(92vh - 24px);
  object-fit: contain;
}

.image-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}

.empty-state {
  display: none;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

dialog {
  width: min(700px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 26px 80px rgba(15, 23, 42, 0.24);
}

#imageDialog {
  width: min(96vw, 1600px);
  max-width: none;
  background: transparent;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

#issueForm {
  padding: 20px;
}

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

#exportForm {
  padding: 22px;
}

.export-head {
  align-items: flex-start;
  padding-bottom: 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.export-head .eyebrow {
  margin-bottom: 5px;
}

.dialog-note {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

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

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

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

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

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

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

  .toolbar,
  .export-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    gap: 12px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .table-wrap table {
    display: none;
  }

  .mobile-cards {
    display: grid;
    gap: 12px;
  }

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

  .issue-card-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
  }

  .date-chip {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475467;
    font-size: 12px;
    font-weight: 800;
  }

  .issue-card-desc {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.55;
    overflow-wrap: anywhere;
  }

  .issue-card-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 12px;
  }

  .issue-card-meta div {
    min-width: 0;
    padding: 9px;
    border-radius: 8px;
    background: #f9fafb;
  }

  .issue-card-meta dt {
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
  }

  .issue-card-meta dd {
    margin: 0;
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
    overflow-wrap: anywhere;
  }

  .issue-card-shot {
    min-height: 22px;
  }

  .issue-card-shot .screenshot-thumb {
    width: 112px;
    height: 72px;
  }

  .screenshot-field {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
  }

  .primary-button {
    flex: 1;
  }
}
