.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: var(--sp-4);
    padding: 0 var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.brand-text { font-family: var(--font); }
.brand-mark { width: 28px; height: 28px; flex: none; }
.nav { display: flex; gap: 2px; margin-left: var(--sp-4); }
.nav-link {
    display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
    border-radius: var(--r-md); color: var(--text-2); font-weight: 500; transition: all var(--dur) var(--ease);
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active { color: var(--text); background: var(--surface-2); }
.nav-link.is-active .icon { color: var(--accent); }
.topbar-spacer { flex: 1; }
.search-trigger {
    display: inline-flex; align-items: center; gap: 10px; width: 240px; height: 34px; padding: 0 8px 0 12px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text-3);
    transition: border-color var(--dur);
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-trigger span:first-of-type { flex: 1; text-align: left; }
.icon-badge { position: relative; }
.icon-badge .count { position: absolute; top: 2px; right: 0; transform: scale(.85); }
.user-btn { background: none; border: 0; padding: 2px; border-radius: 50%; }
.user-btn:hover .avatar { box-shadow: 0 0 0 2px var(--border-strong); }

/* ===== Project bar ===== */
.project-bar {
    flex: none; display: flex; align-items: center; gap: var(--sp-5); padding: 10px var(--sp-4);
    border-bottom: 1px solid var(--border); background: var(--bg); min-height: 56px;
}
.project-name {
    display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 4px 8px 4px 4px;
    border-radius: var(--r-md); font-size: var(--fs-lg); font-weight: 650; letter-spacing: -.01em;
}
.project-name:hover { background: var(--surface-2); }
.project-name .icon { color: var(--text-3); }
.project-progress { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.project-progress .progress { width: 140px; }
.project-stat { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap; }
.project-stat strong { color: var(--text); font-weight: 600; }
.project-stat .icon { color: var(--text-3); width: 16px; height: 16px; }
.project-actions { margin-left: auto; display: flex; gap: var(--sp-2); }
/* U-03: расход / бюджет проекта — полоса жёлтая с 80 %, красная с 100 %. */
.project-spend {
    display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 4px 8px; border-radius: var(--r-md);
    color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap; cursor: pointer;
}
.project-spend:hover { background: var(--surface-2); }
.project-spend strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.project-spend .icon { color: var(--text-3); width: 16px; height: 16px; }
.spend-bar { width: 64px; height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.spend-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--st-working); }
.project-spend[data-level="warn"] .spend-bar > span { background: var(--st-waiting); }
.project-spend[data-level="over"] .spend-bar > span { background: var(--st-error); }
.project-spend[data-level="warn"] strong { color: var(--st-waiting); }
.project-spend[data-level="over"] strong { color: var(--st-error); }

/* ===== View ===== */
.view { flex: 1; min-height: 0; position: relative; }
.view-office { display: grid; grid-template-columns: var(--chat-w) 1fr; height: 100%; }
.view-page { height: 100%; overflow: auto; padding: var(--sp-6); }
.page-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-title { margin: 0; font-size: var(--fs-xl); font-weight: 650; letter-spacing: -.01em; flex: 1; }

/* ===== Command palette ===== */
.palette { width: min(600px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden; animation: pop 180ms var(--ease); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 var(--sp-4); border-bottom: 1px solid var(--border); }
.palette-input .icon { color: var(--text-3); }
.palette-input input { flex: 1; height: 52px; background: none; border: 0; outline: none; font-size: var(--fs-lg); }
.palette-list { max-height: 380px; overflow: auto; padding: 6px; }
.palette-group { padding: 8px 10px 4px; font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: var(--r-md); text-align: left; }
.palette-item.is-focused { background: var(--surface-2); }
.palette-item .sub { margin-left: auto; color: var(--text-3); font-size: var(--fs-sm); }
.palette-foot { display: flex; gap: var(--sp-4); padding: 8px var(--sp-4); border-top: 1px solid var(--border); color: var(--text-3); font-size: var(--fs-xs); }

/* ===== Notifications ===== */
.notif-panel { position: fixed; z-index: 900; width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); animation: pop var(--dur) var(--ease); overflow: hidden; }
.notif-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.notif-head button { margin-left: auto; }
.notif-list { max-height: 400px; overflow: auto; }
.notif-item { display: flex; gap: 10px; width: 100%; padding: 12px 14px; border: 0; background: none; text-align: left; border-bottom: 1px solid var(--border); }
.notif-item:hover { background: var(--surface-2); }
.notif-item:last-child { border-bottom: 0; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: transparent; }
.notif-item.unread .notif-dot { background: var(--accent); }
.notif-time { color: var(--text-3); font-size: var(--fs-xs); }

/* ===== Responsive (Q-15) ===== */
@media (max-width: 1180px) {
    :root { --chat-w: 320px; }
    .search-trigger { width: 40px; padding: 0; justify-content: center; }
    .search-trigger span, .search-trigger .kbd { display: none; }
    .nav-link span { display: none; }
}
@media (max-width: 860px) {
    .view-office { grid-template-columns: 1fr; }
    .project-bar { flex-wrap: wrap; gap: var(--sp-3); }
    .project-stat.optional { display: none; }
}
@media (max-width: 560px) {
    .nav { margin-left: 0; }
    .brand-text { display: none; }
    .project-progress .progress { width: 80px; }
}
.view-host { height: 100%; }
.balance-chip { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.balance-chip:hover { border-color: var(--accent); }
.balance-chip.is-low { color: var(--st-error); border-color: color-mix(in srgb, var(--st-error) 45%, var(--border)); }
.balance-chip[hidden] { display: none; }

/* U-04: поповер расхода проекта. */
.popover { width: 320px; max-height: min(70vh, 520px); overflow: auto; }
.spend-pop .menu-label { margin-top: 2px; }
.spend-list { list-style: none; margin: 0 0 6px; padding: 0 6px; }
.spend-list li { display: flex; align-items: baseline; gap: 8px; padding: 4px 4px; font-size: var(--fs-sm); color: var(--text-2); }
.spend-list .spend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.spend-list .spend-note { color: var(--text-3); font-size: var(--fs-xs); }
.spend-list strong { font-variant-numeric: tabular-nums; color: var(--text); }
.spend-list .spend-empty { color: var(--text-3); }
.spend-budget { padding: 6px 10px 8px; }
.spend-budget-row { display: flex; gap: 6px; margin-top: 4px; }
.spend-budget-row .input { flex: 1; min-width: 0; }

/* U-11: индикатор фонового воркера. */
.worker-badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
.worker-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-idle); }
.worker-badge[data-state="alive"] .dot { background: var(--st-working); box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-working) 25%, transparent); }
.worker-badge[data-state="dead"] .dot { background: var(--st-error); }
.worker-badge[data-state="fallback"] .dot { background: var(--st-waiting); animation: worker-pulse 1.2s ease-in-out infinite; }
@keyframes worker-pulse { 50% { opacity: .35; } }
