:root {
  --portal-bg: linear-gradient(180deg, #f4f9fc 0%, #eaf3f8 45%, #f7fbfd 100%);
  --portal-panel: rgba(255, 255, 255, 0.92);
  --portal-panel-strong: #ffffff;
  --portal-line: #d7e5ec;
  --portal-line-soft: #e6eff4;
  --portal-text: #17313d;
  --portal-muted: #6f8895;
  --portal-brand: #3387a9;
  --portal-brand-dark: #255f77;
  --portal-brand-soft: #eaf5fb;
  --portal-teal: #4bc5d3;
  --portal-danger: #e1625f;
  --portal-success: #34a67d;
  --portal-warning: #f2a840;
  --portal-shadow: 0 24px 52px rgba(38, 82, 103, 0.12);
  --portal-radius-xl: 28px;
  --portal-radius-lg: 22px;
  --portal-radius-md: 18px;
  --portal-radius-pill: 999px;
  --portal-font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: #f4f9fc;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(51, 135, 169, 0.18), transparent 24%),
    radial-gradient(circle at left bottom, rgba(75, 197, 211, 0.16), transparent 18%),
    var(--portal-bg);
  color: var(--portal-text);
  font-family: var(--portal-font);
  overflow-x: hidden;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.portal-page {
  min-height: 100vh;
  overflow-x: hidden;
}

.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(18px);
  background: rgba(243, 249, 252, 0.88);
  border-bottom: 1px solid rgba(215, 229, 236, 0.88);
}

.portal-topbar-inner {
  width: min(1500px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.portal-brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(215, 229, 236, 0.9);
  display: grid;
  place-items: center;
  padding: 4px;
  overflow: hidden;
  box-shadow: 0 16px 30px rgba(37, 95, 119, 0.16);
}

.portal-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.portal-brand-text strong {
  display: block;
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.portal-brand-text span {
  display: block;
  color: var(--portal-muted);
  font-size: 0.92rem;
  margin-top: 2px;
}

.portal-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.portal-chip,
.portal-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--portal-radius-pill);
  background: #fff;
  border: 1px solid var(--portal-line);
  color: var(--portal-brand-dark);
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(38, 82, 103, 0.08);
}

.portal-user-chip {
  color: var(--portal-text);
}

.portal-btn,
.portal-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: var(--portal-radius-pill);
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.portal-btn:hover,
.portal-link-btn:hover {
  transform: translateY(-1px);
}

.portal-btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
}

.portal-btn-primary,
.portal-link-btn-primary {
  background: linear-gradient(180deg, var(--portal-brand) 0%, var(--portal-brand-dark) 100%);
  color: #fff;
  box-shadow: 0 16px 30px rgba(37, 95, 119, 0.22);
}

.portal-btn-soft,
.portal-link-btn-soft {
  background: #fff;
  color: var(--portal-brand-dark);
  border-color: var(--portal-line);
}

.portal-btn-ghost,
.portal-link-btn-ghost {
  background: transparent;
  color: var(--portal-brand);
  border-color: transparent;
}

.portal-main {
  width: min(1500px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.portal-hero {
  display: grid;
  gap: 20px;
  margin-bottom: 22px;
}

.portal-hero-card {
  background: linear-gradient(140deg, rgba(41, 116, 144, 0.96) 0%, rgba(52, 135, 169, 0.94) 55%, rgba(75, 197, 211, 0.92) 100%);
  color: #fff;
  border-radius: var(--portal-radius-xl);
  padding: 28px;
  box-shadow: 0 28px 56px rgba(37, 95, 119, 0.26);
}

.portal-hero-card h1,
.portal-section-head h2,
.portal-card-title {
  margin: 0;
  letter-spacing: -0.03em;
}

.portal-hero-card p {
  margin: 12px 0 0;
  max-width: 720px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.86);
}

.portal-grid {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.portal-grid-main {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  align-items: start;
  min-width: 0;
}

.portal-stack {
  min-width: 0;
}

.portal-panel {
  background: var(--portal-panel);
  border: 1px solid rgba(215, 229, 236, 0.86);
  border-radius: var(--portal-radius-xl);
  padding: 22px;
  box-shadow: var(--portal-shadow);
  min-width: 0;
  overflow: hidden;
}

.portal-panel-strong {
  background: var(--portal-panel-strong);
}

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

.portal-section-head > div {
  min-width: 0;
}

.portal-section-head p,
.portal-empty-copy,
.portal-helper {
  margin: 8px 0 0;
  color: var(--portal-muted);
  line-height: 1.55;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.portal-client-strip {
  display: grid;
  gap: 12px;
}

.portal-client-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  max-width: 100%;
  min-width: 0;
}

.portal-client-card {
  text-align: left;
  border: 1px solid var(--portal-line);
  background: #fff;
  border-radius: var(--portal-radius-lg);
  padding: 16px;
  cursor: pointer;
  min-height: 122px;
  box-shadow: 0 14px 24px rgba(38, 82, 103, 0.08);
}

.portal-client-card.is-active {
  background: linear-gradient(180deg, #ffffff 0%, #eef8fc 100%);
  border-color: rgba(51, 135, 169, 0.4);
  box-shadow: 0 18px 32px rgba(51, 135, 169, 0.18);
}

.portal-client-card strong {
  display: block;
  font-size: 1rem;
}

.portal-client-card small,
.portal-client-card p {
  margin: 6px 0 0;
  color: var(--portal-muted);
  line-height: 1.45;
}

.portal-balance-card {
  display: grid;
  gap: 18px;
}

.portal-balance-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.portal-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: var(--portal-muted);
  font-weight: 800;
}

.portal-balance-value {
  margin: 6px 0 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.portal-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.portal-metric-card {
  border: 1px solid var(--portal-line-soft);
  background: #fff;
  border-radius: var(--portal-radius-lg);
  padding: 18px;
  min-width: 0;
}

.portal-metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.15rem, 1.1vw + 0.9rem, 1.45rem);
  letter-spacing: -0.04em;
  line-height: 1.02;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-metric-card span {
  color: var(--portal-muted);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.portal-summary-panel .portal-metrics {
  grid-template-columns: 1fr;
  gap: 10px;
}

.portal-summary-panel .portal-metric-card {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
}

.portal-summary-panel .portal-metric-card span {
  font-size: 0.82rem;
}

.portal-summary-panel .portal-metric-card strong {
  margin-top: 0;
  text-align: left;
  white-space: nowrap;
  font-size: clamp(1.02rem, 0.55vw + 0.9rem, 1.28rem);
  line-height: 1;
}

.portal-actions-stack,
.portal-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.portal-actions-stack {
  flex-direction: column;
}

.portal-info-list {
  display: grid;
  gap: 10px;
}

.portal-info-row {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--portal-radius-md);
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--portal-line-soft);
}

.portal-info-row span {
  color: var(--portal-muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.portal-info-row strong {
  font-size: 1rem;
}

.portal-movement-list {
  display: grid;
  gap: 14px;
}

.portal-movement-card {
  border: 1px solid var(--portal-line-soft);
  background: #fff;
  border-radius: var(--portal-radius-lg);
  padding: 20px;
  display: grid;
  gap: 18px;
}

.portal-movement-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.portal-movement-copy {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.portal-movement-title-group {
  display: grid;
  gap: 6px;
}

.portal-movement-kind {
  color: var(--portal-brand);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 800;
}

.portal-movement-summary {
  margin: 0;
  color: var(--portal-muted);
  line-height: 1.45;
}

.portal-movement-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.portal-inline-detail-btn {
  min-height: 40px;
  padding: 9px 14px;
  font-size: 0.92rem;
}

.portal-movement-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: var(--portal-radius-pill);
  background: var(--portal-brand-soft);
  color: var(--portal-brand-dark);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.2;
}

.portal-movement-status.tone-debt {
  background: #fff1ef;
  color: #b64845;
}

.portal-movement-status.tone-credit {
  background: #edf9f4;
  color: #20885f;
}

.portal-movement-status.tone-warning {
  background: #fff6e7;
  color: #b67919;
}

.portal-movement-status.tone-neutral {
  background: #f1f6f9;
  color: var(--portal-muted);
}

.portal-movement-card strong {
  display: block;
  font-size: 1.18rem;
  letter-spacing: -0.03em;
}

.portal-movement-fact {
  display: grid;
  gap: 5px;
  padding: 12px 14px;
  border-radius: var(--portal-radius-md);
  background: rgba(244, 249, 252, 0.9);
  border: 1px solid var(--portal-line-soft);
}

.portal-movement-fact span {
  color: var(--portal-muted);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.portal-movement-fact strong {
  font-size: 0.98rem;
}

.portal-movement-impact {
  display: grid;
  gap: 6px;
  min-width: min(280px, 100%);
  padding: 18px;
  border-radius: 24px;
  border: 1px solid transparent;
}

.portal-movement-impact span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}

.portal-movement-impact strong {
  font-size: clamp(1.3rem, 1vw + 1rem, 1.85rem);
  line-height: 0.95;
}

.portal-movement-impact small {
  color: inherit;
  opacity: 0.88;
  line-height: 1.4;
}

.portal-movement-impact.tone-debt {
  background: #fff1ef;
  color: #b64845;
  border-color: rgba(225, 98, 95, 0.18);
}

.portal-movement-impact.tone-credit {
  background: #edf9f4;
  color: #20885f;
  border-color: rgba(52, 166, 125, 0.18);
}

.portal-movement-impact.tone-warning {
  background: #fff6e7;
  color: #b67919;
  border-color: rgba(242, 168, 64, 0.18);
}

.portal-movement-impact.tone-neutral {
  background: #f4f9fc;
  color: var(--portal-muted);
  border-color: var(--portal-line-soft);
}

.portal-movement-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.portal-movement-notes {
  color: var(--portal-text);
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: var(--portal-radius-md);
  background: #fbfdfe;
  border: 1px solid var(--portal-line-soft);
}

.portal-order-detail {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: var(--portal-radius-lg);
  border: 1px solid var(--portal-line-soft);
  background: linear-gradient(180deg, #fbfdff 0%, #f4f9fc 100%);
}

.portal-order-detail.is-loading,
.portal-order-detail.is-error {
  color: var(--portal-muted);
}

.portal-order-detail.is-error {
  color: #b64845;
  background: #fff3f2;
  border-color: rgba(225, 98, 95, 0.18);
}

.portal-order-detail-items {
  display: grid;
  gap: 10px;
}

.portal-order-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--portal-radius-md);
  background: #fff;
  border: 1px solid var(--portal-line-soft);
}

.portal-order-item-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.portal-order-item-copy strong {
  font-size: 1rem;
}

.portal-order-item-copy small {
  color: var(--portal-muted);
  line-height: 1.4;
}

.portal-order-item-prices {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
}

.portal-order-item-prices span {
  color: var(--portal-muted);
  font-size: 0.9rem;
}

.portal-order-item-prices strong {
  font-size: 1rem;
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--portal-radius-pill);
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 800;
}

.portal-badge.debt {
  background: #fff2f1;
  color: #b64845;
}

.portal-badge.credit {
  background: #edf9f4;
  color: #20885f;
}

.portal-badge.warning {
  background: #fff6e7;
  color: #b67919;
}

.portal-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(2, minmax(160px, 0.7fr));
  gap: 12px;
}

.portal-field {
  display: grid;
  gap: 8px;
}

.portal-field label {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--portal-muted);
  font-weight: 800;
}

.portal-input,
.portal-select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--portal-line);
  border-radius: 18px;
  background: #fbfdfe;
  color: var(--portal-text);
  padding: 12px 16px;
  box-shadow: 0 10px 24px rgba(38, 82, 103, 0.05);
}

.portal-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2317313d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 7 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 48px;
}

.portal-empty {
  padding: 24px;
  border-radius: var(--portal-radius-lg);
  background: #fff;
  border: 1px dashed var(--portal-line);
  color: var(--portal-muted);
  text-align: center;
}

.portal-message {
  display: none;
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--portal-radius-pill);
  font-weight: 700;
}

.portal-message.is-success,
.portal-message.is-error {
  display: inline-flex;
}

.portal-message.is-success {
  background: #e8faf2;
  color: #238861;
}

.portal-message.is-error {
  background: #fff0ef;
  color: #b44745;
}

.portal-login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.portal-login-card {
  width: min(100%, 460px);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(215, 229, 236, 0.88);
  border-radius: 32px;
  padding: 28px;
  box-shadow: var(--portal-shadow);
}

.portal-login-card h1 {
  margin: 20px 0 0;
  font-size: clamp(2rem, 6vw, 2.8rem);
  letter-spacing: -0.05em;
}

.portal-login-card p {
  margin: 12px 0 0;
  color: var(--portal-muted);
  line-height: 1.6;
}

.portal-login-form {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

.portal-login-footer {
  margin-top: 18px;
  color: var(--portal-muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.portal-install-note {
  margin-top: 18px;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(51, 135, 169, 0.08), rgba(75, 197, 211, 0.1));
  color: var(--portal-brand-dark);
  border: 1px solid rgba(51, 135, 169, 0.16);
}

.portal-stack {
  display: grid;
  gap: 16px;
}

.portal-hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .portal-grid-main,
  .portal-metrics,
  .portal-filters {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1320px) {
  .portal-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .portal-topbar-inner,
  .portal-main {
    width: 100%;
    max-width: 100%;
    padding-left: 10px;
    padding-right: 10px;
  }

  .portal-topbar-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .portal-topbar-actions {
    width: auto;
    justify-content: flex-end;
    gap: 8px;
  }

  .portal-brand {
    min-width: 0;
    gap: 12px;
  }

  .portal-brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    font-size: 1rem;
  }

  .portal-brand-text strong {
    font-size: 0.94rem;
  }

  .portal-brand-text span {
    font-size: 0.84rem;
  }

  .portal-user-chip,
  .portal-topbar-actions .portal-btn,
  .portal-topbar-actions .portal-link-btn {
    min-height: 42px;
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .portal-user-chip {
    padding: 10px 12px;
  }

  .portal-main {
    padding-top: 18px;
    padding-bottom: 34px;
  }

  .portal-hero {
    gap: 8px;
    margin-bottom: 12px;
  }

  .portal-hero-card {
    background: transparent;
    color: var(--portal-text);
    box-shadow: none;
    border: 0;
    padding: 0;
  }

  .portal-hero-card h1 {
    font-size: clamp(2.25rem, 9vw, 3.2rem);
  }

  .portal-hero-card p {
    display: none;
  }

  .portal-panel,
  .portal-login-card {
    border-radius: 24px;
    padding: 18px;
  }

  .portal-client-rail {
    grid-auto-columns: minmax(240px, 82vw);
  }

  .portal-balance-top,
  .portal-section-head,
  .portal-movement-main {
    flex-direction: column;
    align-items: flex-start;
  }

  .portal-movement-impact {
    width: 100%;
    min-width: 0;
  }

  .portal-order-item {
    flex-direction: column;
  }

  .portal-order-item-prices {
    justify-items: start;
    text-align: left;
  }

  .portal-section-head > div {
    width: 100%;
  }

  .portal-btn,
  .portal-link-btn {
    width: 100%;
  }

  .portal-topbar-actions .portal-btn,
  .portal-topbar-actions .portal-link-btn {
    width: auto;
  }

  .portal-actions-row > * {
    flex: 1 1 100%;
  }
}
