:root {
  --bg: #f6f7f9;
  --sidebar-bg: #fbfbfc;
  --surface: #ffffff;
  --border: #e7e8ea;
  --hover: #f0f1f3;
  --text: #1b1d1f;
  --text-muted: #7c828c;
  --accent: #2f6ff3;
  --accent-hover: #1f5bd1;
  --accent-soft: #e8f0fe;
  --p1: #d1453b;
  --p2: #eb8909;
  --p3: #246fe0;
  --danger: #d1453b;
  --overdue: #d1453b;
  --money-in: #0e9d8b;
  --money-out: #d64545;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 3px 12px rgba(0, 0, 0, 0.07);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 16px 50px rgba(0, 0, 0, 0.22);
  --shadow-sidebar: 1px 0 0 var(--border), 3px 0 16px rgba(0, 0, 0, 0.06);
}

:root[data-theme="dark"] {
  --bg: #151617;
  --sidebar-bg: #1c1d1f;
  --surface: #232427;
  --border: #33353a;
  --hover: #2a2c30;
  --text: #e8e8e8;
  --text-muted: #9aa0a6;
  --accent: #5b8ef7;
  --accent-hover: #7aa3fa;
  --accent-soft: #1a2940;
  --danger: #ef6a5c;
  --overdue: #ef6a5c;
  --money-in: #3fd0b8;
  --money-out: #f0716a;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 3px 12px rgba(0, 0, 0, 0.28);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 50px rgba(0, 0, 0, 0.6);
  --shadow-sidebar: 1px 0 0 var(--border), 3px 0 16px rgba(0, 0, 0, 0.45);
}

/* Themed, low-attention section wallpapers (dark) */
:root[data-theme="dark"] .main:has(#module-dashboard:not(.hidden)) {
  background-image:
    url("walls/dashboard.svg"),
    radial-gradient(1100px 600px at 85% -10%, rgba(91, 142, 247, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(63, 208, 184, 0.05), transparent 60%);
  background-color: #141519;
  background-size: 44px 44px, auto, auto;
}
:root[data-theme="dark"] .main:has(#module-tasks:not(.hidden)) {
  background-image:
    url("walls/tasks.svg"),
    radial-gradient(1000px 550px at 90% -10%, rgba(91, 142, 247, 0.08), transparent 60%),
    radial-gradient(800px 450px at 0% 110%, rgba(63, 208, 184, 0.04), transparent 60%);
  background-color: #14171d;
  background-size: 44px 44px, auto, auto;
}
:root[data-theme="dark"] .main:has(#module-habits:not(.hidden)) {
  background-image:
    url("walls/habits.svg"),
    radial-gradient(1000px 550px at 85% -5%, rgba(74, 191, 133, 0.08), transparent 60%),
    radial-gradient(800px 450px at 0% 110%, rgba(139, 195, 74, 0.05), transparent 60%);
  background-color: #141a16;
  background-size: 52px 52px, auto, auto;
}
:root[data-theme="dark"] .main:has(#module-budget:not(.hidden)) {
  background-image:
    url("walls/budget.svg"),
    radial-gradient(1000px 550px at 90% -10%, rgba(63, 208, 184, 0.06), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(235, 137, 9, 0.05), transparent 60%);
  background-color: #141a18;
  background-size: 56px 56px, auto, auto;
}
:root[data-theme="dark"] .main:has(#module-journal:not(.hidden)) {
  background-image:
    url("walls/journal.svg"),
    radial-gradient(1000px 600px at 85% -10%, rgba(222, 168, 97, 0.07), transparent 60%),
    radial-gradient(800px 450px at 0% 110%, rgba(139, 122, 95, 0.05), transparent 60%);
  background-color: #1a1713;
  background-size: 120px 44px, auto, auto;
}
:root[data-theme="dark"] .main:has(#module-reports:not(.hidden)) {
  background-image:
    url("walls/reports.svg"),
    radial-gradient(1000px 550px at 85% -10%, rgba(124, 108, 214, 0.08), transparent 60%),
    radial-gradient(800px 450px at 0% 110%, rgba(91, 142, 247, 0.05), transparent 60%);
  background-color: #15141c;
  background-size: 64px 64px, auto, auto;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ---------------- Sidebar ---------------- */

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sidebar);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 4px 10px 22px;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.brand-title {
  position: relative;
  letter-spacing: -0.02em;
}

.brand-tag {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  margin: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: background 0.12s ease;
}

.side-btn:hover {
  background: var(--hover);
}

.side-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.side-btn .ico {
  width: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.side-btn.active .ico {
  color: var(--accent);
}

.side-btn .count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 10px 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.side-head-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.side-head-label .ico {
  width: 18px;
  text-align: center;
}

.icon-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.side-lists {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: auto;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  position: relative;
}

.list-row:hover {
  background: var(--hover);
}

.list-row.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.list-row .list-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  border: none;
  background: none;
  text-align: left;
  padding: 0;
}

.list-row .count {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.list-row .list-actions {
  display: none;
  gap: 2px;
  position: absolute;
  right: 6px;
  background: inherit;
  padding-left: 6px;
}

.list-row:hover .list-actions,
.list-row.active .list-actions {
  display: flex;
}

.list-row .list-actions button {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.list-row .list-actions button:hover {
  background: var(--hover);
  color: var(--text);
}

.list-row .list-actions .del:hover {
  color: var(--danger);
}

.list-edit-input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
}

.side-footer {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lang-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.lang-select:focus {
  border-color: var(--accent);
}

.side-foot-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
}

.side-foot-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.side-foot-btn .ico {
  width: 18px;
  text-align: center;
}

a.side-foot-btn {
  text-decoration: none;
  color: var(--text-muted);
}

a.side-foot-btn:hover {
  color: var(--text);
}

.link {
  color: var(--accent);
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 4px;
}

.link:hover {
  text-decoration: underline;
}

/* ---------------- Main ---------------- */

.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 80px;
  background: var(--bg);
}

.main-inner {
  max-width: 720px;
  margin: 0 auto;
}

/* Themed, low-attention section wallpapers (light) */
.main:has(#module-dashboard:not(.hidden)) {
  background-image:
    url("walls/dashboard.svg"),
    radial-gradient(1100px 600px at 85% -10%, rgba(47, 111, 243, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(14, 157, 139, 0.05), transparent 60%);
  background-color: #f4f6fb;
  background-size: 44px 44px, auto, auto;
}
.main:has(#module-tasks:not(.hidden)) {
  background-image:
    url("walls/tasks.svg"),
    radial-gradient(1000px 550px at 90% -10%, rgba(47, 111, 243, 0.07), transparent 60%),
    radial-gradient(800px 450px at 0% 110%, rgba(14, 157, 139, 0.04), transparent 60%);
  background-color: #f4f7fd;
  background-size: 44px 44px, auto, auto;
}
.main:has(#module-habits:not(.hidden)) {
  background-image:
    url("walls/habits.svg"),
    radial-gradient(1000px 550px at 85% -5%, rgba(56, 178, 119, 0.07), transparent 60%),
    radial-gradient(800px 450px at 0% 110%, rgba(139, 195, 74, 0.05), transparent 60%);
  background-color: #f4faf6;
  background-size: 52px 52px, auto, auto;
}
.main:has(#module-budget:not(.hidden)) {
  background-image:
    url("walls/budget.svg"),
    radial-gradient(1000px 550px at 90% -10%, rgba(14, 157, 139, 0.06), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(235, 137, 9, 0.05), transparent 60%);
  background-color: #f4faf8;
  background-size: 56px 56px, auto, auto;
}
.main:has(#module-journal:not(.hidden)) {
  background-image:
    url("walls/journal.svg"),
    radial-gradient(1000px 600px at 85% -10%, rgba(222, 168, 97, 0.08), transparent 60%),
    radial-gradient(800px 450px at 0% 110%, rgba(139, 122, 95, 0.05), transparent 60%);
  background-color: #fbf7ef;
  background-size: 120px 44px, auto, auto;
}
.main:has(#module-reports:not(.hidden)) {
  background-image:
    url("walls/reports.svg"),
    radial-gradient(1000px 550px at 85% -10%, rgba(106, 90, 205, 0.08), transparent 60%),
    radial-gradient(800px 450px at 0% 110%, rgba(47, 111, 243, 0.05), transparent 60%);
  background-color: #f6f5fc;
  background-size: 64px 64px, auto, auto;
}

.main-head {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 720px;
  margin: 0 auto 20px;
}

.mobile-menu {
  display: none;
}

.main-head h1 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.sec-ico {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
}

.view-count {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.search {
  margin-left: auto;
  position: relative;
  min-width: 200px;
}

.search input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.12s ease;
}

.search input:focus {
  border-color: var(--accent);
}

/* ---------------- Add form ---------------- */

.add-form {
  max-width: 720px;
  margin: 0 auto 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
}

.add-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.add-row .plus {
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.add-form input[type="text"] {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 8px 0;
  font-size: 1rem;
}

.add-form input[type="text"]::placeholder {
  color: var(--text-muted);
}

.add-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 8px;
}

.add-opts input[type="date"],
.add-opts select,
.edit-row input[type="date"],
.edit-row select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
  font-size: 0.9rem;
}

.add-opts input[type="date"]:focus,
.add-opts select:focus,
.edit-row input[type="date"]:focus,
.edit-row select:focus {
  border-color: var(--accent);
}

.add-btn {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  padding: 7px 16px;
  border-radius: 8px;
  font-weight: 600;
}

.add-btn:hover {
  background: var(--accent-hover);
}

/* ---------------- Filter row ---------------- */

.filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 720px;
  margin: 0 auto 10px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--surface);
}

.filter-chip:hover {
  color: var(--text);
}

.filter-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.filter-row .spacer {
  flex: 1;
}

.sort-select {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
}

.sort-select:focus {
  border-color: var(--accent);
  color: var(--text);
}

/* ---------------- Status ---------------- */

.status {
  max-width: 720px;
  margin: 24px auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---------------- Task list ---------------- */

.todo-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 720px;
}

li.task {
  border-bottom: 1px solid var(--border);
}

li.task:first-child {
  border-top: 1px solid var(--border);
}

li.task.dragging {
  opacity: 0.35;
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 8px;
  border-radius: 8px;
  cursor: grab;
}

.task-row:hover {
  background: var(--hover);
}

.task-row.dragging {
  background: var(--hover);
}

.task-check {
  appearance: none;
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  margin-top: 2px;
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
}

.task-check:hover {
  border-color: var(--accent);
}

.task-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.task-check:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.flag {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  border-radius: 3px;
  margin-top: 6px;
  background: transparent;
}

.flag.p1 {
  background: var(--p1);
}

.flag.p2 {
  background: var(--p2);
}

.flag.p3 {
  background: var(--p3);
}

.task-body {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 1rem;
  word-break: break-word;
}

li.task.done .task-title {
  color: var(--text-muted);
  text-decoration: line-through;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 3px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.task-meta .due {
  color: var(--text-muted);
}

.task-meta .due.overdue {
  color: var(--overdue);
  font-weight: 600;
}

.task-meta .due.today {
  color: var(--accent);
  font-weight: 600;
}

.task-meta .pill {
  background: var(--hover);
  border-radius: 999px;
  padding: 1px 8px;
}

.task-meta .repeat {
  color: var(--accent);
}

.task-meta .notes-hint {
  color: var(--text-muted);
  font-style: italic;
}

.task-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.task-row:hover .task-actions,
.task-row:focus-within .task-actions {
  opacity: 1;
}

.task-actions button {
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.task-actions button:hover {
  background: var(--hover);
  color: var(--text);
}

.task-actions .del:hover {
  color: var(--danger);
}

/* Subtasks inline */
.subtask-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0 0 0 0;
}

.subtask-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 4px;
  border-radius: 6px;
}

.subtask-list li:hover {
  background: var(--hover);
}

.subtask-list .sub-check {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
}

.subtask-list .sub-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.subtask-list .sub-check:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0;
  width: 4px;
  height: 7px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.subtask-list .sub-text {
  flex: 1;
  font-size: 0.92rem;
  word-break: break-word;
}

.subtask-list li.done .sub-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.subtask-list .sub-del {
  opacity: 0;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
}

.subtask-list li:hover .sub-del {
  opacity: 1;
}

.subtask-list .sub-del:hover {
  color: var(--danger);
}

/* ---------------- Edit panel ---------------- */

.edit-panel {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 16px 16px;
  margin: 4px 0 10px;
  box-shadow: var(--shadow);
}

.edit-panel input[type="text"],
.edit-panel textarea {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 8px 4px;
  outline: none;
  font-size: 1rem;
}

.edit-panel input[type="text"]:focus,
.edit-panel textarea:focus {
  border-bottom-color: var(--accent);
}

.edit-panel textarea {
  resize: vertical;
  min-height: 64px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.edit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.edit-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.edit-actions .save {
  background: var(--accent);
  color: #fff;
  padding: 7px 18px;
  border-radius: 8px;
  font-weight: 600;
}

.edit-actions .save:hover {
  background: var(--accent-hover);
}

.edit-actions .cancel {
  color: var(--text-muted);
  padding: 7px 10px;
  border-radius: 8px;
}

.edit-actions .cancel:hover {
  background: var(--hover);
}

.edit-actions .del {
  margin-left: auto;
  color: var(--danger);
  padding: 7px 10px;
  border-radius: 8px;
}

.edit-actions .del:hover {
  background: var(--accent-soft);
}

.sub-add {
  display: flex;
  gap: 6px;
  margin: 10px 0 6px;
}

.sub-add input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
  font-size: 0.9rem;
}

.sub-add input:focus {
  border-color: var(--accent);
}

.sub-add button {
  color: var(--accent);
  font-weight: 600;
  padding: 6px 10px;
}

.edit-sub-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.edit-sub-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 6px;
}

.edit-sub-list li:hover {
  background: var(--hover);
}

.edit-sub-list .sub-del {
  margin-left: auto;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
}

.edit-sub-list .sub-del:hover {
  color: var(--danger);
}

/* ---------------- Module nav ---------------- */

.module-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.module-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  width: 100%;
  text-align: left;
  transition: background 0.12s ease;
}

.module-btn .m-ico {
  width: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
}

.module-btn:hover {
  background: var(--hover);
}

.module-btn.active {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--accent);
}

#task-nav {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}

/* ---------------- Placeholder modules ---------------- */

.module {
  max-width: 720px;
  margin: 0 auto;
}

.placeholder {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  margin-top: 8vh;
}

.placeholder h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  color: var(--text);
}

.placeholder p {
  margin: 0;
  font-size: 0.95rem;
}

/* ---------------- Backup nudge ---------------- */

.nudge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto 16px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  color: var(--accent);
  font-size: 0.92rem;
}

.nudge span {
  flex: 1 1 220px;
  text-wrap: pretty;
}

.nudge button {
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  flex-shrink: 0;
}

.nudge button:hover {
  background: var(--accent-hover);
}

.nudge button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.nudge button.ghost:hover {
  background: var(--accent-soft);
}

/* ---------------- Modal ---------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 40px 16px;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  margin-top: 4vh;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 1.4rem;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
}

.modal-close:hover {
  background: var(--hover);
  color: var(--text);
}

.modal-card h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.modal-sub {
  color: var(--text-muted);
  margin: 0 0 18px;
  font-size: 0.9rem;
}

.btn-primary,
.btn-secondary {
  display: block;
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--hover);
}

.import-choice {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 14px;
}

.import-choice p {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.backup-msg {
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.backup-msg.err {
  color: var(--danger);
}

/* ---------------- Habits ---------------- */

li.habit {
  border-bottom: 1px solid var(--border);
}

li.habit:first-child {
  border-top: 1px solid var(--border);
}

.habit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-radius: 8px;
}

.habit-row:hover {
  background: var(--hover);
}

.habit-check {
  appearance: none;
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
}

.habit-check:hover {
  border-color: var(--accent);
}

.habit-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.habit-check:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.habit-color {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  border-radius: 50%;
}

.habit-body {
  flex: 1;
  min-width: 0;
}

.habit-name {
  display: block;
  font-weight: 600;
  word-break: break-word;
}

.habit-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 3px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.habit-streak {
  color: var(--accent);
  font-weight: 600;
}

.habit-goal.met {
  color: var(--accent);
  font-weight: 600;
}

.week-dots {
  display: inline-flex;
  gap: 3px;
}

.week-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--border);
}

.week-dots .dot.on {
  border-color: transparent;
}

.week-dots .dot.rest {
  border-style: dashed;
  border-color: var(--text-muted);
  opacity: 0.5;
}

.rest-days {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 10px 0 4px;
}

.rest-days .rd-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 4px;
}

.rest-day-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  background: none;
}

.rest-day-btn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.habit-detail {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 16px 16px;
  margin: 0 0 10px;
  box-shadow: var(--shadow);
}

.heatmap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 12px;
}

.hm-week {
  display: flex;
  gap: 3px;
}

.hm-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.hm-cell.on {
  border-color: transparent;
}

.habit-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.habit-stats b {
  color: var(--text);
  font-weight: 700;
}

.goal-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.goal-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--hover);
  overflow: hidden;
}

.goal-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* ---------------- Budget ---------------- */

.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.month-nav button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  background: none;
}

.month-nav button:hover {
  background: var(--hover);
  color: var(--text);
}

.month-nav span {
  min-width: 120px;
  text-align: center;
  line-height: 1;
}

.budget-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.bcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.bcard:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.bcard-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.bcard-val {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.bcard-val.income {
  color: var(--money-in);
}

.bcard-val.expense {
  color: var(--money-out);
}

.bcard-val.neg {
  color: var(--money-out);
}

.add-form input[type="number"] {
  flex: 0 0 auto;
  width: 120px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
  font-size: 1rem;
}

.add-form input[type="number"]:focus {
  border-color: var(--accent);
}

.budget-cats {
  max-width: 720px;
  margin: 0 auto 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 14px;
}

.budget-cats summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.budget-cats summary:hover {
  color: var(--text);
}

.budget-cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--hover);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.cat-chip .cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.cat-chip .cat-x {
  color: var(--text-muted);
  padding: 0 2px;
  font-size: 0.9rem;
  line-height: 1;
}

.cat-chip .cat-x:hover {
  color: var(--danger);
}

.budget-cat-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.budget-cat-add input[type="text"] {
  flex: 1 1 100%;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
  font-size: 0.9rem;
}

.budget-cat-add input:not([type="text"]) {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
  font-size: 0.9rem;
}

.budget-cat-add input[type="color"] {
  padding: 4px 4px;
  width: 44px;
  height: 34px;
}

.budget-cat-add input[type="number"],
.budget-cat-add input[type="time"] {
  width: 110px;
}

.budget-cat-add input:focus {
  border-color: var(--accent);
}

.budget-cat-add select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
  font-size: 0.9rem;
}

.budget-cat-add .add-btn {
  margin-left: auto;
}

.budget-breakdown {
  max-width: 720px;
  margin: 0 auto 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.bd-head {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.bd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 0.9rem;
}

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

.bd-name {
  flex: 0 0 auto;
  min-width: 90px;
  font-weight: 600;
}

.bd-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--hover);
  overflow: hidden;
}

.bd-fill {
  height: 100%;
  border-radius: 999px;
}

.bd-amt {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.bd-row.over .bd-name,
.bd-amt.over {
  color: var(--money-out);
  font-weight: 600;
}

.bd-fill.over {
  background: var(--money-out);
}

li.txn-group {
  border-bottom: 1px solid var(--border);
}

li.txn-group:first-child {
  border-top: 1px solid var(--border);
}

.txn-date-head {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 12px 8px 6px;
}

.txn-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
}

li.txn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 8px;
}

li.txn:hover {
  background: var(--hover);
}

.txn-body {
  flex: 1;
  min-width: 0;
}

.txn-body > span:first-child {
  display: block;
  font-weight: 500;
  word-break: break-word;
}

.txn-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.txn-amt {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

li.txn.income .txn-amt {
  color: var(--money-in);
}

li.txn:not(.income) .txn-amt {
  color: var(--money-out);
}

@media (max-width: 600px) {
  .budget-cards {
    grid-template-columns: 1fr;
  }
}

/* ---------------- Journal ---------------- */

.journal-toolbar {
  max-width: 720px;
  margin: 0 auto 14px;
}

.journal-toolbar button {
  background: var(--accent);
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
}

.journal-toolbar button:hover {
  background: var(--accent-hover);
}

.journal-editor {
  max-width: 720px;
  margin: 0 auto 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.journal-editor .edit-row {
  margin: 0 0 8px;
}

.journal-editor input[type="text"],
.journal-editor textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  padding: 10px 12px;
  outline: none;
  margin-bottom: 8px;
}

.journal-editor input[type="text"]:focus,
.journal-editor textarea:focus {
  border-color: var(--accent);
}

.journal-editor textarea {
  min-height: 120px;
  resize: vertical;
}

.journal-editor .edit-actions {
  margin-top: 0;
}

.journal-cal {
  max-width: 720px;
  margin: 0 auto 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 10px;
  font-weight: 600;
}

.cal-head button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 1.05rem;
  background: none;
}

.cal-head button:hover {
  background: var(--hover);
  color: var(--text);
}

.cal-head span {
  min-width: 120px;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-wd {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 2px 0;
}

.cal-cell {
  text-align: center;
  padding: 6px 0;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  position: relative;
}

.cal-cell:hover {
  background: var(--hover);
}

.cal-cell.has::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.cal-cell.sel {
  background: var(--accent);
  color: #fff;
}

.cal-cell.sel.has::after {
  background: #fff;
}

.cal-cell.today:not(.sel) {
  outline: 1px solid var(--accent);
}

.cal-blank {
  padding: 6px 0;
}

.journal-filter-row {
  max-width: 720px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.journal-filter-row .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.journal-filter-row .chip button {
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  background: none;
  padding: 0;
}

.journal-filter-row .link {
  font-size: 0.85rem;
}

.journal-card {
  max-width: 720px;
  margin: 0 auto 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
}

.journal-card:hover {
  border-color: var(--accent);
}

.jc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.jc-date {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.jc-mood {
  font-size: 1.15rem;
}

.jc-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
  word-break: break-word;
}

.jc-preview {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.jc-full {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.jc-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.journal-card:hover .jc-actions {
  opacity: 1;
}

.jc-actions button {
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: none;
}

.jc-actions button:hover {
  background: var(--hover);
  color: var(--text);
}

.jc-actions .del:hover {
  color: var(--danger);
  background: var(--accent-soft);
}

/* ---------------- Dashboard ---------------- */

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  text-align: left;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.dash-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.dash-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.dash-card-lbl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.dash-card-ico {
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
}

.dash-card-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

.dash-card-val {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dash-card-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dash-card.budget .dash-card-val.neg {
  color: var(--money-out);
}

.dash-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dash-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.dash-panel h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.dash-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dash-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
}

.dash-row:hover {
  background: var(--hover);
}

.dash-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
}

.dash-row input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.dash-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.dash-row .dash-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  font-size: 0.95rem;
}

.dash-row .dash-due {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.dash-row .dash-due.overdue {
  color: var(--overdue);
  font-weight: 600;
}

.dash-row .dash-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dash-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 6px 4px;
}

.dash-journal-card {
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 8px;
}

.dash-journal-card:hover {
  background: var(--hover);
}

.dash-journal-card .dj-date {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.dash-journal-card .dj-title {
  font-weight: 600;
  margin-top: 2px;
  word-break: break-word;
}

.dash-journal-card .dj-preview {
  color: var(--text-muted);
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-more {
  display: block;
  margin-top: 8px;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  background: none;
  padding: 4px 0;
}

.dash-more:hover {
  text-decoration: underline;
}

/* ---------------- Toasts ---------------- */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
}

.toast {
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

:root[data-theme="dark"] .toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast b {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.toast span {
  display: block;
  font-size: 0.85rem;
  opacity: 0.85;
  word-break: break-word;
}

.task-meta .remind,
.habit-meta .remind {
  color: var(--accent);
  font-weight: 600;
}

/* ---------------- Payments ---------------- */

.payment-summary {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 10px 0 4px;
}

.payment-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

li.payment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 4px;
  border-radius: 8px;
}

li.payment:hover {
  background: var(--hover);
}

.payment-paid {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
}

.payment-paid:checked {
  background: var(--money-in);
  border-color: var(--money-in);
}

.payment-paid:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.payment-body {
  flex: 1;
  min-width: 0;
}

.payment-name {
  display: block;
  font-weight: 600;
  word-break: break-word;
}

.payment-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.payment-amt {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--money-out);
  flex-shrink: 0;
}

.payment-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s ease;
}

li.payment:hover .payment-actions {
  opacity: 1;
}

.payment-actions button {
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: none;
}

.payment-actions button:hover {
  background: var(--hover);
  color: var(--text);
}

.payment-actions .del:hover {
  color: var(--danger);
}

.payment-inactive .payment-name,
.payment-inactive .payment-amt {
  opacity: 0.45;
}

.payment-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.payment-toggle input {
  accent-color: var(--accent);
}

/* ---------------- Settings ---------------- */

.set-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 12px 0 6px;
}

.set-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
}

.set-select:focus {
  border-color: var(--accent);
}

.set-divider {
  border-top: 1px solid var(--border);
  margin: 18px 0 12px;
}

.modal-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.pin-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.pin-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
  letter-spacing: 0.2em;
  font-size: 1rem;
}

.pin-row input:focus {
  border-color: var(--accent);
}

.pin-row .btn-secondary {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}

/* ---------------- Trash ---------------- */

.trash-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 50vh;
  overflow-y: auto;
}

li.trash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
}

li.trash-item:last-child {
  border-bottom: none;
}

.trash-type {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 8px;
}

.trash-body {
  flex: 1;
  min-width: 0;
}

.trash-name {
  display: block;
  font-weight: 600;
  word-break: break-word;
}

.trash-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.trash-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.trash-actions button {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: none;
}

.trash-actions button:hover {
  background: var(--hover);
  color: var(--text);
}

.trash-actions .restore {
  color: var(--accent);
}

.trash-actions .del:hover {
  color: var(--danger);
}

/* ---------------- Global search ---------------- */

.search-card {
  max-width: 560px;
}

#global-search-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
  font-size: 1.05rem;
  margin-bottom: 12px;
}

#global-search-input:focus {
  border-color: var(--accent);
}

.search-results {
  max-height: 55vh;
  overflow-y: auto;
}

.search-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 4px 4px;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: none;
}

.search-result:hover {
  background: var(--hover);
}

.search-result .sr-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.search-result .sr-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 12px 4px;
}

/* ---------------- Pomodoro ---------------- */

.pomo-card {
  text-align: center;
}

.pomo-type {
  display: inline-flex;
  gap: 6px;
  background: var(--hover);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}

.pomo-type button {
  padding: 6px 18px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
}

.pomo-type button.active {
  background: var(--accent);
  color: #fff;
}

.pomo-time {
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 16px;
}

.pomo-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.pomo-controls .btn-primary,
.pomo-controls .btn-secondary {
  width: auto;
  margin: 0;
  padding: 10px 24px;
}

/* ---------------- Lock screen ---------------- */

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lock-card {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 32px;
  text-align: center;
}

.lock-card .brand {
  justify-content: center;
  padding: 0 0 26px;
}

.lock-card input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
  text-align: center;
  letter-spacing: 0.3em;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.lock-card input:focus {
  border-color: var(--accent);
}

.lock-card .btn-primary {
  width: 100%;
}

/* ---------------- Task calendar ---------------- */

.task-calendar {
  max-width: 720px;
  margin: 0 auto 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.task-calendar .cal-head button.link {
  margin-left: 6px;
  font-size: 0.85rem;
}

/* ---------------- Reports ---------------- */

.toolbar-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  margin-left: 8px;
}

.toolbar-ghost:hover {
  background: var(--accent-soft);
}

.rep-habit {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.rep-habit:last-child {
  border-bottom: none;
}

.rep-habit-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

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

.rep-habit-head .name {
  flex: 1;
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rep-habit-head .pct {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.rep-weeks {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 40px;
}

.rep-week-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
  height: 100%;
}

.rep-week-bar {
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.rep-week-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
}

.jc-head .wc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: 8px;
}

.modal-card code {
  background: var(--hover);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.82rem;
}

/* ---------------- i18n overflow fixes ---------------- */

.side-btn,
.module-btn,
.side-foot-btn {
  min-width: 0;
  overflow-wrap: anywhere;
}

.side-btn .count {
  flex-shrink: 0;
}

.side-foot-btn span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.main-head {
  flex-wrap: wrap;
  row-gap: 8px;
}

.main-head h1 {
  flex-wrap: wrap;
  min-width: 0;
  white-space: normal;
}

.search {
  min-width: 0;
  flex: 1 1 auto;
  max-width: 280px;
}

.dash-card-head {
  min-width: 0;
}

.dash-card-head .dash-card-label {
  min-width: 0;
  overflow-wrap: break-word;
}

.dash-card-val {
  flex-shrink: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

.dash-card-sub {
  overflow-wrap: break-word;
}

.dash-panel h2 {
  overflow-wrap: break-word;
}

.cal-head {
  flex-wrap: wrap;
  row-gap: 6px;
}

.cal-head span {
  min-width: 0;
}

.month-nav span {
  min-width: 0;
  padding: 0 4px;
  overflow-wrap: break-word;
}

.edit-row select,
.edit-row input {
  max-width: 100%;
  min-width: 0;
}

.payment-sub,
.payment-body,
.txn-sub {
  overflow-wrap: break-word;
}

.bd-name,
.bd-amt {
  overflow-wrap: break-word;
}

.btn-primary,
.btn-secondary {
  overflow-wrap: break-word;
}

.modal-sub {
  overflow-wrap: break-word;
}

.pomo-type button {
  white-space: nowrap;
}

.lang-select option {
  overflow-wrap: break-word;
}

/* ---------------- Kanban board ---------------- */

.task-board {
  max-width: 1080px;
  margin: 0 auto 16px;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.board-col {
  flex: 0 0 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.board-col.over {
  border-color: var(--accent);
}

.board-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

.board-col-count {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.board-col-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}

.board-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: grab;
}

.board-card:hover {
  border-color: var(--accent);
}

.board-card.dragging {
  opacity: 0.4;
}

.board-card.done .board-card-title {
  color: var(--text-muted);
  text-decoration: line-through;
}

.board-card-title {
  font-size: 0.9rem;
  word-break: break-word;
}

.board-card-meta {
  display: flex;
  gap: 8px;
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.board-due.overdue {
  color: var(--overdue);
  font-weight: 600;
}

/* ---------------- Tags ---------------- */

.tag-chip {
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.tag-chip:hover {
  text-decoration: underline;
}

.tag-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.tag-filter-chip button {
  background: none;
  color: inherit;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

/* ---------------- Savings goals ---------------- */

.goal-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--hover);
  overflow: hidden;
  margin: 4px 0;
}

.goal-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* ---------------- Budget trend ---------------- */

.trend-chart {
  display: flex;
  gap: 10px;
  height: 160px;
  align-items: flex-end;
}

.trend-month {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
}

.trend-bars {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  flex: 1;
}

.trend-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.trend-bar.in {
  background: var(--money-in);
}

.trend-bar.out {
  background: var(--money-out);
}

.trend-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
}

/* Left-align content columns next to the sidebar to shorten mouse travel */
.main-inner,
.module,
.main-head,
.add-form,
.filter-row,
.status,
.todo-list,
.nudge,
.budget-cats,
.budget-breakdown,
.journal-toolbar,
.journal-editor,
.journal-cal,
.journal-filter-row,
.journal-card,
.task-calendar,
.task-board {
  margin-left: 0;
  margin-right: auto;
}

/* On ultra-wide screens, center the content again for a balanced look */
@media (min-width: 1600px) {
  .main-inner,
  .module,
  .main-head,
  .add-form,
  .filter-row,
  .status,
  .todo-list,
  .nudge,
  .budget-cats,
  .budget-breakdown,
  .journal-toolbar,
  .journal-editor,
  .journal-cal,
  .journal-filter-row,
  .journal-card,
  .task-calendar,
  .task-board {
    margin-left: auto;
    margin-right: auto;
  }
}

/* ---------------- Responsive ---------------- */

@media (max-width: 760px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding: 16px 16px 80px;
  }

  .mobile-menu {
    display: inline-flex;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: var(--text);
    font-size: 1.2rem;
    align-items: center;
    justify-content: center;
  }

  .mobile-menu:hover {
    background: var(--hover);
  }

  .search {
    min-width: 0;
    flex: 1;
  }

  .task-actions {
    opacity: 1;
  }
}
