/* App shell. Breakpoints from the prototype: mobile < 640, tablet 640–1023, desktop ≥ 1024. */

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
@media (max-width: 1023px) { .shell { grid-template-columns: 68px minmax(0, 1fr); } }
@media (max-width: 639px) { .shell { grid-template-columns: minmax(0, 1fr); } }

/* ── Sidebar ───────────────────────────────────────── */
.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; border-right: 1px solid var(--bd);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 20px; background: var(--bg); scrollbar-width: thin;
}
.side-logo { padding: 4px 8px; }
.side-logo .logo-name { font-size: 15px; letter-spacing: -0.01em; }
.ws-btn {
  width: 100%; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 7px; border: 1px solid var(--bd);
  border-radius: 9px; background: var(--sf); color: var(--tx); font-size: 13px; text-align: left;
}
.ws-btn:hover { border-color: var(--bd2); }
.ws-ini { width: 22px; height: 22px; border-radius: 7px; background: var(--sf3); display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; }
.ws-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.ws-btn .ic { font-size: 18px; color: var(--mu); }

.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-title { font-size: 11px; color: var(--mu); padding: 0 10px 6px; letter-spacing: 0.05em; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 7px; font-size: 13.5px;
  color: var(--mu); background: transparent; border: 0; width: 100%; text-align: left; transition: background-color .12s, color .12s;
}
.nav-item:hover, .nav-item[aria-current=page] { background: var(--sf2); color: var(--tx); }
.nav-item > .ic { font-size: 20px; }
.nav-label { flex: 1; white-space: nowrap; }
.nav-count { font-family: var(--mono); font-size: 11.5px; color: var(--mu); }
.nav-item .lock { font-size: 16px; color: var(--mu); }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 1px; }

.usage { border: 1px solid var(--bd); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--sf); cursor: pointer; text-align: left; color: var(--tx); width: 100%; }
.usage-head { display: flex; justify-content: space-between; font-size: 12px; }
.usage-row { display: flex; flex-direction: column; gap: 6px; }
.usage-line { display: flex; justify-content: space-between; font-size: 12px; }
.usage-line .mono { font-size: 11px; color: var(--mu); white-space: nowrap; }

.side-account {
  position: sticky; bottom: -14px; z-index: 5; margin: 0 -10px -14px; padding: 8px 10px 14px; background: var(--bg);
  border-top: 1px solid var(--bd); display: flex; justify-content: center;
}
.acc-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; border: 1px solid var(--bd); border-radius: 9px; padding: 8px 10px;
  background: var(--sf); color: var(--tx); text-align: left;
}
.acc-btn:hover { border-color: var(--bd2); }
.acc-btn > .ic { font-size: 18px; color: var(--mu); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--acbg); color: var(--act); display: grid; place-items: center; font-size: 11.5px; font-weight: 600; flex: none; }
.avatar--m { width: 32px; height: 32px; font-size: 12px; }
.avatar img, .acc-dot img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.acc-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.acc-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-plan { font-size: 11.5px; color: var(--mu); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-dot { width: 36px; height: 36px; border: 1px solid var(--bd); border-radius: 50%; background: var(--acbg); color: var(--act); font-size: 12px; font-weight: 600; padding: 0; }

/* Tablet rail: icons only. */
@media (max-width: 1023px) {
  .side .logo-name, .side .ws-name, .side .ws-btn > .ic, .side .nav-title, .side .nav-label, .side .nav-count, .side .nav-item .lock, .side .usage { display: none; }
}
@media (max-width: 639px) { .side { display: none; } }

/* ── Main column ───────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar); height: 56px; border-bottom: 1px solid var(--bd);
  display: flex; align-items: center; gap: 10px; padding: 0 24px; background: var(--bg);
}
.topbar-crumb { flex: 1; min-width: 0; font-size: 13px; color: var(--mu); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-crumb b { color: var(--tx); font-weight: 400; }
.topbar-crumb a:hover { color: var(--tx); opacity: 1; }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; position: relative; }
.topbar-search {
  display: flex; align-items: center; gap: 8px; width: 280px; height: 36px; border: 1px solid var(--bd); border-radius: 9px;
  padding: 0 14px; color: var(--mu); font-size: 13.5px; background: var(--sf); text-align: left; white-space: nowrap; overflow: hidden;
}
.topbar-search:hover { border-color: var(--bd2); }
.topbar-search .ic { font-size: 18px; }
.topbar-search .kbd { margin-left: auto; }
.topbar-brand { font-weight: 600; font-size: 15px; }
.notif-dot { position: absolute; top: 6px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--ac); box-shadow: 0 0 0 2px var(--sf); }
@media (max-width: 1023px) { .topbar-search { width: 200px; } }
@media (max-width: 639px) { .topbar { padding: 0 12px; } }

.page { padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; flex: 1; min-width: 0; width: 100%; max-width: 1384px; margin: 0 auto; }
@media (max-width: 1023px) { .page { padding: 24px 24px 40px; } }
@media (max-width: 639px) { .page { padding: 16px 16px 96px; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-sub { color: var(--mu); font-size: 13px; margin-top: 4px; }
/* the title gives way first, so the actions stay on one line while they fit (they wrap only when they don't) */
.page-title { flex: 1 1 0; min-width: 160px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 639px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .page-title { flex: none; min-width: 0; }
  .page-actions { justify-content: flex-start; }
  /* as in the mockup: a head made only of buttons fills the row (one full width, two halves); mixed heads (Calendar) keep their sizes */
  .page-actions:not(:has(> :not(.btn))) > .btn { flex: 1 1 0; }
  /* mixed heads: controls on the left, the main button at the right edge (Overview: period · New project) */
  .page-actions:has(> :not(.btn)) > .btn:last-child { margin-left: auto; }
}

/* Subscription banner and impersonation bar sit above the top bar. */
.sub-banner { display: flex; align-items: center; gap: 12px; padding: 10px 24px; font-size: 13.5px; flex-wrap: wrap; background: var(--cbg); border-bottom: 1px solid var(--cbd); }
.sub-banner > .ic { font-size: 20px; color: var(--c); }
.sub-banner-text { flex: 1; min-width: 200px; }
@media (max-width: 639px) {  /* icon by the first line, the close button stays beside the text, actions go under it */
  .sub-banner { padding: 10px 16px; align-items: flex-start; gap: 8px 12px; }
  .sub-banner > .ic { margin-top: 1px; }
  .sub-banner-text { min-width: 0; flex-basis: calc(100% - 76px); line-height: 1.45; }
  .sub-banner > .ibtn { order: 1; }
  .sub-banner > .btn { order: 2; margin-left: 32px; }
}
.imp-bar {
  position: sticky; top: 0; z-index: var(--z-impersonation); height: 36px; display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 0 12px; background: var(--warn); color: #1a1300; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden;
}
.imp-exit { height: 26px; padding: 0 12px; border: 0; border-radius: 7px; background: #1a1300; color: #fff; font-weight: 600; font-size: 12.5px; flex: none; }  /* dark on amber, as in the mockup */
.imp-exit:hover:not(:disabled) { background: #000; }
/* everything sticky moves down by the bar */
.shell--imp .side { top: 36px; height: calc(100dvh - 36px); }
.shell--imp .topbar { top: 36px; }
.imp-short { display: none; }
@media (max-width: 639px) { .imp-long { display: none; } .imp-short { display: inline; } }

/* ── Mobile tab bar & drawer ───────────────────────── */
.tabbar {
  position: sticky; bottom: 0; z-index: var(--z-topbar); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--bg);
  border-top: 1px solid var(--bd); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.tabbar button { height: 52px; border: 0; background: none; color: var(--mu); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; }
.tabbar button[aria-current=page] { color: var(--tx); }
.tabbar .ic { font-size: 22px; }

.drawer-scrim { position: fixed; inset: 0; z-index: var(--z-drawer); background: var(--scrim); }
.drawer {
  width: min(300px, 85vw); height: 100%; background: var(--bg); border-right: 1px solid var(--bd); padding: 16px 12px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px; animation: kp-in .16s ease-out; outline: none;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.drawer-ws { display: flex; flex-direction: column; gap: 2px; padding: 4px; border: 1px solid var(--bd); border-radius: 12px; background: var(--sf); }
.drawer .nav-group { gap: 2px; }
.drawer .nav-item { height: 44px; gap: 12px; border-radius: 9px; font-size: 15px; }
.drawer .menu-item { min-height: 44px; }
.drawer-section { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--bd); padding-top: 12px; }
.drawer-me { display: flex; align-items: center; gap: 10px; padding: 0 10px 8px; }

/* Workspace menu rows */
.ws-row { display: flex; align-items: center; gap: 2px; }
.ws-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 6px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--tx); font-size: 13px; text-align: left; }
.ws-item:hover { background: var(--sf2); }
.ws-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ws-item-sub { font-size: 11.5px; color: var(--mu); }
.ws-item .check-mark { font-size: 16px; color: var(--act); }
.drawer .ws-item { min-height: 44px; }
.drawer .ws-row .ibtn--s { width: 44px; height: 44px; }

/* Command palette */
.palette-scrim { position: fixed; inset: 0; z-index: var(--z-palette); background: var(--scrim); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette { width: min(600px, 100%); background: var(--sf); border: 1px solid var(--bd2); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; animation: kp-in .14s ease-out; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--bd); }
.palette-input .ic { font-size: 20px; color: var(--mu); }
.palette-input input { flex: 1; height: 52px; border: 0; outline: none; background: transparent; font-size: 15px; min-width: 0; }
.palette-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 10px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.palette-item[aria-selected=true] { background: var(--sf2); }
.palette-item > .ic { font-size: 20px; color: var(--mu); }
.palette-item .g { font-size: 12px; color: var(--mu); white-space: nowrap; flex: none; }
.palette-item .k { font-family: var(--mono); font-size: 11px; color: var(--mu); width: 14px; }

/* Notifications popover */
.notif {
  position: absolute; top: 46px; right: 0; width: min(360px, calc(100vw - 24px)); background: var(--sf); border: 1px solid var(--bd);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; animation: kp-in .14s ease-out; z-index: 40;
}
.notif-head { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--bd); }
.notif-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 14px; border-bottom: 1px solid var(--bd); }  /* RU labels are longer: a second row, not a hidden scroll */
.notif-empty { padding: 28px 14px; text-align: center; font-size: 13px; color: var(--mu); }
.notif-foot { padding: 10px 14px; font-size: 12.5px; color: var(--mu); }
.notif-item { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--bd); cursor: pointer; background: transparent; }
.notif-item[data-unread=true] { background: var(--acbg); }
.notif-item:hover { background: var(--sf2); }

/* Page grids (prototype layout tokens L.kpi, L.g21, L.g11, L.g3) */
.grid-kpi { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.grid-21 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.grid-11 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(220px, 31%), 1fr)); gap: 16px; }
.grid-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
@media (max-width: 1023px) { .grid-21 { grid-template-columns: minmax(0, 1fr); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) { .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-11, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.step-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; text-align: left; color: var(--tx); transition: border-color .12s; white-space: normal; }
.step-card:hover { border-color: var(--bd2); }
