:root {
  --bg: #f7faf9;
  --panel: #ffffff;
  --surface: #f3f7f5;
  --border: #dfe9e5;
  --text: #10251d;
  --muted: #6c7d76;
  --accent: #009859;
  --accent-dark: #08764a;
  --danger: #b42318;
  --warning: #a15c07;
  --success: #08764a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

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

button.secondary {
  border: 1px solid var(--border);
  color: var(--text);
  background: #fff;
}

button.secondary:hover {
  background: var(--surface);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 152, 89, 0.12);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
}

.admin-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 72px;
}

.admin-header,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-header {
  margin-bottom: 24px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel {
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  background: var(--panel);
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading p,
.auth-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  align-items: end;
}

.auth-form,
.create-form {
  display: grid;
  gap: 14px;
}

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

.create-form .wide {
  grid-column: auto;
}

.form-actions {
  display: flex;
  align-items: end;
}

.form-actions button {
  width: 100%;
}

label span,
.generated-link > span {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.generated-link {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.generated-link > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.generated-link input {
  min-width: 0;
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.generated-link button {
  min-width: 92px;
  white-space: nowrap;
}

.count-pill,
.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.state-pill.active {
  color: var(--danger);
  background: #fff0ed;
}

.state-pill.used {
  color: var(--success);
  background: rgba(0, 152, 89, 0.11);
}

.state-pill.expired {
  color: var(--warning);
  background: #fff4e5;
}

.state-pill.disabled {
  color: var(--danger);
  background: #fff0ed;
}

.batch-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--text);
  background: var(--surface);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.batch-status-pill.status-pending,
.batch-status-select.status-pending {
  border-color: #d6dfdc;
  color: #51645c;
  background: #eef4f1;
}

.batch-status-pill.status-processing,
.batch-status-select.status-processing {
  border-color: #bdd7ff;
  color: #1455a3;
  background: #edf5ff;
}

.batch-status-pill.status-more-info,
.batch-status-select.status-more-info {
  border-color: #ffd59b;
  color: #9a4d00;
  background: #fff6e8;
}

.batch-status-pill.status-approved,
.batch-status-select.status-approved {
  border-color: #bde8ce;
  color: #08764a;
  background: #eaf8f0;
}

.batch-status-pill.status-rejected,
.batch-status-select.status-rejected {
  border-color: #ffc6be;
  color: #b42318;
  background: #fff0ed;
}

.batch-status-pill.status-discarded,
.batch-status-select.status-discarded {
  border-color: #cfd8d4;
  color: #334139;
  background: #e8eeeb;
}

.batch-status-select {
  font-weight: 800;
}

.lark-sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.lark-sync-pill.sync-pending {
  border-color: #ffd59b;
  color: #9a4d00;
  background: #fff6e8;
}

.lark-sync-pill.sync-syncing {
  border-color: #bdd7ff;
  color: #1455a3;
  background: #edf5ff;
}

.lark-sync-pill.sync-synced {
  border-color: #bde8ce;
  color: #08764a;
  background: #eaf8f0;
}

.lark-sync-pill.sync-failed {
  border-color: #ffc6be;
  color: #b42318;
  background: #fff0ed;
}

.sync-error {
  display: block;
  max-width: 260px;
  overflow: hidden;
  color: var(--danger);
  text-overflow: ellipsis;
}

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

.retry-sync-button {
  white-space: nowrap;
}

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

.detail-sync-item strong {
  display: flex;
}

.detail-sync-item .retry-sync-button {
  width: max-content;
  min-height: 34px;
  padding: 0 12px;
}

.message {
  margin-bottom: 14px;
  border: 1px solid #ffd7a8;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--warning);
  background: #fff9f0;
  font-size: 14px;
  font-weight: 700;
}

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

.links-table-wrap {
  max-width: 100%;
}

.links-table {
  width: max-content;
  min-width: 100%;
}

.links-table th,
.links-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.links-table td strong,
.links-table td small {
  display: inline;
  margin: 0;
}

.links-table .inline-meta {
  margin-left: 10px;
}

.links-table .link-cell input {
  width: 380px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.detail-item {
  min-height: 74px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.detail-item span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.status-edit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.status-edit-row button {
  min-height: 42px;
  padding: 0 14px;
}

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

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

.photo-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 78px;
  min-height: 78px;
  border: 1px solid var(--border);
  padding: 6px;
  color: var(--text);
  background: #fff;
}

.photo-preview:hover {
  background: var(--surface);
}

.photo-preview img {
  width: 66px;
  height: 66px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface);
}

.photo-preview-failed {
  display: block;
  width: 90px;
  color: var(--warning);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  border-top: 0;
  color: var(--muted);
  background: var(--surface);
  font-weight: 800;
  white-space: nowrap;
}

td strong {
  display: block;
  margin-bottom: 2px;
}

td small {
  display: block;
  color: var(--muted);
}

.link-cell {
  display: flex;
  gap: 8px;
  align-items: center;
}

.link-cell input {
  min-width: 280px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.empty-cell {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .admin-shell {
    width: min(100% - 28px, 1180px);
    padding-top: 24px;
  }

  .admin-header,
  .panel-heading,
  .auth-panel {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .create-form {
    grid-template-columns: 1fr;
  }

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

  .detail-actions {
    flex-direction: column;
  }

  .detail-actions button {
    width: 100%;
  }
}
