/* LAYOUT — application shell (sidebar, topbar, page), auth shell, error shell. */
@layer layout{
.skip-link{position:absolute;inset-inline-start:var(--s-3);inset-block-start:-4rem;z-index:var(--z-loader);background:var(--primary);color:var(--primary-ink);padding:.6rem 1rem;border-radius:var(--r-s);text-decoration:none;font-weight:600}
.skip-link:focus{inset-block-start:var(--s-3)}

.app-shell{display:grid;grid-template-columns:var(--sidebar-w) minmax(0,1fr);min-height:100vh;transition:grid-template-columns var(--t-base) var(--ease)}
html[data-sidebar="rail"] .app-shell{grid-template-columns:var(--sidebar-w-rail) minmax(0,1fr)}

/* sidebar */
.app-sidebar{position:sticky;inset-block-start:0;height:100vh;display:flex;flex-direction:column;background:var(--surface);border-inline-end:var(--border);z-index:var(--z-sidebar);min-width:0}
.app-sidebar__head{display:flex;align-items:center;gap:var(--s-2);height:var(--topbar-h);padding:0 var(--s-4);border-block-end:var(--border);flex:none}
.ui-brand{display:flex;align-items:center;gap:var(--s-2);min-width:0;text-decoration:none;color:var(--text);flex:1}
.ui-brand__logo{display:block;max-height:2.1rem;width:auto;max-width:100%;object-fit:contain}
.ui-brand__logo--dark{display:none}[data-theme="dark"] .ui-brand__logo--light{display:none}[data-theme="dark"] .ui-brand__logo--dark{display:block}
.ui-brand__name{font-family:var(--font-display);font-weight:650;font-size:var(--fs-l)}
.app-sidebar__collapse{margin-inline-start:auto}
.app-nav{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:var(--s-3) var(--s-3) var(--s-5)}
.app-nav__label{margin:var(--s-4) var(--s-3) var(--s-1);font-size:var(--fs-xs);font-weight:650;letter-spacing:.09em;text-transform:uppercase;color:var(--text-mute)}
.app-nav__label:first-child{margin-block-start:var(--s-1)}
.app-nav ul{list-style:none;margin:0;padding:0;display:grid;gap:2px}
.app-nav a{position:relative;display:flex;align-items:center;gap:var(--s-3);min-height:2.5rem;padding:.4rem var(--s-3);border-radius:var(--r-s);color:var(--text-soft);text-decoration:none;font-weight:500;font-size:var(--fs-m);transition:background var(--t-fast) var(--ease),color var(--t-fast) var(--ease)}
.app-nav a:hover{background:var(--sunken);color:var(--text)}
.app-nav a .ui-icon{width:1.25rem;height:1.25rem;color:var(--text-mute);transition:color var(--t-fast)}
.app-nav a:hover .ui-icon{color:var(--text)}
.app-nav a.active,.app-nav a[aria-current="page"]{background:var(--primary-soft);color:var(--primary);font-weight:650}
.app-nav a.active .ui-icon,.app-nav a[aria-current="page"] .ui-icon{color:var(--primary)}
.app-nav a.active::before,.app-nav a[aria-current="page"]::before{content:"";position:absolute;inset-inline-start:calc(var(--s-3) * -1);inset-block:.5rem;width:3px;border-radius:0 3px 3px 0;background:var(--primary)}
[dir="rtl"] .app-nav a.active::before,[dir="rtl"] .app-nav a[aria-current="page"]::before{border-radius:3px 0 0 3px}
.app-nav__ext{margin-inline-start:auto;opacity:.55}
html[data-sidebar="rail"] .app-sidebar__head{padding:0;justify-content:center}
html[data-sidebar="rail"] .ui-brand{display:none}
html[data-sidebar="rail"] .app-sidebar__collapse{margin:0}
html[data-sidebar="rail"] .app-nav{padding-inline:var(--s-2)}
html[data-sidebar="rail"] .app-nav a{justify-content:center;padding-inline:0}
html[data-sidebar="rail"] .app-nav a>span,html[data-sidebar="rail"] .app-nav__label,html[data-sidebar="rail"] .app-nav__ext{display:none}
html[data-sidebar="rail"] .app-nav a.active::before{inset-inline-start:calc(var(--s-2) * -1)}
html[data-sidebar="rail"] .app-nav ul+.app-nav__label,html[data-sidebar="rail"] .app-nav .app-nav__label+ul{margin-block-start:0}
html[data-sidebar="rail"] .app-nav li+li{margin-block-start:0}
.app-nav__divider{display:none}
html[data-sidebar="rail"] .app-nav__divider{display:block;height:1px;background:var(--line);margin:var(--s-3) var(--s-2)}

/* main column */
.app-main{display:flex;flex-direction:column;min-width:0;min-height:100vh}
.app-topbar{position:sticky;inset-block-start:0;z-index:var(--z-topbar);display:flex;align-items:center;gap:var(--s-3);height:var(--topbar-h);padding:0 var(--s-5);background:color-mix(in srgb,var(--surface) 92%,transparent);backdrop-filter:saturate(1.4) blur(10px);border-block-end:var(--border)}
.app-topbar__menu{display:none}
.app-topbar__context{display:flex;align-items:center;gap:var(--s-2);min-width:0;font-size:var(--fs-s);color:var(--text-mute)}
.app-topbar__context strong{color:var(--text);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.app-topbar__actions{margin-inline-start:auto;display:flex;align-items:center;gap:var(--s-2)}
.app-topbar__brand{display:none}
.app-content{flex:1;width:100%;max-width:88rem;margin-inline:auto;padding:var(--s-6) var(--s-5) var(--s-7)}
.app-footer{padding:var(--s-4) var(--s-5);text-align:center;color:var(--text-mute);font-size:var(--fs-xs);border-block-start:var(--border)}
.app-scrim{position:fixed;inset:0;background:var(--overlay);z-index:calc(var(--z-sidebar) - 1);opacity:0;pointer-events:none;transition:opacity var(--t-base)}

/* page header — every screen starts the same way */
.ui-page-head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:var(--s-4);margin-block-end:var(--s-5)}
.ui-page-head__copy{min-width:0;display:grid;gap:var(--s-1)}
.ui-page-head__eyebrow{font-size:var(--fs-xs);font-weight:650;letter-spacing:.09em;text-transform:uppercase;color:var(--primary)}
.ui-page-head h1{font-size:var(--fs-h1)}
.ui-page-head p{color:var(--text-soft);max-width:60ch}
.ui-page-head__actions{display:flex;flex-wrap:wrap;gap:var(--s-2);align-items:center}

/* tablet: rail by default */
@media (max-width:1180px){
  .app-shell{grid-template-columns:var(--sidebar-w-rail) minmax(0,1fr)}
  html:not([data-sidebar="open"]) .app-sidebar__head{padding:0;justify-content:center}
  html:not([data-sidebar="open"]) .ui-brand,html:not([data-sidebar="open"]) .app-sidebar__collapse{display:none}
  html:not([data-sidebar="open"]) .app-nav{padding-inline:var(--s-2)}
  html:not([data-sidebar="open"]) .app-nav a{justify-content:center;padding-inline:0}
  html:not([data-sidebar="open"]) .app-nav a>span,html:not([data-sidebar="open"]) .app-nav__label,html:not([data-sidebar="open"]) .app-nav__ext{display:none}
  html:not([data-sidebar="open"]) .app-nav a.active::before{inset-inline-start:calc(var(--s-2) * -1)}
  html:not([data-sidebar="open"]) .app-nav__divider{display:block;height:1px;background:var(--line);margin:var(--s-3) var(--s-2)}
  .app-content{padding-inline:var(--s-4)}
}
/* mobile: drawer */
@media (max-width:900px){
  .app-shell{display:block}
  .app-sidebar{position:fixed;inset-block:0;inset-inline-start:0;width:min(20rem,86vw);height:100dvh;transform:translateX(-100%);transition:transform var(--t-base) var(--ease);box-shadow:var(--shadow-3)}
  [dir="rtl"] .app-sidebar{transform:translateX(100%)}
  html[data-sidebar="open"] .app-sidebar{transform:none}
  html[data-sidebar="open"] .app-scrim{opacity:1;pointer-events:auto}
  html[data-sidebar="open"] body{overflow:hidden}
  /* drawer always shows the full navigation */
  html .app-sidebar .ui-brand,html .app-sidebar .app-sidebar__collapse{display:flex}
  html .app-sidebar .app-nav a{justify-content:flex-start;padding-inline:var(--s-3)}
  html .app-sidebar .app-nav a>span,html .app-sidebar .app-nav__label{display:revert}
  html .app-sidebar .app-nav__divider{display:none}
  html .app-sidebar__head{padding:0 var(--s-4);justify-content:flex-start}
  .app-topbar{padding:0 var(--s-3);gap:var(--s-2)}
  .app-topbar__actions{gap:var(--s-1)}
  .app-topbar .topbar-profile-trigger>.ui-icon,.app-topbar .topbar-mail{display:none}
  .app-topbar__menu{display:inline-flex}
  .app-topbar__context{display:none}
  .app-topbar__brand{display:flex;align-items:center;min-width:0}
  .app-topbar__brand .ui-brand__logo{max-height:1.75rem}
  .app-content{padding:var(--s-5) var(--s-3) var(--s-6)}
  .ui-page-head{align-items:stretch}
  .ui-page-head__actions{width:100%}
}

/* auth shell */
.auth-shell{min-height:100vh;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.05fr)}
.auth-shell__aside{position:relative;display:flex;flex-direction:column;justify-content:flex-end;padding:var(--s-7);color:#fff;background:#2A2126 center/cover no-repeat;overflow:hidden;isolation:isolate}
.auth-shell__aside::before{content:"";position:absolute;inset:0;z-index:-1;background:linear-gradient(180deg,rgba(23,18,26,.15) 0%,rgba(23,18,26,.86) 100%)}
.auth-shell__aside h2{color:#fff;font-size:clamp(1.75rem,1.2rem + 1.6vw,2.5rem);max-width:16ch}
.auth-shell__aside p{color:rgba(255,255,255,.82);max-width:38ch;margin-block-start:var(--s-3)}
.auth-shell__main{display:flex;flex-direction:column;justify-content:center;align-items:center;padding:var(--s-6) var(--s-5);gap:var(--s-5);background:var(--bg)}
.auth-card{width:min(100%,26rem);display:grid;gap:var(--s-5)}
.auth-card__brand{display:flex;justify-content:center}.auth-card__brand .ui-brand__logo{max-height:3rem}
.auth-card__head{display:grid;gap:var(--s-2);text-align:start}
.auth-card__head p{color:var(--text-soft)}
.auth-tools{display:flex;justify-content:flex-end;align-items:center;gap:var(--s-2);width:min(100%,26rem)}
.auth-tools .select2-container{width:9rem!important}
@media (max-width:900px){.auth-shell{grid-template-columns:1fr}.auth-shell__aside{display:none}.auth-shell__main{justify-content:flex-start;padding-block-start:var(--s-6)}}

/* error shell */
.error-shell{min-height:100vh;display:grid;place-items:center;padding:var(--s-5);background:var(--bg)}
.error-card{width:min(100%,34rem);text-align:center;display:grid;gap:var(--s-4);justify-items:center}
.error-card__code{font-family:var(--font-display);font-size:clamp(4rem,3rem + 6vw,7rem);line-height:1;font-weight:600;color:var(--primary);letter-spacing:-.03em}
.error-card__actions{display:flex;flex-wrap:wrap;gap:var(--s-2);justify-content:center}
.error-card details{text-align:start;width:100%}
}
