.app-header {
  min-height: 72px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* 🔥 medium logo (balanced) */
.app-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
}

/* user + logout */
.user-badge {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--border);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  border: 0;
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}

/* layout shell */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 72px);
}

.app-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.nav-link {
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
}

.nav-link:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.app-main {
  padding: var(--space-6);
}

.page-title {
  font-size: var(--title);
  font-weight: 800;
  margin-bottom: var(--space-5);
}

/* 📱 mobile safe */
@media (max-width: 700px) {
  .app-header {
    padding: 12px 16px;
  }

  .app-logo {
    height: 36px;
  }

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

  .app-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-link {
    white-space: nowrap;
  }
}

/* ===== FIXED HEADER + SIDEBAR LAYOUT ===== */

html, body {
  height: 100%;
  overflow: hidden;
}

/* Header stays fixed at top */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  z-index: 1000;
}

/* Sidebar stays fixed on left */
.app-sidebar {
  position: fixed;
  top: 72px;
  left: 0;
  bottom: 0;
  width: 240px;
  overflow-y: auto;
  z-index: 900;
}

/* Main content scrolls */
.app-main {
  position: absolute;
  top: 72px;
  left: 240px;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 24px;
  background: #f8fafc;
}

/* Ensure shell doesn't interfere */
.shell {
  height: 100%;
}

/* Mobile adjustment */
@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    width: 220px;
    transform: translateX(-100%);
  }

  .app-main {
    left: 0;
    padding: 16px;
  }
}


/* ===== GLOBAL MOBILE FRIENDLY PATCH ===== */

* {
  max-width: 100%;
}

img, table, iframe, canvas {
  max-width: 100%;
}

.app-main {
  overflow-x: hidden;
}

@media (max-width: 900px) {
  html, body {
    overflow: auto;
    height: auto;
  }

  .app-header {
    position: sticky;
    top: 0;
    height: auto;
    min-height: 64px;
  }

  .app-sidebar {
    position: relative;
    top: auto;
    left: auto;
    bottom: auto;
    width: 100%;
    transform: none;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;
    white-space: nowrap;
  }

  .app-sidebar a,
  .nav-link {
    flex: 0 0 auto;
    display: inline-flex;
  }

  .app-main {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    overflow-y: visible;
    padding: 14px;
  }

  .shell {
    display: block;
    height: auto;
  }
}

@media (max-width: 560px) {
  body {
    padding: 0;
  }

  .page-title {
    font-size: 22px;
    line-height: 1.2;
  }

  .app-main {
    padding: 12px;
  }

  button,
  input,
  select,
  textarea {
    font-size: 16px;
  }
}


.disabled-link {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}
