/* ---------- Base / resets ---------- */
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--text);
  font-family:Inter,system-ui,-apple-system,sans-serif;
  font-size:14px; line-height:1.5;
  -webkit-font-smoothing:antialiased;
  padding-bottom:env(safe-area-inset-bottom);
}
button{font-family:inherit; font-size:inherit; cursor:pointer}
input,select,textarea{font-family:inherit; font-size:14px}
::placeholder{color:var(--muted)}
a{color:var(--accent)}

/* ---------- Forms ---------- */
.form{
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-card); padding:14px; margin-bottom:16px;
}
.form-head{
  display:flex; align-items:center; justify-content:space-between;
  cursor:pointer; user-select:none;
}
.form-head h2{margin:0; font-size:14px; font-weight:600}
.form-head .chev{color:var(--muted); transition:transform .18s ease; font-size:12px}
.form.collapsed .chev{transform:rotate(-90deg)}
.form.collapsed .form-body{display:none}
.form-body{margin-top:12px; display:flex; flex-direction:column; gap:10px}
.field{display:flex; flex-direction:column; gap:5px}
.field > label{font-size:12px; color:var(--muted); font-weight:500}
.row{display:flex; gap:8px}
.row > .field{flex:1; min-width:0}

input[type=text], input[type=number], input[type=datetime-local], input[type=date],
input[type=time], input[type=password], select, textarea{
  width:100%; background:var(--card); border:1px solid var(--border);
  color:var(--text); padding:8px 10px; border-radius:var(--radius-input);
  appearance:none;
}
input[type=datetime-local]{min-height:36px}
textarea{resize:vertical; min-height:60px}
select{background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat:no-repeat; background-position:right 10px center; padding-right:30px}
input:focus-visible, select:focus-visible, textarea:focus-visible{
  outline:none; border-color:var(--accent); box-shadow:0 0 0 1px var(--accent)
}
.hint{font-size:11px; color:var(--muted)}

.note-toggle{
  align-self:flex-start; background:none; border:none; color:var(--muted);
  padding:2px 0; font-size:12px; font-weight:500;
}
.note-toggle:hover{color:var(--text)}
.note-wrap{display:none}
.note-wrap.open{display:block}

/* segmented toggle (unit pickers, ongoing) */
.seg{display:inline-flex; background:var(--card); border:1px solid var(--border); border-radius:var(--radius-input); padding:2px}
.seg button{
  background:none; border:none; color:var(--muted); padding:5px 12px;
  border-radius:4px; font-weight:500; font-size:13px;
}
.seg button.on{background:var(--border); color:var(--text)}

.check{display:flex; align-items:center; gap:8px; cursor:pointer; user-select:none}
.check input{width:16px; height:16px; accent-color:var(--accent)}

.btn{
  width:100%; border:none; border-radius:var(--radius-input);
  padding:10px 14px; font-weight:600; color:#0a0a0a; margin-top:2px;
  background:var(--accent);
  transition:filter .12s ease, transform .04s ease;
}
.btn:active{transform:translateY(1px)}
.btn:hover{filter:brightness(1.06)}
.btn:focus-visible{outline:2px solid var(--text); outline-offset:2px}
.btn-ghost{
  background:none; color:var(--muted); border:1px solid var(--border);
  width:auto; padding:8px 12px; margin-top:0;
}
.btn-ghost:hover{filter:none; color:var(--text); border-color:var(--muted)}
.edit-bar{display:none; align-items:center; gap:8px; margin-bottom:8px; font-size:12px; color:var(--amber)}
.edit-bar.show{display:flex}

/* ---------- Stat strip ---------- */
.stats{display:flex; gap:8px; margin-bottom:14px}
.stat{
  flex:1; min-width:0; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-card); padding:10px 11px;
}
.stat .k{font-size:11px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.stat .v{font-size:16px; font-weight:700; margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-variant-numeric:tabular-nums}

/* ---------- Log ---------- */
.log{display:flex; flex-direction:column; gap:8px}
.entry{
  background:var(--card); border:1px solid var(--border);
  border-radius:var(--radius-card); padding:11px 12px;
  display:flex; align-items:flex-start; gap:10px;
}
.entry.milestone{border-left:3px solid var(--teal)}
.entry .body{flex:1; min-width:0}
.entry .line1{display:flex; align-items:center; gap:8px; flex-wrap:wrap}
.entry .when{font-weight:600}
.entry .abs{color:var(--muted); font-size:12px}
.entry .meta{color:var(--muted); font-size:12.5px; margin-top:3px; word-break:break-word}
.entry .big{font-size:15px; font-weight:600}
.entry .actions{display:flex; gap:4px; flex-shrink:0}
.icon-btn{
  background:none; border:none; color:var(--muted); padding:4px;
  border-radius:5px; line-height:0; display:inline-flex;
}
.icon-btn:hover{color:var(--text); background:var(--surface)}
.icon-btn.danger:hover{color:var(--red)}
.icon-btn:focus-visible{outline:2px solid var(--accent); outline-offset:1px}
.icon-btn svg{width:15px; height:15px; stroke:currentColor; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round}
.confirm{display:flex; gap:6px; align-items:center}
.confirm .yes{background:var(--red); color:#0a0a0a; border:none; padding:5px 9px; border-radius:5px; font-weight:600; font-size:12px}
.confirm .no{background:none; color:var(--muted); border:1px solid var(--border); padding:5px 9px; border-radius:5px; font-size:12px}

.badge{
  display:inline-flex; align-items:center; gap:4px;
  font-size:11px; font-weight:600; padding:2px 7px; border-radius:var(--radius-badge);
  border:1px solid transparent;
}
.b-teal{background:rgba(45,212,191,.13); color:var(--teal); border-color:rgba(45,212,191,.25)}
.b-amber{background:rgba(245,158,11,.13); color:var(--amber); border-color:rgba(245,158,11,.25)}
.b-indigo{background:rgba(129,140,248,.14); color:var(--indigo); border-color:rgba(129,140,248,.28)}
.b-blue{background:rgba(96,165,250,.14); color:var(--blue); border-color:rgba(96,165,250,.28)}
.b-purple{background:rgba(167,139,250,.14); color:var(--purple); border-color:rgba(167,139,250,.28)}
.b-red{background:rgba(248,113,113,.13); color:var(--red); border-color:rgba(248,113,113,.25)}
.b-green{background:rgba(74,222,128,.13); color:var(--green); border-color:rgba(74,222,128,.25)}
.b-gray{background:var(--surface); color:var(--muted); border-color:var(--border)}

/* ---------- Empty state ---------- */
.empty{
  text-align:center; color:var(--muted); padding:34px 16px;
  background:var(--surface); border:1px dashed var(--border); border-radius:var(--radius-card);
}
.empty .e-ico{font-size:26px; opacity:.55}
.empty p{margin:8px 0 0; font-size:13px}

/* ---------- Export button ---------- */
.export{
  width:100%; background:none; color:var(--text); border:1px solid var(--border);
  border-radius:var(--radius-input); padding:11px; font-weight:600;
  display:flex; align-items:center; justify-content:center; gap:8px;
}
.export:hover{border-color:var(--muted)}
.export svg{width:15px; height:15px; stroke:currentColor; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round}
