:root {
  --bg: #e9e9e7; --surface: #fcfcfb; --ink: #151515; --muted: #8a8a86; --line: #ececea;
  --chip: #ededeb; --chip-ink: #555551;
  --lime: #d2f45a; --lime-2: #b6ec3c; --lime-ink: #1c2a05;
  --danger: #c2412d; --ok: #2f8a4a;
  --radius: 20px; --radius-sm: 999px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04);
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111111; --surface: #1b1b1b; --ink: #f1f1ee; --muted: #8f8f8a; --line: #282828;
          --chip: #262626; --chip-ink: #b9b9b4; --danger: #ff7a63; --ok: #7bd58f;
          --shadow: 0 1px 2px rgba(0,0,0,.3); }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45;
       -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
a:hover { opacity: .75; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 13px; font-weight: 600; margin: 0; }
h3 { font-size: 11px; font-weight: 500; margin: 18px 0 6px; color: var(--muted); text-transform: none; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--danger); }

/* ---------- верхняя панель ---------- */
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
       padding: 14px 24px; position: sticky; top: 0; z-index: 5;
       background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.logo span { font-weight: 400; color: var(--muted); }
.logo svg { width: 20px; height: 20px; stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; fill: none; }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-sm); background: var(--surface);
       box-shadow: var(--shadow); flex-wrap: wrap; }
.seg a, .seg button { padding: 6px 14px; border-radius: var(--radius-sm); font-size: 13px; color: var(--chip-ink);
       white-space: nowrap; background: none; border: 0; }
.seg a.on { background: var(--ink); color: var(--surface); }
.seg a:hover { opacity: 1; color: var(--ink); }
.seg a.on:hover { color: var(--surface); }
.seg.sub { background: var(--chip); box-shadow: none; }
.seg.sub a.on { background: var(--ink); }

.who { justify-self: end; position: relative; }
.who summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer;
               background: var(--surface); padding: 4px 12px 4px 4px; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.who summary::-webkit-details-marker { display: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--surface);
          display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.who-text { display: flex; flex-direction: column; line-height: 1.1; }
.who-text b { font-size: 12px; }
.who-text small { font-size: 10px; color: var(--muted); }
.who-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border-radius: 14px;
            box-shadow: var(--shadow); padding: 8px; display: flex; flex-direction: column; gap: 2px; min-width: 170px; }
.who-menu a, .who-menu .plain { padding: 8px 10px; border-radius: 8px; font-size: 13px; text-align: left; }
.who-menu a:hover, .who-menu .plain:hover { background: var(--chip); opacity: 1; }

/* ---------- раскладка ---------- */
main { padding: 8px 24px 40px; max-width: 1400px; margin: 0 auto; }
.subnav { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap;
             margin: 6px 4px 16px; }
.banner { background: var(--surface); color: var(--muted); padding: 10px 16px; border-radius: 14px; margin-bottom: 14px;
          font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; align-items: start; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
        min-width: 0; margin-bottom: 12px; }
.grid .card, .stack .card { margin-bottom: 0; }
.card.soon { background: transparent; box-shadow: none; border: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.metric { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.metric small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 2px; }

/* KPI плитки */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi small { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi b { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.kpi.alert b { color: var(--danger); }

/* ---------- цели ---------- */
.goal { padding: 12px 0; border-top: 1px solid var(--line); }
.goal:first-of-type { border-top: 0; padding-top: 0; }
.goal-top { display: flex; justify-content: space-between; gap: 12px; font-weight: 500; }
.bar { height: 8px; background: var(--chip); border-radius: 999px; margin: 10px 0 8px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--lime), var(--lime-2)); }
.goal-actions { display: flex; gap: 12px; align-items: center; font-size: 12px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; }
form.inline input { width: 64px; }
form.add { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
form.add .row { display: flex; gap: 8px; }
form.add .row input { flex: 1; min-width: 0; }

/* ---------- элементы форм ---------- */
input, button { font: inherit; color: inherit; }
input { background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 6px 2px;
        font-size: 13px; }
input:focus { outline: none; border-bottom-color: var(--ink); }
label.field { font-size: 11px; color: var(--muted); display: block; }
button { cursor: pointer; border: 0; }
.btn { background: var(--chip); color: var(--ink); border-radius: var(--radius-sm); padding: 6px 12px; font-size: 12px; font-weight: 500; }
.btn-lime { background: linear-gradient(90deg, var(--lime), var(--lime-2)); color: var(--lime-ink);
            border-radius: 14px; padding: 12px 16px; font-weight: 600; font-size: 13px; width: 100%;
            box-shadow: inset 0 -2px 0 rgba(0,0,0,.06); }
.btn-lime:hover { filter: brightness(1.03); }
.plain { background: none; padding: 0; color: var(--muted); font-size: 12px; }

/* ---------- списки ---------- */
ul.tasks, ul.docs, ul.bullets { list-style: none; padding: 0; margin: 0; }
ul.tasks li, ul.docs li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0;
                          border-top: 1px solid var(--line); }
ul.tasks li:first-child, ul.docs li:first-child { border-top: 0; }
ul.tasks li.late > :first-child { color: var(--danger); }
ul.tasks .muted, ul.docs .muted { font-size: 12px; white-space: nowrap; }
ul.bullets li { position: relative; padding: 0 0 10px 16px; }
ul.bullets li::before { content: ""; position: absolute; left: 0; top: .5em; width: 6px; height: 6px; border-radius: 50%;
                        background: var(--lime-2); }

.chip { display: inline-block; background: var(--chip); color: var(--chip-ink); border-radius: var(--radius-sm);
        padding: 2px 9px; font-size: 11px; }
.chip.dark { background: var(--ink); color: var(--surface); }
.chip.red { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.chip.green { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: top; }
thead th { border-top: 0; color: var(--muted); font-weight: 500; font-size: 11px; white-space: nowrap; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 600; }
td a { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }

/* ---------- контент ---------- */
.cards { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 8px; scroll-snap-type: x mandatory; }
.cards img { width: 216px; height: 270px; object-fit: cover; flex: none; border-radius: 14px; scroll-snap-align: start;
             background: var(--chip); box-shadow: 0 6px 18px rgba(0,0,0,.12); }
details > summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 8px; }
.prose { max-width: 780px; font-size: 14px; line-height: 1.6; }
.prose h1 { font-size: 22px; margin-bottom: 14px; }
.prose h2 { font-size: 16px; margin: 26px 0 8px; }
.prose h3 { font-size: 14px; color: var(--ink); font-weight: 600; margin: 18px 0 6px; }
.prose li { margin: 4px 0; }
.prose a { text-decoration: underline; text-underline-offset: 3px; word-break: break-word; }
.prose table { margin: 12px 0; }

/* ---------- вход ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { text-align: center; max-width: 360px; width: 100%; padding: 32px; }
.login-card .logo { justify-content: center; margin-bottom: 8px; font-size: 18px; }

@media (max-width: 1000px) {
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
}
@media (max-width: 760px) {
  .top { grid-template-columns: 1fr auto; padding: 10px 16px; }
  .main-nav { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; flex-wrap: nowrap; justify-self: stretch;
              scrollbar-width: none; }
  .main-nav::-webkit-scrollbar { display: none; }
  .who-text { display: none; }
  .who summary { padding: 4px; }
  main { padding: 8px 16px 32px; }
  .subnav .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
}
