/* Customer dashboard, authentication and KYC review screens. Uses Tide Ledger tokens from design-tokens.css. */

.portal-header .header-inner {
  justify-content: space-between;
  height: calc(100% - 12px);
  top: 6px;
  padding-inline: clamp(.75rem, 2vw, 1.5rem);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 22px;
  background: rgba(251, 254, 254, .78);
  box-shadow: 0 12px 32px rgba(8, 47, 57, .1), inset 0 1px rgba(255, 255, 255, .7);
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
}
.portal-header { top: 0; height: var(--header-h); }
.portal-header--guest .portal-nav { order: 2; }
.portal-header.is-scrolled .header-inner { background: rgba(255, 255, 255, .94); box-shadow: 0 16px 40px rgba(8, 47, 57, .16); }

.portal-nav {
  display: flex;
  align-items: center;
  gap: .2rem;
  padding: .3rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.portal-nav a,
.portal-link-button {
  color: var(--color-ink-soft);
  font: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  background: none;
  border: 0;
  padding: .5rem .8rem;
  cursor: pointer;
  border-radius: 999px;
}

.portal-nav a:hover,
.portal-link-button:hover {
  color: var(--color-brand);
  background: rgba(13, 115, 119, .1);
}
.portal-nav a:focus-visible,
.portal-link-button:focus-visible,
.nav-toggle:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 3px; }

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

.portal-main {
  padding: 2.5rem 0 4rem;
  min-height: calc(100vh - var(--header-h));
}

.portal-page-head {
  margin-bottom: 1.75rem;
}

.portal-page-head h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.portal-page-head p {
  margin: 0;
  color: var(--color-muted);
}

.portal-card {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-soft);
}

.portal-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  line-height: 1.5;
}

.portal-card p {
  margin: 0 0 0.75rem;
  color: var(--color-muted);
}

.portal-card p:last-child {
  margin-bottom: 0;
}

.auth-motion-card {
  position: relative;
  overflow: hidden;
  animation: authCardIn .55s var(--ease) both;
}

.auth-motion-card::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(11, 143, 148, .22), transparent 70%);
  inset-inline-end: -50px;
  top: -60px;
  pointer-events: none;
}

@keyframes authCardIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.portal-auth {
  width: min(460px, 100%);
  margin: 2rem auto 0;
}
.portal-auth--wide { width: min(860px, 100%); }
.auth-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.auth-options .portal-card { min-width: 0; }
.auth-switch { margin: 1.15rem 0 0; text-align: center; color: var(--color-muted); }
.auth-phone-input { display: flex; align-items: stretch; overflow: hidden; border: 1px solid var(--color-line); border-radius: var(--radius-sm); background: var(--color-surface-elevated); }
.auth-phone-prefix { display: flex; align-items: center; padding: 0 .9rem; background: rgba(13, 115, 119, .1); color: var(--color-brand); font-weight: 700; }
.portal-field .auth-phone-input input[type="tel"] { min-width: 0; flex: 1; border: 0; border-radius: 0; box-shadow: none; }
.auth-phone-input:focus-within { outline: 2px solid rgba(13, 115, 119, .28); border-color: var(--color-brand); }
@media (max-width: 640px) { .auth-options { grid-template-columns: 1fr; } }

/* Authentication screens: clear hierarchy, compact cards and field-level feedback. */
.auth-shell { margin-top: clamp(1rem, 4vw, 3rem); }
.auth-intro { text-align: center; margin-bottom: 1.5rem; }
.auth-intro h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 800; }
.auth-intro p { max-width: 44rem; margin-inline: auto; line-height: 1.9; }
.auth-eyebrow { display: inline-block; margin-bottom: .75rem; color: var(--color-brand); font-size: .82rem; font-weight: 800; letter-spacing: .02em; }
.auth-card { padding: clamp(1.4rem, 3vw, 2.2rem); border-radius: 24px; box-shadow: 0 22px 60px rgba(7, 42, 51, .09); }
.auth-card--primary { border-color: rgba(13, 115, 119, .35); }
.auth-options { align-items: stretch; }
.auth-options .auth-card { display: flex; flex-direction: column; }
.auth-options .auth-card .portal-form { flex: 1; align-content: start; }
.auth-options .auth-card .portal-btn { align-self: end; }
.auth-shell .portal-field { gap: .55rem; }
.auth-shell .portal-field input { min-height: 52px; border-radius: 13px; background: var(--color-surface-elevated); }
.auth-shell .portal-field input[aria-invalid="true"] { border-color: #ca4d52; box-shadow: 0 0 0 3px rgba(202, 77, 82, .12); }
.auth-field-error { color: #b93640; font-size: .82rem; font-weight: 600; line-height: 1.6; }
.auth-field-error:empty { display: none; }
.auth-resend { margin-top: .75rem; }
.auth-shell .auth-switch { line-height: 2; }
@media (max-width: 640px) {
  .auth-shell { margin-top: .5rem; }
  .auth-card { border-radius: 18px; }
  .auth-options { gap: .8rem; }
}

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

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

.portal-form {
  display: grid;
  gap: 1rem;
}

.portal-field {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
}

.portal-field input[type="text"],
.portal-field input[type="password"],
.portal-field input[type="email"],
.portal-field input[type="tel"],
.portal-field input[type="number"],
.portal-field input[type="file"],
.portal-field textarea,
.portal-field select {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-weight: 400;
  background: #fff;
  color: var(--color-ink);
  box-sizing: border-box;
}

.portal-field textarea {
  min-height: 110px;
  resize: vertical;
}

.portal-field input:focus,
.portal-field textarea:focus,
.portal-field select:focus {
  outline: 2px solid rgba(13, 115, 119, 0.28);
  border-color: var(--color-brand);
}

.portal-field input[dir="ltr"] {
  text-align: left;
}

.portal-code-input {
  letter-spacing: 0.4em;
  text-align: center !important;
  font-size: 1.35rem;
}

.portal-hint {
  color: var(--color-muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.25rem;
  border-radius: 14px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 7px 18px rgba(7, 42, 51, .08);
  transition: transform 180ms var(--ease), background 180ms var(--ease), border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}

.portal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(7, 42, 51, .15);
}
.portal-btn:active { transform: translateY(0); }
.portal-btn:focus-visible { outline: 3px solid rgba(11, 143, 148, .55); outline-offset: 3px; }
.portal-btn:disabled, .portal-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.portal-btn--primary {
  background: linear-gradient(135deg, var(--color-brand-strong), #0aa3a8);
  color: #fff;
  box-shadow: 0 9px 22px rgba(5, 74, 83, .18);
}

.portal-btn--primary:hover {
  background: var(--color-brand-strong);
}

.portal-btn--secondary {
  background: #fff;
  color: var(--color-ink);
  border-color: var(--color-line);
}

.portal-btn--secondary:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.portal-btn--danger {
  background: var(--color-danger);
  color: #fff;
}

.portal-btn--block {
  width: 100%;
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.portal-alert {
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}

.portal-alert--success {
  background: #e8f7ef;
  border-color: #bfe5d0;
  color: var(--color-success);
}

.portal-alert--danger {
  background: #fdecec;
  border-color: #f3c4c0;
  color: var(--color-danger);
}

.portal-alert--info {
  background: var(--color-brand-soft);
  border-color: #b4dfe1;
  color: var(--color-brand-strong);
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.portal-badge--ok {
  background: #e8f7ef;
  color: var(--color-success);
}

.portal-badge--info {
  background: var(--color-brand-soft);
  color: var(--color-brand-strong);
}

.portal-badge--warn {
  background: #fff4df;
  color: #8a6a1f;
}

.portal-badge--danger {
  background: #fdecec;
  color: var(--color-danger);
}

.portal-badge--muted {
  background: #eaeef3;
  color: var(--color-muted);
}

.portal-meta {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

.portal-meta div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px dashed var(--color-line);
}

.portal-meta div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

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

.portal-meta dd {
  margin: 0;
  min-width: 0;
  font-weight: 600;
  text-align: end;
  overflow-wrap: anywhere;
}

.portal-table-wrap {
  overflow-x: auto;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.portal-table th,
.portal-table td {
  padding: 0.85rem 1rem;
  text-align: start;
  border-bottom: 1px solid var(--color-line);
}

.portal-table th {
  background: #eef2f6;
  color: var(--color-ink-soft);
  font-size: 0.9rem;
}

.portal-table tr:last-child td {
  border-bottom: 0;
}

.portal-table a {
  color: var(--color-brand);
  font-weight: 600;
}

.portal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.portal-filters a {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--color-line);
  background: #fff;
  font-size: 0.9rem;
}

.portal-filters a.is-active {
  background: var(--color-ink);
  border-color: var(--color-ink);
  color: #fff;
}

.portal-pager {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  color: var(--color-muted);
}

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

.portal-doc {
  margin: 0;
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.portal-doc img {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  background: #eef2f6;
}

.portal-doc figcaption {
  padding: 0.65rem 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.portal-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.portal-timeline li {
  padding: 0.85rem 1rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.portal-timeline strong {
  display: block;
}

.portal-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--color-muted);
}

.portal-stack {
  display: grid;
  gap: 1rem;
}

/* Admin panel helpers */

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

.admin-stat {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-ink) !important;
  font-variant-numeric: tabular-nums;
}

.portal-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  max-width: 520px;
}

.portal-search input[type="search"] {
  flex: 1;
  min-height: 48px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font: inherit;
  background: #fff;
  color: var(--color-ink);
}

.portal-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.portal-row-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.portal-row-form select {
  min-height: 36px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  font: inherit;
  background: #fff;
}

.portal-btn--sm {
  min-height: 36px;
  padding: 0.3rem 0.85rem;
  font-size: 0.9rem;
}

@media (max-width: 1000px) {
  .portal-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .portal-header .header-inner { direction: ltr; }
  .portal-header .brand { direction: rtl; }
  .portal-header .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
  }
  .portal-nav {
    display: none;
    position: absolute;
    top: calc(100% + .55rem);
    inset-inline: 0;
    direction: rtl;
    flex-direction: column;
    align-items: stretch;
    gap: .15rem;
    max-height: calc(100dvh - var(--header-h) - 1rem);
    overflow-y: auto;
    padding: .65rem;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 18px 48px rgba(7, 42, 51, .16);
  }
  .portal-nav.is-open { display: flex; }
  .portal-nav a,
  .portal-link-button { display: block; width: 100%; text-align: right; padding: .75rem 1rem; border-radius: 12px; }
  .portal-nav .nav-mobile-actions {
    display: grid;
    gap: .35rem;
    margin-top: .45rem;
    padding-top: .55rem;
    border-top: 1px solid var(--color-line);
  }
  .portal-inline-form { width: 100%; border-top: 1px solid var(--color-line); padding-top: .4rem; }
}

@media (max-width: 760px) {
  .portal-grid,
  .portal-grid--3,
  .portal-grid--4,
  .portal-doc-grid {
    grid-template-columns: 1fr;
  }

  .portal-main {
    padding-top: 1.5rem;
  }

  .portal-main .shell,
  .portal-stack,
  .portal-grid > *,
  .portal-card {
    min-width: 0;
  }

  .portal-card {
    padding: 1.1rem;
  }

  .portal-card p,
  .portal-alert,
  .portal-timeline li,
  .portal-doc figcaption {
    overflow-wrap: anywhere;
  }

  .portal-field input[type="file"] {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .portal-page-head h1 {
    overflow-wrap: anywhere;
  }

  .portal-meta div {
    flex-direction: column;
    gap: .1rem;
  }

  .portal-meta dd {
    text-align: start;
  }

  .portal-actions > .portal-btn,
  .portal-actions > form,
  .portal-actions > form .portal-btn {
    width: 100%;
  }

  .portal-pager .portal-actions {
    width: 100%;
  }
}
