*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100dvh;
}

.sky-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  display: block;
}

.app-root {
  position: relative;
  z-index: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

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

h1, h2, h3, h4, p {
  margin: 0;
}

.num,
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
}

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

.small {
  font-size: 0.85rem;
}

/* Boot loader */
.boot-loader {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-secondary);
}

.boot-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-emerald);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Cards */
.card {
  background: rgba(15, 21, 34, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card-elevated {
  background: rgba(22, 30, 48, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.92rem;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--accent-emerald);
  color: #052e1e;
  box-shadow: var(--shadow-glow-emerald);
}

.btn-primary:hover:not(:disabled) {
  background: #34d399;
}

.btn-gold {
  background: var(--accent-gold);
  color: #291802;
}

.btn-gold:hover:not(:disabled) {
  background: #fbbf24;
}

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--accent-rose-soft);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fda4af;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.24);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

/* Form controls */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px var(--accent-emerald-soft);
}

.input::placeholder {
  color: var(--text-muted);
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-emerald {
  background: var(--accent-emerald-soft);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.25);
}

.badge-gold {
  background: var(--accent-gold-soft);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.25);
}

.badge-blue {
  background: var(--accent-blue-soft);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.25);
}

.badge-muted {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

/* Avatar */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #16302b, #1d283a);
  border: 2px solid var(--border-strong);
  font-size: 0.95rem;
  font-weight: 700;
  color: #e2e8f0;
  position: relative;
  flex-shrink: 0;
  user-select: none;
}

.avatar-lg {
  width: 60px;
  height: 60px;
  font-size: 1.55rem;
  border-width: 2px;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.avatar-initial {
  line-height: 1;
}

.avatar-online-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent-emerald);
  border: 2px solid var(--bg-surface);
}

/* Data table */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr.is-self {
  background: rgba(16, 185, 129, 0.06);
}

/* Toasts */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent-emerald);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
  font-size: 0.9rem;
  animation: toast-in 0.2s ease-out;
}

.toast-error {
  border-left-color: var(--accent-rose);
}

.toast-gold {
  border-left-color: var(--accent-gold);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Error / Notice Box */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--accent-rose-soft);
  border-color: rgba(244, 63, 94, 0.35);
  color: #fecdd3;
}

.alert-emerald {
  background: var(--accent-emerald-soft);
  border-color: rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
}
