/* Owner: P8a (UI shell and design system). Keep this Owner line.
   Reset, typography, focus, forms and layout utilities. Tokens only: see tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + var(--space-4));
}

body {
  margin: 0;
  background-color: var(--bg-app);
  background-image: var(--grad-canvas);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  font-weight: 400;
  line-height: var(--lh-body);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1;
}

/* Numbers line up in KPIs, tables and charts */
.num,
td,
.kpi-value,
.chart-value {
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure,
blockquote {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  text-wrap: balance;
  font-weight: 700;
  line-height: var(--lh-snug);
}

h1,
h2,
.display {
  font-family: var(--font-display);
  letter-spacing: var(--tracking-display);
}

h1 {
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
}

h2 {
  font-size: var(--fs-2xl);
  line-height: var(--lh-tight);
}

h3 {
  font-size: var(--fs-lg);
}

h4 {
  font-size: var(--fs-md);
}

p {
  max-width: 68ch;
  text-wrap: pretty;
}

ul[role="list"],
ol[role="list"],
.plain-list {
  list-style: none;
  padding: 0;
}

a {
  color: var(--teal-700);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--navy);
}

strong,
b {
  font-weight: 700;
}

small,
.small {
  font-size: var(--fs-sm);
}

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--space-6) 0;
}

img,
svg {
  max-width: 100%;
}

img {
  display: block;
}

[hidden] {
  display: none !important;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: var(--focus-offset);
}

.on-dark :focus-visible,
.sidebar :focus-visible,
.bottombar :focus-visible,
.welcome :focus-visible {
  outline-color: var(--focus-on-dark);
}

::selection {
  background: var(--peach-200);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--hit);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-ctl);
  color: var(--ink);
  box-shadow: var(--shadow-0);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

input:hover:not(:disabled):not(:focus-visible),
select:hover:not(:disabled):not(:focus-visible),
textarea:hover:not(:disabled):not(:focus-visible) {
  border-color: var(--navy-700);
}

textarea {
  min-height: calc(var(--hit) * 2);
  resize: vertical;
  line-height: var(--lh-body);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: 0;
  border-color: var(--teal);
  box-shadow: var(--ring);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  min-height: 20px;
  height: 20px;
  padding: 0;
  accent-color: var(--teal);
}

input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-10);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

progress,
meter {
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: var(--radius-pill);
  overflow: hidden;
  vertical-align: middle;
}

label {
  font-weight: 700;
  font-size: var(--fs-sm);
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

legend {
  padding: 0;
  font-weight: 700;
  font-size: var(--fs-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

caption {
  text-align: left;
  font-weight: 700;
  padding-bottom: var(--space-2);
}

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--muted);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
}

.break {
  overflow-wrap: anywhere;
}

.right {
  text-align: right;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.grow {
  flex: 1 1 0;
  min-width: 0;
}

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-2 {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-auto {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}

@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }
}

@media (max-width: 340px) {
  .grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Page frame: the shell gives the outlet "page page-<name>" */
.page {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-head > :first-child {
  min-width: 0;
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-brand);
}

.page-lead {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--teal-700);
}

.page-head .eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--peach);
}

@media (max-width: 480px) {
  .page-lead {
    font-size: var(--fs-md);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar,
  .topbar,
  .bottombar,
  .banners,
  .toasts {
    display: none !important;
  }

  body {
    background: var(--surface);
  }
}
