/* Element defaults and the few utilities every screen uses. Mobile-first; tokens from tokens.css. */

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background: var(--surface-0);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading);
    -webkit-font-smoothing: antialiased;
}

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

h1,
h2,
h3,
h4 {
    font-weight: 700;
    line-height: var(--leading-tight);
}

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

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

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

button {
    cursor: pointer;
}

a {
    color: var(--accent);
    text-underline-offset: 0.18em;
}

table {
    border-collapse: collapse;
}

[hidden] {
    display: none !important;
}

:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

::selection {
    background: var(--accent);
    color: var(--accent-contrast);
}

/* Numbers: FoXE's default figures share one advance width, so columns align without tnum
   (which the font lacks); kerning is switched off so digit pairs never shift. */
.num,
.tabular {
    font-family: var(--font-numeric);
    font-variant-numeric: lining-nums tabular-nums;
    font-kerning: none;
    white-space: nowrap;
}

.label {
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--label-weight);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}

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

.tone-danger {
    color: var(--danger);
    font-weight: var(--danger-weight, inherit);
}

.tone-positive {
    color: var(--positive);
}

.tone-warning {
    color: var(--warning);
}

.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;
}

.skip-link {
    position: fixed;
    top: var(--space-2);
    left: var(--space-2);
    z-index: var(--z-toast);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 700;
    transform: translateY(-200%);
}

.skip-link:focus-visible {
    transform: none;
}

.icon {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

/* Buttons: one base, three looks. Every button is at least a touch target tall. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--touch);
    padding: 0 var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    font-size: var(--text-sm);
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--accent) 88%, var(--text));
}

.btn-secondary {
    border-color: var(--border-control);
    background: var(--surface-1);
    color: var(--text);
}

.btn-secondary:hover,
.btn-ghost:hover {
    background: var(--surface-hover);
}

.btn-ghost {
    color: var(--text);
}

/* A destructive action (Descartar, Eliminar): the danger fill, never the primary accent. */
.btn-danger {
    background: var(--danger);
    color: var(--on-danger);
}

.btn-danger:hover {
    background: color-mix(in srgb, var(--danger) 88%, var(--text));
}

/* The accent text-button of the reference (EXPORTAR): uppercase, accent ink, an icon before it. */
.btn-link {
    padding: 0 var(--space-2);
    color: var(--accent);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}

.btn-link:hover {
    background: var(--accent-soft);
}

.btn-icon {
    width: var(--touch);
    padding: 0;
    border-radius: var(--radius-pill);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.55;
}

/* Form fields */
.field {
    display: grid;
    gap: var(--space-1);
}

.field-label {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.input,
.select {
    width: 100%;
    min-height: var(--touch);
    padding: 0 var(--space-3);
    border: 1px solid var(--border-control);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    color: var(--text);
}

/* A select's list is drawn by the browser outside the page, aligning each option's text with the
   field's: an option indented as the field is (and nothing else indented) keeps the list's edge on the
   field's and its text whole; it is written in the system's face, which that list always has. */
select option,
select optgroup {
    padding-inline: var(--space-3);
    text-indent: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* A native select wears the app's one chevron (components.md, "The chevron"): the sprite's chevron-down in
   --text-muted (--chevron), 20 px, centred in the field's last touch target, the text stopping before it - as the
   combobox's and the date fields' chevron button. */
select.select,
select.input {
    padding-right: calc(var(--touch) + var(--space-1));
    appearance: none;
    background-image: var(--chevron);
    background-repeat: no-repeat;
    background-position: right calc((var(--touch) - 20px) / 2) center;
    background-size: 20px;
    background-origin: border-box;
    text-indent: 0;
    text-overflow: ellipsis;
}

select.select:disabled,
select.input:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.input:focus-visible,
.select:focus-visible {
    outline-offset: 0;
    border-color: var(--focus-ring);
}

.input[aria-invalid="true"] {
    border-color: var(--danger);
}

.field-error {
    color: var(--danger);
    font-size: var(--text-sm);
}

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

@media (forced-colors: active) {
    .btn,
    .input,
    .select {
        border: 1px solid ButtonText;
    }

    select.select,
    select.input {
        appearance: auto;
        background-image: none;
    }
}
