:root {
    --bg: #0f1115;
    --bg-2: #161923;
    --card: #1b1f2a;
    --card-2: #212636;
    --line: #2a3040;
    --text: #e8ecf4;
    --muted: #8b93a7;
    --muted-2: #626b80;
    --accent: #7c6cff;
    --accent-2: #9d7bff;
    --green: #00b894;
    --blue: #0984e3;
    --yellow: #fdcb6e;
    --red: #d63031;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(0,0,0,.35);
    --topbar-bg: rgba(15,17,21,.82);
    --overlay: rgba(6,8,12,.62);
    --accent-tint: rgba(124,108,255,.14);
}

/* Светлая тема — включается, когда система в светлом режиме */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #f5f7fc;
        --bg-2: #eef1f8;
        --card: #ffffff;
        --card-2: #eef1f8;
        --line: #e1e6f0;
        --text: #1a1f2b;
        --muted: #6b7385;
        --muted-2: #9aa2b4;
        --green: #06a17f;
        --blue: #0a72c7;
        --yellow: #e0a500;
        --red: #d63031;
        --shadow: 0 8px 30px rgba(60,70,110,.14);
        --topbar-bg: rgba(255,255,255,.85);
        --overlay: rgba(30,36,54,.42);
        --accent-tint: rgba(124,108,255,.12);
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
    background: radial-gradient(1200px 600px at 80% -10%, var(--accent-tint), transparent 60%), var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 18px 26px;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
    background: var(--topbar-bg); backdrop-filter: blur(10px);
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
    width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center; font-size: 22px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 6px 18px rgba(124,108,255,.4);
}
.brand h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.brand-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.me { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.me input {
    width: 120px; padding: 8px 10px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font-size: 13px;
}

/* ---------- Buttons ---------- */
.btn {
    padding: 9px 15px; border-radius: 11px; border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; transition: .15s;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost { background: var(--card-2); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: #2a3145; }
.btn-danger-ghost { background: transparent; color: var(--red); border-color: rgba(214,48,49,.4); }
.btn-danger-ghost:hover { background: rgba(214,48,49,.12); }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--card-2); color: var(--text); }

/* ---------- Stats ---------- */
.stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    gap: 10px; padding: 16px 26px 4px;
}
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: 11px;
    padding: 10px 13px; display: flex; flex-direction: column; gap: 2px;
}
.stat .num { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.stat .lbl { font-size: 11.5px; color: var(--muted); }
.stat.progress-stat { flex-direction: row; align-items: center; gap: 10px; }
.ring { --p: 0; width: 42px; height: 42px; border-radius: 50%; flex: none;
    background: conic-gradient(var(--green) calc(var(--p)*1%), var(--card-2) 0);
    display: grid; place-items: center; }
.ring::after { content: attr(data-label); width: 31px; height: 31px; border-radius: 50%; background: var(--card);
    display: grid; place-items: center; font-size: 11px; font-weight: 700; }

/* ---------- Controls ---------- */
.controls {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 16px 26px; flex-wrap: wrap;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 13px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600;
    background: var(--card); border: 1px solid var(--line); color: var(--muted); transition: .15s;
}
.chip:hover { color: var(--text); }
.chip.active { color: #fff; border-color: transparent; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip .cnt { font-size: 11.5px; opacity: .8; background: rgba(255,255,255,.1); padding: 1px 7px; border-radius: 999px; }
.control-right { display: flex; align-items: center; gap: 10px; }
.mini-select {
    padding: 8px 12px; border-radius: 10px; background: var(--card); color: var(--text);
    border: 1px solid var(--line); font: inherit; font-size: 13px; cursor: pointer;
}
.view-toggle { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.vt-btn { padding: 8px 14px; background: none; border: none; color: var(--muted); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; }
.vt-btn.active { background: var(--accent); color: #fff; }

/* ---------- Main / Board ---------- */
main { padding: 8px 26px 60px; }
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
.col { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.col-head { display: flex; align-items: center; gap: 8px; margin: 4px 4px 12px; font-size: 13.5px; font-weight: 700; }
.col-head .badge { font-size: 11px; color: var(--muted); background: var(--card-2); padding: 1px 8px; border-radius: 999px; }
.col-dot { width: 10px; height: 10px; border-radius: 50%; }

.card-idea {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 13px 14px; margin-bottom: 11px; cursor: pointer; transition: .15s;
    border-left: 3px solid var(--accent);
}
.card-idea:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.card-idea .ci-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-idea .ci-title { font-weight: 700; font-size: 14.5px; line-height: 1.35; }
.card-idea .ci-dir { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.card-idea .ci-desc { font-size: 12.5px; color: var(--muted); margin: 7px 0 0; line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-idea .ci-meta { display: flex; align-items: center; gap: 12px; margin-top: 11px; font-size: 12px; color: var(--muted); }
.ci-ice { font-weight: 800; color: var(--text); }
.ci-ice small { color: var(--muted); font-weight: 600; }
.pbar { height: 6px; border-radius: 999px; background: var(--card-2); overflow: hidden; margin-top: 10px; }
.pbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #55efc4); border-radius: 999px; }
.ci-meta .vote { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--card-2); }
.tag { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.mini-pbar { width: 90px; height: 6px; border-radius: 999px; background: var(--card-2); overflow: hidden; display: inline-block; vertical-align: middle; }
.mini-pbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #55efc4); }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-overlay[hidden] { display: none; }
.modal { width: 100%; max-width: 480px; background: var(--card); border: 1px solid var(--line);
    border-radius: 18px; box-shadow: var(--shadow); max-height: 92vh; display: flex; flex-direction: column; }
.modal-wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }

.fld { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.fld > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.fld input[type=text], .fld textarea, .fld select {
    padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--bg-2); color: var(--text); font: inherit; font-size: 14px; width: 100%;
}
.fld textarea { resize: vertical; }
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Приоритет — цветные точки */
.prio-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--c); display: inline-block; flex: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 20%, transparent), 0 0 9px color-mix(in srgb, var(--c) 55%, transparent); }
.prio-lbl { font-weight: 600; font-size: 12.5px; }
.ci-prio { display: inline-flex; align-items: center; gap: 7px; }
.prio-cell { display: inline-flex; align-items: center; gap: 8px; }
.prio-select { display: flex; gap: 8px; }
.prio-opt { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2);
    color: var(--muted); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; transition: .15s; }
.prio-opt:hover { color: var(--text); }
.prio-opt.active { color: var(--text); border-color: var(--accent); background: var(--card-2); }
.slider-fld label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 6px; }
.slider-fld label b { color: var(--text); }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ---------- Detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 4px 0 16px; }
.detail-stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.detail-stat .n { font-size: 20px; font-weight: 800; }
.detail-stat .l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.detail-desc { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 0 18px; white-space: pre-wrap; }
.detail-section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 0 10px; text-transform: uppercase; letter-spacing: .04em; }
.comment { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.comment .c-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.comment .c-author { font-weight: 700; color: var(--text); }
.comment .c-text { font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font: inherit; }

/* ---------- Directions modal ---------- */
.dir-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.dir-row { display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.dir-row input[type=text] { flex: 1; background: none; border: none; color: var(--text); font: inherit; font-size: 14px; }
.dir-row input[type=color] { width: 30px; height: 30px; border: none; background: none; border-radius: 8px; cursor: pointer; }
.dir-add { display: flex; gap: 8px; }
.dir-add input[type=text] { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font: inherit; }
.dir-add input[type=color] { width: 42px; border: 1px solid var(--line); background: var(--bg-2); border-radius: 10px; cursor: pointer; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--card-2); border: 1px solid var(--line); color: var(--text);
    padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow); z-index: 100; font-size: 14px; }
.toast[hidden] { display: none; }

@media (max-width: 900px) {
    .board { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
    .board { grid-template-columns: 1fr; }
    .fld-row { grid-template-columns: 1fr; }
    .topbar { padding: 14px 16px; }
    .stats, .controls, main { padding-left: 16px; padding-right: 16px; }
}
