/**
 * Sand & Sea — App shell
 * Milestone 0B1 Layout Foundation — fixed desktop ERP shell
 */
[x-cloak] { display: none !important; }

html {
  height: 100%;
}

body {
  font-family: var(--ss-font-ui);
  font-size: var(--ss-text-body);
  line-height: var(--ss-leading-body);
  -webkit-font-smoothing: antialiased;
}

/* Fixed application shell — desktop software contract
   body uses ss-app; layout root uses .ss-shell (do not put ss-shell on body) */
body.ss-app {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ss-bg-app);
  color: var(--ss-text-primary);
  display: block;
}

.ss-brand {
  font-family: var(--ss-font-brand);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: inherit;
  text-decoration: none;
}

.ss-shell {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: var(--ss-shell-height, 100dvh);
  max-height: var(--ss-shell-height, 100dvh);
  overflow: hidden;
  background: var(--ss-bg-app);
  color: var(--ss-text-primary);
}

/* —— Sidebar —— */
.ss-sidebar {
  width: var(--ss-sidebar-width);
  flex: 0 0 var(--ss-sidebar-width);
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, #0f2a44 0%, var(--ss-sidebar-bg) 48%, #0a1c30 100%);
  color: var(--ss-sidebar-text);
  border-right: 1px solid var(--ss-sidebar-border);
  transition: width var(--ss-medium) var(--ss-ease), flex-basis var(--ss-medium) var(--ss-ease);
  z-index: 1040;
  box-shadow: 2px 0 12px rgba(8, 25, 41, 0.18);
  overflow: hidden;
}

.ss-sidebar.is-collapsed {
  width: var(--ss-sidebar-collapsed);
  flex-basis: var(--ss-sidebar-collapsed);
}

.ss-sidebar-brand {
  flex: 0 0 auto;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ss-sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.ss-sidebar-nav {
  padding: 8px;
}

.ss-nav-utility {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px 8px 12px;
}

.ss-sidebar .ss-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ss-sidebar-text);
  text-decoration: none;
  border-radius: var(--ss-radius-md);
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 500;
  min-height: 40px;
  transition: background var(--ss-fast) var(--ss-ease), color var(--ss-fast) var(--ss-ease), border-color var(--ss-fast) var(--ss-ease);
  border: 1px solid transparent;
}

.ss-sidebar .ss-nav-link:hover {
  background: var(--ss-sidebar-hover);
  color: #fff;
}

.ss-sidebar .ss-nav-link:focus-visible {
  outline: 2px solid var(--ss-secondary-300);
  outline-offset: 1px;
}

.ss-sidebar .ss-nav-link.active {
  background: linear-gradient(90deg, var(--ss-sidebar-active) 0%, #216399 100%);
  color: #fff;
  font-weight: 600;
  border-color: rgba(127, 179, 219, 0.18);
  box-shadow: inset 3px 0 0 var(--ss-secondary-500);
}

.ss-sidebar .ss-nav-link i {
  font-size: 1.15rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.92;
  line-height: 1;
}

.ss-sidebar .ss-nav-section {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ss-sidebar-text-muted);
  margin: 16px 12px 8px;
  padding-top: 4px;
}

.ss-sidebar.is-collapsed .ss-nav-label,
.ss-sidebar.is-collapsed .ss-nav-section,
.ss-sidebar.is-collapsed .ss-brand-sub,
.ss-sidebar.is-collapsed .ss-submenu {
  display: none;
}

.ss-sidebar.is-collapsed .ss-nav-link {
  justify-content: center;
  padding-inline: 0;
}

.ss-submenu {
  padding-left: 2rem;
  margin-bottom: 4px;
}

.ss-submenu .ss-nav-link {
  font-size: 13px;
  padding: 8px 12px;
  font-weight: 400;
  min-height: 36px;
}

/* —— Main column —— */
.ss-main {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 100%;
}

.ss-wallet-strip {
  flex: 0 0 auto;
  background: linear-gradient(90deg, var(--ss-secondary-50), var(--ss-bg-surface));
  border-bottom: 1px solid var(--ss-secondary-100);
  padding: 8px var(--ss-content-gutter, var(--ss-space-6));
  font-size: var(--ss-text-label);
  color: var(--ss-text-primary);
}

[data-bs-theme="dark"] .ss-wallet-strip {
  background: linear-gradient(90deg, rgba(61, 155, 147, 0.16), var(--ss-bg-surface));
  border-bottom-color: var(--ss-border-subtle);
  color: var(--ss-text-primary);
}

.ss-header {
  flex: 0 0 auto;
  height: var(--ss-header-height);
  min-height: var(--ss-header-height);
  max-height: var(--ss-header-height);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ss-border-subtle);
  box-shadow: var(--ss-shadow-header);
  display: flex;
  align-items: center;
  padding: 0 var(--ss-content-gutter, var(--ss-space-6));
  gap: var(--ss-space-3);
  position: relative;
  z-index: 1020;
}

[data-bs-theme="dark"] .ss-header {
  background: rgba(18, 26, 42, 0.96);
}

/* Primary content scrollport */
.ss-content {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--ss-space-5) var(--ss-content-gutter, var(--ss-space-6)) var(--ss-space-6);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ss-border-default) transparent;
}

.ss-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--ss-border-subtle);
  padding: 12px var(--ss-content-gutter, var(--ss-space-6));
  font-size: var(--ss-text-meta);
  color: var(--ss-text-muted);
  background: var(--ss-bg-surface);
}

.ss-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ss-space-4);
  margin-bottom: var(--ss-page-gap, var(--ss-space-5));
  padding-bottom: var(--ss-space-4);
  border-bottom: 1px solid var(--ss-border-subtle);
}

/* —— Workspace system (0B2) —— */
.ss-workspace {
  display: flex;
  flex-direction: column;
  gap: var(--ss-page-gap, var(--ss-space-5));
  width: 100%;
  min-width: 0;
}

.ss-workspace-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ss-card-gap, var(--ss-space-4));
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.ss-workspace-main {
  flex: 1 1 0;
  min-width: 0;
}

.ss-workspace-aside {
  flex: 0 1 320px;
  min-width: min(100%, 280px);
  max-width: 100%;
}

.ss-workspace-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--ss-card-gap, var(--ss-space-4));
  width: 100%;
}

.ss-workspace-section {
  display: flex;
  flex-direction: column;
  gap: var(--ss-card-gap, var(--ss-space-4));
  min-width: 0;
}

.ss-report-page {
  display: flex;
  flex-direction: column;
  gap: var(--ss-section-gap, var(--ss-space-6));
  width: 100%;
  min-width: 0;
}

.ss-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ss-space-3);
  padding: var(--ss-space-3) var(--ss-space-4);
  border: 1px dashed var(--ss-border-default);
  border-radius: var(--ss-radius-md);
  background: var(--ss-bg-toolbar);
  font-size: var(--ss-text-meta);
  color: var(--ss-text-muted);
}

.ss-page-title {
  font-family: var(--ss-font-brand);
  font-weight: 700;
  font-size: var(--ss-text-page-title);
  line-height: 1.2;
  margin: 0;
  color: var(--ss-text-primary);
  letter-spacing: -0.02em;
}

.ss-page-desc {
  margin: 6px 0 0;
  color: var(--ss-text-secondary);
  font-size: var(--ss-text-body);
  max-width: 52rem;
}

.ss-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ss-space-2);
  align-items: center;
  justify-content: flex-end;
}

.ss-breadcrumbs {
  margin-bottom: var(--ss-space-2);
  font-size: var(--ss-text-meta);
}

.ss-breadcrumbs a {
  color: var(--ss-text-muted);
  text-decoration: none;
}

.ss-breadcrumbs a:hover {
  color: var(--ss-text-link);
}

/* Reading measure — forms/prose only, not dashboards/tables */
.ss-form-page {
  max-width: 1100px;
}

.ss-form-page.ss-form-page-wide {
  max-width: none;
}

.ss-card {
  background: var(--ss-bg-surface);
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-lg);
  box-shadow: var(--ss-shadow-sm);
}

.ss-branch-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--ss-border-default);
  background: var(--ss-bg-toolbar);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: var(--ss-text-label);
  font-weight: 600;
  color: var(--ss-text-secondary);
  box-shadow: var(--ss-shadow-xs);
  max-width: min(280px, 42vw);
}

.ss-branch-pill i {
  color: var(--ss-primary-600);
}

.ss-icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ss-radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ss-text-secondary);
  transition: background var(--ss-fast) var(--ss-ease), color var(--ss-fast) var(--ss-ease), border-color var(--ss-fast) var(--ss-ease);
}

.ss-icon-btn:hover {
  background: var(--ss-hover-surface);
  color: var(--ss-text-primary);
  border-color: var(--ss-border-subtle);
}

.ss-icon-btn:focus-visible {
  outline: 2px solid var(--ss-border-focus);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--ss-primary-700);
  border-color: var(--ss-primary-700);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--ss-primary-800);
  border-color: var(--ss-primary-800);
}

.ss-customer-topnav {
  background: var(--ss-bg-surface);
  border-bottom: 1px solid var(--ss-border-default);
  box-shadow: var(--ss-shadow-header);
}

.ss-auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ss-space-6);
  background:
    radial-gradient(1000px 420px at 8% -10%, rgba(61, 155, 147, 0.18), transparent 55%),
    radial-gradient(900px 380px at 100% 0%, rgba(212, 181, 106, 0.2), transparent 50%),
    linear-gradient(180deg, #e8f2fa 0%, var(--ss-bg-app) 100%);
}

[data-bs-theme="dark"] .ss-auth-shell {
  background:
    radial-gradient(1000px 420px at 8% -10%, rgba(61, 155, 147, 0.12), transparent 55%),
    radial-gradient(900px 380px at 100% 0%, rgba(78, 150, 204, 0.14), transparent 50%),
    linear-gradient(180deg, #0b1220 0%, var(--ss-bg-app) 100%);
}

.ss-auth-shell .ss-brand {
  color: var(--ss-text-primary) !important;
}

.ss-auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--ss-bg-surface);
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-xl);
  padding: var(--ss-space-8);
  box-shadow: var(--ss-shadow-lg);
}

.ss-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ss-space-3);
  margin-bottom: var(--ss-page-gap, var(--ss-space-5));
}

.ss-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ss-space-3);
  padding: var(--ss-space-4);
  margin-bottom: var(--ss-page-gap, var(--ss-space-5));
  background: var(--ss-bg-toolbar);
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-lg);
  box-shadow: var(--ss-shadow-xs);
  width: 100%;
}

.ss-widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: var(--ss-card-gap, var(--ss-space-5));
  margin-bottom: var(--ss-section-gap, var(--ss-space-6));
  width: 100%;
}

.ss-widget {
  grid-column: auto;
  background: var(--ss-bg-surface);
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-lg);
  padding: var(--ss-space-5);
  box-shadow: var(--ss-shadow-sm);
  min-height: 120px;
  min-width: 0;
}

@media (max-width: 1199.98px) {
  .ss-widget-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  }
}

@media (max-width: 767.98px) {
  .ss-widget-grid {
    grid-template-columns: 1fr;
  }
  .ss-content { padding: var(--ss-space-4) var(--ss-content-gutter-sm, var(--ss-space-4)); }
  .ss-header { padding: 0 var(--ss-content-gutter-sm, var(--ss-space-4)); }
  .ss-footer { padding-inline: var(--ss-content-gutter-sm, var(--ss-space-4)); }
  .ss-page-title { font-size: 22px; }
  .ss-page-actions { width: 100%; justify-content: stretch; }
  .ss-page-actions .ss-btn { flex: 1 1 auto; }
}

@media (max-width: 991.98px) {
  .ss-sidebar.ss-sidebar-desktop {
    display: none !important;
  }

  body.ss-app {
    overflow: hidden;
  }
}

@media (min-width: 992px) {
  .ss-sidebar-backdrop,
  .ss-mobile-offcanvas {
    display: none !important;
  }
}

@media (min-width: 1600px) {
  :root {
    --ss-content-gutter: 28px;
  }
}

@media (min-width: 1920px) {
  :root {
    --ss-content-gutter: 32px;
  }
}

.ss-mobile-offcanvas {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(86vw, var(--ss-sidebar-width));
  height: 100dvh;
  max-height: 100dvh;
  transform: translateX(-105%);
  transition: transform var(--ss-medium) var(--ss-ease);
  z-index: 1050;
  box-shadow: var(--ss-shadow-lg);
}

.ss-mobile-offcanvas.is-open {
  transform: translateX(0);
}

.ss-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--ss-overlay);
  z-index: 1045;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ss-medium) var(--ss-ease);
}

.ss-sidebar-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .ss-sidebar,
  .ss-mobile-offcanvas,
  .ss-sidebar-backdrop {
    transition: none !important;
  }
}
