:root {
  --portal-primary: #2563eb;
  --portal-primary-dark: #1d4ed8;
  --portal-ink: #172033;
  --portal-muted: #64748b;
  --portal-line: #dbe3ee;
  --portal-surface: #ffffff;
  --portal-bg: #f4f7fb;
  --portal-success: #16803c;
  --portal-danger: #c62828;
  --portal-warning: #a15c00;
}

body {
  background: var(--portal-bg);
  color: var(--portal-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--portal-primary-dark);
}

.portal-skip-link {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 1060;
  min-height: 44px;
  padding: 11px 14px;
  border-radius: 6px;
  background: #172033;
  color: #fff;
  transition: top 0.18s ease;
}

.portal-skip-link:focus {
  top: 8px;
  color: #fff;
}

a:focus,
button:focus,
input:focus,
select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35) !important;
  outline-offset: 2px;
}

.navbar-white {
  min-height: 58px;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--portal-line);
  box-shadow: none;
}

.navbar-white .navbar-brand {
  height: 58px;
  line-height: 28px;
  color: #16356b;
  font-size: 19px;
  font-weight: 700;
}

.navbar-white .navbar-nav > li > a {
  min-height: 58px;
  padding-top: 19px;
  padding-bottom: 17px;
  color: #3f5068;
}

.navbar-white .navbar-nav > li > a:hover,
.navbar-white .navbar-nav > li > a:focus,
.navbar-white .navbar-nav > .open > a,
.navbar-white .navbar-nav > .open > a:hover {
  background: #f3f6fb;
  color: #173e7c;
}

.header-account-icon {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  margin: -5px 7px -5px 0;
  border-radius: 6px;
  background: #e8f0ff;
  color: var(--portal-primary-dark);
}

.header-account-name {
  display: inline-block;
  max-width: 150px;
  overflow: hidden;
  vertical-align: middle;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.content {
  min-height: calc(100vh - 126px);
  padding-top: 78px;
  padding-bottom: 26px;
}

.portal-layout {
  width: 100%;
  max-width: 1220px;
}

.portal-sidenav,
.sidenav.portal-sidenav {
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
}

.portal-identity {
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 11px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--portal-line);
}

.portal-identity-icon {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: #eaf1ff;
  color: var(--portal-primary-dark);
  font-size: 16px;
}

.portal-identity strong,
.portal-identity small {
  display: block;
  max-width: 170px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.portal-identity strong {
  color: #21324a;
  font-size: 14px;
}

.portal-identity small {
  margin-top: 2px;
  color: var(--portal-muted);
  font-size: 12px;
}

.nav-section-label,
.portal-local-nav .list-group-heading {
  margin: 0;
  padding: 17px 15px 7px;
  border: 0;
  background: #fff;
  color: #7a899c;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.portal-nav-item,
.portal-local-nav .list-group-item > a {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  margin: 2px 8px;
  padding: 10px 11px;
  border-radius: 6px;
  color: #42526a;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.portal-nav-item:hover,
.portal-nav-item:focus,
.portal-nav-item.active,
.portal-local-nav .list-group-item > a:hover,
.portal-local-nav .list-group-item.active > a {
  background: #eaf1ff;
  color: #18499c;
}

.portal-local-nav.list-group {
  margin: 0 0 8px;
  box-shadow: none;
}

.portal-local-nav .list-group-item {
  padding: 0;
  border: 0;
  background: transparent;
}

.portal-local-nav .list-group-item.active,
.portal-local-nav .list-group-item.active:hover {
  background: transparent;
}

.portal-page-header {
  display: flex;
  min-height: 76px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.portal-page-header h1 {
  margin: 2px 0 4px;
  color: #172033;
  font-size: 25px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
}

.portal-page-header p,
.panel-heading-row p {
  margin: 0;
  color: var(--portal-muted);
}

.page-kicker {
  color: var(--portal-primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.status-badge,
.quota-text {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  margin-top: 8px;
  padding: 7px 10px;
  border: 1px solid var(--portal-line);
  border-radius: 6px;
  background: #fff;
  color: #4e5f75;
  font-size: 12px;
  font-weight: 600;
}

.status-success {
  border-color: #bde5c9;
  background: #f0fbf4;
  color: var(--portal-success);
}

.status-danger {
  border-color: #f1c6c6;
  background: #fff5f5;
  color: var(--portal-danger);
}

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

.metric-item {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: #fff;
}

.metric-item span,
.metric-item small {
  display: block;
  color: var(--portal-muted);
  font-size: 12px;
}

.metric-item strong {
  display: block;
  margin: 7px 0 3px;
  color: #18366b;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.metric-grid-compact .metric-item {
  min-height: 88px;
}

.portal-panel,
#content-container .panel,
.uc-card {
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
}

.panel-heading-row,
.uc-card-head,
#content-container .panel-heading {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--portal-line);
  background: #fff;
}

.panel-heading-row h2,
.panel-heading-row h3,
.uc-card-head h3,
#content-container .panel-title {
  margin: 0 0 2px;
  color: #22324a;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: 6px 16px 16px;
}

.detail-grid > div {
  padding: 13px 12px 5px 0;
}

.detail-grid dt {
  color: var(--portal-muted);
  font-size: 12px;
  font-weight: 500;
}

.detail-grid dd {
  margin: 4px 0 0;
  color: #22324a;
  font-size: 15px;
  font-weight: 600;
}

.portal-table {
  min-width: 680px;
  margin: 0;
}

.portal-table > thead > tr > th,
.table > thead > tr > th {
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid var(--portal-line);
  background: #f8fafc;
  color: #617086;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.portal-table > tbody > tr > td,
.table > tbody > tr > td {
  padding: 12px 13px;
  border-top: 1px solid #edf1f6;
  color: #35445b;
  vertical-align: middle;
}

.portal-table > tbody > tr:hover,
.table-hover > tbody > tr:hover {
  background: #f7faff;
}

.portal-copy-field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 280px;
}

.portal-copy-field .portal-ipn-url {
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.portal-copy-ipn {
  flex: 0 0 auto;
  min-width: 36px;
}

.table-empty {
  padding: 34px !important;
  color: var(--portal-muted) !important;
  text-align: center;
}

.mono {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.amount {
  color: #173e7c !important;
  font-weight: 700;
  white-space: nowrap;
}

.cell-subtext {
  display: block;
  margin-top: 2px;
  color: #8794a6;
  font-size: 11px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #596a80;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-dot::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  content: "";
}

.status-dot.is-success { color: var(--portal-success); }
.status-dot.is-success::before { background: #22a652; }
.status-dot.is-pending { color: var(--portal-warning); }
.status-dot.is-pending::before { background: #e0a21a; }
.status-dot.is-disabled { color: var(--portal-danger); }
.status-dot.is-disabled::before { background: #d93a3a; }

.account-chip {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 3px 6px;
  border: 1px solid #d7e2f0;
  border-radius: 4px;
  background: #f6f9fd;
  color: #3d5575;
  font-size: 11px;
}

.portal-notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 16px;
  padding: 13px 15px;
  border: 1px solid #cddcf0;
  border-radius: 7px;
  background: #f5f9ff;
  color: #34506f;
}

.portal-notice > i {
  margin-top: 2px;
  color: var(--portal-primary-dark);
  font-size: 16px;
}

.portal-notice strong,
.portal-notice p {
  display: block;
  margin: 0;
}

.portal-notice p {
  margin-top: 2px;
  color: #60738b;
  font-size: 12px;
}

.portal-filter {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: #fff;
}

.portal-filter label {
  align-self: center;
  margin: 0;
  color: #485a71;
}

.portal-filter .form-control {
  width: min(420px, 100%);
}

.portal-pagination {
  padding: 12px 14px;
  border-top: 1px solid var(--portal-line);
  text-align: right;
}

.portal-pagination .pagination {
  margin: 0;
}

.portal-form-panel form {
  max-width: 560px;
  padding: 18px;
}

.form-control {
  height: 42px;
  border: 1px solid #cbd6e4;
  border-radius: 6px;
  box-shadow: none;
  color: #26364d;
}

.form-control:focus {
  border-color: var(--portal-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn {
  min-height: 38px;
  border-radius: 6px;
  font-weight: 600;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn-primary,
.btn-success {
  border-color: var(--portal-primary-dark);
  background: var(--portal-primary);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-success:hover,
.btn-success:focus {
  border-color: #173e8f;
  background: var(--portal-primary-dark);
  color: #fff;
}

.btn-default {
  border-color: #cbd6e4;
  background: #fff;
  color: #31445f;
}

.quick-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--portal-line);
}

.quick-action-grid > a {
  display: grid;
  min-height: 82px;
  grid-template-columns: 34px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  padding: 15px;
  background: #fff;
  color: #32445d;
  text-decoration: none;
}

.quick-action-grid > a:hover,
.quick-action-grid > a:focus {
  background: #f5f8fd;
}

.quick-action-grid > a > i:first-child {
  color: var(--portal-primary-dark);
  font-size: 18px;
  text-align: center;
}

.quick-action-grid strong,
.quick-action-grid small {
  display: block;
}

.quick-action-grid small {
  margin-top: 2px;
  color: var(--portal-muted);
  font-size: 12px;
}

.empty-state {
  padding: 32px 18px;
  color: var(--portal-muted);
  text-align: center;
}

.empty-state i {
  margin-bottom: 8px;
  color: #8aa0bd;
  font-size: 28px;
}

.empty-state h3 {
  margin: 0 0 4px;
  color: #34465f;
  font-size: 15px;
}

.empty-state p {
  margin: 0;
}

.portal-login-page {
  width: 100%;
  max-width: 1000px;
  padding-top: 26px;
  padding-bottom: 26px;
}

.portal-login-shell {
  display: grid;
  min-height: 510px;
  grid-template-columns: minmax(0, 1fr) 430px;
  overflow: hidden;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: #fff;
}

.portal-login-context {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  border-right: 1px solid #cddaf0;
  background: #edf4ff;
}

.portal-login-context.local-login-context {
  background: #f1f6fc;
}

.mode-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid #bfd2f2;
  border-radius: 5px;
  background: #fff;
  color: #17488f;
  font-size: 12px;
  font-weight: 700;
}

.portal-login-context h1 {
  margin: 17px 0 9px;
  color: #173362;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0;
}

.portal-login-context > p {
  max-width: 440px;
  color: #536a87;
  font-size: 15px;
}

.portal-login-points {
  display: grid;
  gap: 11px;
  margin-top: 24px;
}

.portal-login-points span {
  color: #354f72;
}

.portal-login-points i {
  margin-right: 7px;
  color: var(--portal-success);
}

.portal-login-form {
  padding: 38px 36px;
}

.portal-login-form h2 {
  margin: 0 0 4px;
  color: #1f2f45;
  font-size: 22px;
  font-weight: 700;
}

.form-intro,
.login-support {
  color: var(--portal-muted);
  font-size: 12px;
}

.portal-login-form form {
  margin-top: 24px;
}

.portal-login-form label {
  color: #394b64;
  font-size: 13px;
}

.portal-login-form .btn-lg {
  height: 44px;
  padding: 10px 16px;
  font-size: 14px;
}

.login-support {
  margin: 17px 0 0;
  text-align: center;
}

.login-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--portal-line);
  border-radius: 7px;
  background: #f3f6fa;
}

.login-mode-switch a {
  min-height: 44px;
  padding: 12px 8px;
  border-radius: 5px;
  color: #5a6b80;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.login-mode-switch a.active,
.login-mode-switch a:hover {
  background: #fff;
  color: #17488f;
  box-shadow: 0 1px 3px rgba(31, 55, 90, 0.12);
}

.entry-choice-page {
  width: 100%;
  max-width: 940px;
  padding-top: 54px;
  padding-bottom: 42px;
}

.entry-choice-header {
  max-width: 640px;
  margin: 0 auto 28px;
  text-align: center;
}

.entry-choice-header .mode-badge {
  margin: 0 auto;
}

.entry-choice-header h1 {
  margin: 16px 0 7px;
  color: #173362;
  font-size: 29px;
  font-weight: 700;
  letter-spacing: 0;
}

.entry-choice-header p {
  margin: 0;
  color: var(--portal-muted);
  font-size: 15px;
}

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

.entry-choice-card {
  display: grid;
  min-height: 214px;
  grid-template-rows: 48px 1fr auto;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: var(--portal-surface);
  color: var(--portal-ink);
  text-decoration: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.entry-choice-card:hover,
.entry-choice-card:focus {
  border-color: #a9c3ec;
  background: #fbfdff;
  color: var(--portal-ink);
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(34, 62, 104, 0.09);
}

.entry-choice-icon {
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: #eaf2ff;
  color: var(--portal-primary-dark);
  font-size: 20px;
}

.legacy-entry .entry-choice-icon {
  background: #edf2f7;
  color: #465b75;
}

.entry-choice-copy strong,
.entry-choice-copy small {
  display: block;
}

.entry-choice-copy strong {
  margin-bottom: 7px;
  color: #1f3554;
  font-size: 19px;
}

.entry-choice-copy small {
  color: var(--portal-muted);
  font-size: 13px;
  line-height: 1.6;
}

.entry-choice-action {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  padding-top: 13px;
  border-top: 1px solid #e7edf5;
  color: var(--portal-primary-dark);
  font-size: 13px;
  font-weight: 700;
}

.legacy-entry .entry-choice-action {
  color: #3f5878;
}

.entry-choice-help {
  margin: 20px 0 0;
  color: #607089;
  font-size: 13px;
  text-align: center;
}

.entry-choice-help i {
  margin-right: 5px;
  color: #5274a4;
}

.portal-choice-page {
  max-width: 760px;
  margin: 24px auto;
  padding: 28px;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: #fff;
}

.portal-choice-page > h1 {
  margin: 5px 0;
  color: #1d2e45;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0;
}

.portal-choice-page > p {
  color: var(--portal-muted);
}

.service-choice-grid {
  display: grid;
  gap: 10px;
  margin: 24px 0;
}

.service-choice {
  display: grid;
  min-height: 78px;
  grid-template-columns: 38px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--portal-line);
  border-radius: 7px;
  color: #31445f;
  text-decoration: none;
}

.service-choice:hover,
.service-choice:focus,
.service-choice.primary-choice {
  border-color: #b8cdf1;
  background: #f4f8ff;
  color: #183f7a;
  text-decoration: none;
}

.service-choice > i:first-child {
  color: var(--portal-primary-dark);
  font-size: 20px;
  text-align: center;
}

.service-choice strong,
.service-choice small {
  display: block;
}

.service-choice small {
  margin-top: 2px;
  color: var(--portal-muted);
}

.uc-intro {
  padding: 18px;
  border: 1px solid #c8d8ec;
  border-radius: 8px;
  background: #eef5ff;
  box-shadow: none;
  color: #294869;
}

.uc-intro h1,
.uc-intro h2,
.uc-intro h3,
.uc-intro p {
  color: #214270;
}

.uc-card-body,
#content-container .panel-body {
  padding: 16px;
}

.uc-metric,
.uc-table-wrap {
  border-radius: 7px;
  background: #fff;
}

.label,
.alert,
.modal-content,
.pagination > li > a,
.pagination > li > span {
  border-radius: 6px;
}

#content-container .panel {
  animation: none;
}

.footer {
  padding: 18px 15px;
  background: transparent;
  color: #718096;
}

.sidebar-toggle {
  display: none;
  border: 0;
}

@media (max-width: 991px) {
  .content {
    padding-top: 72px;
  }

  .portal-page-header {
    min-height: auto;
  }

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

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

  .portal-login-shell {
    grid-template-columns: 1fr;
  }

  .portal-login-context {
    min-height: 300px;
    padding: 32px;
    border-right: 0;
    border-bottom: 1px solid #cddaf0;
  }

  .sidenav.portal-sidenav {
    position: fixed;
    top: 58px;
    bottom: 0;
    left: -286px;
    z-index: 1040;
    width: 276px;
    overflow-y: auto;
    border-radius: 0;
    transition: left 0.2s ease;
  }

  body.sidebar-open .sidenav.portal-sidenav {
    left: 0;
  }

  .sidebar-toggle {
    position: fixed;
    right: 16px;
    bottom: 20px;
    z-index: 1050;
    display: inline-flex;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--portal-primary);
    color: #fff;
    box-shadow: 0 5px 15px rgba(23, 62, 124, 0.25);
  }
}

@media (max-width: 767px) {
  body {
    font-size: 16px;
  }

  .form-control {
    font-size: 16px;
  }

  .btn {
    min-height: 44px;
  }

  .navbar-white .navbar-toggle {
    margin-top: 12px;
    border-color: #d4deeb;
  }

  .navbar-white .navbar-collapse {
    border-color: var(--portal-line);
    background: #fff;
  }

  .portal-page-header {
    flex-direction: column;
    gap: 4px;
  }

  .portal-page-header h1 {
    font-size: 22px;
  }

  .metric-grid,
  .quick-action-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .metric-item {
    min-height: 94px;
  }

  .portal-filter {
    align-items: stretch;
    flex-direction: column;
  }

  .portal-filter label {
    align-self: flex-start;
  }

  .portal-filter .form-control {
    width: 100%;
  }

  .portal-login-page {
    padding: 10px;
  }

  .portal-login-context {
    min-height: 260px;
    padding: 24px;
  }

  .portal-login-context h1 {
    font-size: 25px;
  }

  .portal-login-form {
    padding: 24px 20px;
  }

  .login-mode-switch {
    grid-template-columns: 1fr;
  }

  .entry-choice-page {
    padding: 24px 16px 30px;
  }

  .entry-choice-header {
    margin-bottom: 20px;
  }

  .entry-choice-header h1 {
    font-size: 24px;
  }

  .entry-choice-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .entry-choice-card {
    min-height: 190px;
    padding: 20px;
  }

  .entry-choice-copy small,
  .entry-choice-action,
  .entry-choice-help {
    font-size: 14px;
  }

  .portal-choice-page {
    margin: 8px auto;
    padding: 20px 16px;
  }
}

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