/* PalmStat ERP · sidebar + topbar + main layout */

.app-shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
  background: var(--bg-base);
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 200;
             transform: translateX(-100%); transition: transform var(--t-base) var(--ease); }
  .sidebar.is-open { transform: translateX(0); }
}

.sidebar {
  grid-area: sidebar;
  background: var(--bg-sidebar);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar__brand-mark {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  display: grid; place-items: center;
  color: #07211A; font-weight: 800; font-size: 14px;
  box-shadow: 0 4px 12px rgba(63, 166, 111, .35);
}
.sidebar__brand-name { font-weight: 700; letter-spacing: -.02em; font-size: 1rem; }
.sidebar__brand-sub  { font-size: .68rem; color: var(--fg-tertiary); margin-top: -2px; letter-spacing: .04em; text-transform: uppercase; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 8px; scrollbar-width: thin; }
.sidebar__group { padding: 6px 6px 4px; }
.sidebar__group-label { font-size: .65rem; font-weight: 600; letter-spacing: .08em; color: var(--fg-tertiary); padding: 12px 10px 6px; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.sidebar__group-pill {
  font-size: .58rem; font-weight: 800; letter-spacing: .08em;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  padding: 1px 6px; border-radius: 999px;
  box-shadow: 0 0 8px rgba(63, 166, 111, 0.35);
}
.nav-item--core {
  position: relative;
  background: linear-gradient(90deg, rgba(63, 166, 111, 0.08), transparent);
  border-left: 3px solid var(--brand-500);
  border-radius: 6px;
}
.nav-item--core::before {
  content: '';
  position: absolute;
  left: -3px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 70%;
  background: linear-gradient(180deg, var(--brand-300), var(--brand-700));
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(63, 166, 111, 0.6);
}
.nav-item__badge--core {
  box-shadow: 0 0 10px rgba(63, 166, 111, 0.55);
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 10px; margin: 1px 0;
  border-radius: var(--r-sm);
  color: var(--fg-primary);
  font-weight: 500; font-size: .875rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  user-select: none;
}
.nav-item:hover  { background: var(--bg-hover); }
.nav-item:active { background: var(--bg-active); }
.nav-item.is-active { background: var(--brand-bg-soft); color: var(--brand-fg); font-weight: 600; }
.nav-item.is-active .nav-item__icon { color: var(--brand-fg); }
.nav-item__icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--fg-secondary); display: grid; place-items: center; }
.nav-item__icon svg { width: 18px; height: 18px; }
.nav-item__badge {
  margin-left: auto;
  background: var(--brand-700);  /* WCAG AA contrast for white text */
  color: var(--fg-on-brand);
  font-size: .68rem; font-weight: 700;
  padding: 1px 7px; border-radius: var(--r-pill);
  min-width: 18px; text-align: center;
}

.sidebar__footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: 10px;
}
.sidebar__user { display: flex; align-items: center; gap: 10px; flex: 1; padding: 6px; border-radius: var(--r-sm); cursor: pointer; transition: background var(--t-fast) var(--ease); }
.sidebar__user:hover { background: var(--bg-hover); }
.avatar {
  width: 32px; height: 32px; border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--brand-300), var(--brand-600));
  display: grid; place-items: center;
  color: #07211A; font-weight: 700; font-size: .75rem;
  flex-shrink: 0;
}
.sidebar__user-info { line-height: 1.15; min-width: 0; }
.sidebar__user-name { font-size: .8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-role { font-size: .7rem; color: var(--fg-tertiary); text-transform: capitalize; }

.topbar {
  grid-area: topbar;
  background: var(--bg-overlay);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center;
  padding: 0 18px;
  gap: 12px;
  z-index: 50;
  min-width: 0; /* allow children to shrink rather than overflow */
}
.topbar__menu-btn { display: none; background: transparent; border: none; width: 32px; height: 32px; border-radius: var(--r-sm); color: var(--fg-primary); flex-shrink: 0; }
@media (max-width: 980px) { .topbar__menu-btn { display: inline-grid; place-items: center; } }
.topbar__menu-btn:hover { background: var(--bg-hover); }

/* Title + crumbs wrapper · shrinks first when topbar runs out of room.
 * min-width:0 unblocks flex shrinking; overflow:hidden + ellipsis prevent the
 * page title (e.g. "Operations Overview") from colliding with the tour button. */
.topbar__heading { min-width: 0; flex: 1 1 auto; overflow: hidden; }
.topbar__title {
  font-size: 1rem; font-weight: 600; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__crumbs {
  display: flex; align-items: center; gap: 6px;
  font-size: .8125rem; color: var(--fg-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__crumbs span:not(:last-child)::after { content: "›"; margin-left: 8px; color: var(--fg-tertiary); }

/* The spacer no longer needs flex:1 because the heading now takes the slack;
 * keep a tiny minimum so the heading and right-cluster don't touch. */
.topbar__spacer { flex: 0 0 12px; }

.topbar__search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 12px; height: 34px;
  width: 280px; max-width: 32vw;
  color: var(--fg-secondary);
  flex-shrink: 0;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.topbar__search:focus-within { border-color: var(--brand-400); box-shadow: var(--shadow-glow); }
.topbar__search input { flex: 1; border: none; outline: none; background: transparent; font: inherit; color: var(--fg-primary); min-width: 0; }
.topbar__search kbd { font-size: .68rem; padding: 1px 5px; background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--r-xs); color: var(--fg-tertiary); }
/* Hide the global search on narrow viewports · Cmd-K palette is still available */
@media (max-width: 1100px) { .topbar__search { display: none; } }

.topbar__icon-btn { width: 34px; height: 34px; border-radius: var(--r-sm); border: none; background: transparent; color: var(--fg-primary); display: grid; place-items: center; position: relative; flex-shrink: 0; transition: background var(--t-fast) var(--ease); }
.topbar__icon-btn:hover { background: var(--bg-hover); }
.live-pulse { flex-shrink: 0; }
@media (max-width: 880px) { .live-pulse #live-text { display: none; } }
.theme-toggle { flex-shrink: 0; }
@media (max-width: 820px) { .theme-toggle { display: none; } }

.theme-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 3px;
  display: flex; align-items: center;
  position: relative;
}
.theme-toggle:hover { border-color: var(--brand-400); box-shadow: 0 0 0 3px rgba(63,166,111,.14); }
.theme-toggle button { background: transparent; border: none; color: var(--fg-secondary); width: 32px; height: 30px; border-radius: var(--r-pill); display: grid; place-items: center; cursor: pointer; transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.theme-toggle button:hover { color: var(--fg-primary); }
.theme-toggle button.is-active { background: var(--bg-card); color: var(--brand-fg); box-shadow: var(--shadow-xs); }
.theme-toggle button svg { width: 16px; height: 16px; }

.main {
  grid-area: main;
  overflow-y: auto;
  padding: 24px 28px 40px;
  scroll-behavior: smooth;
}
@media (max-width: 700px) { .main { padding: 16px; } }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header__title { font-size: 1.875rem; font-weight: 700; letter-spacing: -.028em; }
.page-header__sub  { color: var(--fg-secondary); font-size: .9375rem; margin-top: 4px; }
.page-header__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-grid { display: grid; gap: 16px; }
.cols-1 { grid-template-columns: 1fr; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (max-width: 1100px) {
  .cols-4, .cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .cols-2, .cols-3, .cols-4, .cols-6 { grid-template-columns: 1fr; }
}

/* PALMSTAT_BRAND_LOGO_V1 · use Palm brand logo (whitewashed) instead of P tile */
.sidebar__brand-mark { background: transparent !important; padding: 0 !important; }
.sidebar__brand-mark img { width: 30px; height: 30px; display: block; }
/* End PALMSTAT_BRAND_LOGO_V1 */
