/* Base reset + typography */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg);
  font-feature-settings: var(--num-features);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* Focus */
:focus-visible {
  outline: 3px solid var(--brand-gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Typography */
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0; }
.mono, .num { font-feature-settings: var(--num-features); font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  transition: transform .12s var(--ease), box-shadow .18s var(--ease), background .18s;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover { background: var(--brand-primary-dark); }
.btn-gold {
  background: linear-gradient(135deg, var(--brand-gold) 0%, var(--brand-gold-strong) 100%);
  color: #2C0F49;
}
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--brand-primary); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f2a20; }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 8px; border-radius: 10px; }

/* Chip / badge */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--brand-primary-dark);
}
.chip-success { background: var(--success-soft); color: var(--success); }
.chip-warning { background: var(--warning-soft); color: var(--warning); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-gold { background: linear-gradient(135deg, #fff3ce, #ffe28a); color: #8a5a00; }
.chip-purple { background: #ede0fa; color: var(--brand-primary-dark); }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card + .card { margin-top: 16px; }

/* Form */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.input, .select, .textarea {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(111, 45, 168, 0.15);
}
.input-search {
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235B2A86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

/* Table */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data thead th {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--brand-primary-dark);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
table.data tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:hover { background: rgba(111, 45, 168, 0.04); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Toast */
.toast-host {
  position: fixed;
  top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}
.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--surface-dark);
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toast-in .28s var(--ease-out);
}
.toast.success { background: var(--success); }
.toast.warning { background: var(--warning); }
.toast.danger  { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 8, 40, 0.55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 8000;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modal-in .22s var(--ease-out);
}
.modal-wide { width: min(920px, 100%); }
@keyframes modal-in { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

/* Utility */
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-gold { color: var(--brand-gold-strong); }
.text-purple { color: var(--brand-primary); }
.hidden { display: none !important; }
.center { display: flex; align-items: center; justify-content: center; }
.right { text-align: right; }
.grid { display: grid; gap: 16px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-cols-4, .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
}

/* Empty state */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty h3 { color: var(--text-secondary); margin-bottom: 6px; }

/* Loading spinner */
.spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand-primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
