* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

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

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

button,
a {
    touch-action: manipulation;
}

button {
    cursor: pointer;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 3px;
}

/* Finech Form and Display: small 1238:148815 (45px); medium 811:1836 (56px).
 * CSS padding discounts the 1px border, which Figma draws inside the frame. */
input:not([type='checkbox']):not([type='radio']),
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 11px;
    color: var(--ink);
    min-height: 45px;
    font-size: var(--font-size-body-medium);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-body);
    letter-spacing: var(--letter-spacing-finech);
    box-shadow: var(--shadow-xs);
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}

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

input:not([type='checkbox']):not([type='radio']):focus-visible,
select:focus-visible,
textarea:focus-visible {
    border-color: var(--blue);
    box-shadow: var(--focus-ring);
    outline: none;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

input:not([type='checkbox']):not([type='radio']):disabled,
select:disabled,
textarea:disabled {
    background: var(--canvas);
    border-color: var(--line);
    color: var(--muted);
    opacity: 1;
    cursor: not-allowed;
}

.field.medium :is(input:not([type='checkbox']):not([type='radio']), select, textarea) {
    min-height: 56px;
    padding: 15px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-body-large);
}

.field.medium textarea {
    min-height: 120px;
}

.field.medium :is(label, small) {
    font-size: var(--font-size-body-large);
}

/* Validation is an application state, using the guide's Error palette. */
:is(input, select, textarea):is([aria-invalid='true'], :user-invalid):not(:disabled) {
    border-color: var(--error);
}

:is(input, select, textarea):is([aria-invalid='true'], :user-invalid):not(:disabled):focus-visible {
    border-color: var(--error);
    box-shadow: 0 0 0 4px var(--error-focus);
}

select {
    cursor: pointer;
}

h1,
h2,
h3,
p {
    margin: 0;
}

button svg,
a svg {
    flex-shrink: 0;
}

/* Original 32px Figma SVGs remain unmodified; their alpha masks inherit the
 * surrounding component colour and fit its 16/20/24px icon slot. */
.icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    vertical-align: middle;
}

.figma-icon {
    background-color: currentColor;
    -webkit-mask: var(--icon-asset) center / contain no-repeat;
    mask: var(--icon-asset) center / contain no-repeat;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 41px;
    padding: 9px 13px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-body-medium);
    line-height: var(--line-height-body);
    letter-spacing: var(--letter-spacing-finech);
    white-space: nowrap;
    transition:
        background 0.15s,
        border-color 0.15s,
        color 0.15s,
        box-shadow 0.15s;
}

/* Figma Button 44:692: primary = Primary/Default, accent = Secondary/Default.
   The existing secondary class is the neutral Tertiary/Outline action, so
   cancellation and navigation controls retain their established hierarchy. */
.button:is(:disabled, [aria-disabled='true']),
.icon-button:is(:disabled, [aria-disabled='true']) {
    opacity: 1;
    cursor: not-allowed;
}

.button.primary {
    background: var(--blue);
    color: var(--neutral-10);
    box-shadow: var(--shadow);
}

.button.primary:hover:not(:disabled) {
    background: var(--blue-hover);
}

.button.primary:active:not(:disabled) {
    background: var(--blue-pressed);
}

.button.primary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring-primary);
}

.button.primary:is(:disabled, [aria-disabled='true']) {
    background: var(--blue-surface);
    color: var(--neutral-60);
}

.button.accent {
    background: var(--orange);
    color: var(--surface);
    box-shadow: var(--shadow);
}

.button.accent:hover:not(:disabled) {
    background: var(--orange-hover);
}

.button.accent:active:not(:disabled) {
    background: var(--orange-pressed);
}

.button.accent:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring-secondary);
}

.button.accent:is(:disabled, [aria-disabled='true']) {
    background: var(--orange-surface);
    color: var(--neutral-60);
}

.button.secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--neutral-80);
    padding-inline: 15px;
}

.button.secondary:hover:not(:disabled) {
    border-color: var(--neutral-50);
    color: var(--neutral-90);
}

.button.secondary:active:not(:disabled) {
    border-color: var(--neutral-60);
    color: var(--neutral-100);
}

.button.secondary:focus-visible {
    outline: none;
    border-color: var(--neutral-80);
    box-shadow: var(--shadow);
}

.button.secondary:is(:disabled, [aria-disabled='true']) {
    border-color: var(--neutral-30);
    color: var(--neutral-30);
}

.button.tertiary {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
}

.button.tertiary:not(.small):not(.large) {
    min-height: 37px;
    padding-block: 7px;
}

.button.tertiary:is(:disabled, [aria-disabled='true']) {
    background: var(--neutral-20);
    color: var(--neutral-60);
}

.button.ghost {
    background: transparent;
    color: var(--muted);
}

.button.ghost:hover:not(:disabled) {
    background: var(--neutral-20);
    color: var(--ink);
}

.button.ghost:is(:disabled, [aria-disabled='true']) {
    color: var(--neutral-40);
}

/* The Link variant has no container padding; its icon slots remain optional. */
.button.link {
    min-height: 0;
    padding: 0;
    border: 0;
    color: var(--blue);
    background: transparent;
    box-shadow: none;
}

.button.link:hover:not(:disabled) {
    color: var(--blue-hover);
    text-decoration: underline;
}

.button.link:active:not(:disabled) {
    color: var(--blue-pressed);
}

.button.link:focus-visible {
    text-decoration: underline;
}

.button.link:is(:disabled, [aria-disabled='true']) {
    color: var(--neutral-40);
    text-decoration: none;
}

.button.danger {
    background: var(--neutral-10);
    border-color: var(--error-border);
    color: var(--error-pressed);
}

.button.small {
    padding: 5px 9px;
    min-height: 30px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-body-small);
}

.button.secondary.small {
    min-height: 34px;
    padding: 7px 11px;
}

.button.small .icon {
    width: 16px;
    height: 16px;
}

.button.large {
    padding: 13px 17px;
    min-height: 52px;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-body-large);
}

.button.secondary.large {
    padding-inline: 19px;
}

.button.link:is(.small, .large) {
    min-height: 0;
    padding: 0;
}

.button.large .icon {
    width: 24px;
    height: 24px;
}

.button.full {
    width: 100%;
}

.icon-button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--neutral-80);
    box-shadow: var(--shadow);
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
}

.icon-button:hover:not(:disabled) {
    color: var(--neutral-100);
}

.icon-button:is(:disabled, [aria-disabled='true']) {
    background: var(--neutral-20);
    color: var(--neutral-60);
}

/* Generic Card shell: Card/Features V1 22459:64096. Dashboard panels
   intentionally retain the separate 12px dashboard card treatment. */
.card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface);
    overflow: hidden;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    font-size: 19px;
    font-weight: 640;
    letter-spacing: -0.65px;
}

.brand b {
    font-weight: 450;
}

.brand img {
    flex-shrink: 0;
}

.brand-mark {
    display: block;
    width: 42px;
    height: 42px;
    background: url('/assets/brand.svg') center/contain no-repeat;
}

.boot-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-direction: column;
    color: var(--muted);
    background: var(--canvas);
}

.spinner {
    width: 22px;
    height: 22px;
    border: 2px solid var(--blue-border);
    border-top-color: var(--blue);
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

.mono {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.92em;
    overflow-wrap: anywhere;
}

.nowrap {
    white-space: nowrap;
}

.small-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 100%;
    background: var(--blue);
    flex-shrink: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 5px;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: var(--font-weight-medium);
    line-height: 1.1;
    white-space: nowrap;
}

.badge:before {
    content: '';
    width: 5px;
    height: 5px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.8;
}

.badge.positive {
    background: var(--success-surface);
    color: var(--success-pressed);
}

.badge.pending {
    background: var(--warning-surface);
    color: var(--warning-pressed);
}

.badge.negative {
    background: var(--error-surface);
    color: var(--error-pressed);
}

.badge.blue {
    background: var(--blue-surface);
    color: var(--blue-pressed);
}

.badge.neutral {
    background: var(--neutral-20);
    color: var(--neutral-60);
}

.badge.violet {
    background: var(--info-surface);
    color: var(--info-pressed);
}

.eyebrow {
    font-size: 11px;
    letter-spacing: 1.6px;
    font-weight: var(--font-weight-semibold);
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.noscript-message {
    position: fixed;
    inset: 20px 20px auto;
    padding: 20px;
    background: white;
    border: 1px solid var(--line);
    z-index: 1000;
}

.toast-region {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: grid;
    gap: 10px;
    max-width: 400px;
}

/* Shown as a popover so toasts sit above an open modal dialog; undo the UA popover box. */
.toast-region[popover] {
    inset: auto 24px 24px auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
}

.toast-region[popover]:not(:popover-open) {
    display: none;
}

.toast {
    padding: 15px 20px;
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--neutral-90);
    color: white;
    border-radius: 9px;
    box-shadow: 0 8px 30px #14263a26;
    font-size: 13px;
    line-height: 1.5;
}

.toast.error {
    background: var(--error-pressed);
}

.toast .icon {
    width: 18px;
}

.form-error {
    font-size: 12px;
    color: var(--error-pressed);
    line-height: 1.5;
}

.inline-feedback {
    margin: 0;
    font-size: var(--font-size-body-medium);
    line-height: var(--line-height-body);
    color: var(--neutral-70);
}

.form-error:empty,
.inline-feedback:empty,
#account-connection-status:empty {
    display: none;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field label,
.field-label {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: -0.05em;
    color: var(--ink);
}

.field small,
.field-hint {
    font-size: var(--font-size-body-medium);
    color: var(--ink);
    line-height: var(--line-height-body);
    letter-spacing: var(--letter-spacing-finech);
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.field-grid .span-2 {
    grid-column: 1/-1;
}

.form-stack {
    display: grid;
    gap: 20px;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-size-body-medium);
    cursor: pointer;
    line-height: 1.5;
}

/* Finech Checkbox / Small, 20387:3308 and 20387:3320.
 * Keep a native input for keyboard, validation and assistive technology. */
input[type='checkbox'] {
    appearance: none;
    min-height: 0;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface) center / 12px 12px no-repeat;
    box-shadow: none;
    cursor: pointer;
}

input[type='checkbox']:checked {
    border-color: var(--blue-hover);
    background-color: var(--blue);
    background-image: url('/assets/figma/forms/checkbox-check-small.svg');
}

input[type='checkbox']:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}
