@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=Space+Grotesk:wght@600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #080b0f;
  --bg-soft: #0c1118;
  --panel: rgba(16, 22, 31, 0.84);
  --panel-strong: rgba(20, 27, 38, 0.96);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #edf2f7;
  --muted: #8f9cac;
  --muted-strong: #b7c0cc;
  --accent: #7dd3fc;
  --accent-strong: #38bdf8;
  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.44);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 88% 6%, rgba(56, 189, 248, 0.16), transparent 28rem),
    radial-gradient(circle at 12% 84%, rgba(52, 211, 153, 0.08), transparent 26rem),
    linear-gradient(135deg, #07090d 0%, #0d121a 52%, #07090d 100%);
  font-family: Manrope, sans-serif;
}

a {
  color: var(--accent);
}

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

.portal-sidebar {
  position: sticky;
  top: 0;
  width: 268px;
  height: 100vh;
  padding: 28px 18px;
  border-right: 1px solid var(--line);
  background: rgba(8, 11, 15, 0.78);
  backdrop-filter: blur(22px);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.brand-mark::before {
  width: 12px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--success));
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.55);
  content: '';
}

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

.portal-nav a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.portal-nav a.active,
.portal-nav a:hover {
  border-color: var(--line-strong);
  color: white;
  background: rgba(255, 255, 255, 0.06);
  transform: translateX(3px);
}

.portal-main {
  flex: 1;
  min-width: 0;
}

.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 28px 38px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 15, 0.52);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.portal-header h1,
.hero-card h2,
.connect-panel h2,
.search-panel h2 {
  margin: 0;
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.portal-header h1 {
  font-size: clamp(28px, 4vw, 44px);
}

.user-chip {
  display: grid;
  min-width: 170px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logout-link,
.logout-nav {
  border: 1px solid rgba(251, 113, 133, 0.28);
  border-radius: 999px;
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.08);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.logout-link {
  padding: 11px 14px;
}

.logout-nav {
  margin-top: 10px;
}

.user-chip span {
  color: white;
  font-weight: 800;
}

.user-chip small {
  color: var(--muted);
}

.portal-content {
  padding: 34px 38px 48px;
}

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

.login-shell {
  width: min(980px, 100%);
}

.login-card {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 28px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background:
    radial-gradient(circle at 14% 12%, rgba(125, 211, 252, 0.18), transparent 19rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035)),
    var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 430px;
  padding: 16px;
}

.login-brand h1 {
  max-width: 520px;
  margin: 0;
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(42px, 7vw, 78px);
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.login-brand p:last-child {
  max-width: 470px;
  margin: 18px 0 0;
  color: var(--muted-strong);
}

.login-form {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(8, 11, 15, 0.58);
}

.login-form label {
  display: grid;
  gap: 8px;
}

.login-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-form input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  color: white;
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.login-form input:focus {
  border-color: rgba(125, 211, 252, 0.72);
  box-shadow: 0 0 0 4px rgba(125, 211, 252, 0.11);
}

.login-alert {
  padding: 13px 15px;
  border: 1px solid rgba(251, 113, 133, 0.34);
  border-radius: 16px;
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.1);
  font-weight: 700;
}

.hero-card,
.connect-panel,
.search-panel,
.users-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03)),
    var(--panel);
  box-shadow: var(--shadow);
}

.hero-card::after,
.connect-panel::after,
.search-panel::after,
.users-hero::after {
  position: absolute;
  inset: auto -18% -55% auto;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(125, 211, 252, 0.16), transparent 68%);
  content: '';
  pointer-events: none;
}

.hero-card h2 {
  max-width: 760px;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 0.95;
}

.users-hero {
  margin-bottom: 20px;
}

.users-hero.compact h2,
.users-hero h2 {
  margin: 0;
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 16px;
}

.user-card,
.user-form-card,
.user-detail-board div {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.user-card,
.user-form-card {
  padding: 22px;
  border-radius: 24px;
}

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

.user-card-top span,
.user-fields span,
.user-form-card span,
.user-detail-board span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.user-card h3 {
  margin: 4px 0 0;
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
}

.user-card-top strong {
  padding: 8px 12px;
  border: 1px solid rgba(52, 211, 153, 0.24);
  border-radius: 999px;
  color: #bbf7d0;
  background: rgba(52, 211, 153, 0.1);
}

.user-fields,
.user-detail-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.user-fields div,
.user-detail-board div {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.user-fields b,
.user-detail-board strong {
  display: block;
  margin-top: 5px;
  color: white;
  overflow-wrap: anywhere;
}

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

.user-actions-row.wide {
  margin-top: 22px;
}

.po-detail-btn.muted {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.danger-btn {
  padding: 10px 16px;
  border: 1px solid rgba(251, 113, 133, 0.34);
  border-radius: 999px;
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.1);
  font-weight: 800;
}

.user-form-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 16px;
}

.user-form-card label {
  display: grid;
  gap: 8px;
}

.user-form-card input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  color: white;
  background: rgba(255, 255, 255, 0.06);
}

.hero-card p:last-child,
.connect-panel p,
.search-panel p {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted-strong);
}

.btn,
.btn-connect,
.po-detail-btn {
  border: 1px solid rgba(125, 211, 252, 0.34);
  border-radius: 999px;
  color: #061016;
  background: linear-gradient(135deg, #e0f7ff, var(--accent-strong));
  font-weight: 800;
  box-shadow: 0 16px 34px rgba(56, 189, 248, 0.18);
}

.btn-connect {
  padding: 13px 22px;
}

.btn-light {
  padding: 12px 20px;
}

.metric-card,
.po-card,
.po-detail-panel,
.po-summary-grid div,
.po-list-row,
.po-pagination {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.metric-card {
  display: grid;
  gap: 14px;
  min-height: 146px;
  padding: 24px;
  border-radius: 24px;
}

.metric-card span,
.po-summary-grid span,
.po-meta-grid span,
.po-field-grid span,
.po-label,
.po-info-board span,
.po-clean-field span,
.po-note span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metric-card strong {
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 38px;
}

.gateway-result {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.045);
}

.gateway-result strong {
  color: white;
}

.gateway-result.success {
  border-color: rgba(52, 211, 153, 0.34);
  background: rgba(52, 211, 153, 0.09);
}

.gateway-result.error,
.po-detail-panel.error {
  border-color: rgba(251, 113, 133, 0.34);
  background: rgba(251, 113, 133, 0.09);
}

.data-table-wrap {
  margin-top: 20px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
}

.data-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  color: var(--muted-strong);
}

.data-table th,
.data-table td {
  max-width: 360px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  color: white;
  background: #111824;
  text-align: left;
}

.data-table pre,
.raw-json {
  margin: 0;
  color: var(--muted-strong);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.po-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.po-summary-grid.compact strong {
  font-size: 22px;
}

.po-summary-grid div {
  padding: 18px;
  border-radius: 18px;
}

.po-summary-grid strong {
  display: block;
  margin-top: 6px;
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
}

.po-card-grid,
.po-list-strip {
  display: grid;
  gap: 14px;
}

.po-list-strip {
  margin-bottom: 20px;
}

.po-list-row {
  display: grid;
  grid-template-columns: 110px minmax(160px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
}

.po-list-row strong,
.po-card h3,
.po-detail-hero h3 {
  color: white;
  font-family: 'Space Grotesk', sans-serif;
}

.po-list-row strong {
  font-size: 20px;
}

.po-detail-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 10px 16px;
  color: #061016;
  text-align: center;
  text-decoration: none;
}

.po-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 14px;
  border-radius: 18px;
}

.po-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.po-detail-panel {
  padding: 24px;
  border-radius: 24px;
}

.po-detail-page-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.po-detail-page-title a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.po-detail-page-title h2,
.po-section h4,
.po-lines h4,
.po-item-head h5 {
  margin: 0;
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
}

.po-detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.po-detail-hero.refined {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.14), rgba(255, 255, 255, 0.04));
}

.po-detail-hero h3 {
  margin: 4px 0 0;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 700;
  word-break: break-word;
}

.po-info-board {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.po-info-board div,
.po-clean-field,
.po-meta-grid div,
.po-field-grid div,
.po-line-table article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.po-info-board strong,
.po-clean-field strong,
.po-meta-grid strong,
.po-field-grid strong {
  display: block;
  margin-top: 5px;
  color: white;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.po-note,
.po-memo,
.empty-state,
.po-lines {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(125, 211, 252, 0.07);
}

.po-note p {
  margin: 0;
}

.po-section {
  margin-top: 22px;
}

.po-section h4,
.po-lines h4 {
  margin-bottom: 12px;
}

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

.po-section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.po-items-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.035);
}

.po-items-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.po-items-table th,
.po-items-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted-strong);
  vertical-align: middle;
}

.po-items-table th {
  color: white;
  background: rgba(17, 24, 36, 0.92);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.po-items-table tbody tr:hover {
  background: rgba(125, 211, 252, 0.055);
}

.po-items-table td:first-child,
.po-items-table th:first-child {
  width: 72px;
  text-align: center;
}

.po-items-table td:nth-child(3),
.po-items-table td:nth-child(5),
.po-items-table td:nth-child(6) {
  text-align: right;
}

.po-items-table strong {
  display: block;
  color: white;
  font-weight: 800;
}

.po-items-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.po-items-table b {
  color: #bbf7d0;
}

.po-line-index {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: var(--accent);
  background: rgba(125, 211, 252, 0.1);
  font-weight: 800;
}

.compact-info .po-clean-field {
  padding: 14px;
}

.po-clean-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.po-line-table {
  display: grid;
  gap: 12px;
}

.po-line-table article {
  display: grid;
  grid-template-columns: 54px repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.po-line-table b {
  color: var(--accent);
}

.po-line-table span {
  color: var(--muted-strong);
  overflow-wrap: anywhere;
}

.po-line-table em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  text-transform: uppercase;
}

.po-card {
  padding: 24px;
  border-radius: 24px;
}

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

.po-card h3 {
  margin: 4px 0 0;
  font-size: 30px;
  font-weight: 700;
}

.po-status {
  padding: 8px 12px;
  border: 1px solid rgba(52, 211, 153, 0.24);
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.11);
  color: #bbf7d0;
  font-weight: 800;
}

.po-meta-grid,
.po-field-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.po-meta-grid {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.po-field-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

@media (max-width: 900px) {
  .portal-shell,
  .portal-header,
  .user-actions,
  .login-card,
  .hero-card,
  .connect-panel,
  .search-panel,
  .users-hero,
  .user-card-top,
  .po-card-head,
  .po-pagination,
  .po-detail-page-title,
  .po-detail-hero,
  .po-section-heading,
  .po-item-head {
    display: block;
  }

  .portal-sidebar {
    position: relative;
    width: auto;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .portal-header,
  .portal-content {
    padding: 24px 18px;
  }

  .user-chip,
  .logout-link,
  .btn-light,
  .btn-connect {
    margin-top: 16px;
  }

  .login-brand {
    min-height: auto;
    padding: 4px;
  }

  .login-form {
    margin-top: 22px;
    padding: 20px;
  }

  .po-summary-grid,
  .po-meta-grid,
  .po-info-board,
  .po-list-row {
    grid-template-columns: 1fr;
  }

  .po-item-head h5 {
    margin-top: 12px;
    text-align: left;
  }

  .user-form-card {
    grid-template-columns: 1fr;
  }
}