/* AppLayout / Sidebar / TopActions / AuthLayout. Shared by every customer route. */
.app-shell {
  --sidebar-width:240px;
  --content-gutter:24px;
  padding:0 var(--content-gutter) 24px calc(var(--sidebar-width) + var(--content-gutter));
  min-height:100dvh;
  width:100%;
  max-width:none;
  margin:0;
  display:flex;
  flex-direction:column;
  gap:24px
}

/* Shared full-width rail; individual forms keep their readable input widths. */
.app-content {
  width:100%;
  max-width:none;
  min-width:0;
  margin:0 auto
}

.app-sidebar {
  position:fixed;
  left:0;
  top:0;
  bottom:0;
  width:var(--sidebar-width);
  border-radius:0;
  border-width:0 1px 0 0;
  box-shadow:none;
  z-index:110;
  display:flex;
  flex-direction:column;
  padding:0 14px 16px;
  background:var(--chrome);
  backdrop-filter:none;
  overflow:auto
}

.sidebar-brand {
  display:flex;
  align-items:center;
  gap:9px;
  text-decoration:none;
  min-height:72px;
  padding:18px 10px;
  margin-bottom:8px;
  white-space:nowrap
}

.sidebar-brand strong {
  font-size:16px;
  font-weight:650
}

.brand-symbol {
  display:block;
  flex:0 0 30px;
  width:30px;
  height:30px
}
.auth-brand {display:flex;align-items:center;gap:12px}
.auth-brand img {flex:none}

.app-section-nav {
  display:flex;
  flex-direction:column;
  gap:3px;
  min-width:0
}

.nav-group-title {margin:24px 12px 9px;font-size:12px;font-weight:400;letter-spacing:.08em;color:var(--muted)}
.nav-group-title:first-child {margin-top:10px}

.app-section-nav a {
  display:flex;
  align-items:center;
  gap:11px;
  min-height:46px;
  padding:11px 12px;
  font-size:15px;
  font-weight:550;
  text-decoration:none;
  border:1px solid transparent;
  border-radius:9px;
  color:var(--text);
  white-space:nowrap
}

.app-section-nav a svg {
  width:21px;
  height:21px;
  color:var(--muted)
}

.app-section-nav a:hover {
  background:var(--hover-bg)
}

.app-section-nav a.active {
  background:var(--accent-soft);
  border-color:transparent;
  color:var(--accent-text)
}

.app-section-nav a.active svg {
  color:var(--accent-text)
}

.sidebar-foot {
  margin-top:auto;
  padding:24px 4px 5px
}

.sidebar-caption {
  padding:16px 4px 0;
  font-size:9px;
  letter-spacing:.16em;
  color:var(--muted);
  opacity:.65
}

.topbar {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:16px;
  min-height:72px;
  flex:none;
  background:var(--chrome);
  border:0;
  border-bottom:1px solid var(--border);
  border-radius:0;
  margin:0 calc(-1 * var(--content-gutter));
  padding:14px var(--content-gutter);
  box-shadow:none;
  position:relative;
  z-index:120
}

.top-actions {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  flex-wrap:wrap
}

.topbar-page-label {margin-right:auto;font-size:14px;color:var(--muted);white-space:nowrap}
@media(max-width:950px) {.topbar-page-label {display:none}}

.top-actions>button,.username-status,.license-card,#logoutBtn {
  background:var(--surface);
  backdrop-filter:none;
  border:1px solid var(--border);
  box-shadow:var(--ui-shadow);
  border-radius:11px;
  min-height:42px
}

.announcement-bell,.theme-toggle {
  position:relative;
  width:42px;
  height:42px;
  padding:9px;
  font-size:22px
}

.announcement-bell.has-new::after {
  content:"";
  position:absolute;
  top:7px;
  right:8px;
  width:6px;
  height:6px;
  border-radius:50%;
  background:#ef7c84;
  border:1px solid var(--solid-surface)
}

.session-user-menu {
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:8px
}

.username-status {
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px;
  font-size:14px;
  width:100%;
  min-width:0
}

.username-value {
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap
}

.username-mark {
  display:grid;
  place-items:center;
  width:29px;
  height:29px;
  flex:none;
  background:var(--hover-bg);
  border:1px solid var(--control-border);
  border-radius:8px;
  font-weight:700;
  font-size:16px
}

.username-mark::before {
  content:attr(data-initial)
}

#logoutBtn {
  width:100%;
  min-height:40px;
  font-size:13px;
  padding:9px 13px;
  white-space:nowrap
}

.license-card {
  display:grid;
  grid-template-columns:auto auto;
  align-content:center;
  align-items:center;
  column-gap:8px;
  padding:5px 12px;
  min-width:153px;
  max-width:245px;
  background:color-mix(in srgb,var(--surface) 85%,rgba(78,156,112,.3));
  font-size:11px
}

.license-card strong {
  font-size:14px;
  font-weight:650;
  color:var(--success-text);
  font-variant-numeric:tabular-nums
}

.license-card span {
  color:var(--muted)
}

.license-card em {
  font-style:normal;
  color:var(--muted);
  grid-column:1/-1;
  font-size:10px;
  line-height:1.3;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis
}

.license-card em:empty {
  display:none
}

.site-notice {display:flex;align-items:center;gap:12px;min-width:0;flex-shrink:0;padding:12px 16px;border:1px solid color-mix(in srgb,#608ac3 42%,var(--border));border-left:3px solid #648bc0;border-radius:10px;background:color-mix(in srgb,#608ac3 11%,var(--surface));color:var(--text);font-size:13px}
.site-notice-icon {display:flex;flex:none;color:#648bc0}
.site-notice-icon svg {width:18px;height:18px}
.site-notice strong {flex:none;font-size:12px;font-weight:600;padding-right:12px;border-right:1px solid var(--border)}
.site-notice-text {min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.7}
.site-notice.is-expanded {align-items:flex-start}
.site-notice.is-expanded .site-notice-text {white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;overflow:auto}
.site-notice button {flex:none;background:transparent;border:0;padding:2px 0;color:var(--muted);font-size:12px;cursor:pointer}
.site-notice button:hover {color:var(--text)}
@media(max-width:600px) {.site-notice {gap:8px;padding:10px 12px}.site-notice strong {display:none}}

.sidebar-toggle {
  display:none
}

.skip-link {
  position:fixed;
  z-index:500;
  left:264px;
  top:-100px;
  background:var(--solid-surface);
  padding:8px 14px;
  border-radius:8px
}

.skip-link:focus {
  top:10px
}

html[data-auth="guest"] .app-shell {
  padding:0;
  display:block
}

html[data-auth="guest"] :is(.app-sidebar,.topbar,.site-notice,.announcement-modal,.skip-link) {
  display:none!important
}

/* Unknown session is a neutral shell, never a prematurely visible login form. */
html:not([data-auth="checking"]) :is(.session-loading,.session-nav-placeholder) {
  display:none
}

html[data-auth="checking"] :is(.topbar,.site-notice,.sidebar-foot,.skip-link) {
  visibility:hidden
}

html[data-auth="checking"] .app-sidebar {
  pointer-events:none
}

.session-nav-placeholder {
  display:grid;
  gap:18px;
  padding:14px 8px
}

.session-nav-placeholder span,.session-skeleton span {
  display:block;
  height:18px;
  border-radius:6px;
  background:var(--surface-soft)
}

.session-loading {
  display:grid;
  grid-template-columns:minmax(0,1.75fr) minmax(300px,1fr);
  gap:18px;
  min-height:min(680px,calc(100dvh - 108px))
}

.session-loading-panel {
  padding:24px
}

#sessionLoadingText {
  margin:0 0 16px;
  font-size:14px;
  color:var(--muted)
}

.session-skeleton {
  display:grid;
  gap:20px;
  margin-top:24px
}

.session-skeleton span:first-child {
  width:38%
}

.session-skeleton span:nth-child(3) {
  width:75%
}

.session-skeleton div {
  height:180px;
  border-radius:12px;
  background:var(--field-bg)
}

@media(max-width:760px) {
  .session-loading {
    grid-template-columns:1fr
  }
  .session-loading-queue {
    display:none
  }
}

.auth-gate {
  --auth-heading-top:clamp(112px,28dvh,320px);
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(420px,38%);
  width:100%;
  min-height:100dvh;
  margin:0;
  padding:0;
  background:transparent;
  border:0;
  box-shadow:none
}

.auth-intro {
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  min-width:0;
  min-height:100dvh;
  padding:calc(var(--auth-heading-top) - 56px) clamp(40px,7vw,132px) 56px;
  margin:0;
  background:none;
  border:0;
  box-shadow:none;
  backdrop-filter:none;
  color:#fff;
  text-shadow:0 2px 16px #0005
}

.auth-intro .eyebrow {
  font-size:12px;
  letter-spacing:.12em;
  color:#e5e4df;
  font-weight:600
}

.auth-intro h2 {
  font-size:clamp(34px,3.2vw,58px);
  letter-spacing:.02em;
  line-height:1.35;
  margin:13px 0
}

.auth-intro p {
  font-size:clamp(20px,1.6vw,26px);
  font-weight:350;
  margin:0;
  line-height:1.7
}

.auth-card {
  width:100%;
  min-width:0;
  min-height:100dvh;
  display:grid;
  place-items:start center;
  padding:var(--auth-heading-top) 40px 56px;
  border-radius:0;
  background:transparent;
  border:0;
  box-shadow:none;
  color:#f5f4ef;
  --text:#f5f4ef;
  --muted:#c5cbc7;
  --field-bg:rgba(18,23,21,.62);
  --control-border:rgba(237,240,235,.3);
  --border:rgba(237,240,235,.22);
  --surface:#202823;
  --surface-soft:rgba(18,23,21,.62);
  --hover-bg:rgba(237,240,235,.1);
  --accent:#f1f0e9;
  --accent-hover:#fffefa;
  --accent-text:#f1f0e9;
  --accent-soft:rgba(237,240,235,.12);
  --accent-contrast:#202823;
  --error-text:#ffb9b3;
  --success-text:#c3e3c9;
  color-scheme:dark
}

.auth-switch {
  display:flex;
  justify-content:center;
  align-items:center;
  flex-wrap:wrap;
  gap:4px;
  margin:4px 0 0;
  padding-top:18px;
  border-top:1px solid var(--border);
  font-size:14px;
  color:var(--muted)
}
.auth-switch button {
  min-height:36px;
  padding:4px 6px;
  border:0;
  background:transparent;
  color:var(--text);
  font-size:14px;
  font-weight:600;
  text-decoration:underline;
  text-underline-offset:4px
}

.auth-card > .auth-form {
  width:100%;
  max-width:360px
}

.auth-form {
  display:flex;
  flex-direction:column;
  gap:18px
}

.form-heading h2 {
  font-size:30px;
  margin:0 0 8px
}

.form-heading p {
  font-size:14px;
  line-height:1.7;
  color:var(--muted);
  margin:0 0 10px
}

.auth-form label {
  display:flex;
  flex-direction:column;
  gap:7px;
  font-size:13px;
  font-weight:500;
  color:var(--text)
}

.auth-form input {
  width:100%;
  height:48px;
  padding:0 14px;
  border-radius:8px;
  font-size:15px;
  font-weight:400
}

.auth-submit {
  height:48px;
  font-size:15px;
  margin-top:2px
}

.auth-message:empty { display:none }

.auth-message {
  min-height:18px;
  margin:0;
  font-size:12px;
  line-height:1.6;
  color:var(--success-text)
}

.auth-message.error {
  color:var(--error-text)
}


@media(max-width:1200px) {
  .topbar {
    gap:8px
  }
  .top-actions {
    gap:6px
  }
}

@media(max-width:950px) {
  .topbar {
    min-height:48px;
    flex-wrap:wrap
  }
}

@media(max-width:760px) {
  .app-content {
    width:100%;
    margin-top:0
  }
  .app-shell {
    --content-gutter:12px;
    padding:0 var(--content-gutter) 12px;
    gap:16px
  }
  .app-sidebar {
    transform:translateX(calc(-100% - 12px));
    visibility:hidden;
    transition:transform .18s,visibility .18s;
    left:10px;
    top:68px;
    bottom:12px;
    width:min(260px,calc(100vw - 24px));
    background:var(--solid-surface);
    z-index:150
  }
  .sidebar-open .app-sidebar {
    transform:translateX(0);
    visibility:visible;
    box-shadow:0 10px 40px rgba(0,0,0,.4)
  }
  .sidebar-open body::after {
    content:"";
    position:fixed;
    inset:64px 0 0;
    z-index:140;
    background:rgba(0,0,0,.28)
  }
  .sidebar-toggle {
    display:inline-flex;
    flex:none;
    align-self:flex-start;
    background:var(--surface);
    backdrop-filter:blur(14px);
    margin-top:1px
  }
  .topbar {
    min-height:64px;
    padding-top:12px;
    padding-bottom:12px;
    justify-content:space-between;
    align-items:flex-start;
    gap:8px
  }
  .top-actions {
    gap:6px;
    max-width:calc(100% - 48px)
  }
  .top-actions>button,.username-status,.license-card,#logoutBtn {
    min-height:36px;
    border-radius:9px
  }
  .announcement-bell,.theme-toggle {
    width:36px;
    height:36px;
    padding:7px;
    font-size:19px
  }
  .username-status {
    height:36px;
    font-size:11px;
    padding:3px 7px
  }
  .username-mark {
    height:25px;
    width:25px;
    font-size:13px
  }
  .license-card {
    padding:4px 9px;
    min-width:132px;
    max-width:190px;
    grid-template-columns:auto auto
  }
  .license-card strong {
    font-size:12px
  }
  .license-card em {
    font-size:9px
  }
  .session-user-menu {
    gap:6px
  }
  #logoutBtn {
    font-size:11px;
    padding:7px 9px
  }
  .skip-link {
    left:60px
  }
}

@media(max-width:400px) {
  .app-shell {
    --content-gutter:10px
  }
  .top-actions {
    gap:5px
  }
  .session-user-menu {
    gap:5px
  }
}

/* Login keeps one fixed palette; workspace preferences never recolor the form. */
html[data-auth="guest"] {scrollbar-gutter:auto;--page-bg:#181a20;--text:#f5f4f7;--muted:#c1bfc8;color-scheme:dark}
html[data-auth="guest"] body {background:#181a20}

@media(max-width:760px) {
  .auth-gate {grid-template-columns:1fr}
  .auth-intro {min-height:210px;padding:56px 28px 24px}
  .auth-intro h2 {font-size:32px;margin:10px 0}
  .auth-intro p {font-size:20px}
  .auth-intro .eyebrow {font-size:13px}
  .auth-card {min-height:0;padding:24px 28px 56px}
}
@media(max-width:400px) {
  .auth-intro {padding-inline:20px}
  .auth-intro h2 {font-size:29px}
  .auth-card {padding:32px 20px}
}
