/* ============================================================
   COMPONENTS: Shared Cards, Tables, Controls, and Forms
   ============================================================ */
.panel, .metric-card, .table-shell {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.panel { padding: var(--space-2); }
.panel-title { margin: 0 0 var(--space-2); font-size: 16px; font-weight: 700; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-2);
}

.metric-card { position: relative; padding: var(--space-2); border-radius: var(--radius); overflow: hidden; }
.metric-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius-xs);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
}
.metric-card .label { display: block; color: var(--text-muted); font-size: 12px; }
.metric-card .value { display: block; margin-top: 6px; font-size: 28px; line-height: 34px; font-weight: 700; }
.metric-card .sub { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; }

.table-shell { overflow: hidden; }
.table-shell table { width: 100%; border-collapse: collapse; }
.table-shell th, .table-shell td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.table-shell th {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--bg-surface-muted);
}
.table-shell tr:last-child td { border-bottom: 0; }
.table-shell tbody tr { transition: background 140ms ease, box-shadow 140ms ease; }
.table-shell tbody tr:hover td { background: var(--table-row-hover-bg); }
.table-shell td { font-size: 13px; }

.table-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 34px var(--space-2);
  text-align: center;
  color: var(--text-muted);
  background: var(--table-empty-bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.table-empty strong { color: var(--text-primary); }
.table-empty p { margin: 0; font-size: 13px; }

.empty-illustration {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  width: 64px;
  height: 44px;
  margin-bottom: 2px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  box-shadow: inset 0 0 0 1px var(--border-default);
}

.empty-illustration span {
  width: 9px;
  border-radius: 999px 999px 2px 2px;
  background: var(--primary-soft);
}

.empty-illustration span:nth-child(1) { height: 16px; }
.empty-illustration span:nth-child(2) { height: 28px; background: var(--action-soft); }
.empty-illustration span:nth-child(3) { height: 22px; background: var(--success-soft); }

/* ============================================================
   COMPONENTS: Buttons
   ============================================================ */
.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 700;
  transition: opacity 140ms, transform 100ms, box-shadow 140ms;
}

.button:hover { opacity: 0.88; }
.button:active { transform: scale(0.97); }

.button.primary { background: var(--primary); color: #ffffff; }
.button.action { background: var(--action); color: #ffffff; }
.button.success { background: var(--success); color: var(--text-inverse); }
.button.danger { background: var(--danger); color: #ffffff; }
.button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}
.button.ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}
.button.ghost:hover { border-color: var(--primary); color: var(--primary-strong); }
.button.sm { min-height: 30px; padding: 0 12px; font-size: 12px; border-radius: 6px; }

/* Gated / disabled action button */
.button.gated {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.4);
}

/* ============================================================
   COMPONENTS: Status badges
   ============================================================ */
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status.green { background: var(--success-soft); color: var(--success); }
.status.yellow { background: var(--warning-soft); color: var(--warning); }
.status.red { background: var(--danger-soft); color: var(--danger); }
.status.blue { background: var(--info-soft); color: var(--info); }
.status.gray { background: var(--bg-surface-muted); color: var(--text-muted); }

/* ============================================================
   COMPONENTS: Tabs
   ============================================================ */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: var(--space-2);
  border-bottom: 2px solid var(--border-subtle);
}

.tab-btn {
  padding: 10px var(--space-2);
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  transition: color 140ms, border-color 140ms;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary-strong); border-bottom-color: var(--primary); }

/* ============================================================
   COMPONENTS: Forms
   ============================================================ */
.form-group { margin-bottom: var(--space-2); }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 140ms;
}

.form-input:focus { border-color: var(--primary); outline: none; }
textarea.form-input { min-height: 100px; resize: vertical; }
