*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-height: 100%;
  scroll-padding-top: 5.5rem;
}

body {
  --shell-gutter: 1rem;
  margin: 0;
  min-height: 100dvh;
  color: var(--foreground);
  background: var(--background);
  font: 15px/1.5 var(--font-sans, Aptos, "Segoe UI", Arial, sans-serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
button:enabled, select { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell-svg-definitions { position: absolute; }

.shell-icon {
  display: block;
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: .75rem;
  left: .75rem;
  transform: translateY(calc(-100% - 1rem));
  padding: .625rem 1rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  background: var(--background);
  color: var(--foreground);
}

.skip-link:focus { transform: none; }

.startup {
  display: grid;
  min-height: 100dvh;
  place-content: center;
  padding: 1.5rem;
  color: var(--muted-foreground);
  text-align: center;
}

:where(.primary, .quiet) {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .5rem .875rem;
  border: 1px solid transparent;
  border-radius: .625rem;
  font-size: .875rem;
  font-weight: 550;
  line-height: 1.25;
  text-decoration: none;
}

:where(.primary) { background: var(--primary); color: var(--primary-foreground); }
:where(.primary):is(a, button:enabled):hover { background: color-mix(in srgb, var(--primary) 88%, var(--foreground)); }
:where(.quiet) { border-color: var(--input); background: var(--background); color: var(--foreground); }
:where(.quiet):is(a, button:enabled):hover { border-color: var(--primary); background: var(--erp-hover); }
:where(.primary, .quiet):disabled { opacity: .55; }

.shell-topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 95%, transparent);
  backdrop-filter: blur(8px);
}

.shell-header-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 76px;
  align-items: center;
  gap: .5rem 1rem;
  padding: .375rem var(--shell-gutter);
}

.shell-brand-area { display: flex; min-width: 0; align-items: center; gap: .75rem; }
.shell-brand { display: inline-flex; align-items: center; min-width: 0; text-decoration: none; }
.shell-brand .scalgro-brand-composition { width: 158px; }

.shell-product-name {
  padding-inline-start: .75rem;
  border-inline-start: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: .75rem;
  font-weight: 500;
}

.shell-nav {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .2rem;
}

.shell-nav a {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  gap: .5rem;
  padding: 0 .75rem;
  border-radius: .5rem;
  color: var(--muted-foreground);
  font-size: .8125rem;
  font-weight: 500;
  text-decoration: none;
}

.shell-nav a:hover { background: var(--erp-hover); color: var(--foreground); }
.shell-nav a[aria-current="page"] { background: var(--accent); color: var(--primary); }
.shell-actions { display: flex; align-items: center; gap: .75rem; }
.shell-mobile-nav { display: none; }

.shell-logout {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: transparent;
  color: var(--foreground);
}

.shell-logout:enabled:hover { background: var(--erp-hover); }
.shell-logout:disabled { opacity: .55; }

.account-organization {
  max-width: 16rem;
  padding-inline-start: 1rem;
  border-inline-start: 1px solid var(--border);
  color: var(--foreground);
  font-size: .875rem;
  font-weight: 600;
  text-align: end;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.application-switcher { position: relative; display: flex; }

.switcher-trigger {
  display: inline-flex;
  width: 2.5rem;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: 0;
  border: 0;
  border-radius: .75rem;
  background: transparent;
  color: var(--foreground);
  font-size: .875rem;
  font-weight: 550;
}

.switcher-trigger-text { display: none; }
.switcher-trigger:hover, .switcher-trigger[aria-expanded="true"] { background: var(--erp-hover); }

.switcher-popover {
  position: absolute;
  z-index: 40;
  inset-block-start: calc(100% + .75rem);
  inset-inline-end: 0;
  width: 22rem;
  max-width: calc(100vw - 1.5rem);
  max-height: var(--switcher-available-height, calc(100dvh - 5rem));
  padding: 1rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
  transform: translateX(var(--switcher-horizontal-shift, 0px));
}

.switcher-popover h2 {
  margin: 0 0 .5rem;
  padding-inline: .25rem;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.25rem;
}

.switcher-popover nav a {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: .75rem;
  padding: .5rem;
  border-radius: .75rem;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.25rem;
  text-decoration: none;
}

.switcher-popover nav a:hover { background: var(--accent); }
.switcher-popover nav a:focus-visible { outline-offset: -2px; }
.switcher-popover nav .shell-icon { color: var(--primary); stroke-width: 2; }
.switcher-current { margin-inline-start: auto; color: var(--muted-foreground); font-size: .75rem; font-weight: 400; }

.switcher-secondary { margin-top: .5rem; padding-top: .75rem; border-top: 1px solid var(--border); }

.switcher-organization {
  margin: .375rem .5rem 0;
  color: var(--muted-foreground);
  font-size: .875rem;
  overflow-wrap: anywhere;
}

.switcher-organization strong { color: var(--foreground); font-weight: 500; }

@media (min-width: 1536px) {
  .switcher-trigger { width: auto; padding-inline: .75rem; }
  .switcher-trigger-text { display: inline; }
}
.workspace {
  min-width: 0;
  width: 100%;
  padding: .75rem var(--shell-gutter) 5rem;
}

.shell-page-context { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

.workspace .sync-indicator {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  gap: .5rem;
  padding: .25rem .625rem;
  border: 1px solid var(--border);
  border-radius: 100vmax;
  color: var(--muted-foreground);
  font-size: .75rem;
  text-decoration: none;
}

.workspace .sync-indicator:hover { background: var(--erp-hover); color: var(--foreground); }
.sync-dot { width: .375rem; height: .375rem; flex: 0 0 auto; border-radius: 50%; background: currentColor; }
.sync-indicator[data-tone="success"] .sync-dot { color: var(--primary); }
.sync-indicator[data-tone="attention"] .sync-dot { color: var(--erp-warning-text); }

.login-shell { min-height: 100svh; }
.login-container { width: min(1440px, calc(100% - 96px)); margin-inline: auto; }
.login-header { border-bottom: 1px solid var(--border); }
.login-header-inner { display: flex; min-height: 100px; align-items: center; }
.login-brand { display: inline-flex; text-decoration: none; }
.login-brand .scalgro-brand-composition { width: 184px; }
.login-layout {
  display: grid;
  min-height: calc(100svh - 200px);
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2.5rem, 5vw, 5.5rem);
  padding-block: clamp(2.5rem, 5vw, 4.5rem);
}

.login-product { margin: 0 0 .875rem; color: var(--primary); font-size: .75rem; font-weight: 600; }
.login-headline { margin: 0; font-size: clamp(2.375rem, 3.8vw, 3.625rem); font-weight: 550; line-height: 1.08; letter-spacing: -.05em; text-wrap: balance; }
.login-intro-description { max-width: 48ch; margin: 1.25rem 0 0; color: var(--muted-foreground); font-size: 1rem; line-height: 1.8; }

.login-card {
  min-width: 0;
  padding: clamp(1.875rem, 3.4vw, 3.25rem);
  border: 1px solid var(--border);
  border-radius: 1.125rem;
  background: var(--background);
  box-shadow: 0 .625rem 2.25rem rgb(11 37 37 / .05);
  overflow-wrap: anywhere;
}

.login-access-icon {
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  margin-bottom: 1.75rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: var(--card);
  color: var(--primary);
}

.login-access-icon .shell-icon { width: 1.25rem; height: 1.25rem; }
.login-card h1 { margin: 0; font-size: clamp(1.875rem, 2.5vw, 2.375rem); line-height: 1.2; font-weight: 550; letter-spacing: -.04em; }
#login-description { margin: .75rem 0 0; color: var(--muted-foreground); line-height: 1.7; }
.login-actions, #login-form { display: grid; gap: .75rem; margin-top: 1.875rem; }
.login-actions .primary, #login-form .primary { min-height: 3.25rem; font-size: .9375rem; text-align: center; }
#login-erp-link { justify-self: center; padding: .625rem; color: var(--primary); font-size: .875rem; font-weight: 550; text-decoration: none; }
#login-erp-link:hover { text-decoration: underline; text-underline-offset: .2em; }
#login-form label { margin-bottom: -.25rem; font-size: .875rem; font-weight: 550; }
#login-form input { min-width: 0; height: 3.25rem; padding-inline: .875rem; border: 1px solid var(--input); border-radius: .5rem; background: var(--background); color: var(--foreground); font-size: 1rem; }

.form-message {
  margin: 1.125rem 0 0;
  padding: .875rem 1rem;
  border: 1px solid color-mix(in srgb, var(--destructive) 35%, var(--border));
  border-radius: .5rem;
  background: var(--erp-danger-surface);
  color: var(--erp-danger-text);
}

.global-theme-toggle {
  position: fixed;
  z-index: 60;
  right: 1rem;
  bottom: 1rem;
  border: 1px solid var(--input);
  border-radius: 100vmax;
  background: var(--popover);
  color: var(--foreground);
  box-shadow: 0 3px 14px rgb(11 37 37 / .08);
}

.theme-button {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font-size: .75rem;
  font-weight: 600;
}

.theme-sun { color: #d97706; }
.theme-moon, .dark .theme-sun { display: none; }
.dark .theme-moon { display: block; color: var(--primary); }

.theme-track {
  position: relative;
  width: 2rem;
  height: 1.125rem;
  border-radius: 100vmax;
  background: var(--input);
}

.theme-track::after {
  position: absolute;
  inset-block-start: .125rem;
  inset-inline-start: .125rem;
  width: .875rem;
  height: .875rem;
  border-radius: 50%;
  background: var(--background);
  content: "";
}

.dark .theme-track { background: var(--primary); }
.dark .theme-track::after { inset-inline-start: 1rem; }

@media (min-width: 640px) { body { --shell-gutter: 1.75rem; } }
@media (min-width: 1280px) { body { --shell-gutter: 2rem; } }
@media (min-width: 1536px) { body { --shell-gutter: 2.5rem; } }

@media (max-width: 1023px) {
  html { scroll-padding-top: 7.5rem; }
  .shell-header-inner { grid-template-columns: minmax(0, 1fr) auto; }
  .shell-nav { display: none; }
  .shell-mobile-nav { position: relative; display: block; grid-column: 1 / -1; }
  .shell-mobile-nav select {
    appearance: none;
    width: 100%;
    height: 2.5rem;
    padding: 0 2.5rem 0 .875rem;
    border: 1px solid var(--input);
    border-radius: .75rem;
    background: var(--background);
    color: var(--foreground);
    font-size: 1rem;
    font-weight: 550;
  }
  .shell-mobile-nav .shell-icon { position: absolute; inset-block-start: .75rem; inset-inline-end: .875rem; color: var(--muted-foreground); pointer-events: none; }
  .shell-actions { gap: .5rem; }
  .account-organization { display: none; }
}

@media (max-width: 980px) {
  .login-container { width: min(680px, calc(100% - 48px)); }
  .login-layout { grid-template-columns: minmax(0, 1fr); padding-block: 2.5rem; }
  .login-intro { display: none; }
  .login-card { padding: 2.25rem; }
}

@media (max-width: 639px) {
  .shell-header-inner { grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
  .shell-brand .scalgro-brand-composition { width: 132px; --scalgro-tagline-size: 9px; }
  .shell-product-name { display: none; }
  .workspace { padding-top: 1rem; }
  .login-container { width: calc(100% - 32px); }
  .login-header-inner { min-height: 84px; }
  .login-brand .scalgro-brand-composition { width: 132px; --scalgro-tagline-size: 8px; }
  .login-layout { min-height: 0; padding-block: 1.5rem 4.5rem; }
  .login-card { padding: 1.625rem 1.25rem; border-radius: .875rem; }
  .login-access-icon { width: 2.625rem; height: 2.625rem; margin-bottom: 1.375rem; }
  .global-theme-toggle { right: .75rem; bottom: calc(.75rem + env(safe-area-inset-bottom)); }
}

@media print {
  .shell-topbar, .global-theme-toggle, .skip-link, .sync-indicator { display: none !important; }
  .workspace { padding: 0; }
}
