:root {
  --primary: #1a73e8;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #202124;
  --text-muted: #5f6368;
  --border: #dadce0;
  --danger: #d93025;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
}

.hidden { display: none !important; }
.error { color: var(--danger); font-size: 0.9em; }

/* ---------- Login ---------- */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,.12);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.login-card h1 { margin: 0; font-size: 1.4em; color: var(--primary); }
.login-card p { margin: 0; color: var(--text-muted); }
.login-card input {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1em;
}
.login-card button {
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 1em;
  cursor: pointer;
}

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
}
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  z-index: 5;
}
.app-title {
  font-size: 1.15em;
  font-weight: 500;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
}
.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: 4px 8px 10px;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95em;
}
.sidebar li:hover { background: #f1f3f4; }
.sidebar li.active { background: #e8f0fe; color: var(--primary); font-weight: 500; }
.sidebar li .count { color: var(--text-muted); font-size: 0.85em; }

.content {
  overflow-y: auto;
  padding: 24px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.list-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.list-header h2 { margin: 0; font-size: 1.5em; font-weight: 400; flex: 1; }

.icon-btn {
  background: none;
  border: none;
  font-size: 1.1em;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 50%;
  line-height: 1;
}
.icon-btn:hover { background: #f1f3f4; }

/* ---------- Task form ---------- */
.task-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.task-form input {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1em;
  background: var(--surface);
}
.task-form input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.add-btn { align-self: center; color: var(--primary); font-size: 1.4em; }

.task-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.task-details input[type="date"],
.task-details input[type="datetime-local"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95em;
}
.task-details-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.task-details-row label {
  font-size: 0.9em;
  color: var(--text-muted);
  min-width: 80px;
}
.task-details textarea {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95em;
  resize: vertical;
}
.task-details-actions { display: flex; gap: 8px; justify-content: flex-end; }
.task-details-actions button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.9em;
}
.task-details-actions button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Tasks ---------- */
.tasks { list-style: none; margin: 12px 0 0; padding: 0; }
.task {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: box-shadow .15s;
}
.task:hover { box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.task .check {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  margin-top: 2px;
  background: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: transparent;
}
.task .check:hover { border-color: var(--primary); color: var(--primary); }
.task.completed .check { background: var(--primary); border-color: var(--primary); color: #fff; }
.task.completed .task-title { text-decoration: line-through; color: var(--text-muted); }
.task .body { flex: 1; cursor: pointer; }
.task .task-title { font-size: 1em; word-break: break-word; }
.task .task-meta { font-size: 0.8em; color: var(--text-muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.task .task-meta .overdue { color: var(--danger); font-weight: 500; }
.task .task-notes-preview { font-size: 0.85em; color: var(--text-muted); margin-top: 4px; white-space: pre-wrap; }
.task .delete-btn { visibility: hidden; }
.task:hover .delete-btn { visibility: visible; }
.task .delete-btn:hover { color: var(--danger); }

.subtasks { list-style: none; margin: 10px 0 0; padding: 0 0 0 6px; border-left: 2px solid var(--border); }
.subtasks .task { border: none; box-shadow: none; padding: 6px 0 6px 10px; margin-bottom: 4px; background: transparent; }
.add-subtask-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85em;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 4px;
}
.add-subtask-btn:hover { color: var(--primary); }

.empty { text-align: center; color: var(--text-muted); margin-top: 48px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9em;
  z-index: 50;
}

.prompt-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 24px;
  min-width: 300px;
}
.prompt-dialog::backdrop { background: rgba(0,0,0,.4); }
.prompt-dialog label { display: block; margin-bottom: 8px; font-weight: 500; }
.prompt-dialog input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1em;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-actions button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.dialog-actions button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Mobile ---------- */
#btn-menu { display: none; }
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  #btn-menu { display: inline-block; }
  .sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    width: 280px;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform .2s;
    box-shadow: 2px 0 8px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 16px; }
  .task .delete-btn { visibility: visible; }
}
