/**
 * Managed Intelligence — shared theme tokens (Docs app: teal accent).
 * Use these variables everywhere; no hardcoded colors in shell/cards.
 */
:root {
  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Type scale */
  --text-page-title: 2rem;
  --text-section-title: 1.25rem;
  --text-body: 1rem;
  --text-label: 0.875rem;
  --text-caption: 0.75rem;

  /* Neutrals */
  --bg-app: #F8FAFC;
  --bg-sidebar: #F1F5F9;
  --bg-card: #FFFFFF;
  --border: #E2E8F0;

  /* Text */
  --text: #0F172A;
  --text-2: #475569;
  --text-3: #94A3B8;

  /* Interactions */
  --hover: #E2E8F0;
  --focus-ring: rgba(46, 157, 106, 0.35);

  /* Docs accent (teal) — aliased from product accent tokens */
  --accent: var(--mil-product-accent, #2E9D6A);
  --accent-2: var(--mil-product-accent-strong, #267F56);
  --accent-soft: var(--mil-product-accent-soft, rgba(46, 157, 106, 0.10));

  /* Status */
  --ok-bg: #DCFCE7;
  --ok-text: #166534;
  --warn-bg: #FEF9C3;
  --warn-text: #854D0E;
  --bad-bg: #FEE2E2;
  --bad-text: #991B1B;

  /* Spacing */
  --space-section: 1.5rem;
  --space-card: 1rem;

  /* Radii and shadow */
  --radius: 14px;
  --radius-btn: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
}

html {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Base component classes (minimal, reusable) ---- */

.mi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-card) 1.25rem;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.mi-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--text-3);
}

.mi-card--static:hover {
  box-shadow: var(--shadow);
  border-color: var(--border);
}

.mi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.mi-card-header h2 {
  margin: 0;
  font-size: var(--text-section-title);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.mi-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  font-size: var(--text-label);
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent-2);
  border-radius: var(--radius-btn);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.mi-btn-primary:hover {
  background: var(--accent-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), var(--shadow-sm);
}

.mi-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  font-size: var(--text-label);
  font-weight: 600;
  color: var(--text-2);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.mi-btn-secondary:hover {
  background: var(--hover);
  border-color: var(--text-3);
}

.mi-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  font-size: var(--text-label);
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: var(--radius-btn);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mi-btn-ghost:hover {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.mi-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.1875rem 0.5rem;
  font-size: var(--text-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.mi-badge.is-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.mi-badge.is-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.mi-badge.is-bad {
  background: var(--bad-bg);
  color: var(--bad-text);
}

.mi-badge.is-active {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.mi-nav-item {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-label);
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mi-nav-item:hover {
  background: var(--hover);
  color: var(--text);
}

.mi-nav-item.is-active {
  color: var(--text);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.mi-nav-item.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ---- Global header (full width, premium dark) ---- */

.mi-global-header {
  width: 100%;
  background: var(--mil-header-bg);
  border-bottom: 1px solid var(--mil-header-border);
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15), 0 8px 24px rgba(2, 6, 23, 0.25);
}

.mi-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem;
}

.mi-header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-width: 0;
}

.mi-header-logo {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.mi-header-brand {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--mil-header-text);
  white-space: nowrap;
  text-decoration: none;
}

.mi-header-brand:hover,
.mi-header-brand:focus-visible {
  color: var(--mil-header-text);
  text-decoration: none;
}

.mi-header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 16px;
}

.mi-header-tab {
  color: var(--mil-header-text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  transition: background 0.16s ease, color 0.16s ease;
}

.mi-header-tab:hover {
  color: var(--mil-header-text);
  background: var(--mil-header-link-hover-bg);
}

.mi-header-tab.is-active {
  color: var(--mil-header-link-active-text);
  background: var(--mil-header-link-active-bg);
}

.mi-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Pill control: exact same size as Last 7/30 days chips - do not use font: inherit */
.mi-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 30px;
  padding: 0 9px;
  font-size: 12px !important;
  line-height: 1.25;
  font-weight: 600;
  color: var(--mil-header-text);
  background: transparent;
  border: 1px solid var(--mil-header-border);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}

.mi-header-btn:hover {
  background: var(--mil-header-link-hover-bg);
  color: var(--mil-header-text);
}

.mi-header-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Portal layout: header + body (sidebar + main) */

.portal-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Page header block (H1 + subtitle + meta row) */

.mi-page-header {
  margin-bottom: 1.25rem;
}

.mi-page-title {
  margin: 0 0 0.25rem;
  font-size: var(--text-page-title);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.025em;
}

.mi-page-subtitle {
  margin: 0 0 0.5rem;
  font-size: var(--text-body);
  color: var(--text-2);
  letter-spacing: -0.01em;
}

.mi-page-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.mi-meta-tenant {
  font-size: var(--text-label);
  color: var(--text-3);
}

/* ---- Dashboard documentation hub tokens ---- */
:root {
  --completion-on: #0d9488;
  --completion-off: #dbe3ee;
  --completion-outline: rgba(13, 148, 136, 0.25);
}

/* ---- Skeleton loader ---- */
@keyframes mi-skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.mi-skeleton {
  background: linear-gradient(90deg, var(--bg-sidebar) 25%, var(--hover) 50%, var(--bg-sidebar) 75%);
  background-size: 200% 100%;
  animation: mi-skeleton-shimmer 1.5s ease infinite;
  border-radius: var(--radius-btn);
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}

.mi-skeleton-text {
  height: 0.875rem;
  margin-bottom: 0.5rem;
  border-radius: 4px;
}

.mi-skeleton-heading {
  height: 1.5rem;
  width: 60%;
  margin-bottom: 0.75rem;
  border-radius: 6px;
}

.mi-skeleton-card {
  height: 80px;
  border-radius: var(--radius);
}

/* ---- Toast notifications ---- */
.mi-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.mi-toast {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-btn);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: var(--text-label);
  font-weight: 500;
  color: var(--text);
  pointer-events: auto;
  animation: mi-toast-in 0.3s ease;
  max-width: 360px;
}

.mi-toast.is-success {
  border-left: 3px solid var(--ok-text);
}

.mi-toast.is-error {
  border-left: 3px solid var(--bad-text);
}

.mi-toast.is-warning {
  border-left: 3px solid var(--warn-text);
}

.mi-toast.is-exiting {
  animation: mi-toast-out 0.25s ease forwards;
}

@keyframes mi-toast-in {
  from { opacity: 0; transform: translateX(1rem); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes mi-toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(1rem); }
}
