:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --white: #ffffff;
  --bg: #fbfbfd;
  --hairline: #d2d2d7;
  --hairline-light: #e8e8ed;

  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;

  --link: #0066cc;
  --link-hover: #004499;
  --cta: #0071e3;
  --cta-hover: #0077ed;

  --status-relevant: #248a3d;
  --status-relevant-bg: #f3faf5;
  --status-rejected: #d70015;
  --status-rejected-bg: #fff8f8;
  --status-pending: #6e6e73;
  --status-pending-bg: #fbfbfd;

  --max-width: 980px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.022em;
  background: var(--white);
  color: var(--text);
  line-height: 1.47059;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); }

/* Global nav — apple.com style */
.global-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(22px, calc(50% - var(--max-width) / 2));
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline-light);
}

.nav-brand {
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-brand:hover { color: var(--link); }

.nav-back {
  font-size: 12px;
  color: var(--link);
  text-decoration: none;
}

.nav-back:hover { text-decoration: underline; }

.nav-status,
.nav-meta {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-link {
  font-size: 12px;
  color: var(--link);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  text-decoration: none;
}

.nav-link:hover { text-decoration: underline; }

.nav-link.danger { color: var(--text-secondary); }

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 22px 80px;
}

/* Page hero */
.page-hero {
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--hairline-light);
  margin-bottom: 2rem;
}

.page-hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.003em;
  line-height: 1.05;
  color: var(--text);
}

.hero-subtitle {
  margin-top: 0.625rem;
  font-size: 17px;
  color: var(--text-secondary);
  letter-spacing: -0.022em;
}

.hero-status {
  margin-top: 0.375rem;
  font-size: 14px;
  color: var(--text-tertiary);
}

/* Buttons */
.btn-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 980px;
  padding: 0.5rem 1.125rem;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -0.016em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s;
}

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

.btn-pill.primary:hover { background: var(--cta-hover); }

.btn-pill.secondary {
  background: transparent;
  color: var(--link);
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.btn-pill.secondary:hover {
  background: var(--bg);
}

.btn-pill:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-text {
  appearance: none;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 14px;
  color: var(--link);
  cursor: pointer;
  padding: 0;
  letter-spacing: -0.016em;
}

.btn-text:hover { text-decoration: underline; }

.btn-text.danger { color: var(--text-secondary); }

/* Forms */
.form-panel {
  margin: 2rem 0;
  padding: 2rem 0;
  border-top: 1px solid var(--hairline-light);
  border-bottom: 1px solid var(--hairline-light);
}

.form-panel.hidden { display: none; }

.form-panel h3 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.009em;
  margin-bottom: 1.5rem;
}

.form-panel h3:not(:first-child) {
  margin-top: 2rem;
}

.form-panel label {
  display: block;
  margin-bottom: 1.25rem;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.016em;
}

.form-panel input,
.form-panel textarea {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  background: var(--white);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  color: var(--text);
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 17px;
  letter-spacing: -0.022em;
  transition: border-color 0.2s;
}

.form-panel input:focus,
.form-panel textarea:focus {
  outline: none;
  border-color: var(--cta);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.checkbox {
  display: flex !important;
  align-items: center;
  gap: 0.625rem;
  font-size: 17px !important;
  font-weight: 400 !important;
  color: var(--text) !important;
}

.checkbox input {
  width: 1.0625rem;
  height: 1.0625rem;
  margin: 0;
  accent-color: var(--cta);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.reference-field {
  margin-bottom: 1.25rem;
}

.reference-field .field-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.reference-field .field-hint,
.form-hint {
  margin: -0.75rem 0 1.25rem;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.reference-field .field-hint {
  margin: 0.5rem 0 0.875rem;
}

.reference-upload {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.form-panel .reference-input {
  display: none !important;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.reference-dropzone {
  appearance: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 120px;
  padding: 0;
  border: 1px dashed var(--hairline);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  overflow: hidden;
  font-family: inherit;
}

.reference-dropzone:hover .reference-placeholder {
  text-decoration: underline;
}

.reference-dropzone.has-image {
  border-style: solid;
  border-color: var(--hairline-light);
}

.reference-placeholder {
  font-size: 14px;
  color: var(--link);
  letter-spacing: -0.016em;
}

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

.reference-remove {
  font-size: 14px;
  padding: 0;
}

.reference-display {
  width: 200px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--hairline-light);
  background: var(--bg);
}

.reference-display img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.hidden {
  display: none !important;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 22px;
}

.auth-panel {
  width: 100%;
  max-width: 420px;
}

.auth-tabs {
  display: flex;
  gap: 2rem;
  margin: 1.5rem 0 2rem;
  border-bottom: 1px solid var(--hairline-light);
}

.auth-tabs .filter-btn {
  margin-bottom: -1px;
}

.auth-form label {
  display: block;
  margin-bottom: 1.25rem;
  font-size: 14px;
  font-weight: 600;
}

.auth-form input {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  background: var(--white);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 17px;
}

.auth-form .btn-pill {
  width: 100%;
  margin-top: 0.5rem;
}

/* Detail sections */
.detail-section {
  margin-bottom: 2.5rem;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.section-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  letter-spacing: -0.016em;
}

.section-body a {
  text-decoration: none;
  word-break: break-all;
}

.section-body a:hover { text-decoration: underline; }

.section-body.muted { color: var(--text-secondary); }

.activity {
  white-space: pre-line;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 734px) {
  .detail-grid { grid-template-columns: 1fr; gap: 2rem; }
}

/* Agent list */
.agent-list {
  margin-top: 0.5rem;
}

.agent-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--hairline-light);
}

.agent-row:first-child {
  border-top: 1px solid var(--hairline-light);
}

.agent-row.paused { opacity: 0.55; }

.agent-row-title {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.011em;
  color: var(--text);
  text-decoration: none;
  line-height: 1.2;
}

.agent-row-title:hover { color: var(--link); }

.agent-row-detail {
  margin-top: 0.375rem;
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: -0.016em;
}

.agent-row-meta {
  margin-top: 0.25rem;
  font-size: 12px;
  color: var(--text-tertiary);
}

.agent-row-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
  padding-top: 0.125rem;
}

/* Filter tabs — apple support style underline */
.filter-bar {
  margin-bottom: 0;
  border-bottom: 1px solid var(--hairline-light);
}

.filters {
  display: flex;
  gap: 2rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-btn {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0.875rem 0;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: -0.016em;
  transition: color 0.2s;
}

.filter-btn:hover { color: var(--text); }

.filter-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
  font-weight: 600;
}

/* Listing rows — apple store product line style */
.listings {
  margin-top: 0;
}

.listing-row {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem 1rem;
  margin: 0 -1rem;
  border-bottom: 1px solid var(--hairline-light);
  align-items: flex-start;
}

.listing-remove {
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 0.125rem;
  font-size: 12px;
}

.listing-row:first-child {
  border-top: 1px solid var(--hairline-light);
}

.listing-row--relevant {
  background: var(--status-relevant-bg);
}

.listing-row--rejected {
  background: var(--status-rejected-bg);
}

.listing-row--pending {
  background: var(--status-pending-bg);
}

.listing-status {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: 0.375rem;
}

.listing-status.relevant { color: var(--status-relevant); }
.listing-status.rejected { color: var(--status-rejected); }
.listing-status.pending { color: var(--status-pending); }

.listing-row--relevant .listing-title a { color: var(--status-relevant); }
.listing-row--rejected .listing-title a { color: var(--text-secondary); }

.listing-image {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 0;
  overflow: hidden;
  background: var(--bg);
  display: block;
}

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

.listing-image.placeholder { background: var(--bg); }

.listing-main {
  flex: 1;
  min-width: 0;
}

.listing-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
}

.listing-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.23536;
}

.listing-title a {
  color: var(--text);
  text-decoration: none;
}

.listing-title a:hover { color: var(--link); }

.listing-price {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.listing-specs {
  margin-top: 0.25rem;
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: -0.016em;
  line-height: 1.42859;
}

.listing-detail {
  margin-top: 0.375rem;
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: -0.01em;
}

.listing-reason {
  margin-top: 0.5rem;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.42859;
  letter-spacing: -0.016em;
}

.empty {
  padding: 4rem 0;
  text-align: center;
  font-size: 17px;
  color: var(--text-secondary);
  letter-spacing: -0.022em;
}

.updated {
  margin-top: 2rem;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

@media (max-width: 734px) {
  .agent-row {
    flex-direction: column;
    gap: 1rem;
  }

  .agent-row-actions {
    flex-direction: row;
    align-items: center;
    width: 100%;
  }

  .listing-header {
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
  }

  .page-hero-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
