/* Load tokens.css first. All rules are scoped or explicitly prefixed. */
.wz-system *, .wz-system *::before, .wz-system *::after { box-sizing: border-box; }
.wz-system [hidden] { display: none !important; }
.wz-system :where(button, input, select, textarea) { font: inherit; }
.wz-system :where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--wz-focus); outline-offset: 3px;
}
.wz-system :where(button) { cursor: pointer; }
.wz-system :where(button):disabled { cursor: not-allowed; }
.wz-system :where(h1, h2, h3, p) { margin: 0; }
.wz-system :where(a) { color: var(--wz-accent); text-underline-offset: 3px; }
.wz-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.wz-icon { width: 18px; height: 18px; flex: none; stroke-width: 1.7; }
.wz-stack { display: flex; flex-direction: column; gap: var(--wz-space-4); }
.wz-row { display: flex; align-items: center; gap: var(--wz-space-3); flex-wrap: wrap; }
.wz-spread { display: flex; align-items: center; justify-content: space-between; gap: var(--wz-space-4); flex-wrap: wrap; }
.wz-muted { color: var(--wz-text-muted); }
.wz-small { font-size: var(--wz-text-sm); }
.wz-numeric { font-variant-numeric: tabular-nums; }
.wz-code { font-family: var(--wz-font-mono); font-size: var(--wz-text-xs); }

.wz-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--wz-space-2);
  min-height: var(--wz-control-height); padding: 0 var(--wz-space-3); border: 1px solid var(--wz-border-control);
  border-radius: var(--wz-radius-md); background: var(--wz-surface); color: var(--wz-text);
  font-size: var(--wz-text-sm); font-weight: var(--wz-weight-medium); line-height: 1.25;
  white-space: nowrap; text-decoration: none; box-shadow: var(--wz-shadow-sm);
  transition: background var(--wz-duration-fast) var(--wz-ease), border-color var(--wz-duration-fast) var(--wz-ease);
}
.wz-button:hover:not(:disabled) { background: var(--wz-surface-hover); }
.wz-button:active:not(:disabled) { box-shadow: inset 0 1px 2px var(--wz-border); }
.wz-button--primary { background: var(--wz-accent); color: var(--wz-on-accent); border-color: transparent; }
.wz-button--primary:hover:not(:disabled) { background: var(--wz-accent-hover); }
.wz-button--quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--wz-text-secondary); }
.wz-button--soft { background: var(--wz-accent-soft); color: var(--wz-accent); border-color: transparent; box-shadow: none; }
.wz-button--soft:hover:not(:disabled) { background: var(--wz-accent-soft); border-color: var(--wz-accent); }
.wz-button--danger { background: var(--wz-danger); color: var(--wz-surface); border-color: transparent; }
.wz-button--danger:hover:not(:disabled) { background: var(--wz-danger-hover); }
.wz-button--small { min-height: 32px; padding-inline: var(--wz-space-2); }
.wz-button--large { min-height: 48px; padding-inline: var(--wz-space-5); font-size: var(--wz-text-md); }
.wz-button--icon { width: var(--wz-control-height); padding: 0; flex: none; }
.wz-button:disabled { background: var(--wz-surface-hover); border-color: var(--wz-border); color: var(--wz-text-muted); box-shadow: none; }
.wz-button[aria-busy='true'] { cursor: progress; }

.wz-field { display: flex; flex-direction: column; gap: var(--wz-space-2); min-width: 0; }
.wz-label { display: block; font-size: var(--wz-text-sm); font-weight: var(--wz-weight-medium); }
.wz-field__hint { font-size: var(--wz-text-xs); color: var(--wz-text-muted); }
.wz-field__error { font-size: var(--wz-text-xs); color: var(--wz-danger); }
.wz-input, .wz-select, .wz-textarea {
  width: 100%; min-width: 0; min-height: var(--wz-control-height); padding: var(--wz-space-2) var(--wz-space-3);
  border: 1px solid var(--wz-border-control); border-radius: var(--wz-radius-md); background: var(--wz-surface); color: var(--wz-text);
  font-size: var(--wz-text-lg); line-height: 1.25; transition: border-color var(--wz-duration-fast);
}
.wz-input::placeholder, .wz-textarea::placeholder { color: var(--wz-text-muted); opacity: 1; }
.wz-input:focus, .wz-select:focus, .wz-textarea:focus { border-color: var(--wz-accent); }
.wz-input[aria-invalid='true'], .wz-textarea[aria-invalid='true'] { border-color: var(--wz-danger); }
.wz-input:disabled, .wz-input[readonly] { background: var(--wz-bg); color: var(--wz-text-muted); }
.wz-textarea { min-height: 100px; resize: vertical; }
.wz-input-wrap { display: flex; align-items: center; position: relative; min-width: 0; }
.wz-input-wrap > .wz-icon { position: absolute; left: var(--wz-space-3); color: var(--wz-text-muted); pointer-events: none; }
.wz-input-wrap > .wz-input { padding-left: var(--wz-space-10); }
.wz-check { display: inline-flex; align-items: center; gap: var(--wz-space-2); min-height: 32px; font-size: var(--wz-text-sm); cursor: pointer; }
.wz-check input { width: 16px; height: 16px; accent-color: var(--wz-accent); margin: 0; cursor: pointer; }
.wz-switch { display: inline-flex; align-items: center; gap: var(--wz-space-3); cursor: pointer; font-size: var(--wz-text-sm); min-height: 32px; }
.wz-switch input { appearance: none; margin: 0; width: 34px; height: 20px; border: 1px solid var(--wz-border-control); border-radius: var(--wz-radius-full); background: var(--wz-surface-hover); cursor: pointer; position: relative; flex: none; }
.wz-switch input::before { content: ''; position: absolute; width: 14px; height: 14px; top: 2px; left: 2px; border-radius: 50%; background: var(--wz-text-muted); transition: transform var(--wz-duration-fast); }
.wz-switch input:checked { background: var(--wz-accent); border-color: var(--wz-accent); }
.wz-switch input:checked::before { transform: translateX(14px); background: var(--wz-on-accent); }
.wz-switch input:disabled { opacity: .5; cursor: not-allowed; }

.wz-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: var(--wz-radius-sm); font-size: var(--wz-text-xs); font-weight: var(--wz-weight-medium); line-height: 1.5; white-space: nowrap; color: var(--wz-text-secondary); background: var(--wz-surface-hover); }
.wz-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.wz-badge--accent { color: var(--wz-accent); background: var(--wz-accent-soft); }
.wz-badge--success { color: var(--wz-success); background: var(--wz-success-soft); }
.wz-badge--warning { color: var(--wz-warning); background: var(--wz-warning-soft); }
.wz-badge--danger { color: var(--wz-danger); background: var(--wz-danger-soft); }
.wz-badge--info { color: var(--wz-info); background: var(--wz-info-soft); }
.wz-tag { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--wz-border); border-radius: var(--wz-radius-md); padding: 3px 8px; color: var(--wz-text-secondary); font-size: var(--wz-text-xs); background: var(--wz-surface); }
.wz-tag button { background: none; border: 0; color: inherit; display: grid; place-items: center; padding: 2px; border-radius: 2px; }
.wz-tag .wz-icon { width: 14px; height: 14px; }
.wz-avatar { width: 30px; height: 30px; border: 1px solid var(--wz-border); border-radius: 50%; background: var(--wz-accent-soft); color: var(--wz-accent); display: inline-flex; align-items: center; justify-content: center; flex: none; font-size: var(--wz-text-xs); font-weight: var(--wz-weight-semibold); }
.wz-avatar--small { width: 24px; height: 24px; }
.wz-avatar--large { width: 44px; height: 44px; font-size: var(--wz-text-md); }
.wz-avatar--neutral { color: var(--wz-text-secondary); background: var(--wz-surface-hover); }
.wz-avatar-group { display: flex; padding-left: 6px; }
.wz-avatar-group .wz-avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--wz-surface); }

.wz-tabs { display: flex; align-items: center; gap: var(--wz-space-5); border-bottom: 1px solid var(--wz-border); overflow-x: auto; }
.wz-tab { min-height: 44px; padding: 0 0 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--wz-text-secondary); font-size: var(--wz-text-sm); white-space: nowrap; }
.wz-tab[aria-selected='true'] { color: var(--wz-accent); border-bottom-color: var(--wz-accent); font-weight: var(--wz-weight-semibold); }
.wz-tab:focus-visible { outline-offset: -3px !important; }
.wz-tabpanel { padding-block: var(--wz-space-5); }
.wz-segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: var(--wz-radius-lg); background: var(--wz-surface-hover); }
.wz-segmented button { min-height: 30px; padding: 4px 10px; border: 1px solid transparent; border-radius: var(--wz-radius-md); color: var(--wz-text-secondary); background: transparent; font-size: var(--wz-text-xs); display: inline-flex; align-items: center; gap: 6px; }
.wz-segmented button[aria-pressed='true'] { color: var(--wz-text); background: var(--wz-surface); border-color: var(--wz-border); box-shadow: var(--wz-shadow-sm); }
.wz-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: var(--wz-text-xs); color: var(--wz-text-muted); }
.wz-breadcrumb a { color: inherit; text-decoration: none; }
.wz-breadcrumb [aria-current] { color: var(--wz-text); }

.wz-panel { border: 1px solid var(--wz-border); background: var(--wz-surface); border-radius: var(--wz-radius-lg); }
.wz-panel__header { padding: var(--wz-space-4) var(--wz-space-5); border-bottom: 1px solid var(--wz-border); display: flex; align-items: center; justify-content: space-between; gap: var(--wz-space-3); }
.wz-panel__body { padding: var(--wz-space-5); }
.wz-panel__title { font-weight: var(--wz-weight-semibold); font-size: var(--wz-text-md); }
.wz-toolbar { padding: var(--wz-space-3) var(--wz-space-4); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--wz-space-3); border-bottom: 1px solid var(--wz-border); }
.wz-table-wrap { overflow-x: auto; border-radius: inherit; }
.wz-table { width: 100%; border-collapse: collapse; font-size: var(--wz-text-sm); text-align: left; white-space: nowrap; }
.wz-table caption { text-align: left; padding: var(--wz-space-4); font-weight: var(--wz-weight-semibold); }
.wz-table th { background: var(--wz-surface-subtle); color: var(--wz-text-muted); font-size: var(--wz-text-xs); font-weight: var(--wz-weight-medium); }
.wz-table th, .wz-table td { height: var(--wz-row-height); padding: var(--wz-cell-space) var(--wz-space-4); border-bottom: 1px solid var(--wz-border); }
.wz-table th { height: 34px; }
.wz-table tr:last-child td { border-bottom: 0; }
.wz-table tbody tr:hover { background: var(--wz-surface-subtle); }
.wz-table tbody tr[data-selected='true'] { background: var(--wz-accent-soft); }
.wz-table .wz-numeric { text-align: right; }
.wz-table__sort { padding: 0; border: 0; background: none; color: inherit; display: inline-flex; align-items: center; gap: 6px; min-height: 28px; }
.wz-table__sort .wz-icon { width: 14px; height: 14px; }
.wz-table__link { font-weight: var(--wz-weight-medium); color: var(--wz-text); text-decoration: none; border: 0; background: transparent; padding: 0; }
.wz-table__link:hover { color: var(--wz-accent); text-decoration: underline; }
.wz-table__secondary { display: block; color: var(--wz-text-muted); font-size: var(--wz-text-xs); margin-top: 2px; }
.wz-table__footer { display: flex; align-items: center; justify-content: space-between; padding: var(--wz-space-3) var(--wz-space-4); border-top: 1px solid var(--wz-border); color: var(--wz-text-muted); font-size: var(--wz-text-xs); gap: 12px; }
.wz-batch { background: var(--wz-accent-soft); color: var(--wz-accent); }

.wz-deal-card { display: flex; flex-direction: column; gap: var(--wz-space-3); padding: var(--wz-space-4); border: 1px solid var(--wz-border); border-radius: var(--wz-radius-lg); background: var(--wz-surface); box-shadow: var(--wz-shadow-sm); }
.wz-deal-card__title { font-size: var(--wz-text-md); font-weight: var(--wz-weight-semibold); }
.wz-deal-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--wz-border); padding-top: var(--wz-space-3); color: var(--wz-text-muted); font-size: var(--wz-text-xs); }
.wz-metric { display: flex; flex-direction: column; gap: var(--wz-space-2); padding: var(--wz-space-5); }
.wz-metric__value { font-size: var(--wz-text-3xl); font-weight: var(--wz-weight-semibold); letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: var(--wz-leading-tight); }
.wz-timeline { list-style: none; padding: 0; margin: 0; }
.wz-timeline li { display: flex; gap: var(--wz-space-3); position: relative; padding-bottom: var(--wz-space-6); }
.wz-timeline li:not(:last-child)::before { content: ''; position: absolute; left: 14px; top: 30px; bottom: 0; width: 1px; background: var(--wz-border); }
.wz-timeline li:last-child { padding-bottom: 0; }
.wz-timeline__icon { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border: 1px solid var(--wz-border); border-radius: 50%; background: var(--wz-surface); color: var(--wz-text-secondary); }

.wz-alert { display: flex; align-items: flex-start; gap: var(--wz-space-3); padding: var(--wz-space-4); border: 1px solid currentColor; border-radius: var(--wz-radius-lg); background: var(--wz-info-soft); color: var(--wz-info); font-size: var(--wz-text-sm); }
.wz-alert p { margin-top: 4px; }
.wz-alert--success { color: var(--wz-success); background: var(--wz-success-soft); }
.wz-alert--warning { color: var(--wz-warning); background: var(--wz-warning-soft); }
.wz-alert--danger { color: var(--wz-danger); background: var(--wz-danger-soft); }
.wz-empty { padding: var(--wz-space-12) var(--wz-space-5); display: flex; flex-direction: column; align-items: center; gap: var(--wz-space-3); text-align: center; }
.wz-empty__icon { display: grid; place-items: center; border: 1px solid var(--wz-border); border-radius: var(--wz-radius-xl); width: 44px; height: 44px; color: var(--wz-text-muted); background: var(--wz-surface-subtle); margin-bottom: 4px; }
.wz-empty p { max-width: 300px; font-size: var(--wz-text-sm); color: var(--wz-text-muted); }
.wz-skeleton { display: block; height: 14px; border-radius: var(--wz-radius-sm); background: var(--wz-surface-hover); animation: wz-pulse 1.5s ease-in-out infinite alternate; }
.wz-spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: wz-spin .75s linear infinite; flex: none; }
.wz-dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 1px solid var(--wz-border); border-radius: var(--wz-radius-xl); color: var(--wz-text); background: var(--wz-surface); box-shadow: var(--wz-shadow-float); }
.wz-dialog::backdrop { background: var(--wz-overlay); }
.wz-dialog__body { padding: var(--wz-space-6); }
.wz-dialog__title { font-size: var(--wz-text-xl); font-weight: var(--wz-weight-semibold); letter-spacing: -.02em; }
.wz-dialog__footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--wz-space-2); padding: var(--wz-space-4) var(--wz-space-6); background: var(--wz-surface-subtle); border-top: 1px solid var(--wz-border); }
.wz-toast-region { position: fixed; bottom: var(--wz-space-6); right: var(--wz-space-6); z-index: var(--wz-z-toast); display: flex; flex-direction: column; align-items: flex-end; gap: var(--wz-space-2); max-width: calc(100vw - 32px); }
.wz-toast { display: flex; align-items: center; gap: var(--wz-space-3); padding: var(--wz-space-3) var(--wz-space-4); border: 1px solid var(--wz-border); border-radius: var(--wz-radius-lg); background: var(--wz-surface); color: var(--wz-text); box-shadow: var(--wz-shadow-float); font-size: var(--wz-text-sm); }
.wz-toast > .wz-icon { color: var(--wz-success); }
.wz-disclosure { border: 1px solid var(--wz-border); border-radius: var(--wz-radius-lg); }
.wz-disclosure summary { padding: var(--wz-space-4); cursor: pointer; font-weight: var(--wz-weight-medium); }
.wz-disclosure > div { padding: 0 var(--wz-space-4) var(--wz-space-4); color: var(--wz-text-secondary); }
@keyframes wz-pulse { to { opacity: .45; } }
@keyframes wz-spin { to { transform: rotate(360deg); } }
@media (pointer: coarse) {
  .wz-button--small, .wz-segmented button, .wz-check, .wz-switch { min-height: var(--wz-touch-target); }
  .wz-tag button { min-width: 32px; min-height: 32px; }
}
@media (prefers-reduced-motion: reduce) { .wz-skeleton, .wz-spinner { animation: none; } }
