:root {
  --portal-primary: #1a73e8;
  --portal-secondary: #34a853;
  --portal-accent: #fbbc04;
  --portal-danger: #ea4335;
  --portal-bg: #f8f9fa;
  --portal-card: #ffffff;
  --portal-text: #202124;
  --portal-muted: #5f6368;
  --portal-border: #dadce0;
  --portal-radius: 12px;
  --portal-shadow: 0 8px 24px rgba(32, 33, 36, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--portal-bg);
  color: var(--portal-text);
  min-height: 100vh;
}

a { color: var(--portal-primary); text-decoration: none; }
a:hover { color: #125fc4; }

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

.portal-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--portal-border);
  backdrop-filter: blur(10px);
}

.portal-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  background: #e8f0fe;
}

.portal-header-title {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.portal-bell {
  position: relative;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--portal-text);
  border-radius: 50%;
  background: #eef3fd;
}

.portal-bell-badge {
  position: absolute;
  top: 4px;
  right: 3px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--portal-danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}

.portal-main {
  flex: 1;
  padding: 16px;
  padding-bottom: 88px;
  animation: portalFadeIn .25s ease;
}

.portal-card,
.portal-auth-card {
  background: var(--portal-card);
  border: 1px solid rgba(218, 220, 224, 0.7);
  border-radius: var(--portal-radius);
  box-shadow: var(--portal-shadow);
}

.portal-card {
  padding: 16px;
  margin-bottom: 16px;
}

.portal-auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at top right, rgba(26, 115, 232, 0.12), transparent 35%),
    radial-gradient(circle at bottom left, rgba(52, 168, 83, 0.12), transparent 30%),
    var(--portal-bg);
}

.portal-auth-card {
  width: min(100%, 420px);
  padding: 28px 22px;
}

.portal-auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--portal-primary), #6aa5ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 1.5rem;
}

.portal-subtitle,
.portal-muted {
  color: var(--portal-muted);
}

.portal-btn-primary,
.portal-btn-secondary,
.portal-btn-danger {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 600;
}

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

.portal-input,
.portal-select,
.portal-textarea {
  width: 100%;
  border: 1px solid var(--portal-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.95rem;
  background: #fff;
}

.portal-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.92rem;
}

.portal-grid {
  display: grid;
  gap: 12px;
}

.portal-child-card {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 12px;
  align-items: center;
}

.portal-avatar {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  object-fit: cover;
  background: #e8f0fe;
}

.portal-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.portal-fee-strip,
.portal-summary-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 12px;
}

.portal-summary-card {
  padding: 14px;
  border-radius: 12px;
  color: #fff;
}

.portal-summary-card.total { background: linear-gradient(135deg, var(--portal-primary), #5a95ef); }
.portal-summary-card.paid { background: linear-gradient(135deg, var(--portal-secondary), #68c37b); }
.portal-summary-card.outstanding { background: linear-gradient(135deg, var(--portal-danger), #f06b61); }

.portal-summary-card .value {
  font-size: 1.25rem;
  font-weight: 700;
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.portal-badge.paid,
.portal-badge.active,
.portal-badge.success { background: rgba(52, 168, 83, 0.12); color: #137333; }
.portal-badge.partial,
.portal-badge.warning { background: rgba(251, 188, 4, 0.16); color: #8a5b00; }
.portal-badge.unpaid,
.portal-badge.inactive,
.portal-badge.danger { background: rgba(234, 67, 53, 0.12); color: #b3261e; }

.portal-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  background: #fff;
}

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

.portal-table th,
.portal-table td {
  padding: 12px;
  border-bottom: 1px solid #edf0f2;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

.portal-table thead th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--portal-muted);
  background: #fafbfc;
}

.portal-notification {
  border-left: 4px solid transparent;
}

.portal-notification.unread {
  border-left-color: var(--portal-primary);
}

.portal-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--portal-border);
  backdrop-filter: blur(10px);
}

.portal-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 0;
  color: var(--portal-muted);
  font-size: 0.72rem;
  border-radius: 10px;
  transition: color .2s ease, background-color .2s ease, transform .2s ease;
}

.portal-nav-link.active {
  color: var(--portal-primary);
  background: rgba(26, 115, 232, 0.1);
}

.portal-nav-link:active {
  transform: translateY(1px);
}

.portal-kv {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.portal-kv-item {
  border: 1px solid var(--portal-border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.portal-kv-item .label {
  color: var(--portal-muted);
  font-size: 0.8rem;
}

.portal-kv-item .value {
  font-weight: 600;
  margin-top: 4px;
}

.portal-chart-bar {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--portal-primary), #7ca8ef);
}

.portal-empty {
  text-align: center;
  padding: 18px;
  color: var(--portal-muted);
  border: 1px dashed var(--portal-border);
  border-radius: 12px;
  background: #fff;
}

.portal-pull-hint {
  text-align: center;
  color: var(--portal-muted);
  font-size: 0.78rem;
  margin-bottom: 10px;
}

@keyframes portalFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 768px) {
  .portal-main { max-width: 1080px; width: 100%; margin: 0 auto; padding: 24px 24px 104px; }
  .portal-fee-strip,
  .portal-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .portal-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
  .portal-header,
  .portal-bottom-nav,
  .portal-bell,
  .portal-btn-primary,
  .portal-btn-secondary,
  .portal-btn-danger {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .portal-main {
    padding: 0;
    max-width: none;
  }

  .portal-card,
  .portal-table-wrap {
    box-shadow: none;
    border: none;
  }
}
