/* Portal-specific additions. The approved Sales design system owns the shell,
   typography, dashboard cards, panels, tables, buttons, and responsive rules. */

html, body { direction: ltr !important; }

.sidebar-nav {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

.language-switch {
  height: 42px !important;
  min-height: 42px !important;
  padding: 0 13px !important;
  white-space: nowrap;
}

.portal-user-form { display: grid; gap: 18px; }
.user-form-field { display: grid; gap: 7px; }
.user-form-field > label { color: var(--ak-text, #17233d); font-weight: 650; }
.user-form-field input:not([type="checkbox"]),
.user-form-field select { width: 100%; }
.user-form-field .help-text { display: block; margin: 0; }
.user-form-field.checkbox-field { grid-template-columns: max-content 1fr; align-items: center; }
.user-form-field.checkbox-field .help-text,
.user-form-field.checkbox-field .field-error { grid-column: 1 / -1; }

.portal-heading-actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.portal-heading-actions > div:first-child { min-width: 0; }
.portal-page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.portal-filter-fields { grid-template-columns: 135px 135px minmax(155px, 1fr) minmax(135px, 1fr) 72px 62px !important; }
.portal-period-option { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.appscript-kpi strong.portal-kpi-value-compact { font-size: 18px !important; white-space: nowrap; }
.portal-section { margin: 0 0 17px; }
.portal-section-head { align-items: flex-start; margin-bottom: 13px !important; }
.portal-module-grid { margin: 0 !important; gap: 14px !important; }

.portal-system-card {
  display: flex !important;
  flex-direction: column !important;
  min-height: 154px !important;
  padding: 15px 16px 13px !important;
}

.portal-module-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.portal-module-icon {
  width: 35px;
  height: 35px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 18px;
  color: #23538a;
  background: #eaf1fa;
}
.portal-module-icon.purple { color: #7154a2; background: #eee9f6; }
.portal-module-icon.teal, .portal-module-icon.cyan { color: #087e8d; background: #e5f4f5; }
.portal-module-icon.orange { color: #b76e18; background: #fff1df; }
.portal-module-icon.green { color: #287647; background: #e9f5ec; }
.portal-module-icon.navy { color: #fff; background: var(--ui-sidebar, #10295d); }
.portal-system-card h3 { margin: 12px 0 5px; font-size: 14px; color: #17213a; }
.portal-system-card p { margin: 0 0 11px; min-height: 31px; color: #788499; font-size: 10.5px; line-height: 1.5; }
.portal-module-link { margin-top: auto; color: var(--ui-navy, #0b2a67); font-size: 11.5px; font-weight: 700; }
.portal-module-muted { color: #929db0; }

.status-pill { display: inline-flex !important; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 99px; font-size: 10px !important; font-weight: 700; white-space: nowrap; }
.status-pill.healthy, .status-pill.active, .status-pill.connected, .status-pill.completed, .status-pill.completed_local { color: #24734c; background: #e9f5ed; }
.status-pill.warning, .status-pill.in_progress, .status-pill.failed_external, .status-pill.overdue { color: #9b650c; background: #fff4de; }
.status-pill.danger, .status-pill.error, .status-pill.failed, .status-pill.inactive, .status-pill.cancelled { color: #a83733; background: #faebea; }
.status-pill.info, .status-pill.not_connected, .status-pill.new, .status-pill.disabled { color: #566781; background: #edf1f6; }

.portal-two-column { margin-top: 16px; }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.overview-item { padding: 11px; border: 1px solid #e9edf3; border-radius: 8px; background: #fafbfc; }
.overview-item strong { display: block; color: #283850; font-size: 11px; }
.overview-item span { display: block; margin-top: 6px; color: #8490a2; font-size: 10px; }
.activity-item, .mini-notification { padding: 10px 0; border-bottom: 1px solid #edf0f5; }
.activity-item:last-child, .mini-notification:last-child { border-bottom: 0; }
.activity-item strong, .mini-notification strong { display: block; color: #29384e; font-size: 11px; }
.activity-item span, .mini-notification span { display: block; margin-top: 4px; color: #78859a; font-size: 10px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 11px; margin-bottom: 15px; }
.toolbar-search { min-width: 250px; max-width: 380px; width: 100%; }
.portal-table-wrap { overflow-x: auto; }
.portal-table { width: 100%; border-collapse: collapse; }
.portal-table th { background: #f8fafc; color: #637188; text-align: left; white-space: nowrap; font-size: 11px; font-weight: 700; padding: 12px; }
.portal-table td { color: #27364c; font-size: 12px; padding: 12px; border-top: 1px solid #edf0f4; vertical-align: middle; }
.portal-table td small { display: block; margin-top: 4px; color: #7d899b; }
.table-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.inline-form { display: inline-flex; margin: 0; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 11px; }
.btn.subtle { background: #f4f7fb; color: #415573; border: 1px solid #e4eaf2; }
.btn.danger-soft { background: #fbeeed; color: #a43331; border: 1px solid #f2d7d5; }

.portal-form-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(275px, .58fr); align-items: start; gap: 17px; }
.portal-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.portal-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.portal-field.full { grid-column: 1 / -1; }
.portal-field label { color: #4e5e75; font-size: 11px; font-weight: 700; }
.portal-field input, .portal-field select, .portal-field textarea, .toolbar-search {
  min-height: 39px;
  width: 100%;
  border: 1px solid #dfe6ee;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: #24354a;
  font: inherit;
  font-size: 12px;
}
.portal-field textarea { min-height: 92px; resize: vertical; }
.portal-field input[type=color] { width: 58px; padding: 3px; }
.portal-field input[type=checkbox] { width: 18px; min-height: 18px; }
.portal-field small, .help-text { color: #7c899c; font-size: 10px; line-height: 1.5; }
.portal-action-box { position: sticky; top: 90px; }
.portal-action-box .btn { width: 100%; margin-top: 8px; }
.settings-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.settings-tab { padding: 9px 12px; border: 1px solid #dfe5ee; border-radius: 8px; color: #55657b; background: #fff; font-size: 11px; }
.settings-tab.active { color: #fff; background: var(--ui-navy, #0b2a67); border-color: var(--ui-navy, #0b2a67); }

.integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.integration-card { display: flex; flex-direction: column; min-height: 180px; gap: 11px; }
.integration-card-head { display: flex; justify-content: space-between; align-items: center; }
.integration-card h3 { margin: 0; color: #223148; font-size: 15px; }
.integration-card p { margin: 0; color: #788499; font-size: 12px; line-height: 1.6; }
.integration-card .btn { align-self: flex-start; margin-top: auto; }
.permission-checkbox { width: 17px; height: 17px; accent-color: var(--ui-navy, #0b2a67); }
.role-card-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.role-card { min-height: 138px; }
.role-card h3 { margin: 0 0 6px; color: #223148; font-size: 14px; }
.role-card p { min-height: 35px; margin: 0 0 12px; color: #758298; font-size: 11px; line-height: 1.5; }
.role-card-footer { display: flex; align-items: center; justify-content: space-between; }
.role-card-footer span { color: #728097; font-size: 10px; }
.role-card-footer form { margin: 0; }
.role-type { display: inline-flex; margin-bottom: 9px; padding: 4px 8px; border-radius: 999px; background: #edf3fb; color: #31598a; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.btn.small { min-height: 31px; padding: 6px 10px; font-size: 10px; }
.permission-action-cell { background: #f5f8fd; }
.permission-action-cell .permission-checkbox { outline: 3px solid rgba(22,73,137,.08); outline-offset: 2px; }
.workflow-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.workflow-card { display: flex; flex-direction: column; gap: 10px; min-height: 165px; transition: transform .18s ease, box-shadow .18s ease; }
.workflow-card:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(23,54,93,.09); }
.workflow-card h3 { margin: 0; color: #223148; font-size: 15px; }
.workflow-card p { margin: 0; color: #748196; font-size: 11px; line-height: 1.55; }
.workflow-card .btn { align-self: flex-start; margin-top: auto; }
.workflow-module-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.workflow-module-card { display: flex; flex-direction: column; gap: 10px; transition: transform .18s ease, box-shadow .18s ease; }
.workflow-module-card:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(23,54,93,.09); }
.workflow-module-card .role-card-footer { margin-top: auto; }
.workflow-note { margin-bottom: 14px; padding: 12px 14px; border: 1px solid #dbe7f5; border-radius: 10px; background: #f4f8fd; color: #4b607b; font-size: 11px; }
.workflow-note strong,.workflow-note span { display: block; }
.workflow-note span { margin-top: 4px; color: #738198; }
.workflow-table { table-layout: fixed; min-width: 0; }
.workflow-table th,.workflow-table td { padding-left: 8px; padding-right: 8px; }
.role-dropdown { position: relative; width: 100%; min-width: 0; }
.role-dropdown summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; padding: 8px 10px; border: 1px solid #cbd7e5; border-radius: 9px; background: #fff; color: #69778c; font-size: 11px; cursor: pointer; list-style: none; user-select: none; }
.role-dropdown summary::-webkit-details-marker { display: none; }
.role-dropdown.has-selection summary { border-color: #9fb5d2; background: #f8fbff; color: #17365d; font-weight: 750; }
.role-dropdown[open] summary { border-color: #2d609c; box-shadow: 0 0 0 3px rgba(45,96,156,.10); }
.role-dropdown-arrow { color: #60738c; font-size: 15px; transition: transform .16s ease; }
.role-dropdown[open] .role-dropdown-arrow { transform: rotate(180deg); }
.role-dropdown-menu { position: absolute; z-index: 20; top: calc(100% + 5px); left: 0; width: max(100%, 215px); max-height: 230px; overflow-y: auto; padding: 6px; border: 1px solid #d5deea; border-radius: 10px; background: #fff; box-shadow: 0 12px 28px rgba(23,54,93,.16); }
.role-dropdown-menu label { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 7px; color: #34445c; font-size: 11px; cursor: pointer; white-space: nowrap; }
.role-dropdown-menu label:hover { background: #f0f5fb; }
.role-dropdown-menu input { width: 15px; height: 15px; accent-color: #0b2a67; }
.role-dropdown-empty { display: block; padding: 8px; color: #8a96a8; font-size: 11px; }
.workflow-table th:first-child,.workflow-table td:first-child { position: sticky; left: 0; z-index: 1; width: 24%; min-width: 0; background: #fff; }
.workflow-table th:not(:first-child),.workflow-table td:not(:first-child) { width: 15.2%; }
.workflow-table th:first-child { background: #f8fafc; }
.workflow-table td strong { display: block; color: #223148; }
.workflow-table td small { display: block; margin-top: 4px; color: #7c899c; }

.login-shell { width: min(438px, calc(100vw - 32px)); margin: 80px auto 0; padding: 32px !important; }
.login-shell h1 { margin: 0 0 8px; color: #17213a; font-size: 25px; }
.login-shell > p { margin: 0 0 22px; color: #748196; font-size: 12px; line-height: 1.6; }
.login-shell .portal-field { margin-bottom: 14px; }
.login-shell .btn { width: 100%; min-height: 42px; margin-top: 8px; }
.public-topbar { justify-content: space-between; }
.notice { margin: 0 0 15px; padding: 11px 13px; border-radius: 9px; font-size: 12px; }
.notice.success { color: #256f4b; background: #ebf6ee; }
.notice.error { color: #a53a34; background: #faedec; }
.notice.warning { color: #936114; background: #fff3de; }
.empty-state { padding: 28px 16px; text-align: center; color: #7b889a; font-size: 12px; }
.check-label { display: flex; flex-direction: row !important; align-items: center; gap: 9px; }
.mono { font-family: Consolas, Monaco, monospace; font-size: 10px; }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 17px; }
.portal-two-column.portal-single-column { grid-template-columns: minmax(0, 1fr); }
.notification-row { display: flex; justify-content: space-between; gap: 15px; padding: 15px; border-top: 1px solid #ebeff4; color: inherit; text-decoration: none; transition: background-color .15s ease; }
.notification-row:hover { background: #f7f9fc; }
.notification-row:first-child { border-top: 0; }
.notification-row.unread { background: #f1f6fc; }
.notification-row strong { color: #24344b; font-size: 12px; }
.notification-row p { margin: 6px 0 0; color: #748196; font-size: 11px; }
.notification-row small { color: #8390a1; font-size: 10px; white-space: nowrap; }
.logout-button { border: 0; color: #bfd0e5; background: transparent; font-size: 17px; cursor: pointer; }

@media (max-width: 1100px) {
  .portal-filter-fields { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

@media (max-width: 980px) {
  .role-card-list, .integration-grid, .workflow-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-form-layout { grid-template-columns: 1fr; }
  .portal-action-box { position: static; }
}

@media (max-width: 700px) {
  .role-card-list, .integration-grid, .workflow-grid, .portal-form-grid, .overview-grid, .stat-strip, .portal-filter-fields { grid-template-columns: 1fr !important; }
  .portal-heading-actions { flex-direction: column; align-items: flex-start; }
}
.sidebar-section-label {
  padding: 18px 22px 8px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-back-link {
  margin-bottom: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-count {
  display: inline-flex;
  min-width: 1.45rem;
  height: 1.45rem;
  margin-inline-start: 0.35rem;
  padding: 0 0.4rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
  color: #173874;
  font-size: 0.72rem;
  font-weight: 800;
}
