:root {
  color-scheme: light;
  --bg: #fbfdfc;
  --surface: #ffffff;
  --surface-2: #eef6f4;
  --text: #111827;
  --muted: #5f6f82;
  --line: #cbd9d7;
  --accent: #007c78;
  --accent-dark: #005f5b;
  --danger: #e5484d;
  --success: #16803c;
  --warn: #a15c07;
  --signal: #b6e94b;
  --grid-blue: #2f5f98;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --shadow: 0 14px 35px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
}

button,
input {
  font: inherit;
}

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

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

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

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.topbar {
  align-items: center;
  background: var(--text);
  color: #fff;
  display: flex;
  justify-content: space-between;
  min-height: 96px;
  padding: 24px 32px;
}

.eyebrow {
  color: var(--signal);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

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

h1 {
  font-family: var(--display);
  font-size: 28px;
  line-height: 1.18;
  margin-bottom: 0;
}

h2 {
  font-family: var(--display);
  font-size: 18px;
  margin-bottom: 6px;
}

h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.status {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
}

.layout {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 1440px;
  padding: 22px;
}

.panel,
.metric,
.product-list,
.details {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel {
  align-items: end;
  border-radius: 8px;
  display: grid;
  gap: 18px;
  grid-template-columns: 1.2fr 1.4fr auto auto;
  padding: 18px;
}

.panel p {
  color: var(--muted);
  margin-bottom: 0;
}

.import-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) auto;
}

input[type="file"],
input[type="url"],
input[type="text"],
input[type="email"],
input[type="password"] {
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 40px;
  padding: 8px 10px;
  width: 100%;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button-link {
  align-items: center;
  background: var(--accent);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
}

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

.secondary-link {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--accent-dark);
}

.secondary-link:hover {
  background: #e0efec;
}

.auth-panel.is-authenticated {
  display: none;
}

.admin-panel {
  align-items: start;
  grid-template-columns: 280px 1fr;
}

.admin-content {
  display: grid;
  gap: 14px;
}

.admin-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.admin-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.tenant-card {
  cursor: pointer;
}

.tenant-card:hover {
  border-color: var(--accent);
  background: #e0efec;
}

.admin-card strong {
  font-size: 16px;
}

.admin-card span,
.admin-card small {
  color: var(--muted);
}

.admin-detail {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
  padding-top: 12px;
}

.admin-limit-form {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
}

.admin-limit-form label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 6px;
}

.admin-limit-form input {
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 10px;
}

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

.auth-form {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-column: span 3;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) minmax(160px, 1fr) auto auto;
}

.terms-row {
  align-items: start;
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 8px;
  grid-column: 1 / -1;
  grid-template-columns: 16px 1fr;
  line-height: 1.35;
}

.terms-row input {
  min-height: auto;
  margin-top: 2px;
  padding: 0;
}

.terms-row a {
  color: var(--accent);
  font-weight: 700;
}

.message {
  color: var(--muted);
  font-size: 13px;
  min-height: 20px;
}

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

.metric {
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-family: var(--mono);
  font-size: 28px;
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: 390px minmax(0, 1fr);
  min-height: 620px;
}

.product-list,
.details {
  border-radius: 8px;
  min-width: 0;
}

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

.section-head h2 {
  margin: 0;
}

.section-head span {
  color: var(--muted);
  font-weight: 700;
}

.filters {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  padding: 12px;
}

#products {
  display: grid;
  max-height: 650px;
  overflow: auto;
}

.product-item {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--text);
  display: grid;
  gap: 8px;
  min-height: 88px;
  padding: 14px 16px;
  text-align: left;
}

.product-item:hover,
.product-item.active {
  background: var(--surface-2);
}

.product-title {
  font-weight: 800;
  line-height: 1.25;
}

.product-meta,
.offer-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.badge.good {
  background: rgba(182, 233, 75, 0.26);
  color: var(--success);
}

.badge.bad {
  background: rgba(229, 72, 77, 0.12);
  color: var(--danger);
}

.badge.neutral {
  background: #e8eef2;
  color: #334155;
}

.details-inner {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.detail-top {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.detail-title {
  max-width: 760px;
}

.detail-title p {
  color: var(--muted);
  margin-bottom: 0;
}

.link-form {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.5fr) auto;
}

.inline-hint {
  background: rgba(182, 233, 75, 0.22);
  border: 1px solid rgba(0, 124, 120, 0.18);
  border-radius: 8px;
  color: var(--text);
  padding: 12px 14px;
}

.check-diagnostics {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.check-diagnostics summary {
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.check-diagnostics .table-wrap {
  margin-top: 10px;
}

.compact-table table {
  min-width: 760px;
}

.compact-table th,
.compact-table td {
  font-size: 12px;
  padding: 8px;
}

.chart-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

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

table {
  border-collapse: collapse;
  min-width: 820px;
  width: 100%;
}

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

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.empty-state {
  color: var(--muted);
  display: grid;
  gap: 10px;
  min-height: 360px;
  place-content: center;
  padding: 30px;
  text-align: center;
}

.empty-state.compact {
  min-height: 260px;
}

.empty-state h2,
.empty-state h3 {
  color: var(--text);
  margin-bottom: 0;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.mini-button {
  border-radius: 6px;
  font-size: 11px;
  min-height: 28px;
  padding: 0 8px;
}

.secondary-mini {
  background: #e8eef2;
  color: #334155;
}

.secondary-mini:hover {
  background: #d7e1ea;
}

@media (max-width: 980px) {
  .topbar,
  .detail-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel,
  .workspace,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .link-form,
  .admin-limit-form,
  .import-row,
  .auth-form,
  .filters {
    grid-template-columns: 1fr;
  }
}
