/* ════════════ SHARED COMPONENTS ════════════ */

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--t), background var(--t), transform var(--t-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 15px; height: 15px; }

.btn--primary  { background: var(--accent);  color: #fff; }
.btn--primary:hover  { background: var(--accent-dark); }
.btn--ghost    { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn--ghost:hover    { background: var(--surface3); }
.btn--danger   { background: var(--red-dim);  color: var(--red); }
.btn--danger:hover   { background: rgba(239,68,68,.25); }
.btn--sm { padding: 5px 12px; font-size: 0.8rem; }
.btn--icon { padding: 8px; }

/* ── Stats Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  transition: border-color var(--t), box-shadow var(--t);
}
.stat-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.accent::before  { background: var(--accent); }
.stat-card.green::before   { background: var(--green); }
.stat-card.yellow::before  { background: var(--yellow); }
.stat-card.red::before     { background: var(--red); }
.stat-card.blue::before    { background: var(--blue); }

.stat-card__icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-sm);
}
.stat-card__icon svg { width: 20px; height: 20px; }
.stat-card__icon.accent  { background: var(--accent-glow); color: var(--accent); }
.stat-card__icon.green   { background: var(--green-dim);   color: var(--green); }
.stat-card__icon.yellow  { background: var(--yellow-dim);  color: var(--yellow); }
.stat-card__icon.red     { background: var(--red-dim);     color: var(--red); }
.stat-card__icon.blue    { background: var(--blue-dim);    color: var(--blue); }

.stat-card__label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-card__value { font-size: 2rem; font-weight: 800; line-height: 1.1; letter-spacing: -1px; }
.stat-card__trend {
  font-size: 0.78rem;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-card__trend.up   { color: var(--green); }
.stat-card__trend.down { color: var(--red); }
.stat-card__trend.neu  { color: var(--muted); }

/* ── Panel ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
}
.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.panel__title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel__title svg { width: 16px; height: 16px; color: var(--muted); }

/* ── Badge / Tag ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge--high   { background: var(--red-dim);    color: var(--red); }
.badge--med    { background: var(--yellow-dim);  color: var(--yellow); }
.badge--low    { background: var(--green-dim);   color: var(--green); }
.badge--accent { background: var(--accent-glow); color: var(--accent); }
.badge--muted  { background: var(--surface2);    color: var(--muted); }
.badge--blue   { background: var(--blue-dim);    color: var(--blue); }

/* ── Progress bar ── */
.progress { height: 5px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.progress__fill { height: 100%; border-radius: 99px; transition: width 1s ease; }
.progress__fill.accent  { background: var(--accent); }
.progress__fill.green   { background: var(--green); }
.progress__fill.yellow  { background: var(--yellow); }
.progress__fill.red     { background: var(--red); }

/* ── Avatar ── */
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar--sm  { width: 24px; height: 24px; font-size: 0.6rem; }
.avatar--md  { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar--lg  { width: 40px; height: 40px; font-size: 0.875rem; }
.avatar--xl  { width: 48px; height: 48px; font-size: 1rem; }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: var(--space-md) 0; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--muted);
}
.empty-state svg { width: 40px; height: 40px; margin: 0 auto var(--space-md); opacity: .4; }
.empty-state p { font-size: 0.875rem; }

/* ── Tooltip ── */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface3);
  color: var(--text);
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t);
  border: 1px solid var(--border);
  z-index: 99;
}
[data-tip]:hover::after { opacity: 1; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: 460px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}
.modal__title { font-size: 1.05rem; font-weight: 700; }
.modal__close {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: color var(--t), background var(--t);
}
.modal__close:hover { color: var(--text); background: var(--surface3); }
.modal__close svg { width: 14px; height: 14px; }

/* ── Form controls ── */
.form-group { margin-bottom: var(--space-md); }
.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  transition: border-color var(--t), box-shadow var(--t);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--muted); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }

.modal__actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Responsive Stats ── */
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px)  { .stats-grid { grid-template-columns: repeat(2,1fr); gap: var(--space-sm); } }
@media (max-width: 380px)  { .stats-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px)  { .form-row { grid-template-columns: 1fr; } }
