:root {
  color-scheme: light;
  --bg: #f4f7f2;
  --panel: #ffffff;
  --panel-soft: #f8faf7;
  --text: #18241f;
  --muted: #64736b;
  --line: #dce5dd;
  --line-strong: #b5c4ba;
  --accent: #1f7a4d;
  --accent-strong: #155f3a;
  --accent-soft: #e8f4ec;
  --danger: #b42318;
  --success: #087443;
  --warning: #a15c00;
  --shadow: 0 16px 36px rgba(30, 61, 44, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  min-height: 34px;
  padding: 0 12px;
  font-weight: 700;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(31, 122, 77, 0.18);
}

button.primary:hover {
  background: var(--accent-strong);
}

button.danger {
  border-color: #f0b6b0;
  color: var(--danger);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  min-height: 34px;
  padding: 7px 9px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.13);
  outline: none;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  background: #173f2d;
  color: #f8fafc;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: #f6c85f;
  color: #173f2d;
  font-weight: 800;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
}

.brand-subtitle {
  color: #c8d8cf;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  justify-content: flex-start;
  width: 100%;
  border-color: transparent;
  background: transparent;
  color: #e8f3ed;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.main {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  padding: 16px 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.context-line {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: 24px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

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

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

.panel-title {
  font-size: 15px;
  font-weight: 800;
}

.panel-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.panel-body {
  padding: 16px;
}

.panel-body.no-top-padding {
  padding-top: 0;
}

.metric .panel-body {
  min-height: 90px;
}

.metric-value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 800;
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

.session-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dev-auth-box {
  margin-top: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 10px 12px;
}

.dev-auth-box summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dev-auth-box .form-grid {
  margin-top: 10px;
}

.tenant-access-panel {
  grid-column: span 2;
}

.access-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.access-grid .span-2 {
  grid-column: span 2;
}

.access-grid h3 {
  margin: 0 0 10px;
  font-size: 13px;
}

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

.form-actions {
  margin-top: 14px;
}

.subpanel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f6f0;
  padding: 12px;
}

.subpanel.soft {
  border-style: dashed;
}

.subpanel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subpanel-title {
  font-size: 13px;
  font-weight: 800;
}

.whitelist-editor textarea {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.whitelist-note {
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
}

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

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

tbody tr:hover td {
  background: #fbfcf7;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.row-select {
  cursor: pointer;
}

.row-select:hover td {
  background: #eef7f1;
}

.row-select.selected td {
  background: #e4f2e9;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #edf2ee;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pill.success {
  background: #e4f7ec;
  color: var(--success);
}

.pill.warning {
  background: #fff4db;
  color: var(--warning);
}

.pill.danger {
  background: #fff0ee;
  color: var(--danger);
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 440px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(30, 61, 44, 0.18);
  padding: 12px 14px;
  color: var(--text);
}

.toast.error {
  border-color: #f0b6b0;
  color: var(--danger);
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.workspace-hero .panel-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.workspace-hero h2 {
  margin: 4px 0 10px;
  font-size: 24px;
}

.workspace-meta,
.workspace-stats,
.summary-row,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace-stats {
  justify-content: flex-end;
}

.workspace-stats > div,
.stat-tile {
  min-width: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 10px 12px;
}

.workspace-stats strong,
.stat-tile strong {
  display: block;
  color: var(--text);
  font-size: 18px;
}

.workspace-stats span,
.stat-tile span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tabs button.active,
.tabs button:hover {
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.switch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin-top: 16px;
}

.switch-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--text);
  font-size: 13px;
}

.switch-row input {
  width: auto;
  min-height: 0;
}

.toolbar {
  align-items: stretch;
}

.toolbar input {
  min-width: 320px;
  width: min(460px, 100%);
}

.toolbar select {
  width: 190px;
}

.field-table input,
.field-table select,
.field-table textarea {
  min-width: 120px;
}

.field-table textarea {
  min-width: 260px;
  min-height: 54px;
}

.group-table input,
.group-table select,
.team-table input,
.team-table select {
  min-width: 160px;
}

.group-table select[multiple],
.team-table select[multiple] {
  min-width: 300px;
  min-height: 118px;
}

.team-table input[type="color"] {
  min-width: 64px;
  padding: 3px;
}

.score-table input {
  min-width: 86px;
}

.score-table input[type="checkbox"] {
  width: auto;
  min-width: 0;
}

.ranking-table .pill {
  margin: 0 4px 4px 0;
}

.award-table input,
.award-table textarea {
  min-width: 180px;
}

.award-table textarea {
  min-width: 260px;
  min-height: 86px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.publish-preview {
  border-top: 1px solid var(--line);
}

.publish-preview-empty,
.preview-note {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 12px;
  font-weight: 700;
}

.preview-checks,
.award-preview-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.preview-check {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 10px 12px;
}

.review-lists {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.review-list {
  min-width: 0;
}

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

.award-preview-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 12px;
}

.award-preview-winners .pill {
  margin: 0 4px 4px 0;
}

.media-upload {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 160px minmax(180px, 1fr) auto auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
}

.checkbox-label input {
  width: auto;
  min-height: 0;
}

.media-table input,
.media-table select {
  min-width: 160px;
}

.media-table input[data-media-field="url"],
.media-table input[data-media-field="thumbnailUrl"] {
  min-width: 280px;
}

.media-table input[type="checkbox"] {
  min-width: 0;
  width: auto;
}

.media-thumb {
  width: 72px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-soft);
}

.audit-toolbar input {
  min-width: 360px;
}

.audit-table td {
  vertical-align: top;
}

.audit-payload summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

.audit-payload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.audit-payload pre {
  max-width: 360px;
  max-height: 220px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
}

.summary-row {
  align-items: stretch;
}

.refund-list {
  display: grid;
  gap: 6px;
  min-width: 260px;
}

.refund-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 260px;
}

.order-actions {
  min-width: 300px;
}

.row-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .form-grid,
  .switch-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  .tenant-access-panel,
  .audit-payload-grid,
  .access-grid .span-2 {
    grid-column: auto;
  }

  .access-grid,
  .audit-payload-grid,
  .media-upload,
  .review-lists,
  .award-preview-list {
    grid-template-columns: 1fr;
  }

  .topbar,
  .workspace-hero .panel-body {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace-stats {
    justify-content: flex-start;
  }
}
