/* ============================================================
   Цели и задачи — design system v2
   Inter / Manrope · indigo-violet accents · soft depth
   ============================================================ */

:root {
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Manrope', var(--font);

  --bg: #f5f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e7eaf3;
  --border-soft: #eef0f7;

  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-dark: #4f46e5;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --income: #10b981;
  --expense: #f43f5e;
  --warn: #d97706;

  --row-hover: #f7f8fd;
  --input-bg: #ffffff;
  --btn-bg: #eef0f7;
  --danger-bg: #ffe9ee;
  --filter-bg: #fafbfe;

  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 4px 12px rgba(16, 24, 40, .08), 0 24px 60px rgba(16, 24, 40, .14);
  --ring: 0 0 0 3px rgba(99, 102, 241, .18);
  --radius: 14px;

  --side-bg: #0d1226;
  --side-bg2: #111838;
  --side-text: #9aa4c4;
}
/* Midnight indigo rather than near-black: surfaces sit slightly above a violet-lit
   page, which is what gives the dark theme its depth instead of flat blackness. */
:root[data-theme="dark"] {
  --bg: #101127;
  --card: #1b1c3b;
  --text: #edeefc;
  --muted: #9095bf;
  --border: #2c2e57;
  --border-soft: #24264b;

  --primary: #8b83ff;
  --primary-2: #a78bfa;
  --primary-dark: #7a72f5;
  --grad: linear-gradient(135deg, #7c74fb 0%, #a56ffb 100%);

  --income: #34d399;
  --expense: #fb7185;
  --warn: #fbbf24;

  --row-hover: #23254c;
  --input-bg: #171834;
  --btn-bg: #272a54;
  --danger-bg: rgba(244, 63, 94, .16);
  --filter-bg: #15162f;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 8px 20px rgba(0, 0, 0, .5), 0 30px 80px rgba(0, 0, 0, .5);
  --ring: 0 0 0 3px rgba(139, 131, 255, .24);

  --side-bg: #0c0d20;
  --side-bg2: #151632;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* The violet wash is what makes the dark theme read as midnight rather than black.
   Fixed attachment keeps it anchored to the viewport instead of sliding with content. */
:root[data-theme="dark"] body {
  background:
    radial-gradient(1000px 520px at 22% -8%, rgba(139, 92, 246, .20), transparent 62%),
    radial-gradient(760px 420px at 88% 2%, rgba(59, 130, 246, .12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
/* Surfaces float over that wash, so they are tinted rather than opaque… */
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .table-card,
:root[data-theme="dark"] .filter-bar,
:root[data-theme="dark"] .an-card,
:root[data-theme="dark"] .profile-head { background: rgba(27, 28, 59, .78); }
/* …and panels nested inside them step UP in lightness, not down as in the light theme. */
:root[data-theme="dark"] .an-stat,
:root[data-theme="dark"] .an-panel {
  background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .07);
}

.hidden { display: none !important; }
a { color: var(--primary); }
::selection { background: rgba(99, 102, 241, .22); }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============ Login ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(600px 400px at 15% 0%, rgba(99, 102, 241, .10), transparent 60%),
    radial-gradient(700px 500px at 90% 100%, rgba(139, 92, 246, .10), transparent 60%),
    var(--bg);
}
.login-card {
  background: var(--card); width: 100%; max-width: 400px; padding: 40px 36px 32px;
  border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 15px;
}
.login-logo {
  font-family: var(--font-display); font-size: 24px; font-weight: 800; text-align: center;
  letter-spacing: -.02em; margin-bottom: 8px;
}
.login-card label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 500; color: var(--muted); }
.login-card input { padding: 12px 14px; }

/* ============ App layout ============ */
.app { display: flex; min-height: 100vh; }
/* Styled to match the finance module's sidebar: one flat dark surface (no gradient), a
   solid accent on the active item instead of a glowing one, and a round avatar. */
.sidebar {
  width: 236px; color: #cfd6e4; display: flex; flex-direction: column;
  padding: 18px 14px; position: sticky; top: 0; height: 100vh;
  background: #101828;
  transition: width .18s ease, padding .18s ease;
}
.side-head { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.brand {
  font-size: 18px; font-weight: 700; color: #fff;
  padding: 8px 10px; cursor: pointer; flex: 1; min-width: 0;
  border-radius: 9px; user-select: none; display: flex; align-items: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand:hover { background: rgba(255, 255, 255, .06); }
.brand:active { transform: scale(.98); }
.side-toggle {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14);
  color: #cfd6e4; font: inherit; font-size: 13px; line-height: 1;
  transition: background .14s, color .14s;
}
.side-toggle:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px;
  color: #cfd6e4; text-decoration: none; font-weight: 500; font-size: 13.5px;
  transition: background .14s, color .14s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
/* Flat accent, no glow — the finance module's look. */
.nav a.active { background: var(--primary); color: #fff; }
.nav .ic { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-sep { margin-top: auto; border-bottom: 1px solid rgba(255, 255, 255, .08); margin-bottom: 10px; padding-top: 10px; }

.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 12px; }
.user-card {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  background: rgba(255, 255, 255, .05);
  border-radius: 11px; cursor: pointer; transition: background .12s; user-select: none;
}
.user-card:hover { background: rgba(255, 255, 255, .11); }
.user-card:active { transform: scale(.98); }
/* Round, like the finance module's. */
.u-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  flex-shrink: 0; letter-spacing: .02em;
}
/* Photo variants of the initials chips — same box, image instead of letters. */
img.u-avatar, img.ava-sm { display: block; object-fit: cover; }
.ava-edit { display: flex; align-items: center; gap: 14px; }
.ava-edit-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.u-meta { min-width: 0; }
.user-card .u-name { color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .u-role { color: #8b96ab; font-size: 11px; margin-top: 1px; }

.main { flex: 1; min-width: 0; }
.content { padding: 30px 34px 60px; max-width: 1240px; margin: 0 auto; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.head-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ============ Cards ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); padding: 20px 22px;
}
.card h3 { margin: 0 0 16px; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.stat { position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.stat .value { font-family: var(--font-display); font-size: 27px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat-ic {
  position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, .12), rgba(139, 92, 246, .12));
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.value.income { color: var(--income); }
.value.expense { color: var(--expense); }

/* ============ Tables ============ */
.table-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border-soft); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 44px; text-align: center; color: var(--muted); }

table.dt th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.dt th.sortable:hover { color: var(--primary); }
table.dt th .arr { color: var(--primary); font-size: 10px; }
table.dt th.th-tools { text-align: right; width: 72px; }
tr.filter-row td { padding: 8px 10px; background: var(--filter-bg); border-bottom: 1px solid var(--border); }
tr.filter-row input, tr.filter-row select { padding: 7px 10px; font-size: 12.5px; border-radius: 9px; }
tr.filter-row input::placeholder { color: var(--muted); opacity: .55; }

.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 14px; line-height: 1;
  color: var(--muted); padding: 5px 9px; border-radius: 9px; transition: all .14s;
}
.icon-btn:hover { color: var(--primary); background: var(--btn-bg); }

/* ============ Badges ============ */
.badge {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
}
.badge.income { background: rgba(16, 185, 129, .13); color: #059669; }
.badge.expense { background: rgba(244, 63, 94, .12); color: #e11d48; }
.badge.role { background: rgba(99, 102, 241, .13); color: var(--primary-dark); }
.badge.muted { background: var(--btn-bg); color: var(--muted); }
.badge.st-prog { background: rgba(217, 119, 6, .13); color: var(--warn); }
.badge.pr-high { background: rgba(244, 63, 94, .12); color: #e11d48; }
.badge.pr-medium { background: rgba(217, 119, 6, .13); color: var(--warn); }
.badge.pr-low { background: var(--btn-bg); color: var(--muted); }
:root[data-theme="dark"] .badge.income { color: var(--income); }
:root[data-theme="dark"] .badge.expense { color: var(--expense); }
:root[data-theme="dark"] .badge.role { color: #b1b7ff; }
:root[data-theme="dark"] .badge.pr-high { color: var(--expense); }

.amt.income { color: var(--income); font-weight: 600; }
.amt.expense { color: var(--expense); font-weight: 600; }
.due-over { color: var(--expense); font-weight: 600; }

/* ============ Progress ============ */
.pwrap { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.pbar { flex: 1; height: 8px; background: var(--btn-bg); border-radius: 999px; overflow: hidden; }
.pfill { height: 100%; background: var(--grad); border-radius: 999px; transition: width .3s ease; }

/* ============ Buttons ============ */
.btn {
  font: inherit; font-weight: 600; font-size: 13.5px; padding: 10px 17px;
  border-radius: 11px; border: 1px solid var(--border); cursor: pointer;
  background: var(--card); color: var(--text);
  transition: all .15s; box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--grad); color: #fff; border: none;
  box-shadow: 0 8px 20px rgba(99, 102, 241, .35);
}
.btn-primary:hover { color: #fff; filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 10px 24px rgba(99, 102, 241, .42); }
.btn-danger { background: var(--danger-bg); color: var(--expense); border-color: transparent; }
.btn-danger:hover { border-color: var(--expense); color: var(--expense); }
/* "Завершить" — the one action people reach for on a row, so it is filled green rather
   than another outline button. Not var(--income): that green is tuned as TEXT on a light
   card and gives white ~2.2:1 as a background. These two clear 5:1 in their own theme. */
.btn-done { background: #047857; color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(4, 120, 87, .3); }
.btn-done:hover { background: #036a4c; color: #fff; border-color: transparent; }
:root[data-theme="dark"] .btn-done { background: #0b7a5c; }
:root[data-theme="dark"] .btn-done:hover { background: #0d8b69; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
/* A disabled button must not keep offering hover affordances. */
.btn[disabled]:hover { border-color: var(--border); color: var(--text); transform: none; }
.btn[disabled]:active { transform: none; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 4px 7px; font-weight: 600; font-size: 14px; border-radius: 8px; transition: background .12s; }
.btn-link:hover { background: rgba(99, 102, 241, .10); }
.btn-link.danger { color: var(--expense); }
.btn-link.danger:hover { background: var(--danger-bg); }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ============ Forms ============ */
input, select, textarea {
  font: inherit; font-size: 13.5px; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: 11px;
  background: var(--input-bg); color: var(--text); width: 100%;
  transition: border-color .14s, box-shadow .14s;
}
/* The browser's own select arrow sits wherever the platform decides — in practice hard
   against the right border, and it ignores padding-right. Draw our own instead: it obeys
   the inset below, matches the chevrons used elsewhere, and looks the same everywhere. */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 12px;
  padding-right: 38px; /* text must never run under the arrow */
}
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239095bf' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
/* The compact filter row overrides padding, so it needs its own arrow inset too. */
tr.filter-row select { background-position: right 10px center; padding-right: 30px; }

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .6; }
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 15px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: -3px; }
/* Quick-pick chips under a field (deadline shortcuts). */
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.quick .chip { padding: 5px 12px; font-size: 12px; }
.hint { font-size: 11.5px; color: var(--muted); }
.req { color: var(--expense); }
.with-add { display: flex; gap: 8px; }
.with-add select, .with-add input { flex: 1; min-width: 0; }
.with-add .icon-sq { flex: 0 0 auto; width: 42px; height: 42px; font-size: 18px; font-weight: 600; }
.with-add .icon-sq.ok { color: var(--income); border-color: var(--income); }
.with-add .icon-sq.ok:hover { background: rgba(16, 185, 129, .12); }

/* Person dropdown: a select that can show faces and be searched. */
.pick { position: relative; }
.pick-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font: inherit; font-size: 13.5px; padding: 8px 13px; min-height: 42px;
  border: 1px solid var(--border); border-radius: 11px; background: var(--input-bg);
  color: var(--text); cursor: pointer; text-align: left;
}
.pick-btn:hover { border-color: var(--primary); }
.pick-cur { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.pick-cur > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Positioned from JS on <body> so the modal's overflow can never clip it. */
.pick-pop {
  position: fixed; z-index: 90;
  background: var(--card); border: 1px solid var(--border); border-radius: 13px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.pick-srch { padding: 8px; border-bottom: 1px solid var(--border-soft); }
.pick-srch input { padding: 8px 11px; font-size: 13px; border-radius: 9px; }
.pick-list { max-height: 232px; overflow-y: auto; padding: 6px; }
.pick-opt {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  background: none; border: none; border-radius: 9px; font: inherit; font-size: 13.5px;
  color: var(--text); cursor: pointer; text-align: left;
}
.pick-opt:hover { background: var(--btn-bg); }
.pick-opt.on { background: rgba(99, 102, 241, .13); color: var(--primary-dark); font-weight: 600; }
:root[data-theme="dark"] .pick-opt.on { color: #b1b7ff; }
.pick-none { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.pick-ro {
  display: flex; align-items: center; gap: 9px; padding: 9px 13px; min-height: 42px;
  border: 1px solid var(--border-soft); border-radius: 11px; background: var(--bg); color: var(--muted);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-error { color: var(--expense); font-size: 13px; min-height: 18px; }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(9, 12, 26, .55);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  position: relative; background: var(--card); border: 1px solid var(--border);
  border-radius: 22px; width: 100%; max-width: 530px; padding: 28px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto;
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
.modal h2 { font-family: var(--font-display); margin: 0 0 20px; font-size: 19px; font-weight: 800; letter-spacing: -.01em; padding-right: 32px; }
.modal-close {
  position: absolute; top: 16px; right: 17px; background: var(--btn-bg); border: none;
  color: var(--muted); font-size: 14px; line-height: 1; padding: 8px 10px; border-radius: 10px; cursor: pointer;
  transition: all .14s;
}
.modal-close:hover { background: var(--danger-bg); color: var(--expense); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* ============ Column menu ============ */
.col-menu {
  position: absolute; background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 12px 14px; z-index: 70; min-width: 200px;
}
.col-menu label { display: flex; align-items: center; gap: 9px; padding: 6px 2px; font-size: 13px; cursor: pointer; border-radius: 8px; }
.col-menu label:hover { color: var(--primary); }
.col-menu input { width: auto; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #12172b; color: #fff; padding: 13px 24px; border-radius: 999px;
  box-shadow: var(--shadow-lg); z-index: 80; font-weight: 500; font-size: 13.5px;
  border: 1px solid rgba(255, 255, 255, .08);
  animation: rise .2s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.err { background: linear-gradient(135deg, #e11d48, #be123c); }

/* ============ Profile ============ */
.profile-head {
  display: flex; align-items: center; gap: 18px; background: var(--card);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  padding: 24px 26px; margin-bottom: 16px; max-width: 540px;
}
.u-avatar.lg { width: 60px; height: 60px; font-size: 21px; border-radius: 18px; }
.p-name { font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: -.01em; }
.profile-actions { display: flex; flex-direction: column; gap: 11px; max-width: 540px; }
.pa-btn {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: 15px; padding: 15px 18px;
  font: inherit; font-weight: 600; font-size: 14px; color: var(--text); cursor: pointer;
  text-align: left; box-shadow: var(--shadow); transition: all .15s;
}
.pa-btn:hover { border-color: var(--primary); transform: translateY(-1px); }
.pa-btn.danger { color: var(--expense); }
.pa-btn.danger:hover { border-color: var(--expense); background: var(--danger-bg); }

/* ============ Misc ============ */
.muted { color: var(--muted); }
.mt { margin-top: 18px; }

/* ============ Tasks board ============ */
.board-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.board-head h1 { font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0; display: flex; align-items: center; gap: 9px; }
.board-head h1 .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--income); box-shadow: 0 0 8px var(--income); }
.seg { display: inline-flex; background: var(--btn-bg); border-radius: 12px; padding: 4px; gap: 3px; }
.seg-btn { border: none; background: none; padding: 8px 18px; border-radius: 9px; font: inherit; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; transition: all .14s; }
.seg-btn.active { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,.35); }
.board-spacer { flex: 1; }
.icon-sq { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border); background: var(--card); color: var(--muted); font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all .14s; }
.icon-sq:hover { border-color: var(--primary); color: var(--primary); }

.filter-bar { background: var(--card); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 18px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* Collapses the search/selects row; the chips themselves always stay reachable. */
.bar-toggle { width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0; position: relative; }
.bar-toggle.closed .chev { transform: rotate(-90deg); }
/* Collapsed while filters are live — otherwise the short list has no visible cause. */
.bar-toggle.has-filters { border-color: var(--primary); color: var(--primary); }
.bar-toggle.has-filters::after {
  content: ''; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--grad); box-shadow: 0 0 0 2px var(--card);
}
.chip { border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: 7px 14px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; transition: all .14s; white-space: nowrap; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 6px 14px rgba(99,102,241,.3); }
.chip .cc { background: rgba(99,102,241,.15); color: var(--primary-dark); border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.chip.active .cc { background: rgba(255,255,255,.28); color: #fff; }
/* --primary-dark is tuned for light grounds; on a dark chip the count needs the lifted
   tint, the same one .badge.role and .pick-opt.on already switch to. */
:root[data-theme="dark"] .chip .cc { color: #b1b7ff; }
:root[data-theme="dark"] .chip.active .cc { color: #fff; }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; align-items: center; }
/* Names the date the period reads — it differs per tab. */
.chip-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.filter-grid { display: flex; gap: 10px; margin-top: 13px; flex-wrap: wrap; }
.filter-grid .fg { flex: 1 1 170px; min-width: 0; }
.filter-grid .fg.search { flex: 2 1 240px; }
.filter-grid .btn { flex: 0 0 auto; }

.an-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.an-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.an-head h3 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.an-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 16px 0 14px; }
.an-stat { position: relative; background: var(--bg); border: 1px solid var(--border); border-radius: 15px; padding: 22px; text-align: center; overflow: hidden; }
.an-stat::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--grad); }
.an-stat.warn::before { background: linear-gradient(90deg, #f43f5e, #fb923c); }
.an-stat.neutral::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.an-stat.ok::before { background: linear-gradient(90deg, #10b981, #34d399); }
.an-stat .n.ok { color: var(--income); }
.an-stat .n { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.an-stat .n.warn { color: var(--expense); }
.an-stat .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-top: 5px; font-weight: 600; }
.an-panels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.an-panel { background: var(--bg); border: 1px solid var(--border); border-radius: 15px; padding: 15px 17px; }
.an-panel h4 { margin: 0 0 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.an-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
/* Clickable rows are real <button>s — reset the UA styling, keep the flex layout. */
.an-row.cl {
  width: 100%; background: none; border: none; font: inherit; font-size: 13px;
  color: inherit; text-align: left; cursor: pointer; padding: 5px 7px; margin: 0 -7px;
  border-radius: 9px; transition: background .12s;
}
.an-row.cl:hover { background: var(--btn-bg); }
.an-row.on { background: rgba(99, 102, 241, .13); }
.an-row.on .an-name { color: var(--primary-dark); font-weight: 600; }
:root[data-theme="dark"] .an-row.on .an-name { color: #b1b7ff; }
.an-rank { width: 20px; height: 20px; border-radius: 6px; background: var(--btn-bg); color: var(--muted); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.an-name { display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-track { flex: 1; height: 7px; background: var(--btn-bg); border-radius: 999px; overflow: hidden; min-width: 30px; }
.an-fill { height: 100%; background: var(--grad); border-radius: 999px; }
.an-val { font-weight: 700; min-width: 18px; text-align: right; }

.list-tools { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 6px; }
.list-tools .btn { display: inline-flex; align-items: center; gap: 7px; }
.list-tools .btn.on { border-color: var(--primary); color: var(--primary); }
.list-tools .btn[disabled] { opacity: .45; cursor: not-allowed; }
.list-tools .btn[disabled]:hover { border-color: var(--border); color: var(--text); }
.chev { transition: transform .16s ease; flex-shrink: 0; }
.chev.up { transform: rotate(180deg); }

/* Flat "one list" mode: rows carry their own ordinal since there are no group headers. */
th.idx, td.idx { color: var(--muted); font-variant-numeric: tabular-nums; }
th.ta-r { text-align: right; }

/* Every project group renders its OWN table, so without a fixed grid each one would size
   its columns to its own content and the groups would not line up. The colgroup below is
   emitted identically in every group; `fixed` makes the browser honour it. */
table.tsk { table-layout: fixed; }
/* The title column MUST carry a width: under fixed layout an auto column only gets what is
   left AFTER the fixed ones, so on a narrow window it collapses to 0 and the title wraps one
   letter per line. But the widths are also the table's hard minimum — set them too generously
   and a 1280px laptop (card ≈ 954px) overflows by a few pixels, which buys a scrollbar and
   clips the row separators against the card's rounded corner. The sums below fit that case:
   groups 865px, list 905px. Beyond it the surplus is shared out and the grid still lines up. */
table.tsk col.w-title { width: 240px; }
table.tsk col.w-idx { width: 40px; }
table.tsk col.w-status { width: 130px; }
table.tsk col.w-person { width: 140px; }
table.tsk col.w-due { width: 100px; }
table.tsk col.w-act { width: 115px; }
table.tsk col.w-goal { width: 170px; } /* trash table only */
/* The title column takes whatever is left; long titles wrap rather than widen the table. */
table.tsk td.t-title { overflow-wrap: anywhere; }

.t-open {
  background: none; border: none; padding: 0; font: inherit; font-weight: 500;
  color: var(--text); cursor: pointer; text-align: left;
}
.t-open:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

/* Task detail card */
.card-desc { white-space: pre-wrap; margin: -6px 0 18px; font-size: 13.5px; line-height: 1.6; }
.card-tbl { width: 100%; margin-bottom: 6px; }
.card-tbl td { padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: middle; }
.card-tbl tr:last-child td { border-bottom: none; }
.card-tbl td.k { color: var(--muted); width: 42%; font-size: 12.5px; }

/* Task history timeline — collapsed until asked for, so opening a card costs no request. */
.hist-title {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin: 18px 0 4px; padding: 8px 0; background: none; border: none; cursor: pointer;
  font: inherit; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; text-align: left;
}
.hist-title:hover { color: var(--primary); }
.hist { max-height: 240px; overflow-y: auto; padding-right: 4px; }
.hist-row { padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.hist-row:last-child { border-bottom: none; }
.hist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hist-who { font-weight: 600; font-size: 13px; }
.hist-when { color: var(--muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hist-what { color: var(--muted); font-size: 12.5px; margin-top: 2px; line-height: 1.55; overflow-wrap: anywhere; }
.with-add .pick { flex: 1; min-width: 0; }

.range-dates { display: inline-flex; align-items: center; gap: 6px; }
.range-dates input { width: auto; padding: 6px 9px; font-size: 12.5px; border-radius: 9px; }
.rd-sep { color: var(--muted); }

/* Saved-filter manager */
.flt-menu { min-width: 262px; padding: 10px; }
.flt-head { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 4px 6px 8px; }
.flt-row { display: flex; align-items: center; gap: 4px; border-radius: 10px; padding: 2px 4px; }
.flt-row:hover { background: var(--btn-bg); }
.flt-ord { display: flex; flex-direction: column; }
.flt-ord .icon-btn { padding: 0 3px; line-height: 0; height: 13px; display: flex; align-items: center; }
.flt-ord .icon-btn[disabled] { opacity: .3; cursor: default; }
.flt-name { flex: 1; min-width: 0; text-align: left; background: none; border: none; font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text); cursor: pointer; padding: 8px 4px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flt-name:hover { color: var(--primary); }
.icon-btn.star { font-size: 13px; color: var(--muted); }
.icon-btn.star.on { color: #f59e0b; }
.icon-btn.danger { color: var(--expense); }
.flt-add { width: 100%; margin-top: 6px; background: none; border: 1px dashed var(--border); border-radius: 10px; padding: 9px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--primary); cursor: pointer; }
.flt-add:hover { border-color: var(--primary); background: rgba(99, 102, 241, .07); }
.chip .fav { color: #f59e0b; margin-right: 5px; }
.chip.active .fav { color: #fde68a; }
.filter-grid .icon-sq { flex: 0 0 auto; }

.grp { margin-top: 16px; }
.grp-head { display: flex; align-items: center; gap: 11px; padding: 6px 4px 12px; cursor: pointer; user-select: none; }
.grp-chev { color: var(--muted); font-size: 11px; width: 12px; }
.grp-name { font-family: var(--font-display); font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.grp-count { background: var(--grad); color: #fff; border-radius: 999px; min-width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; padding: 0 8px; box-shadow: 0 4px 12px rgba(99,102,241,.35); }
.grp-head .btn-sm { margin-left: auto; }

.ava-cell { display: inline-flex; align-items: center; gap: 8px; }
/* The collaborator rides in the assignee cell: overlapped, smaller, ringed against the row
   so it reads as "and also this person" rather than as a second column. */
.collab { display: inline-flex; margin-left: -6px; vertical-align: middle; }
.collab .ava-sm {
  width: 22px; height: 22px; font-size: 9px; border-radius: 7px;
  box-shadow: 0 0 0 2px var(--card);
}
:root[data-theme="dark"] .collab .ava-sm { box-shadow: 0 0 0 2px #1b1c3b; }
.ava-sm { width: 26px; height: 26px; border-radius: 8px; background: var(--grad); color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; letter-spacing: .02em; }
.t-title { font-weight: 500; color: var(--text); }
table.tsk tbody tr.ov > td:first-child { box-shadow: inset 3px 0 0 0 var(--expense); }
/* Pinned rows sit at the top of the list; the flag explains why they jumped the queue. */
table.tsk tbody tr.pin { background: rgba(99, 102, 241, .05); }
table.tsk tbody tr.pin:hover { background: rgba(99, 102, 241, .09); }
.pin-flag { margin-right: 7px; font-size: 12px; }

/* Subtasks: nested under their parent inside the same table. Indent the TITLE cell, not
   the first one — in list mode the first cell is the ordinal "#", so indenting it left the
   subtask's title flush with its parent's and the nesting was invisible.
   The parent's own title sits ~19px in, behind its chevron, so the indent has to clear that
   before it reads as nesting at all: 44px here lands the child's title ~25px to the right. */
tr.sub > td.t-title { padding-left: 44px; }
.sub-mark { color: var(--muted); margin-right: 6px; opacity: .55; }
.sub-toggle { background: none; border: none; padding: 0 6px 0 0; cursor: pointer; color: var(--muted); line-height: 0; }
.sub-toggle:hover { color: var(--primary); }
.sub-count { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--btn-bg); border-radius: 999px; padding: 1px 7px; margin-left: 2px; }
.sub-of { background: var(--btn-bg); border-radius: 10px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px; }
/* Subtasks queued up in the create form, before the parent has an id to hang them on. */
.subs-list { display: flex; flex-direction: column; gap: 5px; }
.subs-list:not(:empty) { margin-bottom: 8px; }
.sub-chip { display: flex; align-items: center; gap: 8px; background: var(--btn-bg); border-radius: 9px; padding: 7px 8px 7px 11px; font-size: 13px; }
.sub-chip-t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sub-x { background: none; border: none; cursor: pointer; color: var(--muted); font: inherit; font-size: 12px; padding: 2px 5px; border-radius: 6px; flex-shrink: 0; }
.sub-x:hover { color: var(--expense); background: var(--danger-bg); }

/* A deadline that keeps moving is the thing worth noticing, not the date it landed on. */
tr.moved > td:first-child { box-shadow: inset 3px 0 0 0 var(--expense); }
.due-moved { font-size: 11px; font-weight: 700; color: var(--expense); white-space: nowrap; }
/* How long is left, under the date itself. */
.due-left { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.due-left.over { color: var(--expense); font-weight: 600; }

/* Row actions: the destructive/rare ones stay out of sight until the row is hovered, so
   only "Завершить" — the one you actually reach for — is always visible.
   Keyboard users must still get there, hence :focus-within. */
.row-actions { align-items: center; }
.on-hover { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .12s; }
tr:hover .on-hover, tr:focus-within .on-hover { opacity: 1; }
/* A touch screen never hovers: the buttons would stay invisible forever — yet still take
   taps, since opacity does not block pointer events. Show them always on such devices. */
@media (hover: none) { .on-hover { opacity: 1; } }
.btn-xs { padding: 4px 11px; font-size: 12px; border-radius: 8px; white-space: nowrap; }

/* Drag a task onto another to make it a subtask. */
tr.dragging { opacity: .4; }
tr.drop-on > td { background: rgba(99, 102, 241, .12); box-shadow: inset 0 -2px 0 0 var(--primary); }

/* Project member picker */
.mem-list { display: flex; flex-direction: column; gap: 2px; max-height: 190px; overflow-y: auto; border: 1px solid var(--border); border-radius: 11px; padding: 6px; }
.mem { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.mem:hover { background: var(--btn-bg); }
.mem input { width: auto; margin: 0; }

/* Drag a group header to reorder the projects (each person has their own order). */
.grp-head { cursor: pointer; }
.grp-drag { cursor: grab; color: var(--muted); opacity: .45; font-size: 13px; letter-spacing: -1px; }
.grp-head:hover .grp-drag { opacity: .9; }
.grp.dragging { opacity: .45; }
.grp.drop-to .grp-head { box-shadow: inset 0 3px 0 0 var(--primary); border-radius: 4px; }
.btn-link.on { color: var(--primary); background: rgba(99, 102, 241, .13); }
.badge.kind-strategic { background: rgba(139, 92, 246, .15); color: #6d28d9; }
.badge.kind-routine { background: var(--btn-bg); color: var(--muted); }
:root[data-theme="dark"] .badge.kind-strategic { color: #c4b5fd; }
.pa-btn .pa-hint { margin-left: auto; font-size: 11.5px; font-weight: 500; color: var(--muted); }
/* Brief highlight on the row that was just saved, so the change is visible at a glance. */
@keyframes rowflash { from { background: rgba(99, 102, 241, .28); } to { background: transparent; } }
table.tsk tbody tr.flash { animation: rowflash 1.8s ease-out; }
@media (prefers-reduced-motion: reduce) { table.tsk tbody tr.flash { animation: none; background: rgba(99, 102, 241, .12); } }
.badge.st-wait { background: rgba(234,179,8,.16); color: #b45309; }
.badge.st-doing { background: rgba(59,130,246,.15); color: #2563eb; }
:root[data-theme="dark"] .badge.st-wait { color: #fbbf24; }
:root[data-theme="dark"] .badge.st-doing { color: #93c5fd; }

@media (max-width: 900px) {
  .an-stats, .an-panels { grid-template-columns: 1fr; }
}

/* ============ Collapsed sidebar (desktop only) ============ */
@media (min-width: 721px) {
  .sidebar.collapsed { width: 76px; padding-left: 12px; padding-right: 12px; }
  .sidebar.collapsed .side-head { justify-content: center; }
  .sidebar.collapsed .brand { display: none; }
  .sidebar.collapsed .nav a { justify-content: center; padding: 11px 0; gap: 0; }
  .sidebar.collapsed .nav .lbl { display: none; }
  .sidebar.collapsed .user-card { justify-content: center; padding: 8px; }
  .sidebar.collapsed .u-meta { display: none; }
}

/* ============ Mobile ============ */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 720px) {
  /* One group is on screen at a time here, so there is nothing to line columns up WITH —
     and a rigid grid would only force horizontal scrolling. Let the table breathe again. */
  table.tsk { table-layout: auto; }
  .side-toggle { display: none; }
  .app { display: block; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px; padding: 13px 16px;
    position: sticky; top: 0; z-index: 45; color: #fff;
    background: linear-gradient(180deg, var(--side-bg2), var(--side-bg));
  }
  .mtb-btn { background: rgba(255,255,255,.07); border: 1px solid rgba(255, 255, 255, .16); color: #fff; font-size: 17px; line-height: 1; border-radius: 10px; padding: 7px 12px; cursor: pointer; }
  .mtb-title { font-family: var(--font-display); font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; width: 252px; z-index: 60; transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 50px rgba(0, 0, 0, .55); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); backdrop-filter: blur(3px); z-index: 55; }
  .sidebar-backdrop.show { display: block; }
  .main { width: 100%; }
  .content { padding: 18px 16px 50px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card { padding: 16px; }
  .stat .value { font-size: 22px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .form-row { grid-template-columns: 1fr; }
  .modal { max-width: 100%; padding: 22px; border-radius: 18px; }
}
