@font-face {
  font-family: 'WMMain';
  src: url('../fonts/main.ttf') format('truetype');
  font-weight: normal;
}
@font-face {
  font-family: 'WMMain';
  src: url('../fonts/main-bold.ttf') format('truetype');
  font-weight: bold;
}

:root {
  --bg: #101418;
  --panel: #1a2027;
  --panel2: #222a33;
  --border: #303a45;
  --text: #e6eaee;
  --muted: #93a1b0;
  --accent: #4f8cff;
  --green: #37b34a;
  --yellow: #f4b400;
  --red: #d93025;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'WMMain', 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

button {
  font-family: inherit;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: bold; }
button.danger { border-color: var(--red); color: #ff8a80; }
button.small { padding: 3px 9px; font-size: 13px; border-radius: 6px; }

input, select, textarea {
  font-family: inherit;
  background: #0d1116;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { color: var(--muted); font-size: 13px; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: #ff8a80; min-height: 18px; font-size: 13px; }

/* ---- Auth ---- */
#authView {
  max-width: 380px;
  margin: 8vh auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
}
#authView h1 { margin: 0 0 4px; font-size: 26px; }
#authView .tagline { color: var(--muted); margin-bottom: 18px; }
#authView form { display: flex; flex-direction: column; gap: 10px; }
#authView .tabs { display: flex; gap: 8px; margin-bottom: 14px; }
#authView .tabs button { flex: 1; }
#authView .tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.4; }

/* ---- App layout ---- */
#appView { display: flex; flex-direction: column; min-height: 100vh; }
header.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
header.topbar .logo { font-size: 18px; font-weight: bold; display: flex; align-items: center; gap: 7px; }
header.topbar .logo img { width: 22px; height: 22px; display: block; }
header.topbar .logo span { color: var(--accent); }
header.topbar .spacer { flex: 1; }
header.topbar .syncdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

#appView > main.view { flex: 1; }
.cols {
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  gap: 14px;
  padding: 14px;
  align-items: start;
}
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }
.single { max-width: 760px; margin: 0 auto; padding: 14px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.panel h2 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.panel h2 .cnt { color: var(--muted); font-weight: normal; font-size: 13px; }

/* ---- Queue ---- */
.task-card {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-left: 6px solid var(--muted);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.task-card .t-title { font-weight: bold; font-size: 15px; word-break: break-word; }
/* доделка 029: постоянный числовой идентификатор задачи */
.task-card .t-title .t-num {
  display: inline-block; min-width: 20px; text-align: center;
  background: #1a2129; color: var(--muted); border: 1px solid var(--border);
  border-radius: 5px; font-size: 11px; font-weight: bold;
  padding: 0 4px; margin-right: 6px; vertical-align: middle;
}
.task-card .t-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 5px 0; color: var(--muted); font-size: 13px; }
.task-card .t-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.badge {
  display: inline-block; border-radius: 20px; padding: 1px 9px;
  font-size: 12px; border: 1px solid var(--border); background: #0d1116;
}
.badge.zone { color: #0b0d10; font-weight: bold; }
.badge.float { border-color: var(--yellow); color: var(--yellow); }
.badge.done { border-color: var(--green); color: var(--green); }
.zone-green { border-left-color: var(--green) !important; }
.zone-yellow { border-left-color: var(--yellow) !important; }
.zone-red { border-left-color: var(--red) !important; }
.zone-overdue { border-left-color: #7f1d1d !important; background: #2a1514 !important; }

/* ---- Pyramid ---- */
#pyramidBox { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0; min-height: 60px; }
#pyramidLinks { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; z-index: 3; }
.pyr-link { fill: none; stroke: #e53935; stroke-width: 2; stroke-dasharray: 5 4; opacity: .85; }
.pyr-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.bubble {
  position: relative;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-size: 10px; line-height: 1.1;
  color: #0b0d10; font-weight: bold;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,.25);
  padding: 4px;
  overflow: hidden;
  word-break: break-word;
}
.bubble:hover { transform: scale(1.07); }
.bubble.locked { border: 2px dashed #e53935; box-shadow: 0 0 0 2px rgba(229,57,53,.35); }
.bubble .lock-badge {
  position: absolute; top: 1px; right: 1px;
  background: #e53935; color: #fff; border-radius: 8px;
  font-size: 8px; line-height: 1; padding: 1px 3px;
  border: 1px solid #0b0d10; pointer-events: none;
}
/* доделка 029: номер задачи в пузыре (квадратик перед названием) */
.bubble .bub-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15px; height: 15px; padding: 0 2px;
  background: rgba(0,0,0,.32); color: #fff; border-radius: 4px;
  font-size: 9px; font-weight: bold; margin-right: 3px; flex: none;
}
#pyramidHidden { width: 100%; }
#pyramidHidden .hitem { font-size: 13px; padding: 4px 6px; border-bottom: 1px dashed var(--border); cursor: pointer; color: var(--muted); }
#pyramidHidden .hitem:hover { color: var(--text); }

/* ---- Day widget ---- */
#dayList .task-card { opacity: .97; }
#dayBar { height: 10px; background: #0d1116; border-radius: 6px; overflow: hidden; margin: 6px 0; border: 1px solid var(--border); }
#dayBarFill { height: 100%; background: var(--accent); width: 0%; }
#dayBarFill.over { background: var(--red); }

/* ---- Modal ---- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 12px; overflow-y: auto; z-index: 50;
}
.modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px; width: 100%; max-width: 640px;
}
.modal h3 { margin: 0 0 12px; }
.modal .row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.modal .row > * { flex: 0 0 auto; }
.modal .grow { flex: 1 1 160px; }
.modal fieldset {
  border: 1px solid var(--border); border-radius: 10px;
  margin: 0 0 12px; padding: 10px 12px;
}
.modal legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.slider-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.slider-row input[type=range] { flex: 1; }
.slider-row .sv { width: 72px; font-size: 13px; color: var(--muted); }
.zone-preview { display: flex; height: 14px; border-radius: 7px; overflow: hidden; border: 1px solid var(--border); margin: 6px 0; }
.zone-preview div { flex: 1; }
.proc-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.proc-row input { font-size: 13px; padding: 5px 7px; }
.prio-block { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.grad-row { display: flex; gap: 8px; align-items: center; margin: 5px 0; font-size: 13px; }
.grad-row input[type=number] { width: 70px; }
.grad-row input[type=color] { width: 40px; padding: 2px; height: 28px; }

/* ---- Navigation (drawer) ---- */
.nav-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60; }
#navDrawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 260px; max-width: 80vw;
  background: var(--panel); border-right: 1px solid var(--border);
  z-index: 70; padding: 14px; overflow-y: auto;
  transform: translateX(0);
}
#navDrawer.hidden { display: none; }
.nav-head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin: 4px 6px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; border-radius: 9px;
  padding: 11px 12px; font-size: 15px; color: var(--text); text-align: left;
}
.nav-item .ni { width: 22px; text-align: center; }
.nav-item:hover { background: var(--panel2); }
.nav-item.active { background: var(--accent); color: #fff; }

/* ---- Layer chips ---- */
.layer-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 20px; padding: 4px 12px; font-size: 13px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: bold; }
.layer-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }
.chip.cat { border-style: dashed; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }

/* ---- Budget ---- */
.budget-strip { margin: 6px 0 10px; }
.budget-bar { height: 12px; background: #0d1116; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.budget-fill { height: 100%; background: var(--green); width: 0; transition: width .3s; }
.budget-fill.over { background: var(--red); }
.budget-edit { margin-bottom: 6px; }
/* доделка 031: переключатель циклов (‹ Цикл ДД.ММ — ДД.ММ ›) */
.cycle-bar { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.cycle-bar .grow { flex: 1 1 auto; font-weight: 600; font-size: 13px; }

/* ---- Badges / cards phase2 ---- */
.badge.cat { border-color: var(--accent); color: var(--accent); }
.badge.cat.catlink { cursor: pointer; }
.badge.cat.catlink:hover { background: var(--accent); color: #fff; }
.badge.mustbuy { background: #7f1d1d; color: #fff; border-color: #7f1d1d; font-weight: bold; }
.badge.locked { border-color: #e53935; color: #ff8a80; font-weight: bold; }
.task-card.mustbuy { border-left-color: #7f1d1d !important; background: #2a1514 !important; }
.badge.expst { font-weight: bold; }
.expst-overdue { background: #7f1d1d; color: #fff; border-color: #7f1d1d; }
.expst-due { background: var(--yellow); color: #0b0d10; border-color: var(--yellow); }
.expst-soon { background: var(--accent); color: #fff; border-color: var(--accent); }
.expst-waiting, .expst-open { background: #2a333d; color: var(--muted); border-color: var(--border); }
.expst-done { background: #14351c; color: var(--green); border-color: var(--green); }
.task-card.archived { opacity: .85; }

/* ---- Categories ---- */
.cat-add { margin-bottom: 10px; }
.cat-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; margin-bottom: 8px;
}
.cat-ico { font-size: 18px; width: 24px; text-align: center; cursor: pointer; border-radius: 6px; }
.cat-ico:hover { background: rgba(255,255,255,.08); }
.cat-name { flex: 1; }
.cat-ico-btn { font-size: 18px; line-height: 1; min-width: 40px; padding: 6px 8px; }
.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px; max-height: 260px; overflow-y: auto; padding: 2px;
}
.icon-grid .icon-btn {
  font-size: 20px; line-height: 1; padding: 6px 0;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
}
.icon-grid .icon-btn:hover { border-color: var(--accent); background: rgba(79,140,255,.12); }

/* ---- Tree (passwords/ideas) ---- */
.crumbs { margin-bottom: 8px; font-size: 13px; }
.crumb { background: none; border: none; color: var(--accent); padding: 2px 4px; font-size: 13px; cursor: pointer; }
.crumb:hover { text-decoration: underline; }
.crumb-sep { color: var(--muted); }
.tree-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; margin-bottom: 8px;
}
.tree-ico { font-size: 17px; width: 22px; text-align: center; }
.tree-name { flex: 1; word-break: break-word; }

/* ---- Receipts ---- */
.receipt-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.receipt-item { position: relative; width: 84px; }
.receipt-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; display: block; }
.receipt-del { position: absolute; top: -6px; right: -6px; padding: 1px 6px; font-size: 11px; }

/* ---- Savings (копилка) ---- */
.sv-item {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.sv-prog { height: 8px; background: #0d1116; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin: 6px 0; }
.sv-prog-fill { height: 100%; background: var(--accent); width: 0; }
.sv-ahead { color: var(--green); font-weight: bold; }
.chk-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.chk-list .chk { font-size: 13px; }
.dep-cat {
  font-size: 12px; font-weight: bold; color: var(--muted);
  text-transform: uppercase; letter-spacing: .03em;
  margin-top: 6px; padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
.chk-list .dep-cat:first-child { margin-top: 0; }

/* ---- Help (qbtn) ---- */
.qbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0; margin-left: 6px;
  border-radius: 50%; background: var(--panel2); border: 1px solid var(--border);
  color: var(--accent); font-size: 13px; font-weight: bold; cursor: pointer;
  vertical-align: middle;
}
.qbtn:hover { border-color: var(--accent); }
.help-body { font-size: 14px; line-height: 1.5; color: var(--text); }
.help-body p { margin: 0 0 8px; }
/* Поля формы с инструкцией (доделка 021) */
label.fld { display: flex; flex-direction: column; gap: 3px; }
label.fld > input, label.fld > select, label.fld > textarea { width: 100%; }
.fld-lbl { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text); }
.fld-lbl .qbtn { margin-left: 0; }
.btnq { display: inline-flex; align-items: center; gap: 3px; }
.btnq .qbtn { margin-left: 0; }
.help-body b { color: var(--accent); }

/* ---- Misc ---- */
.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
.chk input { width: auto; }
.txtbtn { white-space: nowrap; }

/* ---- Mobile / app-like ---- */
@media (max-width: 640px) {
  header.topbar { gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
  header.topbar .logo { font-size: 16px; }
  header.topbar #whoami, header.topbar #syncLabel { display: none; }
  .single { padding: 10px; }
  .modal { padding: 14px; }
  button { padding: 9px 12px; }
  .nav-item { padding: 13px 12px; }
}

/* ---- Toasts ---- */
#toasts { position: fixed; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 340px; }
.toast {
  background: var(--panel2); border: 1px solid var(--accent);
  border-radius: 10px; padding: 10px 14px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
  animation: tin .25s ease;
}
@keyframes tin { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Вкладки настроек (доделка 019) ---- */
.st-tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.st-tabs button {
  flex: 1; padding: 8px 10px; background: transparent; border: none;
  border-bottom: 2px solid transparent; color: var(--muted);
  font-size: 14px; cursor: pointer; border-radius: 0;
}
.st-tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: bold; }

/* ---- Задачи AI (доделка 015) ---- */
.ai-task {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
}
.ai-task .t-title { font-weight: bold; font-size: 15px; margin-bottom: 4px; }
.ai-prompt { font-size: 13px; color: var(--muted); margin: 6px 0; white-space: pre-wrap; }
.ai-report { margin-top: 8px; background: rgba(55,179,74,.08); border: 1px solid rgba(55,179,74,.3); border-radius: 8px; padding: 8px 10px; }
.ai-report b { font-size: 12px; color: var(--green); }
.ai-report-text { margin: 6px 0 0; font-family: inherit; font-size: 13px; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.ai-error { margin-top: 8px; background: rgba(217,48,37,.1); border: 1px solid rgba(217,48,37,.4); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: #ff8a80; }
.badge.ai-st-new { border-color: var(--muted); color: var(--muted); }
.badge.ai-st-running { border-color: var(--yellow); color: var(--yellow); }
.badge.ai-st-done { border-color: var(--green); color: var(--green); }
.badge.ai-st-error { border-color: var(--red); color: #ff8a80; }

/* ---- Профили AI (настройки) ---- */
.ai-profile-row { display: flex; align-items: center; gap: 10px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.ai-profile-info { flex: 1; min-width: 0; }
.ai-profile-info b { font-size: 14px; }
.ai-profile-info .muted { font-size: 12px; word-break: break-all; }

/* ---- Колокольчик + уведомления ---- */
.bell { position: relative; }
.bell-badge {
  position: absolute; top: -6px; right: -8px;
  background: var(--red); color: #fff; border-radius: 10px;
  font-size: 10px; line-height: 1; padding: 2px 5px; min-width: 16px; text-align: center;
}
.notif-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.notif-item { display: flex; gap: 8px; align-items: flex-start; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.notif-item.unread { border-color: var(--accent); background: rgba(79,140,255,.1); }
.notif-dot { color: var(--accent); font-size: 10px; margin-top: 4px; }
.notif-body { flex: 1; min-width: 0; }
.notif-text { font-size: 14px; }
.notif-time { font-size: 11px; }
