/* Reusable component styles (cards, tiles, tables, gauges, pills, modals…). */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h3 { font-size: var(--fs-md); font-weight: 650; }
.card-head .sub { color: var(--text-faint); font-size: var(--fs-sm); }
.card-head .actions { margin-left: auto; display: flex; gap: var(--sp-2); }

/* KPI / stat tile */
stat-tile { display: block; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden;
}
.stat-tile .label { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.stat-tile .value { font-size: var(--fs-2xl); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-tile .value .unit { font-size: var(--fs-md); color: var(--text-muted); font-weight: 550; margin-left: 3px; }
.stat-tile .trend { font-size: var(--fs-sm); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.stat-tile .trend.up { color: var(--ok); }
.stat-tile .trend.down { color: var(--danger); }
.stat-tile .trend.flat { color: var(--text-faint); }
.stat-tile .spark { position: absolute; right: 0; bottom: 0; width: 90px; height: 38px; opacity: 0.5; }

/* Gauge */
gauge-meter { display: inline-block; }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gauge .gv { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.gauge .gl { font-size: var(--fs-sm); color: var(--text-muted); }

/* Usage bar */
.usage-bar { display: flex; flex-direction: column; gap: 6px; }
.usage-bar .ub-row { display: flex; justify-content: space-between; font-size: var(--fs-sm); }
.usage-bar .ub-track { height: 9px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.usage-bar .ub-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width var(--transition); }
.usage-bar .ub-fill.warn { background: var(--warn); }
.usage-bar .ub-fill.danger { background: var(--danger); }

/* Status pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.6;
}
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.danger { color: var(--danger); background: var(--danger-soft); }
.pill.info { color: var(--info); background: rgba(56,189,248,0.14); }
.pill.muted { color: var(--text-faint); background: var(--surface-2); }
.pill.no-dot::before { display: none; }

.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 650; background: var(--accent-soft); color: var(--accent); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* Data table */
.data-table { width: 100%; }
.data-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 8px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; }
.data-table th.no-sort { cursor: default; }
.data-table th .arrow { opacity: 0.5; font-size: 10px; }
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); }
.data-table tr:hover td { background: var(--surface-2); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .tt-toolbar { display: flex; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-3); }
.data-table .tt-toolbar .input { max-width: 240px; }
.data-table .pager { display: flex; gap: var(--sp-2); align-items: center; justify-content: flex-end; margin-top: var(--sp-3); color: var(--text-muted); font-size: var(--fs-sm); }
.bar-cell { position: relative; }
.bar-cell .bc-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); border-radius: 4px; z-index: 0; }
.bar-cell .bc-text { position: relative; z-index: 1; }

/* Modal */
modal-host { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: grid; place-items: center; padding: var(--sp-5); pointer-events: auto; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  width: 100%; max-width: 540px; box-shadow: var(--shadow-lg); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { padding: var(--sp-5); border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; }
.modal-head h3 { font-size: var(--fs-lg); }
.modal-head .close { margin-left: auto; }
.modal-body { padding: var(--sp-5); overflow-y: auto; }
.modal-foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border-soft); display: flex; gap: var(--sp-3); justify-content: flex-end; }

/* Toasts */
toast-host { position: fixed; bottom: var(--sp-5); right: var(--sp-5); z-index: 1100; display: flex; flex-direction: column; gap: var(--sp-3); pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow); min-width: 260px; max-width: 380px;
  pointer-events: auto; animation: toast-in var(--transition); font-size: var(--fs-sm); }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.danger { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } }

/* Skeleton / empty / error */
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border-soft) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease-in-out infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.empty-state { text-align: center; color: var(--text-muted); padding: var(--sp-7) var(--sp-4); }
.empty-state .ic { font-size: 30px; opacity: 0.4; margin-bottom: var(--sp-2); }
.error-state { color: var(--danger); padding: var(--sp-5); text-align: center; }

/* Segmented control */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; }
.segmented button { padding: 5px 11px; border: none; background: none; color: var(--text-muted); border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 550; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Dropdown (date range / site select) */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; top: calc(100% + 6px); right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg); min-width: 200px; padding: var(--sp-2); z-index: 100; }
.dropdown-menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: none; background: none; color: var(--text); border-radius: var(--r-sm); font-size: var(--fs-sm); }
.dropdown-menu button:hover { background: var(--surface-2); }
.dropdown-menu button.active { color: var(--accent); }

/* Wizard steps */
.wizard-steps { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.wizard-steps .step { flex: 1; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); background: var(--surface-2);
  color: var(--text-faint); font-size: var(--fs-sm); font-weight: 600; text-align: center; }
.wizard-steps .step.active { background: var(--accent-soft); color: var(--accent); }
.wizard-steps .step.done { color: var(--ok); }
.snippet-box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-4);
  font-family: var(--mono); font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-all; position: relative; }

/* Live ticker */
.ticker { display: flex; flex-direction: column; gap: 1px; max-height: 320px; overflow: hidden; }
.ticker-row { display: flex; gap: var(--sp-3); align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--border-soft);
  font-size: var(--fs-sm); animation: toast-in var(--transition); }
.ticker-row .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.ticker-row .t { color: var(--text-faint); margin-left: auto; font-variant-numeric: tabular-nums; }
