/* Shared kconsole shell — kgilles-style fixed header + header auth slot */
:root {
  --site-header-h: 4.5rem;
  --console-brand: #4338ca;
}

body.shell-has-header {
  padding-top: var(--site-header-h);
  padding-bottom: 2.75rem;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  background: #fff;
  border-bottom: 1px solid #d8deea;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-sizing: border-box;
  min-height: var(--site-header-h);
  overflow: visible;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.site-brand img {
  width: 48px;
  height: 48px;
  pointer-events: none;
}

.site-brand .site-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
  overflow: visible;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-nav a {
  color: var(--console-brand);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}

.site-nav a.active {
  font-weight: 600;
  text-decoration: underline;
}

.header-auth {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  overflow: visible;
}

.header-session {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.session-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #d8deea;
  background: #f4f6fb;
}

.lang-switch-mount {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 3;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid #d8deea;
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.lang-btn {
  border: none;
  background: transparent;
  color: #5c6378;
  font: 600 0.6875rem/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
}

.lang-btn:hover {
  color: var(--console-brand);
}

.lang-btn.active {
  background: #eef3ff;
  color: var(--console-brand);
}

.header-auth-slot {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  min-width: 4.5rem;
  min-height: 2.25rem;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.header-auth .status {
  font-size: 0.875rem;
  color: #5c6378;
  white-space: nowrap;
}

.header-auth .logout {
  font-size: 0.875rem;
  color: var(--console-brand);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}

.shell-main.shell-locked {
  visibility: hidden;
  pointer-events: none;
  min-height: 40vh;
}

.auth-gate {
  max-width: 36rem;
  margin: 3rem auto;
  padding: 1.5rem;
  text-align: center;
  color: #5c6378;
  font-size: 1rem;
  line-height: 1.5;
}

.auth-gate.hidden {
  display: none;
}

.kdevice-shell-wrap {
  flex-shrink: 0;
}

.kdevice-shell-counters {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem 0.65rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  background: #f8fafc;
  color: #1e293b;
  text-decoration: none;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
}

.kdevice-shell-counters:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.kdevice-shell-tag {
  font-weight: 700;
  font-size: 0.6875rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #4338ca;
}

.kdevice-shell-counter strong {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.kdevice-shell-counter--connected strong {
  color: #4338ca;
}

.kdevice-shell-counter--idle strong {
  color: #16a34a;
}

@media (max-width: 960px) {
  .kdevice-shell-wrap {
    display: none;
  }
}

.app-selector-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 1 auto;
  margin-left: auto;
  min-width: min(100%, 28rem);
}

.app-selector-wrap.hidden {
  display: none;
}

.app-select-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text, #1a1f36);
  white-space: nowrap;
}

.app-select {
  flex: 1 1 18rem;
  min-width: 15rem;
  max-width: 34rem;
  font: inherit;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  background: var(--card, #fff);
}

/* Smartphone: swipe / scroll the nav strip instead of clipping it. */
@media (max-width: 860px) {
  .site-header {
    padding: 0.65rem 0.75rem;
    gap: 0.5rem;
  }

  .site-brand .site-title {
    display: none;
  }

  .header-right {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 0.15rem;
    gap: 0.5rem;
  }

  .site-nav {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    gap: 0.85rem;
    padding: 0.2rem 0;
  }

  .site-nav.is-overflowing:not(.is-scrolled-end) {
    mask-image: linear-gradient(to right, #000 calc(100% - 1.4rem), transparent);
  }

  .site-nav.is-overflowing.is-scrolled-start:not(.is-scrolled-end) {
    mask-image: linear-gradient(
      to right,
      transparent,
      #000 1.1rem,
      #000 calc(100% - 1.4rem),
      transparent
    );
  }

  .site-nav.is-overflowing.is-scrolled-start.is-scrolled-end {
    mask-image: linear-gradient(to right, transparent, #000 1.1rem, #000);
  }

  .site-nav a {
    flex-shrink: 0;
    padding: 0.35rem 0.1rem;
  }

  .header-auth {
    gap: 0.4rem;
    margin-left: auto;
  }

  .header-session {
    order: 1;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 0.05rem;
    line-height: 1.15;
  }

  .session-avatar {
    display: none !important;
  }

  .header-auth-slot {
    order: 1;
    min-width: 0;
  }

  .lang-switch-mount {
    order: 2;
    margin-left: 0;
  }

  .header-auth .status {
    font-size: 0.75rem;
    max-width: 7.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-auth .logout {
    font-size: 0.75rem;
  }

  .lang-btn {
    padding: 0.3rem 0.4rem;
  }
}

/* Smartphone: shrink the nested page gutters (main + panel). */
@media (max-width: 640px) {
  main.shell-main {
    padding-left: 0.4rem !important;
    padding-right: 0.4rem !important;
  }

  .shell-main > .panel {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }

  .app-pane,
  .add-panel,
  .add-dialog,
  .compteurs-pane,
  .billing-pane,
  .year-card {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }

  .app-selector-wrap {
    margin-left: 0;
    min-width: 0;
    width: 100%;
  }
}

.site-footer-frame {
  position: fixed;
  z-index: 80;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 40px;
  border: 0;
  background: #fff;
  display: block;
}
