:root {
  --brand: #FF9100;
  --brand-ink: #B35F00;
  --bg: #F6F1EA;
  --surface: #FFFFFF;
  --surface-2: #FBF8F4;
  --ink: #1D1A16;
  --muted: #7A7268;
  --line: #E9E1D6;
  --ok: #16A34A;
  --warn: #D97706;
  --err: #DC2626;
  --info: #2563EB;
  --floor-a: #F3E6D3;
  --floor-b: #EBDCC6;
  --wall: #D8C7AE;
  --shadow: 0 1px 2px rgba(40, 25, 5, .06), 0 6px 20px rgba(40, 25, 5, .06);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15120F; --surface: #1F1B17; --surface-2: #26211C; --ink: #F4EEE6; --muted: #A69C90; --line: #352E27;
    --floor-a: #2C251E; --floor-b: #29221B; --wall: #3B3229; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25); --brand-ink: #FFB45C;
  }
}
:root[data-theme="dark"] {
  --bg: #15120F; --surface: #1F1B17; --surface-2: #26211C; --ink: #F4EEE6; --muted: #A69C90; --line: #352E27;
  --floor-a: #2C251E; --floor-b: #29221B; --wall: #3B3229; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25); --brand-ink: #FFB45C;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Manrope, system-ui, -apple-system, sans-serif; font-size: 15px; }
body { overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-ink); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* ---------- шапка ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; padding: calc(10px + var(--safe-t)) 16px 10px; display: flex; align-items: center; gap: 12px; }
.topbar .logo { width: 30px; height: 30px; flex: none; }
.topbar h1 { font-size: 17px; font-weight: 800; letter-spacing: .04em; }
.topbar .sub { font-size: 12px; opacity: .85; }
.goal { margin-left: auto; min-width: 120px; max-width: 220px; flex: 1; }
.goal .bar { height: 7px; border-radius: 9px; background: rgba(255,255,255,.3); overflow: hidden; margin-top: 4px; }
.goal .bar > i { display: block; height: 100%; background: #fff; border-radius: 9px; transition: width .6s; }
.goal .lbl { font-size: 11px; font-weight: 700; display: flex; justify-content: space-between; gap: 6px; }

/* ---------- навигация ---------- */
.layout { display: flex; min-height: calc(100vh - 56px); }
.nav { display: flex; }
.nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 4px; position: relative; }
.nav button .ic { font-size: 21px; line-height: 1; }
.nav button.active { color: var(--brand-ink); }
.nav .badge { position: absolute; top: 2px; right: calc(50% - 20px); }
@media (max-width: 859px) {
  .nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + var(--safe-b)); justify-content: space-around; }
  .nav button { flex: 1; }
  main { padding-bottom: calc(80px + var(--safe-b)); }
}
@media (min-width: 860px) {
  .nav { flex-direction: column; width: 92px; padding: 12px 6px; gap: 6px; border-right: 1px solid var(--line); background: var(--surface); position: sticky; top: 56px; height: calc(100vh - 56px); }
  .nav button { padding: 10px 4px; border-radius: 12px; }
  .nav button.active { background: color-mix(in srgb, var(--brand) 14%, transparent); }
}
main { flex: 1; min-width: 0; padding: 16px; max-width: 1400px; margin: 0 auto; width: 100%; }

.badge { background: var(--err); color: #fff; font-size: 10px; font-weight: 800; border-radius: 99px; padding: 1px 6px; min-width: 18px; text-align: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.err { color: var(--err); } .chip.info { color: var(--info); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 18px 0 10px; }
.section-title h2 { font-size: 18px; font-weight: 800; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 9px 14px; font-weight: 700; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
input.inp, textarea.inp, select.inp { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; outline: none; }
input.inp:focus, textarea.inp:focus, select.inp:focus { border-color: var(--brand); }
textarea.inp { resize: vertical; min-height: 70px; }
label.f { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }

.toggle { position: relative; width: 44px; height: 26px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; }
.toggle span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(18px); }

/* ---------- офис ---------- */
.office-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; font-weight: 800; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }

.office { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.room { position: relative; border-radius: 18px; overflow: hidden; border: 3px solid var(--wall); background:
  repeating-conic-gradient(var(--floor-a) 0 25%, var(--floor-b) 0 50%) 0 0 / 36px 36px; aspect-ratio: 16 / 10; box-shadow: var(--shadow); }
.room.big { grid-column: span 2; aspect-ratio: 32 / 10; }
@media (max-width: 720px) { .room.big { grid-column: span 1; aspect-ratio: 16 / 10; } }
.room .wallstrip { position: absolute; left: 0; right: 0; top: 0; height: 22%; background: linear-gradient(var(--wall), color-mix(in srgb, var(--wall) 70%, var(--floor-a))); border-bottom: 3px solid color-mix(in srgb, var(--wall) 75%, #000); }
.room .rlabel { position: absolute; left: 10px; top: 8px; z-index: 3; display: flex; gap: 6px; align-items: center; background: var(--surface); border-radius: 10px; padding: 3px 9px; font-weight: 800; font-size: 13px; box-shadow: var(--shadow); }
.room .rlabel i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.room .window { position: absolute; top: 4%; width: 13%; height: 13%; background: linear-gradient(135deg, #BFE3FF, #E8F5FF); border: 3px solid #fff; border-radius: 4px; opacity: .9; }
.room .rug { position: absolute; left: 30%; right: 30%; bottom: 8%; height: 26%; border-radius: 50%; opacity: .25; }
.desk { position: absolute; width: 16%; height: 14%; transform: translateX(-50%); z-index: 1; }
.desk .top { position: absolute; inset: 0; background: #A47148; border-radius: 6px; box-shadow: inset 0 -5px 0 #7D5232; }
.desk .pc { position: absolute; left: 30%; width: 40%; top: -55%; height: 70%; background: #2A2A2A; border-radius: 3px; border: 2px solid #444; }
.desk .pc::after { content: ""; position: absolute; inset: 2px; background: #3A3F4A; border-radius: 1px; }
.desk.on .pc::after { background: linear-gradient(180deg, #7CC4FF, #4F9DFF); animation: screen 1.2s infinite alternate; }
@keyframes screen { to { filter: brightness(1.25); } }
.plant { position: absolute; width: 6%; aspect-ratio: 1; z-index: 1; }
.plant::before { content: "🪴"; font-size: clamp(16px, 2.2vw, 26px); }
.coffee::before { content: "☕"; }
.cooler { position: absolute; z-index: 1; font-size: clamp(16px, 2vw, 24px); }

/* персонаж */
.sim { position: absolute; width: 30px; height: 46px; transform: translate(-50%, -100%); z-index: 5; cursor: pointer; transition: left 2.4s linear, top 2.4s linear; }
.sim .body { position: absolute; inset: 0; transform-origin: bottom center; }
.sim.flip .body { transform: scaleX(-1); }
.sim .shadow { position: absolute; bottom: -3px; left: 3px; width: 24px; height: 7px; border-radius: 50%; background: rgba(0,0,0,.18); }
.sim .ring { position: absolute; bottom: -5px; left: -1px; width: 32px; height: 11px; border-radius: 50%; border: 2px solid transparent; }
.sim.working .ring { border-color: var(--ok); animation: pulse 1.4s infinite; }
.sim.talking .ring { border-color: var(--info); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { transform: scale(1.15); opacity: .5; } }
.sim .leg { position: absolute; bottom: 0; width: 7px; height: 11px; background: #2F3542; border-radius: 0 0 3px 3px; }
.sim .leg.l { left: 8px; } .sim .leg.r { right: 8px; }
.sim.walking .leg.l { animation: legL .4s infinite alternate; }
.sim.walking .leg.r { animation: legL .4s infinite alternate-reverse; }
@keyframes legL { from { transform: translateY(0) } to { transform: translateY(-3px) } }
.sim .torso { position: absolute; bottom: 10px; left: 5px; width: 20px; height: 17px; border-radius: 7px 7px 3px 3px; }
.sim .arm { position: absolute; bottom: 12px; width: 5px; height: 13px; border-radius: 3px; }
.sim .arm.l { left: 2px; } .sim .arm.r { right: 2px; }
.sim.working .arm { animation: type .25s infinite alternate; }
@keyframes type { to { transform: translateY(-2px); } }
.sim .head { position: absolute; top: 2px; left: 6px; width: 18px; height: 18px; border-radius: 50%; }
.sim .head::before, .sim .head::after { content: ""; position: absolute; top: 9px; width: 2.5px; height: 2.5px; background: #1D1A16; border-radius: 50%; }
.sim .head::before { left: 5px; } .sim .head::after { right: 5px; }
.sim .hair { position: absolute; top: 0; left: 5px; width: 20px; height: 10px; border-radius: 10px 10px 3px 3px; }
.sim .hair.long::after { content: ""; position: absolute; top: 5px; left: -1px; right: -1px; height: 15px; background: inherit; border-radius: 0 0 6px 6px; z-index: -1; }
.sim .beard { position: absolute; top: 14px; left: 8px; width: 14px; height: 6px; border-radius: 0 0 7px 7px; opacity: .85; }
.sim .glasses { position: absolute; top: 9px; left: 8px; width: 14px; height: 5px; border: 1.5px solid #222; border-radius: 3px; }
.sim .name { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 4px; font-size: 10.5px; font-weight: 800; background: var(--surface); padding: 0 6px; border-radius: 6px; white-space: nowrap; box-shadow: var(--shadow); }
.sim .qcount { position: absolute; top: -4px; right: -8px; z-index: 2; }
.bubble { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 4px 8px; font-size: 11px; font-weight: 700; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; box-shadow: var(--shadow); border: 1px solid var(--line); z-index: 6; animation: pop .25s; }
.bubble::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--surface); }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
.sim:hover .name { background: var(--brand); color: #fff; }

/* лента */
.feed { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow: auto; }
.feed .it { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 7px 9px; border-radius: 10px; background: var(--surface-2); }
.feed .it .t { color: var(--muted); font-size: 11px; white-space: nowrap; margin-top: 1px; }
.feed .it.error { background: color-mix(in srgb, var(--err) 10%, var(--surface)); }
.feed .it.success { background: color-mix(in srgb, var(--ok) 9%, var(--surface)); }
.feed .it.notify { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); }
.ava { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; }

/* ---------- панель (sheet) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 12, 0, .38); z-index: 40; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; z-index: 41; background: var(--bg); display: flex; flex-direction: column; box-shadow: 0 -10px 40px rgba(0,0,0,.2); }
@media (max-width: 859px) { .sheet { left: 0; right: 0; bottom: 0; max-height: 92vh; border-radius: 22px 22px 0 0; animation: up .25s ease-out; padding-bottom: var(--safe-b); } }
@media (min-width: 860px) { .sheet { top: 0; right: 0; bottom: 0; width: 480px; animation: left .25s ease-out; } }
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
@keyframes left { from { transform: translateX(30%); opacity: 0; } }
.sheet-head { padding: 16px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); background: var(--surface); border-radius: inherit; }
.sheet-body { overflow: auto; padding: 14px 16px 24px; flex: 1; }
.portrait { width: 56px; height: 56px; border-radius: 16px; position: relative; flex: none; overflow: hidden; }
.portrait .sim { left: 50%; top: 100%; transform: translate(-50%, -88%) scale(1.25); cursor: default; transition: none; }
.portrait .sim .name { display: none; }
.tabs { display: flex; gap: 6px; margin: 4px 0 12px; overflow-x: auto; }
.tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.tabs button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.x { margin-left: auto; border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 50%; font-size: 18px; flex: none; }

.task { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 11px 12px; margin-bottom: 8px; }
.task .steps { margin: 8px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); display: grid; gap: 3px; }
.task .result { margin-top: 8px; white-space: pre-wrap; font-size: 13.5px; background: var(--surface-2); border-radius: 10px; padding: 9px 10px; }
details > summary { cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 700; margin-top: 6px; }

/* чат */
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; padding: 9px 12px; border-radius: 16px; white-space: pre-wrap; font-size: 14px; line-height: 1.4; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.typing { color: var(--muted); font-style: italic; }
.composer { display: flex; gap: 8px; padding: 10px 16px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea { min-height: 42px; max-height: 140px; }

/* ---------- списки и таблицы ---------- */
.list { display: grid; gap: 10px; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 8px; min-height: 120px; }
.col h3 { font-size: 13px; font-weight: 800; padding: 4px 6px 8px; display: flex; justify-content: space-between; }
.co { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; margin-bottom: 7px; cursor: pointer; }
.co b { font-size: 14px; }
.co .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td, .table th { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plus { color: var(--ok); } .minus { color: var(--err); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.pre { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.media-grid .m { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); font-size: 12px; }
.media-grid img, .media-grid video { width: 100%; aspect-ratio: 4/5; object-fit: cover; display: block; background: #000; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14px; }
.progress-big { height: 14px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.progress-big i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #FFB347); }

.fab { position: fixed; right: 16px; bottom: calc(86px + var(--safe-b)); z-index: 25; border: 0; background: var(--brand); color: #fff; border-radius: 99px; padding: 10px 16px 10px 10px; display: flex; align-items: center; gap: 8px; font-weight: 800; box-shadow: 0 8px 24px rgba(255, 145, 0, .45); }
.fab .ava { background: #fff; color: var(--brand); width: 32px; height: 32px; }
@media (min-width: 860px) { .fab { bottom: 20px; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(64px + var(--safe-t)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 60; font-weight: 700; font-size: 14px; max-width: 90vw; animation: pop2 .25s; }
@keyframes pop2 { from { opacity: 0; transform: translate(-50%, -10px); } }

.login { min-height: 100vh; display: grid; place-items: center; background: var(--brand); padding: 16px; }
.login .card { width: 100%; max-width: 360px; text-align: center; }
.login img { width: 64px; height: 64px; background: var(--brand); border-radius: 18px; padding: 14px; }
.setup-step { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setup-step:last-child { border-bottom: 0; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-size: 13px; }

@media (max-width: 600px) {
  .topbar .sub { display: none; }
  .topbar h1 { font-size: 15px; }
  .stats { display: flex; overflow-x: auto; gap: 8px; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
  .stats::-webkit-scrollbar { display: none; }
  .stat { flex: none; min-width: 118px; padding: 8px 10px; }
  .stat b { font-size: 17px; }
  .office { grid-template-columns: 1fr; }
  .fab { padding: 8px; } .fab .label { display: none; }
}
.list > * { min-width: 0; } .office > * { min-width: 0; }
