:root {
  color-scheme: light;
  --bg: #eef6f0;
  --surface: #ffffff;
  --surface-2: #f2f8f3;
  --border: #d6e6da;
  --text: #13241a;
  --text-2: #475a4d;
  --muted: #6b7f71;
  --ink: #1b7f45;
  --ink-text: #ffffff;
  --accent: #2fa35f;
  --accent-soft: #dcf0e2;
  --good: #1b7f45;
  --good-soft: #e1f3e7;
  --warn: #a8510a;
  --warn-soft: #fbeadb;
  --danger: #b42318;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(19, 60, 35, .05), 0 2px 10px rgba(19, 60, 35, .05);
  --nav-h: 0px;
}

* { box-sizing: border-box; }
/* overscroll-behavior-x: fara „inapoi” al browserului la glisare orizontala (glisarea schimba ziua) */
html, body { overscroll-behavior-x: none; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--nav-h) + 24px);
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- butoane & campuri ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 500;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.btn.primary:hover { filter: brightness(1.15); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; padding: 11px; }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}
textarea { resize: vertical; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); font-weight: 500; }
label.tick { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text); font-weight: 400; min-height: 32px; }
label.tick input { width: 20px; height: 20px; accent-color: var(--ink); flex: none; }
.error { color: var(--danger); font-size: 13px; margin: 0; min-height: 1em; }
.error:empty { display: none; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}
.login-card .brand { margin-bottom: 8px; }

/* ---------- antet ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 34px; height: 34px; flex: none; }
.brand strong { display: block; font-size: 16px; line-height: 1.1; }
.brand span { display: block; font-size: 12px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.top {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, calc((100vw - 1180px) / 2), env(safe-area-inset-right)) 10px max(16px, calc((100vw - 1180px) / 2), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0;
  background: transparent;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
}
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.count:not(:empty) {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 2px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 18px;
}
.me {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 4px 10px 4px 4px;
  border-radius: 20px;
  font-weight: 600;
}
.me:hover { background: var(--surface-2); }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--ink-text);
  font-size: 14px;
  font-weight: 700;
}

main, .goals, .banner { max-width: 1180px; margin-left: auto; margin-right: auto; }
main, .goals { padding: 0 16px; }

/* ---------- bannere ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  margin-left: max(16px, calc((100vw - 1180px) / 2 + 16px));
  margin-right: max(16px, calc((100vw - 1180px) / 2 + 16px));
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 14px;
}
.banner span { flex: 1; }
.banner .logo { width: 28px; height: 28px; flex: none; }
.banner.warn { background: var(--warn-soft); color: var(--warn); font-weight: 500; }

/* ---------- teluri ---------- */
.goals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  padding-top: 18px;
}
.goal {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  align-content: start;
  box-shadow: var(--shadow);
}
.goal:hover { border-color: var(--accent); }
.goal-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.goal-title { font-weight: 600; }
.goal-pct { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 18px; }
.goal-meta { font-size: 12.5px; color: var(--muted); }
.goal.add {
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  box-shadow: none;
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  min-height: 84px;
}
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .4s; }
.bar.full > span { background: var(--good); }

/* ---------- bara de unelte ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 22px 0 12px; }
.toolbar h2 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.toolbar .spacer { flex: 1; }
.daynav { display: flex; align-items: center; gap: 6px; }
.daynav .btn { width: 40px; height: 40px; padding: 0; font-size: 20px; line-height: 1; }
.daytitle { display: flex; align-items: baseline; gap: 8px; margin: 0 4px; }
.daytitle h2::first-letter { text-transform: uppercase; }
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  white-space: nowrap;
}
.summary { color: var(--text-2); font-size: 14px; margin: -4px 0 10px; }
.note { color: var(--text-2); font-size: 14px; margin: 0 0 12px; }
.date-pick { position: relative; width: 40px; height: 40px; padding: 0; overflow: hidden; display: grid; place-items: center; }
.date-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.date-pick input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

/* filtre ca butoane-pastila */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; margin-bottom: 10px; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  padding: 5px 12px;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-2);
}
.chips button.on { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }

/* ---------- formular adaugare (birou) ---------- */
.add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 150px auto;
  gap: 8px;
  margin-bottom: 12px;
}

/* ---------- lista de taskuri ---------- */
.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.list.slide-l { animation: slide-l .22s ease-out; }
.list.slide-r { animation: slide-r .22s ease-out; }
@keyframes slide-l { from { transform: translateX(28px); opacity: .4; } }
@keyframes slide-r { from { transform: translateX(-28px); opacity: .4; } }
.list-head, .row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 14px 10px 6px;
}
.list-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: var(--surface-2);
  padding-top: 8px;
  padding-bottom: 8px;
}
.row { border-top: 1px solid var(--border); align-items: start; }
.list-head + .row { border-top: 0; }
.section-label {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.list-head + .section-label { border-top: 0; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

.check {
  width: 44px;
  height: 44px;
  margin: -8px auto 0;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  padding: 0;
}
.check span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  transition: background .15s, border-color .15s;
}
.check:hover span { border-color: var(--good); color: var(--good); }
.row.done .check span { background: var(--good); border-color: var(--good); color: #fff; }
.row.done-later .check span { border-color: var(--good); color: var(--good); }

.task { min-width: 0; }
.task .title {
  display: block;
  width: 100%;
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.task .title:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.row.done .task .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.chip {
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip.owner { font-weight: 600; color: var(--text); }
.chip.carried { background: var(--accent-soft); color: var(--text); }
.chip.carried.hot { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.chip.discuss { background: transparent; box-shadow: inset 0 0 0 1px var(--accent); color: var(--text); }
.chip.solved { background: var(--good-soft); color: var(--good); }
button.chip { border: 0; cursor: pointer; font-weight: 600; background: var(--ink); color: var(--ink-text); padding: 3px 10px; }

.sol { min-width: 0; font-size: 14px; }
.sol-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.sol-by { margin-top: 4px; font-size: 12px; color: var(--good); font-weight: 500; }
.idea {
  display: block;
  width: calc(100% + 16px);
  border-color: transparent;
  background: transparent;
  resize: none;
  padding: 3px 8px;
  margin: -3px -8px;
  line-height: 1.45;
  min-height: 30px;
  overflow: hidden;
}
.idea:hover { background: var(--surface-2); }
.idea:focus { background: var(--surface); border-color: var(--accent); }
.idea::placeholder { color: var(--muted); opacity: .8; }
.idea.saved { box-shadow: inset 0 0 0 1px var(--good); }

/* ---------- evolutie ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.tile .k { font-size: 12.5px; color: var(--muted); }
.tile .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .s { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel h3 { margin: 0 0 4px; font-size: 15px; }
.panel .note { margin-bottom: 8px; }
.chart-box { position: relative; height: 300px; }
.chart-box.small { height: 180px; }
details summary { cursor: pointer; color: var(--text-2); font-size: 14px; margin-top: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 8px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-weight: 600; }

/* ---------- dialog / foaie ---------- */
dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(10, 10, 10, .45); }
#dlg-form { display: grid; gap: 14px; padding: 20px; max-height: calc(100dvh - 60px); overflow-y: auto; overscroll-behavior: contain; }
#dlg-form h3 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
#dlg-form h4 { margin: 4px 0 -4px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
#dlg-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#dlg-form .info { font-size: 12.5px; color: var(--muted); margin: -6px 0 0; }
#dlg-form .hint { font-size: 13.5px; color: var(--text-2); margin: 0; }
.grip { display: none; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 4px; }
.actions .left { margin-right: auto; }
.kinds { display: flex; gap: 8px; }
.kinds label { flex: 1; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-weight: 400; cursor: pointer; }
.kinds label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.kinds small { display: block; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { display: block; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 6px 13px;
  font-size: 14px;
  color: var(--text-2);
  font-weight: 500;
  cursor: pointer;
}
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.goal-tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.goal-tasks li { display: flex; gap: 8px; }
.goal-tasks li.done { color: var(--muted); text-decoration: line-through; }
.history { font-size: 13px; color: var(--text-2); }
.box { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 20px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--ink-text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 50;
  max-width: calc(100vw - 32px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.toast.err { background: var(--danger); color: #fff; }

.fab, .bottomnav { display: none; }

/* ---------- telefon ---------- */
@media (max-width: 760px) {
  :root { --nav-h: calc(64px + env(safe-area-inset-bottom)); }
  body { font-size: 16px; }
  input, select, textarea { font-size: 16px; } /* sub 16px iOS face zoom la atingere */

  .top { gap: 10px; padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: 8px; }
  .top .brand { flex: 1; }
  .brand .logo { width: 30px; height: 30px; }
  .tabs { display: none; }
  .me #me { display: none; }
  .me { padding: 4px; }
  .avatar { width: 34px; height: 34px; }

  .bottomnav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .bottomnav button {
    position: relative;
    border: 0;
    background: none;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    height: 64px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--muted);
  }
  .bottomnav .ic { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 15px; transition: background .15s; }
  .bottomnav svg { width: 22px; height: 22px; }
  .bottomnav button.active { color: var(--text); font-weight: 600; }
  .bottomnav button.active .ic { background: var(--accent-soft); }
  .bottomnav .count:not(:empty) { position: absolute; top: 5px; left: calc(50% + 8px); margin: 0; background: var(--ink); color: var(--ink-text); font-size: 11px; min-width: 18px; line-height: 17px; }

  .fab {
    display: grid;
    place-items: center;
    position: fixed;
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(var(--nav-h) + 16px);
    z-index: 19;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    border: 0;
    background: var(--ink);
    color: var(--ink-text);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
  }
  .fab[hidden] { display: none; }
  body { padding-bottom: calc(var(--nav-h) + 90px); }

  /* telurile: banda orizontala care se gliseaza */
  .goals {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding: 12px 16px 2px;
    gap: 8px;
    scroll-padding: 0 16px;
  }
  .goals::-webkit-scrollbar { display: none; }
  .goal { flex: 0 0 78%; scroll-snap-align: start; padding: 10px 12px; gap: 6px; }
  .goal-title { font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
  .goal-pct { font-size: 16px; }
  .goal.add { flex: 0 0 auto; min-height: 0; padding: 10px 18px; }

  .toolbar { margin: 14px 0 8px; gap: 8px; }
  .toolbar h2 { font-size: 19px; }
  .toolbar.day { display: grid; grid-template-columns: 44px 1fr 44px 44px; align-items: center; }
  .toolbar.day .daynav { display: contents; }
  .toolbar.day [data-action="prev"] { grid-column: 1; grid-row: 1; }
  .toolbar.day .daytitle { grid-column: 2; grid-row: 1; justify-content: center; flex-wrap: wrap; text-align: center; margin: 0; column-gap: 6px; row-gap: 0; }
  .toolbar.day [data-action="next"] { grid-column: 3; grid-row: 1; }
  .toolbar.day .date-pick { grid-column: 4; grid-row: 1; }
  .toolbar.day .daytitle h2 { font-size: 17px; }
  .toolbar.day .spacer, .toolbar.day .back-today { display: none; }
  .daynav .btn, .date-pick { width: 44px; height: 44px; }
  .chips { margin: 0 -16px 10px; padding: 2px 16px; }
  .chips button { padding: 7px 14px; font-size: 14px; }
  .summary { font-size: 13.5px; margin: 0 0 10px; }
  .note { font-size: 13.5px; }

  .add { display: none; }
  .list { border-radius: 14px; touch-action: pan-y pinch-zoom; }
  .list-head { display: none; }
  .row { grid-template-columns: 44px minmax(0, 1fr); gap: 4px 8px; padding: 12px 14px 12px 4px; }
  .row .sol { grid-column: 2; }
  .check { margin-top: -9px; }
  .task .title { font-size: 16px; }
  .chip { font-size: 12.5px; padding: 2px 8px; }
  .sol { font-size: 15px; }
  .idea { margin: 2px -8px -3px; min-height: 36px; }

  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile .v { font-size: 22px; }
  .chart-box { height: 240px; }

  /* dialogurile urca de jos, ca foile din aplicatiile de telefon */
  dialog {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border: 0;
    border-radius: 18px 18px 0 0;
    max-height: 92dvh;
  }
  dialog[open] { animation: sheet-up .22s ease-out; }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } }
  #dlg-form { padding: 6px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 92dvh; gap: 12px; }
  .grip { display: block; width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 4px auto 2px; }
  #dlg-form .row2 { grid-template-columns: 1fr; }
  .actions { flex-wrap: wrap; }
  .actions .btn.primary { flex: 1 1 100%; order: -1; padding: 13px; font-size: 16px; }
  .actions .btn:not(.primary) { flex: 1; padding: 11px; }
  .actions .left { margin-right: 0; }
  .kinds { flex-direction: column; }
  .seg span { padding: 8px 14px; font-size: 15px; }

  .banner { margin-top: 10px; font-size: 13.5px; }
}

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