/* App shell: sidebar, top bar, content, mobile tab bar. */

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column; gap: 28px;
  padding: 22px 16px 16px;
  background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--brand-fg); }
.brand:hover { color: var(--brand-fg); }
.topbar .brand { color: var(--ink); }
.brand__mark .mk-bg { fill: var(--mark-bg); } .brand__mark .mk-1 { fill: var(--mark-1); } .brand__mark .mk-2 { fill: var(--mark-2); } .brand__mark .mk-3 { fill: var(--mark-3); }
.brand__mark { width: 36px; height: 36px; flex-shrink: 0; }
.brand__name { font-family: var(--font-display); font-size: 18px; font-weight: 800; letter-spacing: 0.01em; line-height: 1; white-space: nowrap; }
.brand__pro {
  display: inline-grid; place-items: center; padding: 4px 7px 3px; border-radius: 6px;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font-ui); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; line-height: 1;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__label { margin: 16px 12px 6px; font-size: var(--text-xs); font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--nav-label); }
.nav__item {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border-radius: var(--r-md);
  color: var(--nav-fg); font-size: var(--text-md); font-weight: 650;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav__item:hover { background: var(--nav-hover-bg); color: var(--nav-hover-fg); }
.nav__item[aria-current='page'] { background: var(--nav-active-bg); color: var(--nav-active-fg); font-weight: 800; }
.nav__item[aria-current='page'] .icon { color: var(--nav-active-icon); }
.nav__item span:not(.count) { flex: 1; }
.nav__item[aria-current='page'] .count { background: var(--accent); color: var(--on-accent); }

.sidebar__foot { margin-top: auto; position: relative; }
.me {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px; border: 1px solid transparent; border-radius: var(--r-lg);
  background: var(--me-bg); color: var(--me-fg); text-align: left;
}
.me:hover, .me[aria-expanded='true'] { border-color: var(--line-strong); }
.me__name { font-size: var(--text-md); font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me__role { font-size: var(--text-xs); color: var(--me-sub); }
/* The account menu is the button's sibling: open it upwards, above the button. */
.me-wrap .menu { left: 0; right: 0; bottom: calc(100% + 8px); max-height: calc(100vh - 120px); overflow-y: auto; }

/* ---------- Main column ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--topbar-h); padding: 14px 40px;
  background: var(--topbar-bg); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__search { flex: 1; max-width: 440px; }
.topbar__search .input { background: var(--surface); }
.topbar__spacer { flex: 1; }
.topbar__mobile-brand { display: none; }
.bell { position: relative; }
.bell__dot { position: absolute; top: 10px; right: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 2px var(--surface); }
.notif { right: 0; top: calc(100% + 8px); width: 340px; }
.notif-wrap { position: relative; }

.content {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: 36px 40px 64px;
  display: flex; flex-direction: column; gap: 28px;
}
.content:focus { box-shadow: none; }

/* Sticky action bar at the bottom of long forms */
.actionbar {
  position: sticky; bottom: 0; z-index: 10;
  margin: 0 -40px -64px; padding: 14px 40px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--glass); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.actionbar__note { flex: 1; min-width: 220px; font-size: var(--text-sm); color: var(--muted); }

/* ---------- Mobile tab bar ---------- */
.tabbar { display: none; }

@media (max-width: 960px) {
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar__search { display: none; }
  .topbar__mobile-brand { display: flex; }
  .content { padding: 24px 16px 104px; gap: 22px; }
  /* Compact bar that sits right above the tab bar, so the form stays visible. */
  .actionbar {
    bottom: calc(68px + env(safe-area-inset-bottom));
    margin: 0 -16px -104px; padding: 10px 16px; gap: 8px; flex-wrap: nowrap;
  }
  .actionbar__note { display: none; }
  /* Secondary buttons take what they need; the last (primary) one fills the rest and may wrap. */
  .actionbar > .btn { flex: 0 0 auto; }
  .actionbar > .btn:last-child { flex: 1 1 auto; min-width: 0; white-space: normal; line-height: 1.2; text-align: center; padding: 6px 14px; }
  .actionbar > .btn:last-child .icon { display: none; }
  h1 { font-size: var(--text-2xl); }

  .tabbar {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--glass); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .tabbar__item {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 56px; border-radius: var(--r-md);
    color: var(--muted); font-size: 11px; font-weight: 750; text-align: center;
  }
  .tabbar__item[aria-current='page'] { color: var(--ink); }
  .tabbar__item[aria-current='page'] .icon { color: var(--primary); }
  .tabbar__item .count { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 10px; }
}
@media (max-width: 380px) { .tabbar__item { font-size: 10px; } }

/* Shown only where the sidebar is hidden. */
.mobile-only { display: none; }
@media (max-width: 960px) { .mobile-only { display: block; } }

/* Phones: top-bar popovers become full-width panels under the top bar,
   instead of hanging off their (not right-aligned) buttons. */
@media (max-width: 960px) {
  .topbar .notif, .topbar .theme-menu {
    position: fixed; left: 16px; right: 16px; top: calc(var(--topbar-h) + 4px);
    width: auto; max-height: calc(100vh - var(--topbar-h) - 100px); overflow-y: auto;
  }
}

/* ---------- Sign-in ---------- */
.login { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); min-height: 100vh; }
.login__aside { position: relative; overflow: hidden; background: var(--dark); color: var(--on-dark); }
.login__aside-inner { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding: 40px 48px; }
.login__aside .brand { color: var(--on-dark); }
.login__quote { max-width: 420px; font-family: var(--font-display); font-size: clamp(28px, 3vw, 38px); font-weight: 700; line-height: 1.12; letter-spacing: -0.03em; }
.login__points { list-style: none; margin-top: 28px; display: flex; flex-direction: column; gap: 14px; }
.login__points li { display: flex; align-items: center; gap: 12px; font-weight: 650; color: var(--on-dark-muted); }
.login__points .icon { color: var(--accent); }
.login__art { position: absolute; z-index: 0; right: 32px; bottom: 0; width: 46%; height: 52%; display: flex; align-items: flex-end; gap: 14px; opacity: 0.22; }
.login__art span { flex: 1; border-radius: 24px 24px 0 0; background: var(--on-dark); }
.login__art span:nth-child(1) { height: 40%; } .login__art span:nth-child(2) { height: 66%; } .login__art span:nth-child(3) { height: 100%; background: var(--accent); }

.login__main { display: grid; place-items: center; padding: 40px 24px; }
.login__main:focus { box-shadow: none; }
.login__card { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 20px; }
.login__back { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; font-size: var(--text-sm); font-weight: 750; color: var(--muted); }
.login__back:hover { color: var(--ink); }
.login__title { font-size: 34px; }
.login__lead { margin-top: -8px; color: var(--ink-2); }
.login__form { display: flex; flex-direction: column; gap: 16px; }
.login__pass { display: block; }
.login__eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.login__remember { display: inline-flex; align-items: center; gap: 10px; font-size: var(--text-sm); font-weight: 650; color: var(--ink-2); cursor: pointer; }
.login__remember input { width: 18px; height: 18px; accent-color: var(--primary); }
.login__submit { min-height: 52px; font-size: var(--text-base); }
.login__demo { margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.login__hint { font-size: var(--text-sm); color: var(--muted); }
.login__accs { list-style: none; display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.login__acc {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); text-align: left; color: var(--ink);
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.login__acc:hover { border-color: var(--primary); transform: translateY(-1px); }
.login__acc > .icon { margin-left: auto; color: var(--muted); }
.login__acc-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.login__acc-name { font-weight: 750; font-size: var(--text-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.login__acc-sub { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) {
  .login { grid-template-columns: minmax(0, 1fr); }
  .login__aside { display: none; }
  .login__main { place-items: start center; padding-top: 32px; }
}
@media (max-width: 480px) { .login__accs { grid-template-columns: minmax(0, 1fr); } }

/* Link back to the landing page, at the bottom of the sidebar */
.sidebar__landing { margin-top: auto; color: var(--nav-fg); font-size: var(--text-sm); }
.sidebar__landing + .sidebar__foot { margin-top: 8px; }
