/* GestioneFinanziaria 0.10.4 — visual design system foundation. */
:root {
  color-scheme: light;

  /* Brand palette: original finance UI interpretation of navy / blue / gold. */
  --color-brand-950: #07182d;
  --color-brand-900: #0a2342;
  --color-brand-800: #0d315b;
  --color-brand-700: #124677;
  --color-electric-600: #0b78c9;
  --color-electric-500: #1495ea;
  --color-electric-100: #dff2ff;
  --color-gold-500: #e7b63f;
  --color-gold-300: #f2d47d;
  --color-gold-100: #fff7df;

  /* Neutral and semantic surfaces. */
  --color-page-bg: #f4f7fb;
  --color-surface: #ffffff;
  --color-surface-subtle: #f8fafc;
  --color-surface-inverse: var(--color-brand-950);
  --color-text: #152235;
  --color-text-muted: #5f6e82;
  --color-text-subtle: #8794a6;
  --color-text-inverse: #f8fbff;
  --color-border: #dce4ee;
  --color-border-strong: #c6d1df;
  --color-control-border: #7a899c;
  --color-focus: var(--color-electric-600);
  --color-success: #16794a;
  --color-success-soft: #eaf8f1;
  --color-warning: #a96105;
  --color-warning-soft: #fff5df;
  --color-danger: #b42318;
  --color-danger-soft: #fff0ef;
  --color-info-soft: #edf7ff;
  --color-heading: var(--color-brand-950);
  --color-control-text: var(--color-brand-900);
  --color-surface-glass: rgba(255, 255, 255, .92);
  --color-input-hover-border: #5f7288;
  --color-primary-hover: #0869b2;
  --color-info-border: #b8dfff;
  --color-info-text: #154f78;
  --color-warning-border: #d28b24;
  --color-warning-text: #73420a;

  /* Compatibility aliases consumed by established feature CSS. */
  --bg: var(--color-page-bg);
  --surface: var(--color-surface);
  --text: var(--color-text);
  --muted: var(--color-text-muted);
  --border: var(--color-border);
  --accent: var(--color-electric-600);

  /* Type, shape, elevation and motion. */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(7, 24, 45, .05), 0 6px 18px rgba(7, 24, 45, .04);
  --shadow-md: 0 16px 40px rgba(7, 24, 45, .10);
  --shadow-nav: 18px 0 40px rgba(7, 24, 45, .16);
  --transition-fast: 140ms ease;
  --transition-base: 180ms ease;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-page-bg: #06111f;
  --color-surface: #0b1b2d;
  --color-surface-subtle: #10263d;
  --color-text: #e9f1f9;
  --color-text-muted: #a8b8ca;
  --color-text-subtle: #8195aa;
  --color-border: #20384f;
  --color-border-strong: #31506d;
  --color-control-border: #607b96;
  --color-focus: var(--color-electric-500);
  --color-electric-100: #0d314d;
  --color-gold-100: #3a2d0d;
  --color-success: #58c78d;
  --color-success-soft: #0d2d21;
  --color-warning: #f0b55a;
  --color-warning-soft: #34260f;
  --color-danger: #ff7c72;
  --color-danger-soft: #351817;
  --color-info-soft: #0b2940;
  --color-heading: #f3f7fc;
  --color-control-text: #d6e6f5;
  --color-surface-glass: rgba(11, 27, 45, .93);
  --color-input-hover-border: #7894b1;
  --color-primary-hover: #188fe4;
  --color-info-border: #27577a;
  --color-info-text: #9dd7ff;
  --color-warning-border: #9b6d26;
  --color-warning-text: #ffd18a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .22), 0 8px 22px rgba(0, 0, 0, .13);
  --shadow-md: 0 18px 44px rgba(0, 0, 0, .28);
  --shadow-nav: 18px 0 44px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--color-page-bg); scroll-padding-top: calc(var(--app-topbar-height, 64px) + 12px); }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 88% -20%, rgba(20, 149, 234, .08), transparent 34rem),
    var(--color-page-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  scroll-margin-top: calc(var(--app-topbar-height, 64px) + 12px);
  scroll-margin-bottom: 12px;
}

::selection { background: var(--color-gold-300); color: var(--color-brand-950); }

.container { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
main.container { padding: 44px 0 72px; }

/* Public shell. */
.nav {
  background: var(--color-surface-glass);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(14px);
}
.nav-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; flex-direction: column; color: var(--color-heading); font-size: 1.15rem; font-weight: 850; letter-spacing: -.025em; line-height: 1.05; text-decoration: none; }
.brand-with-mark { flex-direction: row; align-items: center; gap: 10px; }
.brand-mark { display: block; width: 42px; height: 42px; flex: 0 0 auto; object-fit: contain; }
.brand-copy { display: inline-flex; min-width: 0; flex-direction: column; }
.brand small { margin-top: 4px; color: var(--color-text-muted); font-size: .68rem; font-weight: 650; letter-spacing: 0; }
.nav-links { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav-links a { color: var(--color-text-muted); text-decoration: none; font-weight: 650; }
.nav-links a:hover { color: var(--color-electric-600); }
.link-button { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-decoration: none; }
.inline-form { display: inline; margin: 0; }

/* Typography and basic composition. */
.hero { max-width: 820px; padding: 64px 0; }
.hero h1,
.page-header h1 {
  color: var(--color-heading);
  text-wrap: balance;
}
.hero h1 { margin: 12px 0 20px; font-size: clamp(2.2rem, 6vw, 4.8rem); line-height: .98; letter-spacing: -.055em; }
.hero p { max-width: 680px; color: var(--color-text-muted); font-size: 1.15rem; line-height: 1.65; }
.hero .hero-brand-tagline { margin: 8px 0 20px; color: var(--color-heading); font-size: .95rem; font-weight: 750; letter-spacing: -.01em; }
.eyebrow {
  display: inline-block;
  color: var(--color-electric-600);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .095em;
  text-transform: uppercase;
}
.muted { color: var(--color-text-muted); }
.small { font-size: .86rem; }

/* Surfaces and cards. */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card:hover { border-color: var(--color-border-strong); }
.auth-card { max-width: 540px; margin: 30px auto; }
.narrow-card { max-width: 640px; margin: 0 auto; }

/* Forms. */
form p { display: grid; gap: 7px; }
label { color: var(--color-text); font-weight: 650; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--color-control-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input[type="checkbox"],
input[type="radio"] {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--color-electric-600);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):hover,
select:hover,
textarea:hover { border-color: var(--color-input-hover-border); }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
select:focus,
textarea:focus {
  border-color: var(--color-electric-500);
  box-shadow: 0 0 0 3px rgba(20, 149, 234, .13);
  outline: 0;
}

/* Actions. */
.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-electric-600);
  box-shadow: 0 7px 16px rgba(11, 120, 201, .16);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 760;
  text-decoration: none;
  max-width: 100%;
  white-space: normal;
  text-align: center;
  transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.button:hover { background: var(--color-primary-hover); box-shadow: 0 9px 20px rgba(11, 120, 201, .22); transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button.secondary { border-color: var(--color-control-border); background: var(--color-surface); box-shadow: none; color: var(--color-control-text); }
.button.secondary:hover { border-color: var(--color-electric-500); background: var(--color-electric-100); }
.button.danger { background: var(--color-danger); box-shadow: none; }
.button[disabled], .button.disabled { opacity: .52; pointer-events: none; transform: none; }
.actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* Feedback. */
.alerts { display: grid; gap: 10px; margin-bottom: 18px; }
.alert {
  padding: 12px 14px;
  border: 1px solid var(--color-info-border);
  border-radius: var(--radius-md);
  background: var(--color-info-soft);
  color: var(--color-info-text);
  box-shadow: var(--shadow-sm);
}
.errorlist {
  margin: 4px 0 8px;
  padding-left: 1.25rem;
  color: var(--color-danger);
  font-size: .9rem;
  font-weight: 650;
}
.helptext { color: var(--color-text-muted); font-size: .86rem; }
:where(input, select, textarea)[aria-invalid="true"] {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-danger) 34%, transparent);
}

/* Semantic SVG icon component. */
.icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  vertical-align: -.15em;
}
.icon-16 { width: 16px; height: 16px; }
.icon-20 { width: 20px; height: 20px; }
.icon-24 { width: 24px; height: 24px; }
.icon-32 { width: 32px; height: 32px; }

/* Financial KPI language. */
.kpi-card { position: relative; overflow: hidden; }
.kpi-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(var(--color-electric-500), var(--color-gold-500));
  content: "";
}
.kpi-label { color: var(--color-text-muted); }
.kpi-value { color: var(--color-heading); font-variant-numeric: tabular-nums; }
.amount { color: var(--color-heading); font-variant-numeric: tabular-nums; }
.text-link { color: var(--color-electric-600); text-underline-offset: 3px; }
.text-link:hover { color: var(--color-brand-700); }

/* Tables and rows stay visually quiet to preserve financial scanability. */
.list-row { transition: background var(--transition-fast); }
.list-row:hover { background: linear-gradient(90deg, rgba(20, 149, 234, .035), transparent 75%); }
table { font-variant-numeric: tabular-nums; }

.footer { border-top: 1px solid var(--color-border); color: var(--color-text-muted); text-align: center; padding: 24px; }

/* Vault warning deliberately uses warning semantics, not brand gold. */
.vault-warning {
  border-color: var(--color-warning-border) !important;
  background: var(--color-warning-soft) !important;
  color: var(--color-warning-text);
}
.vault-countdown { color: var(--color-warning); }

.theme-preference {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--color-text-muted);
  font-size: .82rem;
  font-weight: 700;
}
.theme-preference select {
  width: auto;
  min-width: 92px;
  min-height: 36px;
  padding: 7px 28px 7px 9px;
  border-radius: var(--radius-sm);
}
.theme-preference-public { color: var(--color-text-muted); }

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 88% -20%, rgba(20, 149, 234, .11), transparent 34rem),
    var(--color-page-bg);
}
html[data-theme="dark"] ::selection {
  background: var(--color-gold-500);
  color: var(--color-brand-950);
}

@media (max-width: 620px) {
  .container { width: min(100% - 24px, 1120px); }
  main.container { padding-top: 28px; }
  .card { padding: 20px; border-radius: 16px; }
  .actions { align-items: stretch; }
  .public-nav .nav-inner {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding-block: 10px;
  }
  .public-nav .brand { align-self: flex-start; max-width: 100%; }
  .public-nav .nav-links { width: 100%; gap: 6px 12px; }
  .public-nav .theme-preference-public { flex: 1 0 100%; }
}

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

/* 1.0.0 RC accessibility hardening. */
.skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 200;
  min-height: 40px;
  padding: 9px 14px;
  border: 2px solid var(--color-focus);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-heading);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(calc(-100% - 20px));
  transition: transform var(--transition-fast);
}
.skip-link:focus-visible { transform: translateY(0); }
main.container:focus { outline: none; }

/* Reflow guardrails for ordinary content. Data tables keep their explicit
   horizontal wrappers because their two-dimensional layout is meaningful. */
main :where(p, li, dd, dt, small, .helptext, .errorlist, .alert, code) {
  overflow-wrap: anywhere;
}
pre { max-width: 100%; overflow-x: auto; }
img, video, canvas { max-width: 100%; height: auto; }

/* The generic focus ring used above was previously cancelled by the later
   :focus form rule. Keep the visual field state and restore a strong keyboard ring. */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.nav-links a {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
}
