html,
body {
    margin: 0;
    padding: 0;
}

:root {
    /* ── Spacing scale (fluid: tightens on small viewports) ──────── */
    --ar-space-1: 4px;
    --ar-space-2: clamp(6px, 1vw, 8px);
    --ar-space-3: clamp(8px, 1.5vw, 12px);
    --ar-space-4: clamp(12px, 2vw, 16px);
    --ar-space-5: clamp(16px, 3vw, 24px);
    --ar-space-6: clamp(20px, 4vw, 32px);
    --ar-space-7: clamp(28px, 5vw, 48px);
    --ar-space-8: clamp(36px, 6vw, 64px);
    --ar-radius-1: 10px;
    --ar-radius-2: 16px;
    --ar-radius-3: 22px;
    --ar-motion-fast: 180ms;
    --ar-motion-base: 240ms;
    --ar-motion-slow: 300ms;
    --ar-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ar-font-ui: "Public Sans", "Segoe UI Variable", "Segoe UI", sans-serif;
    --ar-header-height: 60px;
    --ar-sidebar-width: 268px;
    --ar-admin-sidebar-width: 232px;
    --ar-shell-max: 1760px;
    --ar-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
    --ar-shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.14);
    /* ── Responsive shell gutter (viewport-aware) ────────────────── */
    --ar-shell-gutter: clamp(12px, 2vw, 16px);
    /* ── Touch-target floor ──────────────────────────────────────── */
    --ar-touch-min: 44px;
    /* ── Responsive font sizes ───────────────────────────────────── */
    --ar-font-base: clamp(0.875rem, 0.82rem + 0.25vw, 1rem);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --ar-bg: #0b0e11;
    --ar-bg-elevated: #12181f;
    --ar-surface: #161d26;
    --ar-surface-2: #1b2530;
    --ar-surface-3: #212d3a;
    --ar-surface-soft: #11161d;
    --ar-text: #edf3f9;
    --ar-text-soft: #c5ced8;
    --ar-text-muted: #98a6b5;
    --ar-line: rgba(231, 237, 244, 0.08);
    --ar-line-strong: rgba(231, 237, 244, 0.16);
    --ar-accent: #2563eb;
    --ar-accent-hover: #1d4ed8;
    --ar-accent-2: #f0b90b;
    --ar-accent-soft: rgba(59, 130, 246, 0.18);
    --ar-positive: #1fb978;
    --ar-warning: #f59e0b;
    --ar-danger: #ef4444;
    --ar-focus: #6ea8ff;
    --ar-overlay: rgba(5, 8, 12, 0.72);
}

:root[data-theme="light"] {
    color-scheme: light;
    --ar-bg: #f3f6fa;
    --ar-bg-elevated: #edf2f8;
    --ar-surface: #ffffff;
    --ar-surface-2: #f8fafc;
    --ar-surface-3: #eef3f8;
    --ar-surface-soft: #f4f7fb;
    --ar-text: #102033;
    --ar-text-soft: #24364a;
    --ar-text-muted: #4f6276;
    --ar-line: rgba(18, 32, 51, 0.1);
    --ar-line-strong: rgba(18, 32, 51, 0.18);
    --ar-accent: #2563eb;
    --ar-accent-hover: #1d4ed8;
    --ar-accent-2: #8a5a00;
    --ar-accent-soft: rgba(37, 99, 235, 0.12);
    --ar-positive: #0a6d49;
    --ar-warning: #8a4b00;
    --ar-danger: #c2410c;
    --ar-focus: #2563eb;
    --ar-overlay: rgba(18, 32, 51, 0.28);
}

body {
    min-height: 100dvh;
    overflow-x: hidden;
    background: var(--ar-bg);
    color: var(--ar-text);
    font-family: var(--ar-font-ui);
    font-size: var(--ar-font-base);
    line-height: 1.45;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

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

main,
header,
footer,
nav,
aside {
    position: relative;
}

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

h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol,
dl {
    margin: 0;
}

h1,
h2,
h3,
h4 {
    color: var(--ar-text);
    font-weight: 600;
    letter-spacing: -0.04em;
}

p,
li,
label,
summary,
span,
small {
    color: inherit;
}

a {
    color: var(--ar-text);
    text-decoration: none;
    transition:
        color var(--ar-motion-fast) var(--ar-ease),
        background-color var(--ar-motion-fast) var(--ar-ease),
        border-color var(--ar-motion-fast) var(--ar-ease),
        opacity var(--ar-motion-fast) var(--ar-ease);
}

a:hover {
    color: var(--ar-accent);
}

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

button,
.buttonish {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--ar-line);
    border-radius: var(--ar-radius-1);
    background: var(--ar-surface-2);
    color: var(--ar-text);
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition:
        transform var(--ar-motion-fast) var(--ar-ease),
        border-color var(--ar-motion-fast) var(--ar-ease),
        background-color var(--ar-motion-fast) var(--ar-ease),
        color var(--ar-motion-fast) var(--ar-ease),
        opacity var(--ar-motion-fast) var(--ar-ease);
}

button:hover,
.buttonish:hover {
    border-color: var(--ar-line-strong);
    background: var(--ar-surface-3);
}

button:disabled,
.buttonish:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

button.primary,
button:not(.secondary):not(.ghost):not(.danger):not(.icon-btn):not(.chip-btn):not(.filter-pad-btn):not(.chip-remove),
.buttonish.primary {
    border-color: rgba(37, 99, 235, 0.28);
    background: var(--ar-accent);
    color: #ffffff;
}

button.primary:hover,
button:not(.secondary):not(.ghost):not(.danger):not(.icon-btn):not(.chip-btn):not(.filter-pad-btn):not(.chip-remove):hover,
.buttonish.primary:hover {
    background: var(--ar-accent-hover);
    color: #ffffff;
}

button.secondary,
.buttonish.secondary,
button.ghost,
.buttonish.ghost {
    background: transparent;
}

button.danger,
.buttonish.danger {
    border-color: rgba(239, 68, 68, 0.24);
    background: rgba(239, 68, 68, 0.08);
    color: var(--ar-danger);
}

button.icon-btn,
.icon-btn {
    width: 36px;
    min-width: 36px;
    padding: 0;
    border-radius: 10px;
    font-size: 0.92rem;
}

button.small,
select.small {
    min-height: 36px;
    padding-inline: 12px;
    font-size: 0.82rem;
}

button.chip-btn,
.chip-btn {
    min-height: 34px;
    padding-inline: 10px;
    border-radius: 999px;
    background: transparent;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--ar-line);
    border-radius: var(--ar-radius-1);
    background: var(--ar-surface-2);
    color: var(--ar-text);
    transition:
        border-color var(--ar-motion-fast) var(--ar-ease),
        background-color var(--ar-motion-fast) var(--ar-ease),
        box-shadow var(--ar-motion-fast) var(--ar-ease);
}

textarea {
    min-height: 120px;
    padding-block: 10px;
    resize: vertical;
}

select[multiple] {
    min-height: 140px;
    padding-block: 8px;
}

select {
    accent-color: var(--ar-accent);
}

select option,
select optgroup {
    background-color: var(--ar-surface-2);
    color: var(--ar-text);
}

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

summary {
    cursor: pointer;
}

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

:root[data-theme-switching="true"] *,
:root[data-theme-switching="true"] *::before,
:root[data-theme-switching="true"] *::after {
    transition: none !important;
    animation: none !important;
}

.skip-link {
    position: absolute;
    top: -120px;
    left: 16px;
    z-index: 200;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--ar-accent);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
}

.skip-link:focus {
    top: max(14px, env(safe-area-inset-top, 0px));
}

.bg-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at top, rgba(59, 130, 246, 0.08), transparent 32%),
        linear-gradient(180deg, transparent, transparent);
}

:root[data-theme="light"] .bg-layer {
    background:
        radial-gradient(circle at top, rgba(37, 99, 235, 0.06), transparent 28%),
        linear-gradient(180deg, transparent, transparent);
}

.panel {
    border: 1px solid var(--ar-line);
    border-radius: var(--ar-radius-2);
    background: var(--ar-surface);
    box-shadow: var(--ar-shadow-soft);
}

.hint,
.sub,
.admin-subtitle,
.footer-note,
.field-help,
.status-note {
    color: var(--ar-text-muted);
    font-size: 0.8rem;
}

.mono,
code,
pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.eyebrow {
    color: var(--ar-text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.field-code,
.metric-code {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ar-text-soft);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.25;
    text-transform: none;
}

.panel-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--ar-line);
    border-radius: 999px;
    background: var(--ar-surface-2);
    color: var(--ar-accent);
}

.ar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
    color: currentColor;
}

.ar-icon svg {
    width: 100%;
    height: 100%;
}

.ar-icon-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ar-icon-label-text {
    min-width: 0;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

.field-code .ar-icon,
.metric-code .ar-icon,
.ar-icon-label .ar-icon {
    width: 1rem;
    height: 1rem;
    color: var(--ar-accent);
}

.panel-code .ar-icon {
    width: 0.95rem;
    height: 0.95rem;
}

.bank-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
}

.bank-badge-logo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    overflow: hidden;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.bank-badge-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.bank-badge-fallback {
    color: #0f172a;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
}

.bank-badge-copy {
    display: inline-grid;
    min-width: 0;
    gap: 2px;
}

.bank-badge-label,
.bank-badge-sub {
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

.bank-badge-label {
    color: var(--ar-text);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.bank-badge-sub {
    color: var(--ar-text-muted);
    font-size: 0.7rem;
    line-height: 1.2;
}

.bank-badge.is-compact {
    gap: 6px;
}

.bank-badge.is-compact .bank-badge-logo-wrap {
    width: 18px;
    height: 18px;
    border-radius: 6px;
}

.bank-badge.is-compact .bank-badge-label {
    font-size: 0.76rem;
}

.chip,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 0 9px;
    border: 1px solid var(--ar-line);
    border-radius: 999px;
    background: var(--ar-surface-2);
    color: var(--ar-text-soft);
    font-size: 0.72rem;
    font-weight: 600;
}

.pill.positive,
.chip.positive {
    border-color: rgba(31, 185, 120, 0.24);
    color: var(--ar-positive);
}

.pill.warning,
.chip.warning {
    border-color: rgba(245, 158, 11, 0.24);
    color: var(--ar-warning);
}

.pill.danger,
.chip.danger {
    border-color: rgba(239, 68, 68, 0.24);
    color: var(--ar-danger);
}

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

[hidden] {
    display: none !important;
}

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