* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f0f4f2;
  color: #222;
  min-height: 100vh;
}

/* --- Login --- */
.auth-card {
  max-width: 400px;
  margin: 10vh auto 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  padding: 32px 28px;
}

.auth-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.subtitle { color: #667; margin-bottom: 20px; font-size: .95rem; }

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .9rem; }

input[type="email"], input[type="text"] {
  width: 100%;
  padding: 12px;
  font-size: 1.05rem;
  border: 1px solid #cbd5d0;
  border-radius: 8px;
  margin-bottom: 14px;
}

input:focus { outline: 2px solid #2c7a5b; border-color: transparent; }

.code-input {
  font-size: 1.6rem;
  letter-spacing: 10px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

button[type="submit"]:not(.link-btn) {
  width: 100%;
  padding: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  background: #2c7a5b;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

button[type="submit"]:not(.link-btn):hover { background: #256a4e; }

.link-btn {
  background: none;
  border: none;
  color: #2c7a5b;
  cursor: pointer;
  font-size: .9rem;
  text-decoration: underline;
  padding: 0;
}

.resend { margin-top: 14px; text-align: center; }
.back { margin-top: 10px; text-align: center; font-size: .9rem; }
.back a { color: #667; }

.msg {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: .92rem;
}
.msg-error { background: #fdecea; color: #a33; }
.msg-info { background: #e8f4ee; color: #1e5c43; }

/* --- Dashboard --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #2c7a5b;
  color: #fff;
  padding: 12px 20px;
  font-weight: 600;
}
.topbar .link-btn { color: #d7ece2; }

.content { max-width: 720px; margin: 24px auto; padding: 0 16px 40px; }
.content h1 { font-size: 1.5rem; margin-bottom: 12px; }
.content p { margin-bottom: 10px; line-height: 1.5; }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-btn {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
}
.topbar-btn:hover { background: rgba(255,255,255,.25); }

.date-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.5rem; font-weight: 700; color: #222;
  padding: 0; display: flex; align-items: center; gap: 8px;
}
select.date-btn { max-width: 100%; font-size: 1.3rem; }
.date-btn:hover { color: #2c7a5b; }
.date-caret { font-size: 1.1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.settings-list { list-style: none; }
.settings-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 6px; border-bottom: 1px solid #f0f0f0; font-size: .95rem;
}
.settings-list li:last-child { border-bottom: none; }
.settings-list li span { flex: 1; }
#clock { font-variant-numeric: tabular-nums; font-weight: 400; }

.day-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 10px;
}

.marker-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.marker { display: flex; align-items: center; gap: 8px; }
.marker-time { font-size: .9rem; color: #445; font-variant-numeric: tabular-nums; }
.day-head h1 { margin: 0; }
.day-since { color: #667; font-size: .9rem; flex: 1; }

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 1.1rem; margin-bottom: 12px; }
.card h2 .pdf-link {
  float: right;
  font-size: .8rem;
  font-weight: 600;
  color: #2c7a5b;
  text-decoration: none;
  border: 1px solid #2c7a5b;
  border-radius: 6px;
  padding: 2px 8px;
}
.card h2 .pdf-link:hover { background: #2c7a5b; color: #fff; }
.card-lock { border-left: 5px solid #d9822b; background: #fdf6ee; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-sm { padding: 7px 12px; font-size: .88rem; }
.btn-primary { background: #2c7a5b; color: #fff; }
.btn-primary:hover { background: #256a4e; }
.btn-dark { background: #37474f; color: #fff; }
.btn-outline { background: #fff; color: #2c7a5b; border: 1.5px solid #2c7a5b; }
.btn-danger { background: #fff; color: #a33; border: 1.5px solid #c66; }
.btn-danger:hover { background: #fdecea; }
.btn-red {
  background: #c0392b;
  border-color: #c0392b;
  color: #fff;
  animation: pulse-btn 2.5s ease-in-out infinite;
}
@keyframes pulse-btn {
  0%, 100% { background: #c0392b; border-color: #c0392b; }
  50% { background: #e74c3c; border-color: #e74c3c; }
}
.btn-outline:hover { background: #e8f4ee; }

.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 4px 6px 4px 0; flex-wrap: wrap; }
.input-sm { width: 90px; padding: 8px; border: 1px solid #cbd5d0; border-radius: 8px; font-size: .95rem; }
.rest-group { display: inline-flex; align-items: center; gap: 4px; }
.btn-icon { padding: 7px 9px; font-size: .95rem; line-height: 1; }
.input-md { width: 220px; padding: 8px; border: 1px solid #cbd5d0; border-radius: 8px; font-size: .95rem; }
select { padding: 8px; border: 1px solid #cbd5d0; border-radius: 8px; font-size: .95rem; }

.todo-list { list-style: none; }
.todo-list li { padding: 7px 8px; border-bottom: 1px solid #f0f0f0; border-radius: 6px; }
.todo-list li:last-child { border-bottom: none; }
.todo-icon { margin-right: 6px; }

.todo-list li.sev-warn { background: #fdf6ee; }
.todo-list li.sev-crit {
  font-weight: 600;
  color: #8a1f11;
  animation: pulse-red 2.5s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { background: #fdecea; }
  50% { background: #f5b7b0; }
}

.live-dot { color: #2c7a5b; font-size: .7rem; vertical-align: middle; }

.sticky-todo {
  position: sticky;
  top: 8px;
  z-index: 40;
  box-shadow: 0 4px 16px rgba(0,0,0,.14);
  border: 1px solid #e0e8e4;
}
.sticky-todo[hidden] { display: none; }

/* --- Chronik --- */
.timeline { list-style: none; }
.timeline li {
  display: flex; gap: 10px; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid #f0f0f0; font-size: .93rem;
}
.timeline li:last-child { border-bottom: none; }
.tl-time { font-weight: 700; min-width: 46px; font-variant-numeric: tabular-nums; color: #445; }
.tl-text { color: #223; flex: 1; }
.tl-edit { font-size: 1.05rem; text-decoration: none; }

/* --- FAB + Modal --- */
.fab {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 60;
  background: #2c7a5b; color: #fff;
  border: none; border-radius: 999px;
  padding: 14px 22px;
  font-size: 1.05rem; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  cursor: pointer;
}
.fab:hover { background: #256a4e; }

.modal {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(20, 30, 25, .5);
  display: flex; align-items: center; justify-content: center;
}
.modal[hidden] { display: none; }
.modal-open { overflow: hidden; }

.modal-inner {
  background: #fff;
  border-radius: 14px;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 18px 20px 24px;
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.modal-head h2 { flex: 1; text-align: center; font-size: 1.15rem; }
.modal-close, .modal-back { font-size: 1rem; text-decoration: none; }

.modal-menu[hidden] { display: none; }
.modal-menu {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.menu-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: #f4f8f6; border: 1.5px solid #dbe6e0; border-radius: 12px;
  padding: 18px 8px; font-size: 1.7rem; cursor: pointer;
}
.menu-btn span { font-size: .88rem; font-weight: 600; color: #234; line-height: 1.25; }
.menu-btn:hover { background: #e8f4ee; border-color: #2c7a5b; }

.pane-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.pane-form label { font-weight: 600; font-size: .88rem; margin-top: 4px; }
.pane-form input, .pane-form select, .pane-form textarea { padding: 11px; font-size: 1rem; border: 1px solid #cbd5d0; border-radius: 8px; width: 100%; font-family: inherit; }
.pane-form .btn { margin-top: 6px; }
.check-list { display: flex; flex-direction: column; gap: 2px; }
.check-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  font-weight: 400; font-size: .97rem;
}
.check-row:hover { background: #f4f8f6; }
.check-row input[type="checkbox"] { width: auto; transform: scale(1.3); }
.check-row:has(input:checked) { background: #e8f4ee; }
.quick-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quick-row form { flex: 1; }
.quick-row .btn { width: 100%; }
.quick-row input { flex: 1 1 50%; width: auto; min-width: 0; }

@media (max-width: 600px) {
  .modal { align-items: stretch; justify-content: stretch; }
  .modal-inner {
    width: 100vw; max-height: none; height: 100%;
    border-radius: 0;
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
  .fab { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
}
.all-done { color: #1e5c43; font-weight: 600; }

.progress {
  position: relative;
  background: #e4ece8;
  border-radius: 10px;
  height: 30px;
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-bar { background: #2c7a5b; height: 100%; transition: width .3s; }
.progress-bar.behind { background: #d9822b; }
.progress-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .9rem; color: #143;
}
.drink-stats { font-size: .95rem; }
.ok { color: #1e5c43; }
.warn { color: #b3541e; }

.bottle-current, .bottle-new {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid #f0f0f0;
}

.med-list { list-style: none; }
.med-list li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 6px; border-bottom: 1px solid #f0f0f0;
}
.med-list li:last-child { border-bottom: none; }
.med-list li.due { background: #fdf6ee; border-radius: 6px; }
.med-list li.taken { opacity: .65; }
.med-time { font-weight: 700; min-width: 52px; font-variant-numeric: tabular-nums; }
.med-name { flex: 1; min-width: 180px; }
.med-ok { color: #1e5c43; font-weight: 600; }

.hint { color: #778; font-size: .88rem; }
.hint-inline { color: #889; font-size: .84rem; font-weight: 400; }

.entry-list { list-style: none; margin-top: 10px; font-size: .92rem; }
.entry-list li { padding: 4px 0; color: #445; }

.retro { margin-top: 12px; font-size: .92rem; }
.inline-details { display: inline-block; margin: 0 0 0 6px; }
.time-sm { padding: 6px; border: 1px solid #cbd5d0; border-radius: 8px; font-size: .85rem; }
input[type="time"] { padding: 8px; border: 1px solid #cbd5d0; border-radius: 8px; }
.retro summary { cursor: pointer; color: #2c7a5b; }
.retro-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.retro-form input[type="date"], .retro-form input[type="time"] {
  padding: 8px; border: 1px solid #cbd5d0; border-radius: 8px;
}

@media (max-width: 480px) {
  .card { padding: 14px; }
  .input-md { width: 100%; }
}
