/* Shared application layout and controls, layered over the legacy UI library. */
:root {
  --color-background: #eaf0f7;
  --color-surface: #fff;
  --color-surface-alt: #f0f5fb;
  --color-border: #d1dce9;
  --color-border-strong: #b8c8db;
  --color-text: #1c2b42;
  --color-text-muted: #58677c;
  --color-text-subtle: #64748b;
  --color-primary: #245de1;
  --color-primary-strong: #194bc2;
  --color-primary-soft: #edf3ff;
  --color-success: #147d5a;
  --color-sidebar-bg: #fff;
  --workspace-heading-background: linear-gradient(115deg, #172f50, #24567b);
  --workspace-heading-border: #274e74;
  --workspace-heading-text: #fff;
  --workspace-heading-muted: #dbe8f5;
  --workspace-heading-eyebrow: #bed6ed;
  --radius-lg: 16px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-flat: 0 2px 4px rgba(28, 43, 66, .025);
  --shadow-soft: 0 4px 16px rgba(28, 43, 66, .05);
  --shadow-lift: 0 16px 48px rgba(28, 43, 66, .12);
}

html {
  font-size: 16px;
  scroll-padding-top: 1.5rem;
}

body:not(.auth-body) {
  margin: 0;
  background: var(--color-background);
  color: var(--color-text);
  font-size: .9375rem;
  line-height: 1.6;
}

body, body button, body input, body select, body textarea,
body h1, body h2, body h3, body h4, body h5, body h6, body p, body a, body td {
  font-family: var(--font-body);
}

body .wrapper {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0;
  width: 100%;
  height: auto;
  min-height: 100vh;
  padding: 0;
}

body .wrapper > .main-panel {
  position: relative;
  float: none;
  flex: 1 1 0%;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: auto;
  min-height: 100vh;
  margin: 0;
  padding: 0 2rem 1.5rem;
}

body .main-panel > .container,
body .main-panel > .container-fluid {
  width: 100%;
  max-width: 1600px;
  min-height: 0;
  margin: 0 auto;
  padding: 0 !important;
  overflow: visible;
}

body .page-inner {
  padding: 0;
}

body .page-container {
  gap: 1.25rem;
}

body .app-header {
  min-height: 76px;
  padding: 1rem 0;
  gap: 1rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.75rem !important;
}

body .app-header__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .7rem;
  color: var(--color-text);
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.app-header__product,
.app-header__separator {
  color: var(--color-text-muted);
  font-weight: 400;
}

body .app-header__actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem;
}

body .app-header__actions .btn {
  min-height: 36px;
  font-size: .8125rem;
  padding: .4rem .75rem;
}

body .workspace-page-heading {
  margin-bottom: 1.5rem;
}

body .workspace-eyebrow {
  display: block;
  margin-bottom: .5rem;
  color: var(--color-primary-strong);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

body .workspace-page-title,
body .workspace-page-heading h1 {
  color: var(--color-text);
  font-size: clamp(1.5rem, 1.2rem + .8vw, 2rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.25;
  margin: 0 0 .5rem;
}

body .workspace-page-description {
  max-width: 70ch;
  margin-bottom: 0;
  color: var(--color-text-muted);
  font-size: .9375rem;
  line-height: 1.6;
}

body .card, body .panel, body .table-card, body .stat-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-flat);
}

body .card-header, body .panel-header {
  background: var(--color-surface-alt);
  padding: 1.15rem 1.4rem;
  border-color: var(--color-border);
}

body .card-body, body .panel-body {
  padding: 1.4rem;
}

body .card .card-title, body .section-heading h4, body .section-heading h5 {
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.45;
}

body .page-hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: none;
}

body .page-hero::after {
  display: none;
}

body .stat-card:hover, body .log-entry:hover, body .filter-step-card:hover {
  transform: none;
  box-shadow: var(--shadow-flat);
}

body .badge, body .tag, body .sidebar-updated-tag {
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.5;
  font-size: .75rem;
}

body .btn, body button.btn, body .btn-range {
  min-height: 40px;
  padding: .55rem .95rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  line-height: 1.4;
  font-weight: 600;
  box-shadow: none;
  transform: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

body .btn.btn-sm {
  min-height: 32px;
  padding: .35rem .65rem;
  font-size: .8125rem;
}

body .btn-primary, body button.btn-primary {
  background: var(--color-primary) !important;
  border: 1px solid var(--color-primary) !important;
  color: #fff;
}

body .btn-primary:hover, body button.btn-primary:hover {
  background: var(--color-primary-strong) !important;
  border-color: var(--color-primary-strong) !important;
}

body .btn-range.active {
  background: var(--color-primary-soft);
  border: 1px solid #b9cffd;
  color: var(--color-primary-strong);
  box-shadow: none;
  transform: none;
}

body .btn-outline-secondary, body .btn-light, body .btn-range {
  border-color: var(--color-border-strong);
}

body .btn-range:hover, body .btn-outline-secondary:hover,
body .btn-outline-light:hover, body .btn-light:hover {
  background: var(--color-surface-alt);
  transform: none;
}

body .form-control, body .form-select, body .choices__inner {
  min-height: 42px;
  font-size: .875rem;
  border-color: var(--color-border-strong);
  box-shadow: none;
}

body .form-label, body label {
  color: #38485f;
  font-size: .8125rem;
  font-weight: 600;
}

body .form-text {
  font-size: .8125rem;
  line-height: 1.5;
}

body .form-control::placeholder {
  color: #68788e;
}

body .input-group-text {
  border-color: var(--color-border-strong);
  background: var(--color-surface-alt);
}

body .choices__inner {
  border-color: var(--color-border-strong) !important;
}

body .choices__input {
  background: transparent;
}

body :focus-visible {
  outline: 3px solid #4579ed !important;
  outline-offset: 3px;
}

body .table {
  color: var(--color-text);
  font-size: .875rem;
  --bs-table-color: var(--color-text);
  --bs-table-striped-bg: #f8fafc;
  --bs-table-hover-bg: #f1f5fc;
  --bs-table-border-color: var(--color-border);
  font-variant-numeric: tabular-nums;
}

body .table thead th {
  padding: .85rem 1rem;
  background: #e3edf7;
  color: #344b67;
  font-size: .8125rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--color-border);
}

body .table > tbody > tr > td {
  padding: .8rem 1rem;
  border-color: var(--color-border);
}

body .table-responsive {
  max-width: 100%;
}

body .table-pagination button {
  min-width: 36px;
  min-height: 36px;
  border-radius: 7px;
}

body .alert {
  font-size: .875rem;
  line-height: 1.6;
  box-shadow: none;
}

body .alert-info {
  background: #edf5ff;
  border-color: #c9ddfb;
  color: #234d88;
}

body .alert-warning {
  background: #fff8eb;
  border-color: #f4dfb3;
  color: #805515;
}

body .alert-danger {
  background: #fff1f1;
  border-color: #f4cccc;
  color: #a02828;
}

body .alert-success {
  background: #edf9f3;
  border-color: #c5e6d6;
  color: #176347;
}

body .empty-state {
  padding: 2rem 1.5rem;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
}

body .floating-icon {
  animation: none;
}

body .footer {
  margin-top: 2.5rem;
  padding: 1.25rem 0 0;
  background: transparent;
  font-size: .75rem;
  color: var(--color-text-muted);
}

body .footer > .container-fluid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 0;
}

body .footer .copyright {
  flex-wrap: wrap;
}

.footer #footerInfo:empty {
  display: none;
}

body #sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 256px;
  width: 256px;
  height: 100vh;
  height: 100dvh;
  padding: 1.5rem 1rem 1rem;
  background: var(--color-sidebar-bg);
  color: var(--color-text);
  border: 0;
  border-right: 1px solid var(--color-border);
  border-radius: 0;
  box-shadow: none;
  z-index: 100;
}

body .app-sidebar__brand {
  min-height: 36px;
  margin: 0 .5rem 1.5rem;
}

body .app-sidebar__logo, body .app-sidebar__logo:hover {
  gap: .65rem;
  color: var(--color-text);
  font-size: 1.125rem;
  letter-spacing: -.04em;
}

body .app-sidebar__logo-mark {
  width: 33px;
  height: 33px;
  border-radius: 9px;
  background: var(--color-primary);
  font-size: .875rem;
  font-weight: 700;
}

.app-sidebar__logo-cloud {
  color: var(--color-text-muted);
  font-weight: 400;
}

.app-sidebar__workspace {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .7rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface-alt);
}

.app-sidebar__workspace-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: #60718b;
}

.app-sidebar__workspace > div {
  min-width: 0;
}

.app-sidebar__workspace strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .8125rem;
  line-height: 1.5;
}

.app-sidebar__workspace div > span {
  display: block;
  color: var(--color-text-muted);
  font-size: .6875rem;
  margin-top: .1rem;
}

.app-sidebar__search {
  position: relative;
  margin-bottom: 1.35rem;
}

.app-sidebar__search > i {
  position: absolute;
  top: 50%;
  left: .7rem;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: .75rem;
  pointer-events: none;
}

.app-sidebar__search input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--color-border);
  padding: .45rem .5rem .45rem 2rem;
  font-size: .8125rem;
}

body .app-sidebar__nav {
  gap: 1.3rem;
  padding-right: .15rem;
  scrollbar-width: thin;
  scrollbar-color: #d0d9e5 transparent;
}

body .app-sidebar__group {
  padding: 0;
  border: 0;
  gap: .35rem;
}

body .app-sidebar__section-label {
  padding: 0 .7rem;
}

body .app-sidebar__section-title {
  color: #67768b;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .08em;
}

body .app-sidebar__group-items {
  gap: .15rem;
  margin-top: .2rem;
}

body .app-sidebar__link {
  min-height: 38px;
  padding: .5rem .7rem;
  border-radius: 7px;
  color: #42536c;
  gap: .65rem;
  font-size: .8125rem;
  font-weight: 500;
  line-height: 1.4;
  transform: none;
}

body .app-sidebar__link > i {
  width: 1.1rem;
  flex-shrink: 0;
  color: #75849a;
  font-size: .875rem;
}

body .app-sidebar__link:hover {
  background: #f2f5f9;
  color: var(--color-text);
  transform: none;
}

body .app-sidebar__link.active {
  background: var(--color-primary-soft);
  color: var(--color-primary-strong);
  box-shadow: inset 3px 0 var(--color-primary);
  font-weight: 650;
}

body .app-sidebar__link.active > i {
  color: var(--color-primary);
}

body .app-sidebar__badge {
  background: transparent;
  padding: 0;
  flex-shrink: 0;
}

body .app-sidebar__badge i {
  width: auto;
  color: #79869a;
  font-size: .625rem;
}

body .app-sidebar__link .app-sidebar__external {
  margin-left: auto;
  width: auto;
  font-size: .625rem;
}

body .app-sidebar__danger {
  border-top: 1px solid var(--color-border);
  margin-top: 1rem;
  padding-top: .7rem;
}

body .app-sidebar__danger .app-sidebar__link {
  background: transparent;
  color: var(--color-text-muted);
}

body .app-sidebar__danger .app-sidebar__link:hover {
  background: #fff1f1;
  color: #a02828;
}

body .app-sidebar__collapse {
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.app-sidebar__empty {
  color: var(--color-text-muted);
  padding: .5rem .7rem;
  font-size: .8125rem;
}

body #sidebar .navigation-filtered {
  display: none;
}

.workspace-skip-link {
  position: fixed;
  top: .75rem;
  left: 1rem;
  z-index: 2100;
  padding: .6rem 1rem;
  border-radius: 8px;
  background: #fff;
  transform: translateY(-180%);
}

.workspace-skip-link:focus {
  transform: translateY(0);
}

@media (min-width: 1200px) {
  body #sidebar {
    inset: auto;
    top: 0;
    transform: none;
  }

  body .sidebar-overlay {
    display: none;
  }

  body .app-sidebar__collapse {
    display: none;
  }
}

@media (max-width: 1199.98px) {
  body #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(288px, calc(100vw - 40px));
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .2s ease, visibility .2s ease;
    z-index: 1040;
  }

  body #sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: var(--shadow-lift);
  }

  body .sidebar-overlay {
    z-index: 1035;
  }

  body.navigation-open {
    overflow: hidden;
  }

  body .app-sidebar__collapse {
    display: inline-flex;
  }

  body .wrapper > .main-panel {
    width: 100%;
    padding: 0 1.5rem 1.5rem;
  }
}

@media (max-width: 575.98px) {
  body .wrapper > .main-panel {
    padding: 0 1rem 1rem;
  }

  body .app-header {
    min-height: 68px;
    margin-bottom: 1.25rem !important;
  }

  .app-header__product, .app-header__separator {
    display: none;
  }

  body .card-body, body .panel-body, body .card-header {
    padding: 1rem;
  }

  body .section-heading, body .app-table-toolbar {
    flex-wrap: wrap;
  }

  body .form-control, body .form-select,
  body input[type="search"], body input[type="date"] {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }

  body .fade-in-up {
    opacity: 1;
    transform: none;
  }
}

@media print {
  body #sidebar, body .app-header, .sidebar-overlay, .workspace-skip-link {
    display: none !important;
  }

  body .wrapper, body .wrapper > .main-panel {
    display: block;
    width: 100%;
    padding: 0;
    min-height: 0;
  }
}
