/* =====================================================
   MKP DeviceFarm · Component library
   Pulled from inline <style> across 10 admin pages.
   Single source of truth · standardised tokens.
   ===================================================== */

/* ─── PILL · status / state / role ─────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 4px 12px;          /* was 2·8 · easier to read */
  border-radius: 999px;
  font-size: 12px;            /* was 10 */
  font-weight: 600;
  text-transform: none;       /* was uppercase · friendly */
  letter-spacing: 0;
  line-height: 1.4;
}
.pill.lg { padding: 5px 14px; font-size: 13px; }

/* Status pills · use design tokens (was hardcoded #22c55e/#f59e0b/#ef4444) */
.pill.success,   .pill-posted, .pill-complete, .pill-achieved, .pill-active, .pill-aged, .pill-ready { background: var(--success-bg); color: var(--success); }
.pill.warning,   .pill-queued, .pill-pending, .pill-partial, .pill-warming, .pill-fyp-training      { background: var(--warning-bg); color: var(--warning); }
.pill.error,     .pill-failed, .pill-shadowban_suspected, .pill-burner, .pill-fyp-failed            { background: var(--error-bg);   color: var(--error); }
.pill.info,      .pill-scheduled, .pill-running, .pill-cooldown, .pill-affiliate                    { background: var(--info-bg);    color: var(--info); }
.pill.neutral,   .pill-cancelled, .pill-skipped, .pill-logged_out, .pill-fyp-unchecked, .pill-idle  { background: rgba(148,163,184,0.18); color: var(--text-secondary); }
.pill.accent,    .pill-firing                                                                       { background: rgba(168,85,247,0.18); color: #C084FC; }

/* Lifecycle stage badges (account warming stages) */
.stage-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.stage-newborn   { background: rgba(148,163,184,0.15); color: #94a3b8; }
.stage-hatching  { background: rgba(251,191,36,0.15); color: #fbbf24; }
.stage-fledgling { background: rgba(250,204,21,0.15); color: #facc15; }
.stage-adult     { background: var(--success-bg);     color: var(--success); }
.stage-monetized { background: rgba(168,85,247,0.18); color: #a855f7; }
.stage-burned    { background: var(--error-bg);       color: var(--error); }
.stage-dead      { background: rgba(71,85,105,0.18);  color: #475569; }

/* Persona pills */
.pill.persona-browser { background: var(--info-bg);    color: var(--info); }
.pill.persona-skipper { background: var(--warning-bg); color: var(--warning); }
.pill.persona-engager { background: var(--success-bg); color: var(--success); }

/* Risk indicators */
.risk-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 700; margin-left: 6px; }
.risk-safe   { background: var(--success-bg); color: var(--success); }
.risk-low    { background: rgba(132,204,22,0.15); color: #84cc16; }
.risk-medium { background: var(--warning-bg); color: var(--warning); }
.risk-high   { background: var(--error-bg);   color: var(--error); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

/* ─── ACTION PILLS · audit log categories ──────────────────────────── */
.action-pill { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; font-family: monospace; }
.action-auth     { background: rgba(168,85,247,0.18); color: #a855f7; }
.action-user     { background: var(--info-bg);    color: var(--info); }
.action-account  { background: var(--success-bg); color: var(--success); }
.action-campaign { background: var(--warning-bg); color: var(--warning); }
.action-bridge   { background: rgba(236,72,153,0.18); color: #ec4899; }
.action-bulk     { background: rgba(20,184,166,0.18); color: #14b8a6; }
.result-success  { color: var(--success); font-weight: 600; }
.result-failed   { color: var(--error);   font-weight: 600; }

/* ─── BAR · health · quota · progress ──────────────────────────────── */
.bar { background: var(--bg-hover); border-radius: 3px; overflow: hidden; }
.bar.sm { height: 5px; }
.bar.md { height: 6px; }
.bar.lg { height: 8px; }
.bar-fill           { height: 100%; transition: width 0.3s; background: var(--success); }
.bar-fill.med, .bar-fill.fair { background: var(--warning); }
.bar-fill.low, .bar-fill.critical, .bar-fill.full { background: var(--error); }
.bar-fill.healthy   { background: #84cc16; }
.bar-fill.excellent { background: var(--success); }
.bar-fill.weak      { background: #f97316; }
.bar-fill.gradient  { background: linear-gradient(90deg, var(--accent), var(--success)); }

/* Legacy aliases (preserve pages still using these class names) */
.health-bar { width: 60px; height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.health-bar-fill { height: 100%; background: var(--success); transition: width 0.3s; }
.health-bar-fill.med { background: var(--warning); }
.health-bar-fill.low { background: var(--error); }
.quota-bar { width: 80px; height: 5px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; display: block; margin: 2px 0; }
.quota-bar-fill { height: 100%; background: var(--success); }
.quota-bar-fill.med  { background: var(--warning); }
.quota-bar-fill.full { background: var(--error); }
.progress      { background: var(--bg-card); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-fill { background: linear-gradient(90deg, var(--accent), var(--success)); height: 100%; transition: width 0.3s; }

/* ─── KEYWORD / FILTER CHIPS ───────────────────────────────────────── */
.kw-chip {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  display: inline-block;
}
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.filter-chips:empty { display: none; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  font-size: 11px; color: var(--text-secondary);
}
.filter-chip b { color: var(--text-primary); font-weight: 600; }
.filter-chip .chip-x { cursor: pointer; color: var(--text-muted); font-weight: 700; padding-left: 2px; }
.filter-chip .chip-x:hover { color: var(--error); }

/* ─── FUNNEL CHIPS · account funnel ────────────────────────────────── */
.funnel-chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.funnel-chip {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 8px; font-size: 11px;
  color: var(--text-secondary); display: inline-flex; align-items: center; gap: 4px;
}
.funnel-chip b { color: var(--text-primary); }

/* ─── HEALTH COMPOSITE ─────────────────────────────────────────────── */
.health-composite { display: flex; flex-direction: column; gap: 3px; min-width: 110px; }
.health-composite .h-row { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.health-composite .h-num { font-weight: 700; min-width: 28px; }
.health-composite .h-num.excellent { color: var(--success); }
.health-composite .h-num.healthy   { color: #84cc16; }
.health-composite .h-num.fair      { color: var(--warning); }
.health-composite .h-num.weak      { color: #f97316; }
.health-composite .h-num.critical  { color: var(--error); }
.health-composite .h-bar { flex: 1; height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; }
.health-composite .h-bar-fill { height: 100%; transition: width 0.3s; }
.health-composite .h-bar-fill.excellent { background: var(--success); }
.health-composite .h-bar-fill.healthy   { background: #84cc16; }
.health-composite .h-bar-fill.fair      { background: var(--warning); }
.health-composite .h-bar-fill.weak      { background: #f97316; }
.health-composite .h-bar-fill.critical  { background: var(--error); }

/* ─── RECOMMENDATION ROW ───────────────────────────────────────────── */
.reco-row {
  display: flex; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--bg-primary);
  border-left: 3px solid var(--accent);
  font-size: 12px; align-items: center;
}
.reco-row.priority-critical { border-left-color: var(--error);   background: rgba(239,68,68,0.08); }
.reco-row.priority-high     { border-left-color: var(--warning); background: rgba(245,158,11,0.08); }
.reco-row.priority-medium   { border-left-color: var(--accent); }
.reco-row.priority-low      { border-left-color: var(--text-muted); }
.reco-icon { font-size: 18px; }
.reco-text { flex: 1; }
.reco-text b { display: block; font-size: 13px; color: var(--text-primary); }
.reco-text span { color: var(--text-secondary); font-size: 11px; }

/* ─── ALERTS BANNER ────────────────────────────────────────────────── */
.alerts-banner {
  background: linear-gradient(90deg, rgba(239,68,68,0.15), rgba(245,158,11,0.1));
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.alerts-banner .icon { font-size: 22px; }
.alerts-banner .text { flex: 1; font-size: 13px; color: var(--text-primary); }
.alerts-banner .text b { color: var(--error); }
.alerts-banner button { font-size: 11px; padding: 4px 10px; }

/* ─── ACTIVITY FEED ────────────────────────────────────────────────── */
.activity-feed {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 12px;
  max-height: 130px; overflow-y: auto;
}
.activity-feed h4 {
  margin: 0 0 6px 0; font-size: 11px;
  text-transform: uppercase; color: var(--text-secondary);
  letter-spacing: 0.4px;
  display: flex; align-items: center; gap: 6px;
}

/* ─── DETAIL MODAL · MCN-style ─────────────────────────────────────── */
.detail-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 720px; max-width: 95vw; max-height: 92vh;
  overflow: auto; padding: 0;
}
.detail-hdr { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.detail-hdr h3 { margin: 0; flex: 1; font-size: 16px; }
.detail-body { padding: 16px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-card { background: var(--bg-primary); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.detail-card h4 { margin: 0 0 8px 0; font-size: 12px; text-transform: uppercase; color: var(--text-secondary); letter-spacing: 0.4px; }
.detail-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; border-bottom: 1px dashed var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-secondary); }
.detail-row .v { color: var(--text-primary); font-weight: 600; }
.breakdown-row { display: grid; grid-template-columns: 110px 1fr 50px; gap: 8px; align-items: center; padding: 4px 0; font-size: 12px; }
.breakdown-row .b-bar { height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; }
.breakdown-row .b-fill { height: 100%; background: var(--accent); }

/* ─── TABLE · shared list table ────────────────────────────────────── */
table.mkp-table { width: 100%; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); border-collapse: separate; border-spacing: 0; }
table.mkp-table th, table.mkp-table td { padding: 16px 18px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; line-height: 1.5; }
table.mkp-table th { background: var(--bg-primary); position: sticky; top: 0; z-index: 2; font-weight: 600; color: var(--text-secondary); font-size: 12px; text-transform: none; letter-spacing: 0; padding-top: 14px; padding-bottom: 14px; }
table.mkp-table tr:last-child td { border-bottom: 0; }
table.mkp-table tr:hover td { background: var(--bg-hover); }
.mkp-table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; }
/* Apply same generous padding to legacy bespoke tables (users-table, acct, audit-table, etc) */
table th, table td { padding: 14px 16px !important; font-size: 14px !important; line-height: 1.5 !important; }
table th { padding-top: 12px !important; padding-bottom: 12px !important; }

/* ─── ROLE / TENANT badges ─────────────────────────────────────────── */
.role-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.role-admin    { background: rgba(168,85,247,0.18); color: #a855f7; }
.role-operator { background: var(--success-bg);     color: var(--success); }
.role-analyst  { background: var(--info-bg);        color: var(--info); }
.role-viewer   { background: rgba(148,163,184,0.18); color: var(--text-secondary); }
.status-pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; }
.status-active   { background: var(--success-bg);     color: var(--success); }
.status-disabled { background: rgba(148,163,184,0.15); color: var(--text-secondary); }

/* ─── ICON BUTTON (square small) ───────────────────────────────────── */
.icon-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 4px;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary); font-size: 13px;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent); }

/* ─── PAGE CONTAINER ───────────────────────────────────────────────── */
.page-pad { padding: 28px 32px; }                /* was 16·24 · much more room */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select, .filters input, .filters select {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 14px;        /* was 6·10 · easier to click */
  color: var(--text-primary); font-size: 14px;   /* was 12 */
  line-height: 1.4;
}
.toolbar input:focus, .toolbar select:focus,
.filters input:focus, .filters select:focus { outline: none; border-color: var(--accent); }
.filters { display: flex; gap: 12px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }

/* ─── CARDS · generic card spacing ─────────────────────────────────── */
.dist-card, .job-card {
  padding: 22px 24px !important;
  margin-bottom: 20px !important;
}

/* ─── DEVICE GRID · more room between tiles ─────────────────────────── */
.grid { padding: 28px 32px !important; gap: 24px !important; }

/* ─── PAYLOAD / CODE blob ──────────────────────────────────────────── */
.payload {
  font-family: monospace; font-size: 10px; color: var(--text-muted);
  max-width: 380px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; cursor: pointer;
}
.payload:hover { color: var(--text-secondary); }
.payload-count { color: var(--text-secondary); font-weight: 600; margin-left: 4px; font-size: 9px; opacity: 0.8; }

/* ─── EMPTY / LOADING ──────────────────────────────────────────────── */
.empty-illustration { font-size: 48px; margin-bottom: 8px; display: block; }
