:root{
  --bg: #1B2430;
  --surface: #232E3D;
  --surface-2: #2B3849;
  --border: #35455A;
  --text: #F1ECE2;
  --text-muted: #93A0B0;
  --amber: #E8A33D;
  --amber-dim: #7A5A28;
  --sage: #8FA888;
  --sage-dim: #4E5F49;
  --danger: #D97757;
  --radius-s: 8px;
  --radius-m: 14px;
  --font-display: "Fraunces", serif;
  --font-body: "Work Sans", sans-serif;
}

*{ box-sizing: border-box; }

html,body{
  margin:0;
  padding:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

button, input, select{
  font-family: inherit;
  color: inherit;
}

h1,h2,h3{
  font-family: var(--font-display);
  font-weight: 500;
  margin: 0;
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Lock screen ---------- */

.lock-screen{
  min-height: 100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 24px;
}

.lock-card{
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 32px 28px;
  text-align: left;
}

.lock-eyebrow{
  margin:0 0 4px;
  color: var(--amber);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.lock-title{
  font-size: 1.6rem;
  margin-bottom: 6px;
  line-height: 1.2;
}

.lock-sub{
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 0.92rem;
}

#lock-form{
  display:flex;
  flex-direction: column;
  gap: 12px;
}

#lock-input{
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 14px 14px;
  font-size: 1rem;
}

#lock-form button{
  background: var(--amber);
  color: #241804;
  border:none;
  border-radius: var(--radius-s);
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor:pointer;
}

.lock-error{
  color: var(--danger);
  margin: 14px 0 0;
  font-size: 0.88rem;
}

/* ---------- App shell ---------- */

.app{
  min-height: 100vh;
  display:flex;
  flex-direction: column;
}

.topbar{
  position: sticky;
  top:0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display:flex;
  flex-direction: column;
  gap: 14px;
}

.brand{
  display:flex;
  align-items:center;
  gap: 12px;
}

.brand-mark{
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink:0;
  background:
    radial-gradient(circle at 35% 35%, var(--amber) 0 40%, transparent 41%),
    conic-gradient(from 210deg, var(--sage) 0 50%, var(--surface-2) 0 100%);
}

.brand-name{
  margin:0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height:1.1;
}

.brand-sub{
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.tabs{
  display:flex;
  gap: 6px;
  overflow-x:auto;
}

.tab-btn{
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
  white-space: nowrap;
  cursor:pointer;
}

.tab-btn.is-active{
  background: var(--surface-2);
  border-color: var(--amber-dim);
  color: var(--text);
}

.content{
  flex:1;
  padding: 22px 20px 60px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel{ display:none; }
.tab-panel.is-active{ display:block; }

.panel-head{
  margin-bottom: 18px;
}

.panel-head h2{
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.panel-hint{
  color: var(--text-muted);
  margin:0;
  font-size: 0.92rem;
  max-width: 60ch;
}

.empty-state{
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-s);
  padding: 16px;
  font-size: 0.92rem;
}

/* ---------- Checklist ---------- */

.check-list{
  list-style:none;
  margin:0 0 20px;
  padding:0;
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.check-list li{
  display:flex;
  align-items:center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 16px;
}

.check-list input[type=checkbox]{
  width: 26px;
  height: 26px;
  flex-shrink:0;
  accent-color: var(--amber);
}

.check-list label{
  font-size: 1.02rem;
  flex:1;
}

.check-list li.is-checked{
  border-color: var(--amber-dim);
}

.check-list li.is-checked label{
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--amber-dim);
}

/* ---------- Sign box / forms ---------- */

.sign-box{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 18px;
  margin: 6px 0 20px;
}

.sign-row{
  display:flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.sign-row label{
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sign-row input, .lab-add input, .lab-add select, .manage-add input{
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 12px 12px;
  font-size: 1rem;
  width: 100%;
}

.btn{
  border:none;
  border-radius: var(--radius-s);
  padding: 14px 18px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor:pointer;
  width: 100%;
}

.btn-primary{
  background: var(--amber);
  color: #241804;
}

.btn-ghost{
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: auto;
  white-space: nowrap;
}

.form-msg{
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: var(--sage);
}

.form-msg.is-error{ color: var(--danger); }

/* ---------- History ---------- */

.history{ margin-top: 6px; }

.history-toggle{
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.92rem;
  padding: 8px 0;
  cursor: pointer;
  display:flex;
  align-items:center;
  gap: 6px;
}

.chev{ transition: transform 0.15s ease; }
.history-toggle.is-open .chev{ transform: rotate(180deg); }

.history-body{ padding-top: 6px; }

.record-list{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  flex-direction: column;
  gap: 10px;
}

.record-list li{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 14px;
}

.record-head{
  display:flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.record-head strong{ color: var(--text); font-weight: 600; }

.record-items{
  margin:0;
  padding-left: 18px;
  font-size: 0.94rem;
  display:flex;
  flex-direction: column;
  gap: 4px;
}

.record-items li{
  background: none;
  border:none;
  padding:0;
}

/* ---------- Laboratorio ---------- */

.lab-add{
  display:flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.lab-add select{ flex: 2; min-width: 160px; }
.lab-add input{ flex: 1; min-width: 100px; }

.cart-list{
  list-style:none;
  margin:0 0 20px;
  padding:0;
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.cart-list li{
  display:flex;
  justify-content: space-between;
  align-items:center;
  background: var(--surface);
  border: 1px solid var(--sage-dim);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  font-size: 0.96rem;
}

.cart-remove{
  background:none;
  border:none;
  color: var(--danger);
  font-size: 1.2rem;
  line-height:1;
  cursor:pointer;
  padding: 4px 8px;
}

/* ---------- Gestisci voci ---------- */

.manage-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 26px;
}

@media (min-width: 640px){
  .manage-grid{ grid-template-columns: 1fr 1fr; }
}

.manage-col h3{
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.manage-add{
  display:flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.manage-add input{ flex: 1; min-width: 100px; }
.manage-unit{ max-width: 140px; }

.manage-list{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.manage-list li{
  display:flex;
  justify-content: space-between;
  align-items:center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 10px 14px;
  font-size: 0.94rem;
}

.manage-list .item-remove{
  background:none;
  border:none;
  color: var(--danger);
  font-size: 1.2rem;
  cursor:pointer;
  padding: 4px 8px;
}

/* focus visibility */
button:focus-visible, input:focus-visible, select:focus-visible{
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
