:root {
  --ink: #001F47;
  --muted: #4B5563;
  --soft-ink: #374151;
  --line: #E5E7EB;
  --line-2: #D1D5DB;
  --bg: #F3F4F6;
  --card: #FFFFFF;
  --danger: #B91C1C;
  --radius: 16px;
  --tg: #229ED9;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Onest, Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--ink); }
img { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { padding: 40px; color: var(--muted); }
:focus-visible { outline: 2px solid #2563EB; outline-offset: 2px; }

/* ---------- кнопки ---------- */
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:disabled { background: #9CA3AF; border-color: #9CA3AF; cursor: not-allowed; }
.btn-tg { background: var(--tg); border-color: var(--tg); color: #fff; min-height: 50px; font-size: 15px; }
.btn-danger { color: var(--danger); border-color: #FECACA; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.seg { display: grid; gap: 4px; padding: 4px; background: var(--bg); border-radius: 10px; }
.seg button { min-height: 38px; border: none; border-radius: 7px; background: transparent; font-size: 12px; font-weight: 600; padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg.light button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,31,71,.12); }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.login-card { width: 100%; max-width: 880px; background: var(--card); border: 1px solid var(--line); border-radius: 24px; display: flex; flex-wrap: wrap; overflow: hidden; }
.login-info { flex: 1 1 360px; padding: 44px 40px; display: flex; flex-direction: column; gap: 24px; }
.login-info h1 { margin: 0; font-size: 32px; line-height: 1.15; }
.login-info p { margin: 0; font-size: 16px; line-height: 1.5; color: var(--soft-ink); }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; font-size: 15px; line-height: 1.45; }
.steps li span { width: 28px; height: 28px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: -3px; }
.login-note { margin-top: auto !important; font-size: 13px !important; color: var(--muted) !important; }
.login-qr { flex: 1 1 320px; background: #F7F8FA; border-left: 1px solid var(--line); padding: 40px 32px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.qr-box { width: 236px; height: 236px; padding: 18px; background: #fff; border-radius: 18px; box-shadow: 0 1px 3px rgba(0,31,71,.1); display: flex; align-items: center; justify-content: center; }
.qr-box img { width: 200px; height: 200px; }
.qr-box.dim img { opacity: .15; }
.or { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 280px; font-size: 13px; color: var(--muted); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-status { font-size: 13px; color: var(--muted); text-align: center; min-height: 18px; }
.login-qr .btn { width: 100%; max-width: 280px; }

/* ---------- шапка ---------- */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 14px; margin: 0; font-size: 18px; font-weight: 600; }
.brand img { height: 26px; width: auto; }
.brand i { width: 1px; height: 22px; background: var(--line-2); }
.nav { display: flex; gap: 4px; padding: 4px; background: var(--bg); border-radius: 12px; }
.nav a { padding: 9px 14px; border-radius: 9px; font-size: 14px; font-weight: 500; text-decoration: none; color: var(--muted); }
.nav a[aria-current="page"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,31,71,.08); }
.month-sw { display: flex; align-items: center; gap: 6px; }
.month-sw strong { min-width: 140px; text-align: center; font-size: 17px; }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 18px; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.me-name { display: flex; flex-direction: column; font-size: 14px; font-weight: 600; }
.me-name small { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------- календарь ---------- */
.page { display: flex; flex-wrap: wrap; gap: 24px; padding: 20px 24px 40px; align-items: flex-start; }
.main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px 0 8px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; font-size: 13px; font-weight: 600; }
.chip img { width: 22px; height: 22px; object-fit: contain; }
.chip[aria-pressed="false"] img { opacity: .4; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 12px; color: var(--soft-ink); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .sep { width: 1px; height: 16px; background: var(--line-2); }
.dot { width: 10px; height: 10px; border-radius: 5px; border: 2px solid var(--ink); flex-shrink: 0; }
.cal { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.cal-inner { min-width: 760px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head { border-bottom: 1px solid var(--line); }
.cal-head div { padding: 12px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cal-grid { gap: 1px; background: var(--line); }
.cell { background: #fff; min-height: 132px; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.cell.out { background: #F9FAFB; }
.daynum { align-self: flex-start; min-width: 28px; height: 28px; padding: 0 7px; border-radius: 14px; border: none; background: transparent; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.daynum:hover { background: var(--bg); }
.cell.out .daynum { color: #6B7280; }
.cell.today .daynum { background: var(--ink); color: #fff; }
.entry { display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 5px 7px; border: none; border-radius: 8px; text-align: left; }
.entry.sel { box-shadow: 0 0 0 2px var(--ink); }
.entry .l1, .entry .l2 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.entry .l1 b { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .l2 { padding-left: 3px; font-size: 11px; color: var(--muted); }
.entry .l2 em { font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry svg { flex-shrink: 0; }
.more { border: none; background: none; font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 2px 6px; }

/* мобильный список */
.mob { display: none; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.week button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0; min-height: 62px; border-radius: 12px; border: none; background: transparent; }
.week button small { font-size: 11px; font-weight: 500; }
.week button b { font-size: 16px; }
.week button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.week .dots { display: flex; gap: 2px; height: 5px; }
.week .dots i { width: 5px; height: 5px; border-radius: 3px; }
.mob-head { display: flex; align-items: center; justify-content: space-between; }
.mob-head h2 { margin: 0; font-size: 22px; }
.daylist { display: flex; flex-direction: column; gap: 10px; }
.daylist .label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.card { width: 100%; text-align: left; background: #fff; border: none; border-radius: 16px; padding: 14px; display: flex; gap: 12px; align-items: flex-start; box-shadow: 0 1px 2px rgba(0,31,71,.06); }
.card .ic { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.card .proj { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--soft-ink); }
.card .proj img { width: 16px; height: 16px; object-fit: contain; }
.card .ttl { font-size: 15px; font-weight: 600; line-height: 1.35; }
.card .meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.card .meta em { font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta .cc { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; }
.empty { background: #fff; border-radius: 16px; padding: 28px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.fab { display: none; position: fixed; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 29px; border: none; background: var(--ink); color: #fff; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(0,31,71,.28); z-index: 20; }

/* ---------- панель / плашка ---------- */
.panel { flex: 1 1 360px; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; }
.panel h2 { margin: 0; font-size: 21px; line-height: 1.25; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head img { height: 24px; width: auto; max-width: 240px; object-fit: contain; object-position: left center; }
.grab { display: none; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .field > .lbl { font-size: 13px; font-weight: 600; }
.input { height: 44px; border-radius: 10px; border: 1px solid var(--line-2); padding: 0 12px; font-size: 14px; background: #fff; width: 100%; }
.pick { display: flex; flex-wrap: wrap; gap: 6px; }
.pick button { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 12px 0 7px; border-radius: 999px; border: 1.5px solid var(--line-2); background: #fff; font-size: 13px; font-weight: 500; }
.pick button img { width: 20px; height: 20px; object-fit: contain; }
.fmt { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.fmt button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 64px; border-radius: 10px; border: 1.5px solid var(--line-2); background: #fff; font-size: 12px; font-weight: 600; }
.fmt button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.whoami { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--bg); border-radius: 12px; }
.whoami .avatar { width: 32px; height: 32px; font-size: 13px; }
.whoami small { display: block; font-size: 12px; color: var(--muted); }
.whoami b { font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.4; margin: 0; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fact { background: #F7F8FA; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact small { font-size: 11px; color: var(--muted); }
.fact b { font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; }
.fact input { border: none; background: transparent; font-size: 13px; font-weight: 600; padding: 0; width: 100%; }
.files a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; font-weight: 500; text-decoration: none; }
.files a span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files a small { color: var(--muted); font-weight: 400; white-space: nowrap; }
.files { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; }
.row .input { flex: 1; min-width: 0; }
.notes { display: flex; flex-direction: column; gap: 10px; }
.note { display: flex; gap: 10px; }
.note .av { width: 30px; height: 30px; border-radius: 15px; background: var(--line); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.note.mine .av { background: var(--ink); color: #fff; }
.note .bubble { flex: 1; min-width: 0; background: var(--bg); border-radius: 4px 14px 14px 14px; padding: 9px 12px; display: flex; flex-direction: column; gap: 3px; }
.note .bubble small { font-size: 12px; font-weight: 600; }
.note .bubble small i { font-style: normal; font-weight: 400; color: var(--muted); }
.note .bubble p { margin: 0; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.compose { display: flex; gap: 8px; align-items: center; }
.compose .input { border-radius: 22px; padding: 0 16px; }
.send { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.backdrop { display: none; }
.upload { cursor: pointer; width: 100%; }
.upload:focus-within { outline: 2px solid #2563EB; outline-offset: 2px; }

/* ---------- отчёты ---------- */
.rep { max-width: 1280px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.rep-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.rep-head h2 { margin: 0; font-size: 28px; }
.rep-head p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.rep-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.tile small { font-size: 13px; color: var(--muted); }
.tile b { font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.box { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.box h3 { margin: 0; font-size: 16px; }
.bar { display: flex; flex-direction: column; gap: 6px; }
.bar .t { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.bar .t .name { flex: 1; }
.bar .t b { font-variant-numeric: tabular-nums; }
.bar .t img { width: 20px; height: 20px; object-fit: contain; }
.bar .track { height: 10px; background: #F1F2F4; border-radius: 4px; }
.bar .fill { height: 10px; background: var(--ink); border-radius: 0 4px 4px 0; }
.table-box { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.table-box h3 { margin: 0; padding: 18px 20px; font-size: 16px; border-bottom: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding: 10px 14px; }
td { padding: 11px 14px; border-top: 1px solid #F1F2F4; }
td:first-child, th:first-child { padding-left: 20px; }
td .pdot { display: inline-block; width: 8px; height: 8px; border-radius: 4px; margin-right: 6px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; transition: transform .2s, opacity .2s; z-index: 50; pointer-events: none; opacity: 0; visibility: hidden; }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }

/* ---------- телефон ---------- */
@media (max-width: 820px) {
  .top { padding: 10px 14px; gap: 10px; }
  .brand span, .brand i, .month-sw, .me-name, .top .add-btn { display: none; }
  .nav { order: 3; width: 100%; }
  .nav a { flex: 1; text-align: center; }
  .page { padding: 14px 14px 100px; gap: 14px; }
  .cal, .legend { display: none; }
  .mob { display: flex; flex-direction: column; gap: 14px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
  .chip { flex-shrink: 0; }
  .fab { display: flex; }
  .panel { display: none; position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-width: none; max-height: 86vh; border-radius: 24px 24px 0 0; z-index: 40; padding: 10px 18px calc(20px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px rgba(0,31,71,.16); }
  .panel.open { display: flex; }
  .grab { display: block; align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); flex-shrink: 0; }
  .backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,31,71,.45); z-index: 30; border: none; }
  .rep { padding: 16px 14px 40px; }
  .rep-head h2 { font-size: 22px; }
  .login-info { padding: 32px 24px; }
  .login-qr { border-left: none; border-top: 1px solid var(--line); }
}
.sheet-only { display: none; }
@media (max-width: 820px) { .sheet-only { display: inline-flex; } }
