:root {
  --md-bg: #fafafa;
  --md-surface: #ffffff;
  --md-line-soft: #f1f1f1;
  --md-text: #121843;
  --md-muted: #686868;
  --md-accent: #00b3ad;
  --md-accent-soft: rgba(0, 179, 173, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  height: 100%;
}

body.mportal-dashboard-page {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--md-bg);
  color: var(--md-text);
  font-family: "Poppins", "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  background: transparent;
}

.md-shell {
  display: grid;
  grid-template-columns: 242px minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

body.mportal-dashboard-page.is-sidebar-collapsed .md-shell {
  grid-template-columns: 92px minmax(0, 1fr);
}

.md-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px 0 32px;
  background: #ffffff;
  border-right: 1px solid var(--md-line-soft);
}

body.mportal-dashboard-page.is-sidebar-collapsed .md-sidebar {
  gap: 28px;
}

.md-sidebar-header {
  position: relative;
  display: flex;
  align-items: center;
  height: 62px;
  min-height: 62px;
}

.md-brand {
  display: flex;
  align-items: center;
  height: 62px;
  min-height: 62px;
  padding: 0 32px;
}

body.mportal-dashboard-page.is-sidebar-collapsed .md-brand {
  padding: 0 32px;
}

.md-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--md-accent);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

body.mportal-dashboard-page.is-sidebar-collapsed .md-brand-mark {
  font-size: 0;
}

body.mportal-dashboard-page.is-sidebar-collapsed .md-brand-mark::before {
  content: "M";
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--md-accent);
}

.md-menu {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

body.mportal-dashboard-page.is-sidebar-collapsed .md-menu {
  gap: 24px;
}

.md-menu-group {
  display: grid;
  grid-template-rows: 28px;
  grid-auto-rows: 56px;
  align-items: stretch;
  gap: 2px;
}

.md-menu-label {
  display: flex;
  align-items: flex-end;
  height: 28px;
  min-height: 28px;
  padding: 0 30px 10px;
  color: rgba(104, 104, 104, 0.62);
  font-family: "Roboto", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

body.mportal-dashboard-page.is-sidebar-collapsed .md-menu-label {
  opacity: 0;
  pointer-events: none;
}

.md-menu-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  column-gap: 20px;
  height: 56px;
  min-height: 56px;
  padding: 0 30px;
  color: var(--md-muted);
  font-size: 1rem;
  font-weight: 400;
}

body.mportal-dashboard-page.is-sidebar-collapsed .md-menu-item {
  grid-template-columns: 28px 0;
  column-gap: 0;
  min-height: 56px;
  width: 88px;
  padding: 0 30px;
  border-radius: 0;
  overflow: hidden;
}

.md-menu-item:hover {
  background: var(--md-accent-soft);
}

.md-menu-item.is-active {
  color: var(--md-accent);
  font-weight: 500;
}

body.mportal-dashboard-page.is-sidebar-collapsed .md-menu-item > span:last-child {
  width: 0;
  max-width: 0;
  min-width: 0;
  overflow: hidden;
  opacity: 0;
  white-space: nowrap;
}

.md-menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: currentColor;
}

.md-menu-icon svg {
  width: 22px;
  height: 22px;
}

.md-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.md-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 91px;
  padding: 0 50px;
  background: #ffffff;
  border-bottom: 1px solid var(--md-line-soft);
}

.md-topbar-lead {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}

.md-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 34px;
  right: -16px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: 1px solid #e0e0e0;
  border-radius: 999px;
  background: #ffffff;
  color: var(--md-accent);
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(18, 24, 67, 0.08);
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.md-sidebar-toggle:hover {
  background: var(--md-accent-soft);
  border-color: rgba(0, 179, 173, 0.24);
}

.md-sidebar-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.18s ease;
}

body.mportal-dashboard-page.is-sidebar-collapsed .md-sidebar-toggle svg {
  transform: rotate(180deg);
}

.md-search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(343px, 100%);
  min-height: 44px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fafafa;
}

.md-breadcrumbs {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: #8b91ad;
  font-size: 0.96rem;
  font-weight: 500;
}

.md-breadcrumb-separator {
  color: #b3b8ca;
}

.md-breadcrumbs [aria-current="page"] {
  color: var(--md-text);
  font-weight: 600;
}

.md-search input {
  width: 100%;
  padding: 0 46px 0 16px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--md-text);
  font-size: 1rem;
}

.md-search input::placeholder {
  color: #b3b3b3;
}

.md-search-icon {
  position: absolute;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #b3b3b3;
}

.md-search-icon svg {
  width: 20px;
  height: 20px;
}

.md-topbar-actions {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}

.md-topbar-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  color: #9b9b9b;
  cursor: pointer;
}

.md-topbar-icon svg {
  width: 28px;
  height: 28px;
}

.md-badge {
  position: absolute;
  top: 5px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--md-accent);
}

.md-user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: min(360px, 34vw);
  padding: 0;
  border: 0;
  cursor: pointer;
  color: var(--md-text);
}

.md-user-menu {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.md-user-menu.is-open .md-user-chip {
  color: var(--md-accent);
}

.md-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: #e4f8eb;
  border: 1px solid #d1f1dd;
  color: #0d9752;
  font-size: 1.05rem;
  font-weight: 700;
  flex-shrink: 0;
}

.md-user-name {
  display: block;
  font-size: 1rem;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-user-arrow {
  display: inline-flex;
  color: #8b91ad;
  flex-shrink: 0;
}

.md-user-arrow svg {
  width: 18px;
  height: 18px;
}

.md-user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  padding: 8px;
  border: 1px solid rgba(18, 24, 67, 0.08);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 20px 40px rgba(18, 24, 67, 0.12);
}

.md-user-dropdown[hidden] {
  display: none;
}

.md-user-dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: transparent;
  color: var(--md-text);
  font-size: 0.96rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.md-user-dropdown-item:hover {
  background: var(--md-accent-soft);
  color: var(--md-accent);
}

.md-user-dropdown-item.is-danger:hover {
  background: rgba(232, 78, 78, 0.08);
  color: #d84d4d;
}

.md-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 34px 50px 40px;
}

.md-page-title {
  margin-bottom: 16px;
}

.md-page-title h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--md-accent);
}

.md-blank-stage {
  min-height: 620px;
}

.md-content.is-decision-tree-view {
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

.md-content.is-decision-tree-view .md-flow-embed {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 91px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #fff;
}

@media (max-width: 980px) {
  .md-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .md-topbar,
  .md-content {
    padding-left: 28px;
    padding-right: 28px;
  }
}

@media (max-width: 820px) {
  body.mportal-dashboard-page {
    overflow: auto;
  }

  .md-shell {
    height: auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  body.mportal-dashboard-page.is-sidebar-collapsed .md-shell {
    grid-template-columns: 1fr;
  }

  .md-sidebar {
    gap: 20px;
    padding: 18px 0 22px;
    border-right: 0;
    border-bottom: 1px solid var(--md-line-soft);
  }

  .md-sidebar-toggle {
    top: 22px;
    right: 18px;
  }

  .md-topbar {
    flex-direction: column;
    align-items: stretch;
    min-height: auto;
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .md-main,
  .md-content {
    overflow: visible;
  }

  .md-search {
    width: 100%;
  }

  .md-topbar-actions {
    justify-content: space-between;
  }

  .md-content {
    padding-top: 24px;
  }
}

@media (max-width: 620px) {
  .md-topbar,
  .md-content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .md-user-name {
    font-size: 0.92rem;
    max-width: 120px;
  }

  .md-brand-mark {
    font-size: 1.8rem;
  }
}

.kb-page-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.kb-page-title p {
  margin: 8px 0 0;
  color: var(--md-muted);
}

.kb-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 22px;
}

.kb-search {
  flex: 1 1 360px;
  max-width: 520px;
}

.kb-filter-popover {
  position: relative;
  flex: 0 0 auto;
  min-width: 150px;
}

.kb-filter-toggle {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid #e1e5ec;
  border-radius: 8px;
  background: #ffffff;
  color: var(--md-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.kb-filter-toggle.is-active {
  border-color: rgba(0, 166, 156, 0.36);
  background: #effdfb;
  color: var(--md-accent);
}

.kb-filter-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.kb-filter-count {
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--md-accent);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
}

.kb-filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 5;
  display: grid;
  gap: 12px;
  width: 360px;
  min-width: 360px;
  max-width: min(92vw, 420px);
  padding: 14px;
  border: 1px solid #e1e5ec;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(18, 20, 38, 0.12);
}

.kb-filter-panel[hidden] {
  display: none !important;
}

.kb-filter-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kb-filter-panel-head strong {
  color: var(--md-text);
  font-size: 0.92rem;
}

.kb-filter-panel-head button {
  border: 0;
  background: transparent;
  color: var(--md-accent);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.kb-filter-field {
  display: grid;
  gap: 6px;
}

.kb-filter-field span {
  color: #6d7486;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.kb-filter-field .lm-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.kb-list-table-wrap,
.kb-empty {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: none;
}

.kb-list-table-wrap {
  max-width: 100%;
  overflow: auto;
}

.kb-list-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  table-layout: fixed;
}

.kb-list-table th,
.kb-list-table td {
  box-sizing: border-box;
  padding: 14px 12px;
  border-bottom: 1px solid #eef0f3;
  color: var(--md-text);
  font-size: 0.9rem;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-list-table th {
  color: #6d7486;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}

.kb-list-table th:nth-child(1),
.kb-list-table td:nth-child(1) {
  width: 145px;
}

.kb-list-table th:nth-child(2),
.kb-list-table td:nth-child(2) {
  width: 520px;
}

.kb-list-table th:nth-child(3),
.kb-list-table td:nth-child(3) {
  width: 130px;
}

.kb-list-table th:nth-child(4),
.kb-list-table td:nth-child(4) {
  width: 56px;
}

.kb-list-table th:nth-child(5),
.kb-list-table td:nth-child(5) {
  width: 125px;
}

.kb-list-table th:nth-child(6),
.kb-list-table td:nth-child(6) {
  width: 125px;
}

.kb-list-table th:nth-child(7),
.kb-list-table td:nth-child(7) {
  width: 104px;
}

.kb-list-table th:nth-child(8),
.kb-list-table td:nth-child(8) {
  width: 106px;
}

.kb-list-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.kb-list-title strong,
.kb-list-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-list-title span {
  color: var(--md-muted);
  font-size: 0.82rem;
}

.kb-code {
  color: var(--md-accent);
}

.kb-type,
.kb-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 4px;
  background: #f4f6f8;
  color: #55617b;
  font-size: 0.78rem;
  font-weight: 600;
}

.kb-status.is-published {
  background: #e4f8eb;
  color: #0d9752;
}

.kb-status.is-paused {
  background: #fff2d8;
  color: #a86700;
}

.kb-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.kb-meta a {
  color: var(--md-accent);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.kb-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 98px;
  white-space: nowrap;
}

.kb-icon-action {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--lm-line);
  background: #ffffff;
  color: #1a1b2f;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.kb-icon-action:hover {
  border-color: rgba(0, 166, 156, 0.28);
  background: #effdfb;
  color: var(--md-accent);
}

.kb-icon-action.is-danger {
  color: #ff3346;
}

.kb-icon-action.is-danger:hover {
  border-color: rgba(255, 51, 70, 0.28);
  background: #fff1f3;
  color: #ff3346;
}

.kb-icon-action svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kb-empty {
  padding: 28px;
  color: var(--md-muted);
}

.kb-modal .lm-modal-card {
  width: min(1180px, 100%);
  display: flex;
  flex-direction: column;
  max-width: 1180px;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  padding: 0;
}

.kb-modal .lm-modal-head {
  flex: 0 0 auto;
  margin-bottom: 0;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--lm-line);
}

.kb-modal .kb-form {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 24px;
}

.kb-modal .lm-modal-actions {
  flex: 0 0 auto;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--lm-line);
  background: #ffffff;
}

.kb-form .kb-wide {
  grid-column: 1 / -1;
}

.kb-form textarea {
  resize: vertical;
}

@media (max-width: 820px) {
  .kb-page-title,
  .kb-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .kb-filter-panel {
    position: static;
    width: 100%;
  }

  .kb-filter-popover {
    width: 100%;
  }

  .kb-modal {
    padding: 10px;
  }

  .kb-modal .lm-modal-card {
    max-height: calc(100dvh - 20px);
  }

  .kb-modal .lm-modal-head,
  .kb-modal .kb-form,
  .kb-modal .lm-modal-actions {
    padding-left: 16px;
    padding-right: 16px;
  }
}
