:root {
  color-scheme: light;
  --portal-ink: #172322;
  --portal-muted: #667371;
  --portal-line: #d8e0de;
  --portal-canvas: #edf1f0;
  --portal-surface: #ffffff;
  --portal-teal-950: #062a28;
  --portal-teal-900: #0a3532;
  --portal-teal-700: #1e635b;
  --portal-mint: #8de6d5;
  --portal-blue: #2d6f9f;
  --portal-red: #b9443d;
  --portal-shadow: 0 12px 34px rgba(11, 47, 44, 0.12);
  --portal-radius: 7px;
  --portal-font: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--portal-canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--portal-ink);
  background: var(--portal-canvas);
  font-family: var(--portal-font);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(45, 111, 159, 0.28);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.portal-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--portal-line);
  border-radius: 5px;
  background: var(--portal-surface);
  cursor: pointer;
  font-weight: 760;
}

.portal-button.is-primary {
  color: #ffffff;
  background: var(--portal-teal-700);
  border-color: var(--portal-teal-700);
}

.portal-button.is-secondary {
  min-height: 34px;
  padding-inline: 11px;
  color: var(--portal-teal-700);
  background: #ffffff;
  border-color: #a9c7c1;
  font-size: 11px;
}

.portal-button:hover:not(:disabled) {
  filter: brightness(0.96);
}

.portal-login {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.2fr) minmax(420px, 0.8fr);
  background: var(--portal-surface);
}

.portal-login-brand {
  display: grid;
  padding: clamp(32px, 6vw, 88px);
  align-content: space-between;
  color: #ffffff;
  background: var(--portal-teal-950);
}

.portal-login-brand > img {
  width: 154px;
  filter: brightness(0) invert(1);
}

.portal-login-brand > div:nth-child(2) {
  max-width: 650px;
}

.portal-login-brand span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.portal-login-brand h1 {
  max-width: 680px;
  margin: 12px 0 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.08;
}

.portal-login-modules {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
}

.portal-login-modules span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  text-transform: none;
}

.portal-login-form {
  display: grid;
  width: min(430px, calc(100% - 48px));
  margin: auto;
  gap: 18px;
}

.portal-login-form > img {
  display: none;
  width: 132px;
}

.portal-login-form h2 {
  margin: 0 0 6px;
  font-size: 28px;
}

.portal-login-form p {
  margin: 0;
  color: var(--portal-muted);
}

.portal-login-form .portal-login-help {
  margin-top: 10px;
  font-size: 12px;
}

.portal-login-help a {
  color: var(--portal-teal-700);
  font-weight: 750;
}

.portal-login-form label {
  display: grid;
  gap: 6px;
  color: var(--portal-muted);
  font-size: 12px;
  font-weight: 760;
}

.portal-login-form input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--portal-line);
  border-radius: 5px;
  color: var(--portal-ink);
  background: #ffffff;
}

.portal-login-separator {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  color: var(--portal-muted);
  font-size: 12px;
}

.portal-login-separator::before,
.portal-login-separator::after {
  height: 1px;
  background: var(--portal-line);
  content: "";
}

.portal-telegram {
  display: grid;
  min-height: 42px;
  place-items: center;
  gap: 8px;
}

.portal-telegram-login {
  display: inline-flex;
  min-height: 42px;
  padding: 0 18px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #ffffff;
  background: #229ed9;
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
}

.portal-telegram-login:hover {
  background: #198bc1;
}

.portal-telegram p,
.portal-form-error {
  min-height: 18px;
  color: var(--portal-red) !important;
  font-size: 12px;
  text-align: center;
}

.portal-loading {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: var(--portal-teal-950);
}

.portal-loading > div {
  display: grid;
  width: min(380px, calc(100vw - 32px));
  padding: 28px;
  gap: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--portal-radius);
  color: #ffffff;
  background: var(--portal-teal-900);
  box-shadow: var(--portal-shadow);
}

.portal-loading img {
  width: 130px;
  filter: brightness(0) invert(1);
}

.portal-loading strong {
  font-size: 18px;
}

.employee-portal {
  min-height: 100vh;
  background: var(--portal-canvas);
}

.employee-header {
  position: relative;
  z-index: 20;
  display: grid;
  min-height: 72px;
  padding: 0 18px;
  grid-template-columns: 210px minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 18px;
  color: #ffffff;
  background: var(--portal-teal-950);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.employee-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  text-decoration: none;
}

.employee-brand img {
  width: 112px;
  filter: brightness(0) invert(1);
}

.employee-brand span {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.58);
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-modules {
  display: flex;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.employee-modules::-webkit-scrollbar {
  display: none;
}

.employee-modules button {
  position: relative;
  display: grid;
  min-width: 148px;
  padding: 13px 18px 10px;
  align-content: center;
  gap: 2px;
  border: 0;
  color: rgba(255, 255, 255, 0.66);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.employee-modules button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.employee-modules button.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.employee-modules button.is-active::after {
  position: absolute;
  right: 18px;
  bottom: 0;
  left: 18px;
  height: 3px;
  background: var(--portal-mint);
  content: "";
}

.employee-modules button.is-locked {
  color: rgba(255, 255, 255, 0.32);
}

.employee-modules strong {
  font-size: 13px;
}

.employee-modules span {
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
}

.employee-user {
  display: flex;
  min-width: 158px;
  margin: 12px 0;
  padding: 0 9px;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  text-align: left;
}

.employee-avatar {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--portal-teal-950);
  background: var(--portal-mint);
  font-weight: 850;
}

.employee-user > span:last-child {
  display: grid;
  min-width: 0;
}

.employee-user strong,
.employee-user small {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-user strong {
  font-size: 12px;
}

.employee-user small {
  color: rgba(255, 255, 255, 0.58);
  font-size: 10px;
}

.employee-context {
  display: flex;
  min-height: 56px;
  padding: 8px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--portal-surface);
  border-bottom: 1px solid var(--portal-line);
}

.employee-context > div:first-child {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 12px;
}

.employee-context strong {
  font-size: 17px;
}

.employee-context span {
  color: var(--portal-muted);
  font-size: 11px;
}

.employee-context.is-declarants-context {
  gap: 12px;
}

.employee-context.is-declarants-context > div:first-child {
  flex: 0 0 auto;
}

.employee-context.is-declarants-context > div:first-child span {
  display: none;
}

.declarants-context-metrics {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.declarants-context-metrics button {
  display: grid;
  min-width: 82px;
  min-height: 36px;
  padding: 4px 8px;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  border: 1px solid var(--portal-line);
  border-radius: 5px;
  color: var(--portal-muted);
  background: #f8faf9;
  cursor: pointer;
  text-align: left;
}

.declarants-context-metrics button:hover,
.declarants-context-metrics button.is-active {
  color: var(--portal-teal-700);
  border-color: #69a99c;
  background: #eef8f5;
}

.declarants-context-metrics button.is-danger strong {
  color: #c9413b;
}

.declarants-context-metrics button.is-danger.is-active {
  border-color: #dd8c87;
  background: #fff2f1;
}

.declarants-context-metrics strong {
  font-size: 15px;
  line-height: 1;
}

.declarants-context-metrics span {
  overflow: hidden;
  font-size: 8px;
  font-weight: 750;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.employee-context-actions,
.employee-online {
  display: flex;
  align-items: center;
  gap: 9px;
}

.employee-online i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2f866e;
}

.employee-online.is-warning i {
  background: #c58d17;
}

.employee-stage {
  min-height: calc(100dvh - 128px);
}

.employee-module {
  width: 100%;
  height: calc(100dvh - 128px);
  overflow: hidden;
}

.employee-portal.is-compact-workspace .employee-stage,
.employee-portal.is-compact-workspace .employee-module,
.employee-portal.is-compact-workspace .employee-no-access {
  min-height: calc(100dvh - 72px);
  height: calc(100dvh - 72px);
}

.employee-module iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--portal-canvas);
}

.employee-no-access {
  display: grid;
  min-height: calc(100dvh - 128px);
  padding: 28px;
  place-content: center;
  text-align: center;
}

.employee-no-access strong {
  font-size: 20px;
}

.employee-no-access p {
  max-width: 440px;
  margin: 8px 0 0;
  color: var(--portal-muted);
}

.employee-no-access .portal-button {
  justify-self: center;
  margin-top: 18px;
}

.employee-mobile-nav {
  display: none;
}

.employee-user-menu {
  position: fixed;
  z-index: 50;
  top: 64px;
  right: 18px;
  display: grid;
  width: 230px;
  padding: 14px;
  gap: 5px;
  border: 1px solid var(--portal-line);
  border-radius: var(--portal-radius);
  background: #ffffff;
  box-shadow: var(--portal-shadow);
}

.employee-user-menu span {
  color: var(--portal-muted);
  font-size: 11px;
}

.employee-user-menu button {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid var(--portal-line);
  border-radius: 5px;
  color: var(--portal-red);
  background: #ffffff;
  cursor: pointer;
  font-weight: 750;
  text-align: left;
}

.employee-access-dialog {
  width: min(430px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: var(--portal-radius);
  box-shadow: 0 26px 74px rgba(5, 35, 33, 0.28);
}

.employee-access-dialog::backdrop {
  background: rgba(5, 35, 33, 0.48);
}

.employee-access-dialog form {
  display: grid;
  padding: 24px;
  gap: 12px;
}

.employee-access-dialog span {
  color: var(--portal-red);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.employee-access-dialog h2,
.employee-access-dialog p {
  margin: 0;
}

.employee-access-dialog p {
  color: var(--portal-muted);
  line-height: 1.5;
}

.employee-access-dialog .portal-button {
  margin-top: 6px;
}

.employee-toast {
  position: fixed;
  z-index: 80;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 11px 14px;
  border-radius: 5px;
  color: #ffffff;
  background: var(--portal-teal-900);
  box-shadow: var(--portal-shadow);
  font-weight: 720;
}

@media (max-width: 1040px) {
  .employee-header {
    grid-template-columns: 164px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .employee-brand span,
  .employee-user small,
  .employee-modules span {
    display: none;
  }

  .employee-modules button {
    min-width: max-content;
    padding-inline: 14px;
  }

  .employee-user {
    min-width: 52px;
  }

  .employee-user > span:last-child {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .portal-login {
    display: block;
    padding: max(22px, env(safe-area-inset-top)) 0 max(22px, env(safe-area-inset-bottom));
    background: #ffffff;
  }

  .portal-login-brand {
    display: none;
  }

  .portal-login-form {
    width: min(430px, calc(100% - 32px));
    min-height: calc(100dvh - 44px);
    align-content: center;
  }

  .portal-login-form > img {
    display: block;
  }

  .employee-header {
    min-height: 58px;
    padding: 0 12px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .employee-brand img {
    width: 102px;
  }

  .employee-modules {
    display: none;
  }

  .employee-user {
    height: 40px;
    margin: 9px 0;
  }

  .employee-context {
    min-height: 52px;
    padding: 7px 12px;
  }

  .employee-context > div:first-child {
    display: grid;
    gap: 1px;
  }

  .employee-context strong {
    font-size: 15px;
  }

  .employee-context > div:first-child span,
  .employee-online {
    display: none;
  }

  .employee-portal.is-service-degraded .employee-context > div:first-child span {
    display: block;
    max-width: 54vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .employee-online.is-warning {
    display: flex;
  }

  .employee-online.is-warning [data-system-status-text] {
    max-width: 124px;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .employee-context .portal-button {
    min-height: 36px;
    padding-inline: 12px;
    font-size: 12px;
  }

  .employee-context.is-declarants-context {
    min-height: 104px;
    padding-block: 6px;
    flex-wrap: wrap;
    align-content: center;
    gap: 5px 10px;
  }

  .employee-context.is-declarants-context > div:first-child {
    order: 1;
  }

  .employee-context.is-declarants-context .employee-context-actions {
    order: 2;
    margin-left: auto;
  }

  .employee-context.is-declarants-context .declarants-context-metrics {
    order: 3;
    width: 100%;
    flex-basis: 100%;
  }

  .declarants-context-metrics button {
    min-width: 86px;
    min-height: 38px;
  }

  .employee-context.is-declarants-context + .employee-stage,
  .employee-context.is-declarants-context + .employee-stage .employee-module,
  .employee-context.is-declarants-context + .employee-stage .employee-no-access {
    min-height: calc(100dvh - 226px - env(safe-area-inset-bottom));
    height: calc(100dvh - 226px - env(safe-area-inset-bottom));
  }

  .employee-stage,
  .employee-module,
  .employee-no-access {
    min-height: calc(100dvh - 174px - env(safe-area-inset-bottom));
    height: calc(100dvh - 174px - env(safe-area-inset-bottom));
  }

  .employee-portal.is-compact-workspace .employee-stage,
  .employee-portal.is-compact-workspace .employee-module,
  .employee-portal.is-compact-workspace .employee-no-access {
    min-height: calc(100dvh - 122px - env(safe-area-inset-bottom));
    height: calc(100dvh - 122px - env(safe-area-inset-bottom));
  }

  .employee-mobile-nav {
    position: fixed;
    z-index: 30;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 5px env(safe-area-inset-bottom);
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: #ffffff;
    border-top: 1px solid var(--portal-line);
  }

  .employee-mobile-nav button {
    position: relative;
    min-width: 0;
    padding: 8px 3px;
    border: 0;
    color: var(--portal-muted);
    background: transparent;
    cursor: pointer;
  }

  .employee-mobile-nav button.is-active {
    color: var(--portal-teal-700);
  }

  .employee-mobile-nav button.is-active::before {
    position: absolute;
    top: 0;
    right: 18%;
    left: 18%;
    height: 3px;
    background: var(--portal-teal-700);
    content: "";
  }

  .employee-mobile-nav button.is-locked {
    color: #adb6b4;
  }

  .employee-mobile-nav strong {
    display: block;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .employee-user-menu {
    top: 54px;
    right: 10px;
  }

  .employee-toast {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: 12px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
