/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f1f5f9;
  --surface:  #ffffff;
  --border:   #e2e8f0;
  --text:     #0f172a;
  --muted:    #64748b;
  --accent:   #2563eb;
  --accent-h: #1d4ed8;
  --success:  #16a34a;
  --danger:   #dc2626;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --nav-h:    64px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
}

button   { font: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font: inherit; }
textarea { resize: vertical; }

/* ── Login page ──────────────────────────────────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.login-card img { margin-bottom: 4px; }

.login-card h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

#login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#login-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  text-align: center;
  outline: none;
  background: var(--bg);
  transition: border-color .15s;
}
#login-form input:focus { border-color: var(--accent); background: #fff; }

#login-form button {
  background: var(--accent);
  color: #fff;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  transition: background .15s;
}
#login-form button:hover     { background: var(--accent-h); }
#login-form button:disabled  { opacity: .6; cursor: not-allowed; }

.error-msg { color: var(--danger); font-size: .85rem; }

/* ── App layout ──────────────────────────────────────────────────────────────── */
body:not(.login-page) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.app-header {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.app-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-h) + 8px);
}

.tab-pane        { display: none; padding: 16px; }
.tab-pane.active { display: block; }

/* ── Bottom nav ──────────────────────────────────────────────────────────────── */
.bottom-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 500;
  transition: color .15s;
}
.nav-tab.active     { color: var(--accent); }
.nav-tab.active svg { transform: scale(1.1); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: .9rem;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-h); }

.btn-ghost {
  color: var(--muted);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: .9rem;
  transition: background .15s;
}
.btn-ghost:hover { background: var(--bg); }

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.btn-icon:hover        { background: var(--bg); color: var(--text); }
.btn-icon.danger:hover { background: #fee2e2; color: var(--danger); }

/* ── Shared ──────────────────────────────────────────────────────────────────── */
.tab-actions { margin-bottom: 16px; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 24px;
  font-size: .95rem;
  line-height: 1.6;
}

/* ── Today tab ───────────────────────────────────────────────────────────────── */
.today-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}
.date-display     { font-size: 1rem; font-weight: 600; }
.progress-display { font-size: .85rem; color: var(--muted); }

.tracks-list { display: flex; flex-direction: column; gap: 20px; }

.category-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.track-cards { display: flex; flex-direction: column; gap: 2px; }

.track-row {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.track-row:first-child { border-radius: 10px 10px 4px 4px; }
.track-row:last-child  { border-radius: 4px 4px 10px 10px; }
.track-row:only-child  { border-radius: 10px; }

.track-main {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.track-main:active { background: var(--bg); }

.track-checkbox-wrap { flex-shrink: 0; }

.track-checkbox {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background: var(--surface);
  transition: background .15s, border-color .15s;
  position: relative;
  display: block;
}
.track-checkbox:checked { background: var(--success); border-color: var(--success); }
.track-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px; top: 2px;
  width: 7px; height: 11px;
  border: 2px solid white;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}

.obj-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.track-text {
  flex: 1;
  font-size: .9rem;
  line-height: 1.35;
  word-break: break-word;
}
.track-row.achieved .track-text { color: var(--muted); text-decoration: line-through; }

.expand-arrow {
  flex-shrink: 0;
  color: var(--muted);
  font-size: .75rem;
  transition: transform .2s;
}
.track-row.expanded .expand-arrow { transform: rotate(180deg); }

.track-note-area {
  display: none;
  padding: 0 14px 12px;
  border-top: 1px solid var(--border);
}
.track-row.expanded .track-note-area { display: block; }

.track-note-area textarea {
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .85rem;
  line-height: 1.5;
  background: var(--bg);
  outline: none;
  transition: border-color .15s;
}
.track-note-area textarea:focus { border-color: var(--accent); background: #fff; }

/* ── Objectives tab ──────────────────────────────────────────────────────────── */
.objectives-list { display: flex; flex-direction: column; gap: 20px; }
.obj-cards       { display: flex; flex-direction: column; gap: 2px; }

.obj-row {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 10px;
}
.obj-row:first-child { border-radius: 10px 10px 4px 4px; }
.obj-row:last-child  { border-radius: 4px 4px 10px 10px; }
.obj-row:only-child  { border-radius: 10px; }

.obj-info    { flex: 1; min-width: 0; }
.obj-name    { font-size: .9rem; word-break: break-word; }
.obj-actions { display: flex; gap: 4px; flex-shrink: 0; }

.color-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 2px; }

.color-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.color-swatch:hover    { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); transform: scale(1.1); }

/* ── Concerns tab ────────────────────────────────────────────────────────────── */
.concerns-list { display: flex; flex-direction: column; gap: 8px; }

.concern-row {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: opacity .2s;
}
.concern-row.resolved { opacity: .45; }

.priority-badge {
  flex-shrink: 0;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 4px;
  margin-top: 1px;
}
.priority-badge.high   { background: #fee2e2; color: #991b1b; }
.priority-badge.medium { background: #fef3c7; color: #92400e; }
.priority-badge.low    { background: #dcfce7; color: #166534; }

.concern-text {
  flex: 1;
  font-size: .9rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}
.concern-row.resolved .concern-text { text-decoration: line-through; color: var(--muted); }
.concern-actions    { display: flex; gap: 4px; flex-shrink: 0; }
.resolved-toggle-wrap { margin-top: 16px; text-align: center; }

/* ── Modals ──────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

@media (min-width: 480px) {
  .modal-backdrop { align-items: center; padding: 24px; }
}

.modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 28px 20px 36px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 90dvh;
  overflow-y: auto;
}

@media (min-width: 480px) {
  .modal { border-radius: 16px; padding: 28px 24px; }
}

.modal h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; }

.modal label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: -6px;
}

.modal input[type="text"],
.modal input[type="time"],
.modal textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  outline: none;
  background: var(--bg);
  transition: border-color .15s;
}
.modal input:focus, .modal textarea:focus { border-color: var(--accent); background: #fff; }

.modal-hint { font-size: .85rem; color: var(--muted); margin-top: -4px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.priority-group { display: flex; gap: 8px; }

.priority-btn {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  transition: all .15s;
}
.priority-btn.active[data-p="low"]    { border-color: #16a34a; background: #dcfce7; color: #166534; }
.priority-btn.active[data-p="medium"] { border-color: #d97706; background: #fef3c7; color: #92400e; }
.priority-btn.active[data-p="high"]   { border-color: #dc2626; background: #fee2e2; color: #991b1b; }

.notif-status {
  font-size: .85rem;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  line-height: 1.4;
}
.notif-status.ok     { color: var(--success); }
.notif-status.denied { color: var(--danger); }

.tz-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: .75rem;
}
