/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-primary);
  font-size: var(--type-body-size);
  line-height: calc(var(--type-body-lh) / var(--type-body-size));
  color: var(--text-primary);
  background-color: var(--bg-canvas);
  min-height: 100vh;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'ss01', 'ss03';
  -webkit-font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'ss01', 'ss03';
}

::selection {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--motion-hover) var(--motion-ease);
}
a:hover { color: var(--text-link-hover); }

/* Global focus visibility (WCAG 2.1 AA) */
*:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
button:focus-visible, a:focus-visible, [role="button"]:focus-visible {
  box-shadow: var(--shadow-focus);
}

img { max-width: 100%; height: auto; }

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  letter-spacing: -0.015em;
}

h1 {
  font-family: var(--font-primary);
  font-size: var(--type-page-title-size);
  line-height: calc(var(--type-page-title-lh) / var(--type-page-title-size));
  font-weight: var(--type-page-title-weight);
}
h2 {
  font-size: var(--type-section-size);
  line-height: calc(var(--type-section-lh) / var(--type-section-size));
  font-weight: var(--type-section-weight);
}
h3 {
  font-size: var(--type-panel-size);
  line-height: calc(var(--type-panel-lh) / var(--type-panel-size));
  font-weight: var(--type-panel-weight);
}
h4 {
  font-size: var(--type-label-size);
  line-height: calc(var(--type-label-lh) / var(--type-label-size));
  font-weight: var(--type-label-weight);
}

/* Tabular numbers + IDs use IBM Plex Sans */
.text-tabular,
table td.numeric,
.kpi-value,
.font-tabular {
  font-family: var(--font-tabular);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

p { margin-bottom: 0.5rem; }

/* Utility classes */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-success { color: var(--state-success); }
.text-warning { color: var(--state-warning); }
.text-danger  { color: var(--state-danger); }
.text-info    { color: var(--state-info); }
.text-link    { color: var(--text-link); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mr-2 { margin-right: 0.5rem; }
.ml-2 { margin-left: 0.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.flex-shrink-0 { flex-shrink: 0; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.relative { position: relative; }
.absolute { position: absolute; }
.rounded { border-radius: var(--border-radius-sm); }
.rounded-md { border-radius: var(--border-radius-md); }
.rounded-lg { border-radius: var(--border-radius-lg); }
.rounded-full { border-radius: var(--border-radius-full); }

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: 100px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gray-300);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--gray-700);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--gray-600);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--gray-200) transparent;
}
[data-theme="dark"] * {
  scrollbar-color: var(--gray-700) transparent;
}

/* Transitions */
.transition-all {
  transition: all var(--transition-base);
}
