.portal-body {
  min-height: 100vh;
  background: var(--bg);
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
}

.portal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 74px;
  padding: 12px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(216, 224, 235, 0.8);
  background: rgba(245, 247, 251, 0.92);
  backdrop-filter: blur(16px);
}

.portal-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(14px, 2vw, 28px);
  color: #304052;
  font-size: 1.06rem;
  font-weight: 700;
}

.portal-nav a:hover {
  color: var(--teal);
}

.portal-menu-dropdown {
  position: relative;
}

.portal-menu-dropdown summary {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid rgba(28, 114, 181, 0.28);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--teal);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 800;
  list-style: none;
}

.portal-menu-dropdown summary::-webkit-details-marker {
  display: none;
}

.portal-menu-dropdown summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.portal-menu-dropdown[open] summary::after {
  transform: translateY(2px) rotate(225deg);
}

.portal-menu-dropdown-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  display: grid;
  min-width: 190px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 18px 38px rgba(14, 28, 48, 0.14);
}

.portal-menu-dropdown-panel a {
  padding: 10px 12px;
  border-radius: 6px;
  color: #304052;
  font-size: 0.94rem;
  font-weight: 800;
}

.portal-menu-dropdown-panel a:hover {
  background: rgba(28, 114, 181, 0.08);
  color: var(--teal);
}

.portal-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 54px) 0;
  flex: 1 0 auto;
}

.portal-body .site-footer {
  width: 100%;
  margin-top: auto;
  font-size: 1rem;
}

.portal-card {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(23, 32, 29, 0.05);
}

.portal-card h1 {
  margin: 0 0 12px;
  font-size: clamp(1.55rem, 2.4vw, 2.1rem);
  line-height: 1.12;
}

.portal-card h2 {
  margin: 0 0 14px;
  font-size: clamp(1.2rem, 1.8vw, 1.55rem);
  line-height: 1.18;
}

.portal-card h3 {
  font-size: 1rem;
}

.portal-section-heading-compact {
  margin-bottom: 10px;
}

.portal-section-heading-compact h3 {
  margin: 0;
}

.portal-card-narrow {
  max-width: 560px;
}

.portal-muted {
  color: var(--muted);
}

.portal-help-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  background: rgba(28, 114, 181, 0.08);
  color: #304052;
  font-size: 0.9rem;
  line-height: 1.5;
}

.portal-security-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbff;
}

.portal-security-status span {
  color: var(--muted);
  font-weight: 700;
}

.portal-security-status strong {
  font-family: Consolas, Monaco, monospace;
}

.portal-security-status.is-warning {
  border-color: rgba(179, 88, 18, 0.35);
  background: #fff7ed;
}

.portal-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(260px, 0.85fr);
  gap: 18px;
  align-items: start;
}

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

.portal-grid-admin {
  grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.15fr);
}

.portal-grid-management {
  grid-template-columns: minmax(360px, 1fr) minmax(320px, 0.85fr);
}

.portal-grid-account {
  grid-template-columns: minmax(320px, 1fr) minmax(260px, 0.72fr);
}

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

.portal-user-form,
.portal-service-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 18px;
}

.portal-user-form button,
.portal-service-form button {
  min-height: 43px;
}

.portal-form label,
.portal-form span {
  display: block;
}

.portal-form span {
  margin-bottom: 6px;
  color: #334052;
  font-weight: 800;
  font-size: 0.86rem;
}

.portal-admin-form {
  margin-top: 22px;
}

.portal-code-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.portal-flash {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #ffffff;
  font-weight: 700;
}

.portal-flash-success {
  border-color: rgba(47, 143, 78, 0.35);
  color: #176234;
  background: #edf8f0;
}

.portal-flash-error {
  border-color: rgba(176, 52, 52, 0.35);
  color: #8f2626;
  background: #fff0f0;
}

.portal-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.portal-section-heading h1,
.portal-section-heading h2 {
  margin: 0;
}

.portal-dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.portal-dashboard article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.portal-dashboard span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.portal-dashboard strong {
  display: block;
  margin-top: 6px;
  color: var(--blue-strong);
  font-size: 1.8rem;
  line-height: 1;
}

.portal-section-heading span,
.portal-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.portal-alert-list,
.portal-note-list {
  display: grid;
  gap: 10px;
}

.portal-alert-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
}

.portal-alert-row span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.portal-ticket-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
}

.portal-ticket-row-action {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.portal-chat-log {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.portal-chat-log-item {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.portal-chat-log-item strong {
  color: var(--muted);
  font-size: 0.78rem;
}

.portal-chat-log-item p {
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.portal-chat-log-user {
  border-color: rgba(45, 110, 200, 0.32);
  background: #f4f8ff;
}

.portal-chat-log-assistant {
  background: #fbfcff;
}

.portal-chat-log-system {
  border-color: rgba(47, 143, 78, 0.3);
  background: #edf8f0;
}

.portal-ticket-row-action .button,
.portal-ticket-row-action .portal-dark-ghost {
  margin-top: 0;
}

.portal-ticket-row .portal-status-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef6ff;
  color: var(--blue-strong);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.portal-sla-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7fb;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.portal-sla-warning {
  border-color: rgba(173, 118, 36, 0.35);
  background: #fff8e8;
  color: #8a5a12;
}

.portal-sla-overdue {
  border-color: rgba(176, 52, 52, 0.35);
  background: #fff0f0;
  color: #8f2626;
}

.portal-ticket-row strong {
  font-size: 0.94rem;
}

.portal-ticket-row:hover,
.portal-ticket-row.is-active {
  border-color: var(--teal);
  background: var(--panel-strong);
}

.portal-ticket-row span {
  color: var(--muted);
  font-size: 0.84rem;
}

.portal-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.portal-pagination a {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--teal);
  background: #ffffff;
}

.portal-ticket-filter-form {
  grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(150px, 1fr)) auto auto;
  align-items: end;
  margin-bottom: 18px;
}

.portal-timeline {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.portal-timeline ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.portal-timeline li span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.portal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0 0;
}

.portal-account-note {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.portal-account-note p {
  margin: 6px 0 0;
}

.portal-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.portal-messages {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.portal-message {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
}

.portal-message header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.portal-message p {
  margin: 0;
}

.portal-message-internal {
  border-color: rgba(212, 154, 42, 0.45);
  background: #fff8e8;
}

.portal-note-label {
  display: inline-flex;
  margin: 0 0 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(212, 154, 42, 0.18);
  color: #81570d;
  font-size: 0.78rem;
  font-weight: 800;
}

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

.portal-compact-list {
  gap: 8px;
}

.portal-user-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
}

.portal-user-row strong,
.portal-user-row span {
  display: block;
}

.portal-user-row span {
  color: var(--muted);
  font-size: 0.84rem;
}

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

.portal-row-actions .button,
.portal-row-actions .portal-dark-ghost {
  margin-top: 0;
}

.portal-management-details {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
}

.portal-management-details summary {
  cursor: pointer;
  color: var(--teal);
  font-weight: 800;
}

.portal-management-details .portal-form {
  margin-top: 14px;
}

.portal-password-reset {
  margin-top: 18px;
  margin-bottom: 0;
}

.portal-form-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.portal-filter-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(130px, 1fr)) auto auto;
  gap: 10px;
  align-items: end;
  margin-top: 16px;
}

.portal-filter-form label {
  display: grid;
  gap: 5px;
}

.portal-filter-form span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.portal-filter-form .button,
.portal-filter-form .portal-dark-ghost {
  margin-top: 0;
}

.portal-client-services {
  display: grid;
  gap: 14px;
}

.portal-client-services article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
}

.portal-client-services h2 {
  margin-bottom: 4px;
}

.portal-service-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.portal-service-row {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.portal-service-row-action {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.portal-service-row .portal-status-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef6ff;
  color: var(--blue-strong);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.portal-service-row span,
.portal-service-row p {
  margin: 0;
  color: var(--muted);
}

.portal-service-row code {
  overflow-wrap: anywhere;
  color: var(--blue-strong);
  font-size: 0.82rem;
}

.portal-service-public-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.portal-service-public-row .button,
.portal-service-public-row .portal-dark-ghost {
  margin-top: 0;
}

.portal-service-notes {
  margin-top: 4px;
}

.portal-service-notes summary {
  cursor: pointer;
  color: var(--teal);
  font-size: 0.84rem;
  font-weight: 800;
}

.portal-attachments {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.portal-attachments li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  font-size: 0.86rem;
}

.portal-attachments a {
  color: var(--teal);
  font-weight: 800;
}

.portal-attachments span {
  color: var(--muted);
}

.portal-inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.portal-inline-form button {
  white-space: nowrap;
}

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

.portal-inline-actions form {
  margin: 0;
}

.portal-inline-actions .button,
.portal-inline-actions .portal-dark-ghost {
  margin-top: 0;
}

.portal-divider {
  width: 100%;
  margin: 22px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.portal-compact-form {
  margin-top: 14px;
}

.portal-compact-form input,
.portal-compact-form select,
.portal-compact-form textarea {
  min-width: 0;
}

.portal-back {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--teal);
  font-weight: 800;
}

.portal-dark-ghost {
  margin-top: 12px;
  color: var(--teal);
  border-color: var(--teal);
  background: transparent;
}

@media (max-width: 760px) {
  .portal-header,
  .portal-grid,
  .portal-grid-admin,
  .portal-grid-management,
  .portal-grid-account,
  .portal-user-form,
  .portal-service-form,
  .portal-filter-form,
  .portal-ticket-filter-form,
  .portal-form-split,
  .portal-user-row,
  .portal-service-row-action,
  .portal-service-public-row,
  .portal-ticket-row-action,
  .portal-alert-row,
  .portal-row-actions,
  .portal-section-heading,
  .portal-message header {
    display: grid;
    grid-template-columns: 1fr;
  }

  .portal-menu-dropdown-panel {
    position: static;
    margin-top: 8px;
    box-shadow: none;
  }

  .portal-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-dashboard strong {
    font-size: 1.45rem;
  }
}

@media (max-width: 460px) {
  .portal-dashboard {
    grid-template-columns: 1fr;
  }
}
