:root {
  --bg-page: #f3f4f6;
  --bg-surface: #ffffff;
  --bg-sidebar: #f9fafb;
  --bg-muted: #f9fafb;
  --bg-hover: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --brand: #ff6b35;
  --brand-hover: #e85a28;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --warn-bg: #fffbeb;
  --warn-text: #b45309;
  --info-bg: #eff6ff;
  --info-text: #1d4ed8;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --radius: 10px;
  --radius-sm: 8px;
  --font: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Auth / login ── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef2ff 0%, #f9fafb 45%, #f3f4f6 100%);
}

.login-box {
  background: var(--bg-surface);
  padding: 2rem 2rem 1.75rem;
  border-radius: 14px;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.login-box h1 {
  color: var(--text);
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

button {
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

button:hover {
  background: var(--accent-hover);
}

.login-box button {
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

.error {
  color: var(--danger-text);
  margin-top: 12px;
  text-align: center;
  font-size: 14px;
}

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

nav.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

nav.sidebar > strong {
  display: block !important;
  color: var(--brand) !important;
  margin: 0 0.5rem 1.25rem !important;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

nav.sidebar a {
  display: block;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}

nav.sidebar a:hover {
  background: var(--bg-hover);
  color: var(--text);
}

nav.sidebar a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

main {
  padding: 1.5rem 1.75rem 2rem;
  min-width: 0;
}

header.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

header.top h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ── Dashboard cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card,
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}

.card h3,
.kpi-card h3 {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card .val,
.kpi-card .val {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.35rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ── Toolbar ── */
.toolbar {
  margin-bottom: 1rem;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(243, 244, 246, 0.92);
  backdrop-filter: blur(8px);
  padding: 10px 0 12px;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 140px;
  margin: 0;
  background: var(--bg-surface);
}

.toolbar input[type='text'] {
  flex: 1 1 220px;
  min-width: 200px;
}

.toolbar button {
  width: auto;
  min-width: 88px;
  background: var(--accent);
  white-space: nowrap;
}

.toolbar button:hover {
  background: var(--accent-hover);
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg-surface);
}

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-muted);
}

tbody tr:hover {
  background: #fafbfc;
}

tbody tr:last-child td {
  border-bottom: none;
}

.creators-table-wrap,
.orders-list-wrap,
.table-scroll {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

table.creators-admin {
  min-width: 720px;
}

table.creators-admin.creators-slender {
  min-width: 640px;
}

.orders-list {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.orders-list th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-muted);
}

.orders-list tbody tr:hover {
  background: #fafbfc;
}

/* ── Status badges ── */
.status,
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid transparent;
}

.status.active,
.badge--ok {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #a7f3d0;
}

.status.suspended,
.badge--warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: #fde68a;
}

.badge {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-color: var(--border);
}

.badge--info {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: #bfdbfe;
}

/* ── Misc ── */
.cell-muted {
  color: var(--text-muted);
  font-size: 12px;
}

.creators-detail-hint,
.compact-hint,
.order-empty {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
  line-height: 1.45;
}

.compact-hint {
  margin-top: -4px;
}

a.creator-detail-link {
  display: inline-block;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff !important;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}

a.creator-detail-link:hover {
  background: var(--accent-hover);
}

.creator-sub-row {
  background: #fafbfc !important;
}

.creator-sub-row td {
  color: var(--text-secondary);
}

/* ── Orders ── */
.order-panels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.orders-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 1rem;
}

.orders-quick-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.quick-chip {
  width: auto;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.quick-chip:hover {
  background: var(--bg-hover);
}

.quick-chip.active {
  background: var(--accent-soft);
  border-color: #93c5fd;
  color: var(--accent);
}

.order-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: var(--shadow-sm);
}

.order-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.order-panel__num {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  word-break: break-word;
}

.order-panel__id {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.order-panel__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 13px;
}

.order-panel__label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.order-panel__value {
  text-align: right;
  word-break: break-word;
  color: var(--text);
}

.order-panel__actions {
  margin-top: 6px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  gap: 8px;
}

.orders-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.mini-btn {
  width: auto;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.mini-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.admin-request-error {
  color: var(--danger-text);
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 1rem;
  font-size: 14px;
  line-height: 1.45;
}

.toolbar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toolbar-toggle button {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.toolbar-toggle button:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

table.creators-admin th.col-detail,
table.creators-admin td.col-detail {
  display: table-cell;
}

table.creators-admin.creators-compact th.col-detail,
table.creators-admin.creators-compact td.col-detail {
  display: none;
}

table.creators-admin td.cell-mono {
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

/* ── Creator detail ── */
header.creator-detail-top .creators-back {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

header.creator-detail-top .creators-back:hover {
  color: var(--accent);
}

.detail-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-sm);
}

.detail-card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
  color: var(--text);
}

.detail-note {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
  line-height: 1.45;
}

.detail-dl {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 8px 16px;
  font-size: 14px;
}

.detail-dl dt {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
}

.detail-dl dd {
  overflow-wrap: anywhere;
  color: var(--text);
}

.detail-link-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.detail-link-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.detail-link-list li:last-child {
  border-bottom: none;
}

.detail-table th,
.detail-table td {
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  vertical-align: top;
}

.detail-table td.cell-bio-snippet {
  max-width: 220px;
  font-size: 12px;
  color: var(--text-secondary);
}

.detail-actions button {
  width: auto;
}

.detail-action-group {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

.detail-action-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.portfolio-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.portfolio-add-row input {
  flex: 1 1 160px;
  width: auto;
  margin-bottom: 0;
}

button.btn-inline {
  width: auto;
  padding: 10px 16px;
  font-size: 14px;
}

button.btn-remove-link {
  width: auto;
  margin-left: 10px;
  padding: 6px 12px;
  font-size: 12px;
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid #fecaca;
}

button.btn-remove-link:hover {
  background: #fee2e2;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  nav.sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem;
  }

  nav.sidebar > strong {
    width: 100%;
    margin-bottom: 0.5rem !important;
  }

  main {
    padding: 1rem;
  }
}
