
  :root{
    --bg:#EAE0C8; --bg-card:#F6F1E2; --ink:#2A2118; --ink-soft:#6B5D48; --ink-faint:#9C8E75;
    --line:rgba(42,33,24,0.14); --line-strong:rgba(42,33,24,0.32);
    --copper:#B5602A; --copper-deep:#8E4A20; --green:#3E4A34; --green-deep:#2B3324;
    --walnut:#4A2E1F; --lemon:#C99A22; --juniper:#4F6B4A; --slate:#46586B;
    --shadow:0 1px 2px rgba(42,33,24,0.06), 0 6px 16px rgba(42,33,24,0.05);
  }
  *{ box-sizing:border-box; }
  html{ -webkit-font-smoothing:antialiased; }
  body{ margin:0; color:var(--ink); font-family:'Public Sans', sans-serif; background:radial-gradient(1200px 600px at 95% -10%, rgba(181,96,42,0.06), transparent), var(--bg); }
  ::selection{ background:var(--copper); color:#fff; }
  a, button, input, select, textarea{ font-family:inherit; }

  .app-shell{ display:flex; min-height:100vh; align-items:stretch; }
  .sidebar{ width:238px; flex-shrink:0; background:var(--green-deep); color:#EFE6D3; padding:20px 14px; position:sticky; top:0; align-self:flex-start; height:100vh; overflow-y:auto; }
  .sb-brand{ display:flex; align-items:center; gap:10px; padding:4px 8px 20px; border-bottom:1px solid rgba(239,230,211,0.14); margin-bottom:14px; }
  .sb-mark{ width:32px; height:32px; border-radius:50%; flex-shrink:0; background:conic-gradient(from 220deg, var(--copper), var(--lemon), var(--juniper), var(--copper)); display:flex; align-items:center; justify-content:center; box-shadow:inset 0 0 0 3px var(--green-deep); }
  .sb-mark::after{ content:""; width:10px; height:10px; border-radius:50%; background:#EFE6D3; }
  .sb-brand h1{ font-family:'Fraunces', serif; font-weight:600; font-size:15px; margin:0; line-height:1.2; }
  .sb-brand p{ margin:1px 0 0; font-size:9.5px; text-transform:uppercase; letter-spacing:1px; color:rgba(239,230,211,0.55); font-weight:600; }
  .nav-group-label{ font-size:10px; text-transform:uppercase; letter-spacing:1px; font-weight:700; color:rgba(239,230,211,0.4); margin:18px 10px 8px; }
  .nav-group-label:first-of-type{ margin-top:4px; }
  .nav-item{ display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:7px; font-size:13px; font-weight:600; color:rgba(239,230,211,0.72); cursor:pointer; margin-bottom:2px; transition:background .12s ease, color .12s ease; }
  .nav-item:hover{ background:rgba(239,230,211,0.07); color:#fff; }
  .nav-item.active{ background:rgba(239,230,211,0.15); color:#fff; }
  .nav-badge{ width:26px; height:20px; border-radius:5px; flex-shrink:0; display:flex; align-items:center; justify-content:center; font-family:'IBM Plex Mono', monospace; font-size:10px; font-weight:700; background:rgba(239,230,211,0.12); color:rgba(239,230,211,0.85); }
  .nav-item[data-color="copper"] .nav-badge{ background:rgba(181,96,42,0.35); color:#F5D9C4; }
  .nav-item[data-color="juniper"] .nav-badge{ background:rgba(79,107,74,0.4); color:#D3E3CE; }
  .nav-item[data-color="lemon"] .nav-badge{ background:rgba(201,154,34,0.35); color:#F3DFA0; }
  .nav-item[data-color="slate"] .nav-badge{ background:rgba(70,88,107,0.5); color:#C6D3E0; }
  .sb-foot{ margin-top:24px; padding:12px 10px; border-top:1px solid rgba(239,230,211,0.14); font-size:10.5px; color:rgba(239,230,211,0.4); line-height:1.5; }

  .content-wrap{ flex:1; min-width:0; }
  .section-header{ display:flex; justify-content:space-between; align-items:flex-end; padding:28px 30px 10px; flex-wrap:wrap; gap:12px; }
  .section-title{ font-family:'Fraunces', serif; font-weight:600; font-size:23px; }
  .section-sub{ color:var(--ink-soft); font-size:13px; margin-top:4px; max-width:560px; line-height:1.4; }
  .section-body{ padding:14px 30px 60px; }

  .btn-new{ background:var(--copper); color:#fff; border:none; padding:10px 18px; border-radius:6px; font-size:13.5px; font-weight:600; cursor:pointer; box-shadow:var(--shadow); white-space:nowrap; transition:transform .15s ease, background .15s ease; }
  .btn-new:hover{ background:var(--copper-deep); transform:translateY(-1px); }
  .btn-secondary-action{ background:transparent; border:1px solid var(--line-strong); color:var(--ink-soft); padding:9px 16px; border-radius:6px; font-size:13px; font-weight:600; cursor:pointer; }
  .btn-secondary-action:hover{ border-color:var(--ink-soft); color:var(--ink); }

  .stats{ display:flex; gap:0; margin-bottom:18px; flex-wrap:wrap; }
  .stat{ flex:1; padding:0 24px; border-left:1px solid var(--line); min-width:150px; }
  .stat:first-child{ border-left:none; padding-left:0; }
  .stat-value{ display:block; font-family:'IBM Plex Mono', monospace; font-weight:600; font-size:24px; color:var(--copper-deep); line-height:1.1; }
  .stat-label{ display:block; font-size:11px; text-transform:uppercase; letter-spacing:0.8px; color:var(--ink-soft); font-weight:600; margin-top:4px; }

  .subtabs{ display:flex; gap:4px; background:rgba(42,33,24,0.06); padding:4px; border-radius:8px; width:fit-content; margin-bottom:16px; }
  .subtab{ border:none; background:transparent; padding:7px 14px; font-size:13px; font-weight:600; color:var(--ink-soft); border-radius:6px; cursor:pointer; }
  .subtab.active{ background:var(--bg-card); color:var(--ink); box-shadow:var(--shadow); }

  .grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(300px, 1fr)); gap:18px; }
  .card{ background:var(--bg-card); border-radius:3px; box-shadow:var(--shadow); border:1px solid var(--line); overflow:hidden; display:flex; flex-direction:column; }
  .card-tab{ height:5px; width:100%; }
  .card-body{ padding:18px 18px 16px; display:flex; flex-direction:column; gap:14px; }
  .card-head{ display:flex; justify-content:space-between; align-items:flex-start; gap:10px; }
  .card-lot{ font-family:'IBM Plex Mono', monospace; font-size:11px; color:var(--ink-faint); letter-spacing:0.5px; }
  .card-product{ font-family:'Fraunces', serif; font-weight:600; font-size:20px; margin-top:2px; }

  .badge{ font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:0.6px; padding:4px 9px; border-radius:20px; white-space:nowrap; }
  .badge-active{ background:rgba(79,107,74,0.15); color:var(--juniper); }
  .badge-ready{ background:rgba(201,154,34,0.18); color:#8a6a17; }
  .badge-warn{ background:rgba(181,96,42,0.16); color:var(--copper-deep); }
  .badge-done{ background:rgba(42,33,24,0.08); color:var(--ink-soft); }

  .pipeline-wrap{ background:rgba(42,33,24,0.04); border:1px solid var(--line); border-radius:8px; padding:14px 10px 10px; }
  .pipeline{ display:flex; align-items:flex-start; }
  .pipeline-step{ display:flex; flex-direction:column; align-items:center; flex:1; position:relative; min-width:0; }
  .pipeline-track{ position:absolute; top:12px; left:50%; width:100%; height:3px; background:var(--line-strong); z-index:1; }
  .pipeline-step:last-child .pipeline-track{ display:none; }
  .pipeline-step.done .pipeline-track{ background:var(--juniper); }
  .pipeline-dot{ width:24px; height:24px; border-radius:50%; background:#fff; border:2px solid var(--line-strong); display:flex; align-items:center; justify-content:center; font-family:'IBM Plex Mono', monospace; font-size:10px; font-weight:700; color:var(--ink-faint); flex-shrink:0; position:relative; z-index:2; transition:all .2s ease; }
  .pipeline-step.done .pipeline-dot{ background:var(--juniper); border-color:var(--juniper); color:#fff; }
  .pipeline-step.current .pipeline-dot{ background:var(--copper); border-color:var(--copper); color:#fff; box-shadow:0 0 0 5px rgba(181,96,42,0.2); }
  .pipeline-label{ margin-top:7px; font-size:9px; text-transform:uppercase; letter-spacing:0.3px; font-weight:700; color:var(--ink-faint); text-align:center; line-height:1.25; padding:0 1px; }
  .pipeline-step.current .pipeline-label{ color:var(--copper-deep); }
  .pipeline-step.done .pipeline-label{ color:var(--juniper); }

  .metrics{ display:grid; grid-template-columns:1fr 1fr; gap:10px 16px; padding-top:12px; border-top:1px solid var(--line); }
  .metric-label{ font-size:10.5px; color:var(--ink-faint); text-transform:uppercase; letter-spacing:0.5px; font-weight:600; }
  .metric-value{ font-family:'IBM Plex Mono', monospace; font-size:14px; margin-top:2px; }
  .countdown{ font-size:12.5px; color:var(--ink-soft); }
  .countdown b{ color:var(--ink); font-family:'IBM Plex Mono', monospace; }
  .card-note{ font-size:12px; color:var(--ink-soft); font-style:italic; line-height:1.4; border-top:1px dashed var(--line); padding-top:10px; }
  .card-open-btn{ background:none; border:1px solid var(--line-strong); color:var(--ink-soft); padding:8px 12px; border-radius:6px; font-size:12.5px; font-weight:600; cursor:pointer; width:100%; text-align:center; }
  .card-open-btn:hover{ border-color:var(--copper); color:var(--copper-deep); }

  .table-wrap{ background:var(--bg-card); border:1px solid var(--line); border-radius:6px; overflow:hidden; box-shadow:var(--shadow); }
  table{ width:100%; border-collapse:collapse; font-size:12.5px; }
  th{ text-align:left; font-size:10.5px; text-transform:uppercase; letter-spacing:0.5px; color:var(--ink-soft); font-weight:700; padding:12px 12px; background:rgba(42,33,24,0.035); border-bottom:1px solid var(--line-strong); white-space:nowrap; }
  td{ padding:10px 12px; border-bottom:1px solid var(--line); vertical-align:middle; }
  tr:last-child td{ border-bottom:none; }
  tbody tr:hover td{ background:rgba(181,96,42,0.045); }
  .mono{ font-family:'IBM Plex Mono', monospace; font-size:12.5px; }
  .table-empty{ padding:44px 20px; text-align:center; color:var(--ink-faint); font-size:13.5px; }
  .cell-strong{ font-weight:600; }

  .stock-bar{ width:100px; height:6px; border-radius:4px; background:rgba(42,33,24,0.1); overflow:hidden; display:inline-block; vertical-align:middle; margin-right:8px; }
  .stock-fill{ height:100%; border-radius:4px; }

  .stat-chip{ display:inline-flex; flex-direction:column; background:var(--bg-card); border:1px solid var(--line); border-radius:8px; padding:10px 16px; margin:0 10px 10px 0; box-shadow:var(--shadow); }
  .stat-chip .chip-value{ font-family:'IBM Plex Mono', monospace; font-weight:600; font-size:19px; color:var(--copper-deep); }
  .stat-chip .chip-label{ font-size:10px; text-transform:uppercase; letter-spacing:0.5px; color:var(--ink-soft); font-weight:600; margin-top:2px; }

  .foglio-tabs{ display:flex; gap:8px; margin-bottom:14px; flex-wrap:wrap; }
  .foglio-tab{ border:1px solid var(--line-strong); background:var(--bg-card); color:var(--ink-soft); padding:9px 14px; border-radius:20px; font-size:12.5px; font-weight:700; cursor:pointer; }
  .foglio-tab.active{ background:var(--green); border-color:var(--green); color:#fff; }
  .registro-print-head{ display:none; }

  .export-panel{ background:var(--bg-card); border:1px solid var(--line); border-radius:8px; padding:20px 22px; box-shadow:var(--shadow); max-width:640px; }
  .export-row{ display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-bottom:14px; }
  .export-actions{ display:flex; gap:10px; margin-top:6px; }
  pre.alcodc-preview{ margin-top:18px; background:#1E2A20; color:#D9E4CE; font-family:'IBM Plex Mono', monospace; font-size:11.5px; line-height:1.6; padding:16px; border-radius:6px; overflow-x:auto; max-height:280px; overflow-y:auto; white-space:pre; }
  .export-note{ font-size:11.5px; color:var(--ink-faint); margin-top:12px; line-height:1.5; }

  .field label{ display:block; font-size:11.5px; text-transform:uppercase; letter-spacing:0.6px; font-weight:600; color:var(--ink-soft); margin-bottom:6px; }
  .field input, .field select, .field textarea{ width:100%; border:1px solid var(--line-strong); border-radius:5px; padding:9px 10px; font-size:14px; background:#fff; color:var(--ink); }
  .field input:focus, .field select:focus, .field textarea:focus{ outline:2px solid var(--copper); outline-offset:1px; border-color:var(--copper); }
  .field-hint{ font-size:11px; color:var(--ink-faint); margin-top:5px; }
  .field input[disabled]{ background:rgba(42,33,24,0.05); color:var(--ink-soft); }
  textarea{ resize:vertical; min-height:56px; }
  .checkbox-row{ display:flex; align-items:center; gap:8px; font-size:12.5px; color:var(--ink-soft); }
  .checkbox-row input{ width:auto; }

  .overlay{ position:fixed; inset:0; background:rgba(42,33,24,0.45); display:none; align-items:flex-start; justify-content:center; padding:40px 16px; z-index:50; overflow-y:auto; }
  .overlay.open{ display:flex; }
  .modal{ background:var(--bg-card); border-radius:6px; width:100%; max-width:520px; box-shadow:0 20px 60px rgba(0,0,0,0.25); animation:rise .18s ease; }
  .modal-wide{ max-width:680px; }
  @keyframes rise{ from{ opacity:0; transform:translateY(10px);} to{ opacity:1; transform:translateY(0);} }
  .modal-head{ padding:20px 24px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:center; }
  .modal-head h2{ font-family:'Fraunces', serif; font-size:19px; font-weight:600; margin:0; }
  .modal-close{ background:none; border:none; font-size:20px; color:var(--ink-soft); cursor:pointer; line-height:1; padding:4px; }
  .modal-body{ padding:22px 24px; display:flex; flex-direction:column; gap:16px; max-height:76vh; overflow-y:auto; }
  .field-row{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
  .modal-foot{ padding:16px 24px 22px; display:flex; justify-content:flex-end; gap:10px; }
  .btn-secondary{ background:transparent; border:1px solid var(--line-strong); color:var(--ink-soft); padding:10px 16px; border-radius:6px; font-size:13.5px; font-weight:600; cursor:pointer; }
  .btn-primary{ background:var(--copper); border:none; color:#fff; padding:10px 18px; border-radius:6px; font-size:13.5px; font-weight:600; cursor:pointer; }
  .btn-primary:hover{ background:var(--copper-deep); }

  .timeline{ display:flex; flex-direction:column; margin-top:2px; }
  .timeline-item{ display:flex; gap:12px; padding:9px 0; border-bottom:1px dashed var(--line); }
  .timeline-item:last-child{ border-bottom:none; }
  .timeline-dot{ width:8px; height:8px; border-radius:50%; background:var(--juniper); margin-top:5px; flex-shrink:0; }
  .timeline-date{ font-family:'IBM Plex Mono', monospace; font-size:11.5px; color:var(--ink-faint); white-space:nowrap; }
  .timeline-label{ font-size:13px; font-weight:600; }

  .material-row{ display:grid; grid-template-columns:1fr 100px 32px; gap:8px; align-items:center; margin-bottom:8px; }
  .btn-icon{ background:none; border:1px solid var(--line-strong); color:var(--ink-soft); width:32px; height:32px; border-radius:5px; cursor:pointer; font-size:15px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
  .btn-icon:hover{ border-color:var(--copper); color:var(--copper); }
  .add-row-btn{ background:none; border:1px dashed var(--line-strong); color:var(--ink-soft); padding:8px 14px; border-radius:6px; font-size:12.5px; font-weight:600; cursor:pointer; width:100%; text-align:center; }
  .add-row-btn:hover{ border-color:var(--copper); color:var(--copper-deep); }

  .recipe-card{ background:var(--bg-card); border:1px solid var(--line); border-radius:8px; box-shadow:var(--shadow); padding:20px 22px; margin-bottom:20px; }
  .recipe-head{ display:flex; align-items:center; gap:10px; margin-bottom:16px; flex-wrap:wrap; }
  .recipe-swatch{ width:16px; height:16px; border-radius:4px; flex-shrink:0; }
  .recipe-name-input{ font-family:'Fraunces', serif; font-weight:600; font-size:17px; border:1px solid transparent; background:transparent; padding:4px 6px; border-radius:4px; min-width:140px; }
  .recipe-name-input:focus{ outline:none; border-color:var(--copper); background:#fff; }
  .recipe-sigla-input{ font-family:'IBM Plex Mono', monospace; font-weight:700; font-size:12px; width:58px; text-align:center; border:1px solid var(--line-strong); border-radius:4px; padding:6px; text-transform:uppercase; }
  .recipe-fields{ margin-left:auto; display:flex; gap:12px; flex-wrap:wrap; }
  .recipe-fields .field{ min-width:100px; }
  .recipe-fields .field input{ padding:7px 8px; font-size:13px; }
  .subsection-label{ font-size:11px; text-transform:uppercase; letter-spacing:0.5px; font-weight:700; color:var(--ink-soft); margin:16px 0 8px; }

  .mini-table{ width:100%; border-collapse:collapse; margin-bottom:8px; }
  .mini-table th{ font-size:10px; text-transform:uppercase; color:var(--ink-faint); font-weight:700; text-align:left; padding:2px 6px 6px; background:none; border:none; }
  .mini-table td{ padding:3px 6px; border:none; }
  .mini-table input, .mini-table select{ width:100%; border:1px solid var(--line-strong); border-radius:4px; padding:6px 8px; font-size:12.5px; background:#fff; }
  .mini-table input:disabled{ background:rgba(42,33,24,0.05); }

  .mobile-toggle{ display:none; align-items:center; gap:8px; margin:0 20px 8px; background:var(--green); color:#fff; border:none; padding:9px 14px; border-radius:6px; font-size:13px; font-weight:600; cursor:pointer; width:fit-content; }

  @media (max-width:900px){
    .sidebar{ position:fixed; z-index:40; transform:translateX(-100%); transition:transform .2s ease; box-shadow:0 0 40px rgba(0,0,0,0.3); }
    .sidebar.open{ transform:translateX(0); }
    .mobile-toggle{ display:flex !important; }
  }
  @media (max-width:640px){
    .section-header{ padding:20px 16px 8px; }
    .section-body{ padding:10px 16px 50px; }
    .field-row, .export-row{ grid-template-columns:1fr; }
    .stats{ flex-direction:column; gap:12px; }
    .stat{ border-left:none; padding-left:0; border-top:1px solid var(--line); padding-top:10px; }
    .stat:first-child{ border-top:none; padding-top:0; }
    .recipe-fields{ margin-left:0; }
  }
  @media print{
    .sidebar, .section-header .btn-new, .mobile-toggle, .foglio-tabs{ display:none !important; }
    .content-wrap{ margin:0; }
    body{ background:#fff; }
    .registro-print-head{ display:block; margin:0 0 16px; }
    .table-wrap{ box-shadow:none; border:1px solid #999; }
  }

/* ---------- Aggiunte per l'app server-side (form a pannello, alert) ---------- */
.panel-form{ display:flex; flex-direction:column; gap:16px; background:var(--bg-card); border:1px solid var(--line); border-radius:8px; padding:22px 24px; box-shadow:var(--shadow); }
.alert-error{ background:rgba(181,96,42,0.12); border:1px solid rgba(181,96,42,0.3); color:var(--copper-deep); padding:12px 16px; border-radius:6px; margin-bottom:16px; font-size:13.5px; font-weight:600; }
.alert-ok{ background:rgba(79,107,74,0.12); border:1px solid rgba(79,107,74,0.3); color:var(--juniper); padding:12px 16px; border-radius:6px; margin-bottom:16px; font-size:13.5px; font-weight:600; }
a.btn-secondary{ text-decoration:none; display:inline-flex; align-items:center; }
a.btn-primary{ text-decoration:none; display:inline-flex; align-items:center; }
a.btn-new{ text-decoration:none; display:inline-flex; align-items:center; }
a.btn-secondary-action{ text-decoration:none; display:inline-flex; align-items:center; }
a.card-open-btn{ text-decoration:none; }
a.foglio-tab{ text-decoration:none; }
a.subtab{ text-decoration:none; display:inline-flex; align-items:center; }

/* ---------- Link di modifica dati e link agenda ---------- */
.subsection-label{ display:flex; justify-content:space-between; align-items:center; gap:10px; }
.mini-edit-link{ font-size:11px; text-transform:none; letter-spacing:0; font-weight:600; color:var(--copper); text-decoration:none; white-space:nowrap; }
.mini-edit-link:hover{ text-decoration:underline; }
.ics-link{ font-size:12.5px; font-weight:600; color:var(--juniper); text-decoration:none; margin-left:4px; }
.ics-link:hover{ text-decoration:underline; }
