.app {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: 100%;
}

.app.is-demo-open {
  grid-template-columns: var(--sidebar) 1fr var(--demo);
}

.sidebar {
  background: var(--ink);
  color: #dbe4ee;
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand__logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(160deg, #1a3a5c, #0d7377);
  display: grid;
  place-items: center;
  color: #f7efe0;
  flex-shrink: 0;
}

.brand__name {
  font-weight: 700;
  color: #fff;
  font-size: 15px;
}

.brand__sub {
  font-size: 11px;
  color: #9bb0c4;
}

.nav {
  padding: 12px 10px;
  overflow: auto;
  flex: 1;
}

.nav__label {
  font-size: 11px;
  color: #8aa0b5;
  padding: 12px 10px 6px;
  font-weight: 600;
}

.nav__item,
.nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: right;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
}

.nav__link:hover,
.nav__item:hover {
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
  color: #fff;
}

.nav__link.is-active {
  background: rgba(13, 115, 119, 0.35);
  color: #fff;
}

.nav__ico {
  width: 18px;
  height: 18px;
  opacity: 0.9;
  flex-shrink: 0;
}

.nav__badge {
  margin-right: auto;
  background: #c4923a;
  color: #1c1917;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  padding: 0 5px;
}

.nav-group__children {
  padding-right: 20px;
}

.sidebar__foot {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.role-switch {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--sand);
}

.topbar {
  height: var(--topbar);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  flex-shrink: 0;
}

.topbar__menu {
  display: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  width: 36px;
  height: 36px;
}

.crumbs {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.crumbs a {
  color: var(--text-soft);
}

.topbar__search {
  margin-right: auto;
  position: relative;
  width: min(360px, 40%);
}

.topbar__search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--sand);
  padding: 8px 36px 8px 12px;
}

.topbar__search svg {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--ink);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.user-chip__av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.page {
  flex: 1;
  overflow: auto;
  padding: 20px 24px 88px;
  min-height: 0;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head__meta {
  color: var(--muted);
  margin-top: 4px;
}

.page-head__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.next-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--teal);
  font-weight: 600;
}

.demo-rail {
  background: #fff;
  border-right: 1px solid var(--line);
  display: none;
  flex-direction: column;
  min-height: 0;
}

.app.is-demo-open .demo-rail {
  display: flex;
}

.demo-rail__head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.demo-rail__head small {
  color: var(--muted);
}

.demo-steps {
  overflow: auto;
  flex: 1;
  padding: 8px;
}

.demo-step {
  width: 100%;
  text-align: right;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  color: var(--text);
}

.demo-step.is-current {
  background: var(--teal-soft);
}

.demo-step.is-done {
  opacity: 0.72;
}

.demo-step__n {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--sand-2);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.demo-step.is-current .demo-step__n {
  background: var(--teal);
  color: #fff;
}

.demo-step.is-done .demo-step__n {
  background: var(--success);
  color: #fff;
}

.demo-step strong {
  display: block;
  font-size: 12px;
}

.demo-step span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.demo-rail__note {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--gold-soft);
  font-size: 12px;
}

.demo-rail__note b {
  display: block;
  margin-bottom: 4px;
}

.demo-fab {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 40;
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  box-shadow: var(--shadow-lg);
}

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 39, 68, 0.45);
  z-index: 50;
}

.scrim.is-on {
  display: block;
}

.drawer,
.modal {
  position: fixed;
  z-index: 60;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.drawer {
  top: 0;
  bottom: 0;
  left: 0;
  width: min(480px, 100%);
  display: none;
  flex-direction: column;
}

.drawer.is-on {
  display: flex;
}

.modal {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100% - 24px));
  border-radius: var(--radius-lg);
  display: none;
}

.modal.is-on {
  display: block;
}

.modal--wide {
  width: min(860px, calc(100% - 24px));
}

.drawer__head,
.modal__head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.drawer__body,
.modal__body {
  padding: 16px 18px;
  overflow: auto;
}

.drawer__body {
  flex: 1;
}

.drawer__foot,
.modal__foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toasts {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #fff;
  border: 1px solid var(--line);
  border-right: 4px solid var(--teal);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 260px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast--success {
  border-right-color: var(--success);
}

.toast--warn {
  border-right-color: var(--warning);
}

.toast--error {
  border-right-color: var(--danger);
}

.toast--sms {
  border-right-color: var(--gold);
  background: var(--gold-soft);
}

.highlight-pulse {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  animation: pulse 1.2s ease infinite;
}

@keyframes pulse {
  50% {
    outline-color: var(--teal);
  }
}

@media (max-width: 1280px) {
  :root {
    --sidebar: 240px;
    --demo: 280px;
  }
}

@media (max-width: 880px) {
  .app,
  .app.is-demo-open {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    transform: translateX(-110%);
    transition: transform var(--ease);
  }

  html[dir="rtl"] .sidebar {
    inset: 0 0 0 auto;
    transform: translateX(110%);
  }

  .app.is-nav-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15, 39, 68, 0.4);
    z-index: 15;
  }

  .topbar__menu {
    display: grid;
  }

  .topbar__search {
    display: none;
  }

  .demo-rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 90vw);
    z-index: 45;
    display: none;
  }

  html[dir="rtl"] .demo-rail {
    inset: 0 auto 0 0;
  }

  .app.is-demo-open .demo-rail {
    display: flex;
  }

  .page {
    padding: 16px 14px 96px;
  }
}

@media (min-width: 881px) {
  .topbar__menu {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .page-head {
    flex-direction: column;
  }

  .user-chip span {
    display: none;
  }
}
