/* App shell: sidebar + topbar + main */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  border-right: 1px solid #E2E8F0;
  z-index: 40;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 20px;
  border-bottom: 1px solid #E2E8F0;
  flex-shrink: 0;
}

.sidebar__logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.sidebar__logo:hover {
  color: var(--text-main);
  text-decoration: none;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar__group-title {
  padding: 0 16px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-muted);
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar__link:hover {
  background: var(--nav-hover);
  color: var(--text-main);
  text-decoration: none;
}

.sidebar__link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  border-left-color: var(--primary);
}

.sidebar__link.is-active:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar__icon {
  display: inline-flex;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: inherit;
}

.sidebar__icon svg {
  width: 18px;
  height: 18px;
}

.sidebar__footer {
  margin-top: auto;
  flex-shrink: 0;
  border-top: 1px solid #E2E8F0;
  padding: 12px;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 12px;
  border-radius: 8px;
}

.sidebar__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}

.sidebar__avatar svg {
  width: 16px;
  height: 16px;
}

.sidebar__user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.sidebar__user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar__logout {
  margin: 0;
  flex-shrink: 0;
}

/* ---------- Content column ---------- */
.app-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  background: var(--bg-app);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: var(--header-height);
  padding: 0 32px;
  background: #FFFFFF;
  border-bottom: 1px solid #E2E8F0;
  flex-shrink: 0;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
  min-width: 0;
}

.breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumbs__sep {
  color: var(--text-subtle);
}

.breadcrumbs__current {
  color: var(--text-main);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.mock-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.demo-readonly-banner {
  background: #C2410C;
  color: #FFFFFF;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 8px 16px;
}

.demo-readonly-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  background: #C2410C;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Greyscale mutating controls for auditor bots / accidental clicks */
body.is-demo-readonly form[method="post"] button,
body.is-demo-readonly form[method="POST"] button,
body.is-demo-readonly form[method="post"] input[type="submit"],
body.is-demo-readonly button[formaction] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.4);
}

.mock-chip--banner {
  justify-content: center;
  width: 100%;
  border-radius: 0;
  padding: 8px 16px;
  font-weight: 600;
  gap: 6px;
  border-bottom: 1px solid #F59E0B33;
}

.mock-chip--banner strong {
  font-weight: 700;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--nav-hover);
  color: var(--text-main);
  text-decoration: none;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.app-main {
  flex: 1;
  padding: 32px;
  max-width: var(--content-max);
  width: 100%;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin: 0 0 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* ---------- Auth shell (login) ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

.auth-main {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-main h1 {
  margin-bottom: 8px;
}

/* ---------- Dashboard grids ---------- */
.dashboard-stack {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin: 0;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin: 0;
}

/* Legacy banner class kept for safety */
.mock-banner,
.real-banner {
  text-align: center;
  padding: var(--space-2) var(--space-4);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.mock-banner {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-bottom: 1px solid #F59E0B33;
}

.real-banner {
  background: var(--text-main);
  color: #CBD5E1;
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #E2E8F0;
  }

  .sidebar__nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .topbar {
    padding: 0 16px;
  }

  .app-main {
    padding: 24px 16px;
  }
}

@media (max-width: 720px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .sidebar__nav {
    grid-template-columns: 1fr;
  }
}
