/* Base tokens come from design-tokens.css (linked before this stylesheet).
   The Portal shell intentionally keeps its slightly cooler surfaces. */
:root {
  --surface-soft: #f5f7fb;
  --border: #dce3ef;
  --amber: #a86613;
  --amber-soft: #fff6e7;
  --shadow: 0 16px 42px rgba(26, 39, 68, 0.09);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--surface-soft);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 4%, rgba(74, 127, 208, 0.12), transparent 30rem),
    linear-gradient(180deg, #f8faff 0, var(--surface-soft) 48%, #eef2f8 100%);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
select,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--navy);
  transform: translateY(-160%);
  transition: transform 0.15s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.portal-state {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.state-card {
  width: min(100%, 470px);
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  text-align: center;
}

.state-card--loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: left;
}

.state-card h1 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: clamp(1.45rem, 4vw, 2rem);
  letter-spacing: -0.04em;
}

.state-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.state-card--loading p {
  margin: 0;
}

.state-icon,
.brand-mark {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--navy), #2d416d);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(26, 39, 68, 0.2);
}

.state-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 20px;
  border-radius: 15px;
  font-size: 1.15rem;
}

.state-icon--error {
  background: var(--red);
}

.state-account {
  margin-top: -12px !important;
  color: var(--ink) !important;
  font-weight: 600;
}

.state-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.loading-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 3px solid #dbe4f4;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.portal-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid rgba(220, 227, 239, 0.9);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  font-size: 0.95rem;
}

.brand-name,
.brand-subtitle {
  display: block;
}

.brand-name {
  color: var(--navy);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.15;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.account-copy {
  display: flex;
  align-items: center;
  gap: 9px;
}

.account-email {
  max-width: 300px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.77rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge,
.module-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1;
  text-transform: uppercase;
}

.role-badge {
  padding: 6px 8px;
  color: var(--blue);
  background: #edf3fc;
}

.portal-main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(36px, 7vw, 82px) 0 48px;
}

.welcome-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
  padding: clamp(28px, 5vw, 48px);
  overflow: hidden;
  border-radius: var(--radius-lg);
  color: #fff;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.05), transparent 38%),
    linear-gradient(135deg, var(--navy-deep), var(--navy) 58%, #294574);
  box-shadow: 0 24px 58px rgba(17, 28, 51, 0.16);
}

.welcome-copy h1 {
  margin: 5px 0 10px;
  font-size: clamp(2rem, 5vw, 3.55rem);
  line-height: 1.06;
  letter-spacing: -0.055em;
}

.welcome-copy h1 span {
  color: #bcd4fa;
  font-weight: 500;
}

.welcome-copy > p:last-child {
  margin: 0;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.95rem;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.welcome-panel .eyebrow {
  color: rgba(255, 255, 255, 0.52);
}

.company-control {
  width: min(100%, 330px);
  flex: 0 0 auto;
}

.company-control label {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.company-control select {
  width: 100%;
  min-height: 46px;
  appearance: none;
  padding: 0 42px 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  outline: none;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.82rem;
  font-weight: 600;
}

.company-control select:focus {
  border-color: #9ec2f8;
  box-shadow: 0 0 0 3px rgba(158, 194, 248, 0.2);
}

.company-control select:disabled {
  opacity: 0.78;
}

.company-control option {
  color: var(--ink);
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 17px;
  width: 7px;
  height: 7px;
  border-right: 2px solid rgba(255, 255, 255, 0.7);
  border-bottom: 2px solid rgba(255, 255, 255, 0.7);
  pointer-events: none;
  transform: translateY(-65%) rotate(45deg);
}

.company-control > span {
  display: block;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.44);
  font-size: 0.67rem;
  line-height: 1.5;
}

.applications-section {
  padding-top: clamp(38px, 6vw, 64px);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.section-heading h2 {
  margin: 5px 0 0;
  color: var(--navy);
  font-size: clamp(1.65rem, 4vw, 2.25rem);
  letter-spacing: -0.045em;
}

.section-heading > p {
  max-width: 360px;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
  text-align: right;
}

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

.module-card {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  padding: clamp(24px, 4vw, 34px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 8px 24px rgba(26, 39, 68, 0.055);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.module-card--available:hover {
  border-color: #b9cbe6;
  box-shadow: 0 16px 34px rgba(26, 39, 68, 0.1);
  transform: translateY(-2px);
}

.module-card--preview {
  background:
    linear-gradient(145deg, rgba(255, 246, 231, 0.8), transparent 55%),
    rgba(255, 255, 255, 0.94);
}

.module-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.module-icon {
  width: 49px;
  height: 49px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, var(--navy), #355685);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 9px 20px rgba(26, 39, 68, 0.17);
}

.module-card--preview .module-icon {
  color: #7c4d0c;
  background: var(--amber-soft);
  box-shadow: none;
}

.module-status {
  padding: 7px 9px;
  color: var(--green);
  background: var(--green-soft);
}

.module-status--preview {
  color: var(--amber);
  background: var(--amber-soft);
}

.module-card h3 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 1.2rem;
  letter-spacing: -0.025em;
}

/* Product name shown after the functional name, e.g. "Invoicing — Purser". */
.module-product {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.module-description {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.7;
}

.module-action {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  color: var(--blue);
  font-size: 0.79rem;
  font-weight: 700;
  text-decoration: none;
}

.module-action::after {
  content: "\2192";
  transition: transform 0.16s ease;
}

.module-action:hover::after {
  transform: translateX(3px);
}

.module-action--disabled {
  color: var(--muted-light);
  cursor: default;
}

.module-action--disabled::after {
  content: none;
}

.security-note {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 22px;
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.64);
}

.security-note-mark {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--blue-light);
  box-shadow: 0 0 0 4px rgba(74, 127, 208, 0.1);
}

.security-note p {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.6;
}

.security-note strong {
  color: var(--ink);
}

.portal-footer {
  width: min(1180px, calc(100% - 40px));
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: auto auto 0;
  padding: 22px 0 26px;
  border-top: 1px solid var(--border);
  color: var(--muted-light);
  font-size: 0.68rem;
  font-weight: 600;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.button:focus-visible,
.module-action:focus-visible,
.brand:focus-visible {
  outline: 3px solid rgba(74, 127, 208, 0.3);
  outline-offset: 3px;
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.button--primary {
  color: #fff;
  background: var(--navy);
}

.button--primary:hover {
  background: #27395f;
}

.button--secondary {
  color: var(--navy);
  border-color: var(--border);
  background: #fff;
}

.button--secondary:hover {
  border-color: #becbe0;
  background: var(--surface-soft);
}

.button--quiet {
  min-height: 36px;
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
}

.button--quiet:hover {
  color: var(--navy);
  background: var(--surface-soft);
}

@media (max-width: 760px) {
  .portal-header {
    align-items: flex-start;
    padding: 14px 18px;
  }

  .account-copy {
    display: none;
  }

  .portal-main,
  .portal-footer {
    width: min(100% - 28px, 1180px);
  }

  .portal-main {
    padding-top: 22px;
  }

  .welcome-panel {
    align-items: stretch;
    flex-direction: column;
    gap: 28px;
  }

  .company-control {
    width: 100%;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .section-heading > p {
    max-width: none;
    text-align: left;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .module-card {
    min-height: 250px;
  }
}

@media (max-width: 430px) {
  .state-card {
    padding: 28px 22px;
  }

  .portal-header {
    align-items: center;
  }

  .button--quiet {
    padding: 0 11px;
  }

  .portal-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
