/* Family CFO — "Caminanti / Conti" design system
   Warm paper palette · Spectral serif display · Hanken Grotesk body · Spline Sans Mono labels.
   Light, editorial, self-hosted-with-affection. Class vocabulary is preserved 1:1 with app.js. */

:root {
  /* paper surfaces */
  --bg: #f4f0e8;
  --paper-2: #faf8f2;
  --panel: #ffffff;
  --panel-2: #faf8f2;
  --panel-3: #ece7db;

  /* ink */
  --text: #20223f;
  --soft: #46496a;
  --muted: #6b6e8c;
  --faint: #9a9db8;

  /* lines */
  --line: rgba(44, 49, 128, 0.12);
  --line-strong: rgba(44, 49, 128, 0.20);

  /* brand */
  --accent: #2c3180;       /* deep indigo */
  --accent-ink: #1d2150;
  --accent-soft: #8b93cf;  /* periwinkle */
  --accent-2: #cf7a52;     /* terracotta */
  --green: #5f9e7a;
  --green-ink: #3f7a58;
  --warn: #c08a2e;
  --danger: #bb5e38;

  --input: #ffffff;
  --shadow: 0 18px 44px -34px rgba(44, 49, 128, 0.55);
  --shadow-lg: 0 22px 50px -36px rgba(44, 49, 128, 0.50);
  --radius: 20px;

  --display: "Spectral", Georgia, "Times New Roman", serif;
  --mono: "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  color-scheme: light;
  font-family: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(207, 122, 82, 0.07) 0, transparent 34rem),
    radial-gradient(circle at 80% -5%, rgba(44, 49, 128, 0.06) 0, transparent 30rem),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: var(--accent); }
::selection { background: #2c3180; color: #f4f0e8; }
.hidden { display: none !important; }

@keyframes camRise { 0% { opacity: 0; transform: translateY(14px); } 100% { opacity: 1; transform: none; } }
@keyframes camPop { 0% { opacity: 0; transform: translateY(12px) scale(.99); } 100% { opacity: 1; transform: none; } }

/* ---------- Lock screen ---------- */
.lock-screen { min-height: 100vh; display: grid; place-items: center; padding: 32px; }
.lock-card {
  width: min(720px, 100%);
  padding: 44px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: camRise .6s ease both;
}
.lock-card h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(42px, 8vw, 78px);
  line-height: 0.98;
  margin: 0 0 18px;
  letter-spacing: -0.025em;
  color: var(--text);
}
.lede { color: var(--soft); font-size: 18px; line-height: 1.6; max-width: 62ch; }
.eyebrow {
  margin: 0 0 8px;
  font-family: var(--mono);
  color: var(--accent-soft);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 11px;
  font-weight: 500;
}
.vault-status { margin: 24px 0 14px; color: var(--muted); }
.field-label {
  display: block;
  margin: 16px 0 8px;
  font-family: var(--mono);
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.input, .select, textarea {
  width: 100%;
  color: var(--text);
  background: var(--input);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 12px 14px;
  outline: 2px solid transparent;
  transition: border-color .15s ease, outline-color .15s ease;
}
.input::placeholder, textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, textarea:focus { border-color: var(--accent); outline-color: rgba(44, 49, 128, 0.18); }
.lock-actions { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.privacy-note { margin-top: 24px; color: var(--muted); border-top: 1px dashed var(--line-strong); padding-top: 18px; }
.privacy-note summary { cursor: pointer; color: var(--soft); font-weight: 700; }

/* ---------- Buttons ---------- */
.button {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: #fff;
  border-radius: 999px;
  padding: 11px 18px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 500;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.button:hover { transform: translateY(-1px); border-color: var(--accent); }
.button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #f4f0e8;
  box-shadow: 0 10px 24px -14px rgba(44, 49, 128, 0.9);
}
.button.primary:hover { background: var(--accent-ink); box-shadow: 0 14px 28px -14px rgba(44, 49, 128, 0.95); }
.button.accent {
  background: var(--accent-2);
  border-color: transparent;
  color: #f4f0e8;
  box-shadow: 0 10px 24px -14px rgba(207, 122, 82, 0.85);
}
.button.accent:hover { background: #bb6843; }
.button.ghost { background: transparent; border-color: var(--line-strong); }
.button.ghost:hover { background: rgba(44, 49, 128, 0.05); }
.button.small { font-size: 11px; padding: 8px 13px; }
.button.danger { background: rgba(187, 94, 56, 0.10); border-color: rgba(187, 94, 56, 0.40); color: var(--danger); }
.button.danger:hover { border-color: var(--danger); background: rgba(187, 94, 56, 0.16); }
.button.full { width: 100%; justify-content: center; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 22px;
  border-right: 1px solid var(--line);
  background: rgba(250, 248, 242, 0.92);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand { display: flex; gap: 13px; align-items: center; }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2c3180, #6b73c4);
  color: #f4f0e8;
  font-family: var(--display);
  font-weight: 600;
  font-size: 24px;
  box-shadow: 0 10px 22px -12px rgba(44, 49, 128, 0.8);
}
.brand strong {
  font-family: var(--display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 5px; }
.nav button {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  color: var(--soft);
  background: transparent;
  border-radius: 13px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14.5px;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.nav button:hover { color: var(--text); background: rgba(44, 49, 128, 0.05); }
.nav button.active {
  color: var(--accent);
  background: rgba(44, 49, 128, 0.08);
  border-color: rgba(44, 49, 128, 0.16);
}
.sidebar-foot { margin-top: auto; display: flex; gap: 8px; }

.workspace { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 22px 34px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 240, 232, 0.82);
  backdrop-filter: saturate(1.1) blur(8px);
}
.topbar h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: -0.02em;
  color: var(--text);
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.save-state { color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.save-state.saved { color: var(--green-ink); }
.save-state.error { color: var(--danger); }
.view { padding: 32px; max-width: 1480px; animation: camPop .4s cubic-bezier(.2, .75, .25, 1) both; }

/* ---------- Cards / panels ---------- */
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card, .panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.card { padding: 24px; }
.card h3, .panel h3 {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}
.metric { font-family: var(--display); font-size: clamp(28px, 5vw, 44px); font-weight: 600; letter-spacing: -0.02em; margin: 0; color: var(--text); }
.metric.good { color: var(--green-ink); }
.metric.warn { color: var(--accent-2); }
.metric.bad { color: var(--danger); }
.sub { color: var(--muted); font-size: 13px; line-height: 1.45; }
.panel { overflow: hidden; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}
.panel-head h3 { margin: 0; }
.panel-body { padding: 20px 22px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { border-bottom: 1px dashed var(--line); padding: 11px 9px; text-align: left; vertical-align: middle; }
th {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--line-strong);
}
td { color: var(--text); }
td strong { font-family: var(--display); font-weight: 600; }
td .input, td .select { padding: 9px 10px; border-radius: 10px; min-width: 120px; }
td .num { text-align: right; }
.row-actions { white-space: nowrap; }

/* ---------- Bits ---------- */
.progress { height: 9px; background: #efeadd; border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #5f9e7a, #2c3180); border-radius: inherit; min-width: 2px; transition: width .5s cubic-bezier(.2, .75, .25, 1); }
.kpi-strip { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.pill {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--soft);
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.pill.red { color: var(--danger); border-color: rgba(187, 94, 56, 0.40); background: rgba(187, 94, 56, 0.08); }
.pill.yellow { color: var(--warn); border-color: rgba(192, 138, 46, 0.40); background: rgba(192, 138, 46, 0.10); }
.pill.green { color: var(--green-ink); border-color: rgba(95, 158, 122, 0.40); background: rgba(95, 158, 122, 0.10); }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: span 2; }
.help { color: var(--muted); line-height: 1.6; }
.empty-state { padding: 32px; color: var(--muted); text-align: center; }
.empty-state h3 { font-family: var(--display); font-weight: 600; color: var(--text); }
textarea { min-height: 90px; resize: vertical; }
.notice {
  border: 1px solid rgba(44, 49, 128, 0.22);
  background: rgba(44, 49, 128, 0.06);
  color: var(--accent-ink);
  padding: 14px 16px;
  border-radius: 14px;
  line-height: 1.55;
}
.drop-zone {
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 2px dashed rgba(44, 49, 128, 0.30);
  border-radius: 20px;
  background: var(--paper-2);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.drop-zone.dragging { border-color: var(--accent); background: rgba(44, 49, 128, 0.07); transform: scale(1.01); }
.drop-zone h3 { margin: 0 0 4px; font-family: var(--display); font-weight: 600; font-size: 22px; color: var(--text); }
.metric-inline-good { color: var(--green-ink); }
.metric-inline-bad { color: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  body { background: #fff; color: #20223f; }
  .sidebar, .topbar-actions, .button { display: none !important; }
  .app { display: block; }
  .topbar { position: static; background: #fff; color: #20223f; border: 0; }
  .view { padding: 0 20px; }
  .card, .panel { box-shadow: none; background: #fff; color: #20223f; border-color: #d9d3c4; }
  .sub, .help, th { color: #5b5e7e; }
}
