/* ==========================================================================
    Patient Portal — Shared Portal Theme
    Consumed by all portal pages so the portal speaks one visual language.
    Reference: public/patient-menu.html
   ========================================================================== */

/* Fonts — pages should also include this <link> themselves for preload hints,
   but we import here as a safety net. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&family=Crimson+Text:wght@400;700&display=swap');

/* ========== TOKENS ========== */
:root {
    --bg: #f7f7f4;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-solid: #ffffff;
    --surface-muted: #f0f0ec;
    --ink: #111111;
    --ink-soft: #3f3f3f;
    --muted: #717171;
    --line: rgba(17, 17, 17, 0.09);
    --line-strong: rgba(17, 17, 17, 0.16);
    --green: #5c7f72;
    --green-soft: rgba(92, 127, 114, 0.13);
    --blue: #4a6f9d;
    --rose: #b35f7b;
    --amber: #b7792e;
    --purple: #7357a8;
    --shadow: 0 14px 38px rgba(17, 17, 17, 0.08);
    --bg-page: #f7f7f4;
    --bg-secondary: #f0f0ec;
    --bg-surface: rgba(255, 255, 255, 0.88);
    --bg-elevated: #ffffff;
    --text-primary: #111111;
    --text-body: #3f3f3f;
    --text-secondary: #555555;
    --text-muted: #717171;
    --accent: #5c7f72;
    --accent-hover: #4f6f63;
    --accent-soft: rgba(92, 127, 114, 0.13);
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.08);
    --line-soft: rgba(17, 17, 17, 0.09);
    --line-strong: rgba(17, 17, 17, 0.16);
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-serif: 'Crimson Text', Georgia, serif;
    --shadow-soft: 0 1px 2px rgba(17, 17, 17, 0.05);
    --shadow-hard: 0 14px 38px rgba(17, 17, 17, 0.08);
    --radius: 18px;
    --radius-sm: 12px;
    --radius-lg: 24px;
    --nav-height: 74px;
}

/* ========== RESET + BASE ========== */
.portal-themed *,
.portal-themed *::before,
.portal-themed *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body.portal-themed {
    font-family: var(--font-main);
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    min-height: 100vh;
    overflow-x: hidden;
}

html {
    background: var(--bg-page);
}

body {
    font-family: var(--font-main);
    background:
        radial-gradient(circle at 12% 4%, rgba(92, 127, 114, 0.12), transparent 27%),
        linear-gradient(180deg, #fbfbf8 0%, var(--bg-page) 52%, #ffffff 100%);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body.portal-themed ::selection {
    background: #0a0a0a;
    color: #ffffff;
}

body.portal-themed a {
    color: inherit;
    text-decoration: none;
}

body.portal-themed h1,
body.portal-themed h2,
body.portal-themed h3,
body.portal-themed h4 {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

body.portal-themed p {
    color: var(--text-body);
    line-height: 1.7;
}

/* ========== TOPBAR (static monochrome, no hero coupling) ========== */
.topbar-portal {
    position: fixed;
    top: env(safe-area-inset-top, 0px);
    left: 0;
    right: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line-soft);
    color: var(--text-primary);
}
.topbar-portal-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px clamp(18px, 4vw, 48px);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
}
.topbar-portal .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar-portal .brand-title {
    font-size: 19px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}
.topbar-portal .brand-title span { color: var(--text-primary); }
.topbar-portal .brand-sub {
    margin-top: 2px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-muted);
}
.topbar-portal .top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar-portal .circle-btn,
.topbar-portal .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    background: var(--bg-surface);
    color: var(--text-primary);
    display: grid;
    place-items: center;
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}
.topbar-portal .circle-btn:hover,
.topbar-portal .avatar:hover { background: var(--bg-elevated); }
.topbar-portal .circle-btn:active,
.topbar-portal .avatar:active { transform: scale(0.94); }
.topbar-portal .back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}
.topbar-portal .back-link:hover { background: var(--bg-elevated); }

/* Spacer so content clears fixed topbar */
.topbar-portal-spacer {
    height: calc(env(safe-area-inset-top, 0px) + 64px);
}

/* ========== GREEN PULSE DOT (green-light) ========== */
.green-light {
    position: relative;
    display: inline-block;
    width: 10px;
    height: 10px;
    vertical-align: middle;
    margin-right: 8px;
}
.green-light-core {
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: var(--success);
}
.green-light-glow {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--success);
    opacity: 0.35;
    animation: greenPulse 1.8s ease-out infinite;
}
@keyframes greenPulse {
    0%   { transform: scale(1);   opacity: 0.5; }
    70%  { transform: scale(2.2); opacity: 0;   }
    100% { transform: scale(2.2); opacity: 0;   }
}

/* ========== GRAIN OVERLAY UTILITY ========== */
.grain-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: url('/images/grain.avif');
    background-size: 100px 100px;
    background-repeat: repeat;
    mix-blend-mode: overlay;
    opacity: 0.35;
}
.grain-overlay.grain-subtle { opacity: 0.15; }

/* ========== Portal cardS ========== */
.portal-card {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-soft);
    transition: box-shadow 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}
.portal-card:hover {
    box-shadow: var(--shadow-hard);
    border-color: var(--line-strong);
}
.portal-card.card-sage {
    background: #eef2f0;
    border-color: transparent;
}
.portal-card-kicker {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 12px;
}
.portal-card-title {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.portal-card-desc {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-muted);
}

/* ========== PORTAL FORMS ========== */
.portal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.portal-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.portal-input,
.portal-textarea,
.portal-select {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    padding: 0 16px;
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.portal-textarea {
    min-height: 120px;
    padding: 12px 16px;
    line-height: 1.6;
    resize: vertical;
}
.portal-input:focus,
.portal-textarea:focus,
.portal-select:focus {
    outline: none;
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.06);
}
.portal-input::placeholder,
.portal-textarea::placeholder { color: var(--text-muted); }

.portal-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--text-primary);
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}
.portal-button:hover { background: var(--accent-hover); }
.portal-button:active { transform: scale(0.98); }
.portal-button.portal-button-ghost {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--line-strong);
}
.portal-button.portal-button-ghost:hover { background: var(--bg-elevated); }

/* ========== CLEARPATH CTA BUTTON (sliding dots) ========== */
.doc-cta-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 14px 40px;
    min-width: 220px;
    border-radius: 999px;
    background: #7ea89f;
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.02em;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: background 0.3s ease;
}
.doc-cta-link:hover { background: #6f988f; }
.doc-cta-track {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transform: translateX(0);
    transition: transform 0.56s cubic-bezier(0.22, 1, 0.36, 1);
}
.doc-cta-link .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffffff;
    transition: transform 0.56s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.36s ease;
}
.doc-cta-link .dot-left  { transform: translateX(-58px); opacity: 0; }
.doc-cta-link .dot-right { transform: translateX(0);     opacity: 1; }
.doc-cta-link:is(:hover, :focus-visible, :active) .doc-cta-track,
.doc-cta-link.is-animating .doc-cta-track { transform: translateX(42px); }
.doc-cta-link:is(:hover, :focus-visible, :active) .dot-left,
.doc-cta-link.is-animating .dot-left { transform: translateX(-42px); opacity: 1; }
.doc-cta-link:is(:hover, :focus-visible, :active) .dot-right,
.doc-cta-link.is-animating .dot-right { transform: translateX(18px); opacity: 0; }

/* ========== SECTION HEADING (kicker + H2) ========== */
.section-heading {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}
.section-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    align-self: flex-start;
}
.section-title {
    font-family: var(--font-display);
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.08;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.section-title .serif { font-family: var(--font-serif); font-style: italic; font-weight: 400; }
.section-lead {
    max-width: 62ch;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ========== SITE FOOTER (Indonesian, sage bg, dark overlay) ========== */
.site-footer {
    position: relative;
    margin-top: 120px;
    color: rgba(255, 255, 255, 0.78);
    overflow: visible;
    isolation: isolate;
}
.site-footer .footer-card-frame {
    position: relative;
    min-height: 480px;
    width: 100%;
    overflow: hidden;
    background-color: #c7d4cf;
    isolation: isolate;
}
.site-footer .footer-card-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(16, 19, 18, 0.08) 0%, rgba(16, 19, 18, 0.28) 42%, rgba(16, 19, 18, 0.68) 100%);
    z-index: 1;
    pointer-events: none;
}
.site-footer .footer-card-frame::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.34), transparent 34%);
    mix-blend-mode: screen;
    z-index: 2;
    pointer-events: none;
}
.site-footer .footer-grain {
    position: absolute;
    inset: 0;
    background-image: url('/images/grain.avif');
    background-size: 90px 90px;
    background-repeat: repeat;
    mix-blend-mode: soft-light;
    opacity: 0.5;
    pointer-events: none;
    z-index: 2;
}
.site-footer .footer-inner {
    position: relative;
    z-index: 3;
    max-width: 1280px;
    margin: 0 auto;
    padding: 68px clamp(22px, 5vw, 80px) calc(32px + env(safe-area-inset-bottom, 0px));
}
.site-footer .footer-newsletter-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 22px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}
.site-footer .footer-newsletter-kicker::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #c7e1d8;
    box-shadow: 0 0 0 6px rgba(199, 225, 216, 0.08);
}
.site-footer .footer-copy h2 {
    margin: 0 0 20px;
    font-family: var(--font-display);
    font-size: clamp(40px, 8vw, 80px);
    line-height: 0.95;
    letter-spacing: -0.04em;
    color: #f4f6f8;
    max-width: 8ch;
}
.site-footer .footer-copy p {
    margin: 0;
    font-size: 15px;
    line-height: 1.8;
    color: rgba(239, 243, 247, 0.74);
    max-width: 48ch;
}
.site-footer .footer-subscribe {
    margin-top: 32px;
    padding: 20px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}
.site-footer .footer-subscribe-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.site-footer .footer-subscribe-input {
    width: 100%;
    min-height: 54px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    background: rgba(8, 11, 15, 0.22);
    padding: 0 18px;
    color: #fff;
    font: inherit;
}
.site-footer .footer-subscribe-input::placeholder { color: rgba(255, 255, 255, 0.42); }
.site-footer .footer-subscribe-button {
    min-height: 54px;
    border: none;
    border-radius: 18px;
    background: #eef2f6;
    color: #10141b;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}
.site-footer .footer-policy {
    margin: 14px 0 0;
    font-size: 12px;
    line-height: 1.6;
    color: rgba(239, 243, 247, 0.56);
}
.site-footer .footer-meta {
    margin-top: 38px;
    padding-top: 26px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    gap: 26px;
}
.site-footer .footer-meta-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    display: block;
    margin-bottom: 10px;
}
.site-footer .footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
}
.site-footer .footer-links a,
.site-footer .footer-social a,
.site-footer .footer-email {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s ease;
    font-size: 14px;
}
.site-footer .footer-links a:hover,
.site-footer .footer-social a:hover,
.site-footer .footer-email:hover { color: #fff; }
.site-footer .footer-email { display: block; margin-bottom: 10px; }
.site-footer .footer-social {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 18px;
}
.site-footer .footer-bottom {
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 12px;
}

@media (min-width: 820px) {
    .site-footer .footer-meta { grid-template-columns: 1.4fr 1fr; }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    body.portal-themed *,
    body.portal-themed *::before,
    body.portal-themed *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    .green-light-glow { animation: none !important; }
}

/* ===========================================================================
   Mobile-First Portal Harmonization
   Loaded last on *.html pages. These overrides mirror the home portal
   dashboard without touching the My Corner editor internals.
   ========================================================================== */

html {
    background: var(--bg-page) !important;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    background:
        radial-gradient(circle at 12% 4%, rgba(92, 127, 114, 0.12), transparent 27%),
        linear-gradient(180deg, #fbfbf8 0%, var(--bg-page) 52%, #ffffff 100%) !important;
    color: var(--text-primary) !important;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body :where(button, a, input, textarea, select):not(#pmc-root *) {
    font-family: inherit !important;
}

body :where(h1, h2, h3, h4, .brand-title, .topbar-title, .section-title, .portal-card-title, .page-title, .hero-title, .hero-greeting, .visit-title, .corner-name, .tracker-panel .big):not(#pmc-root *) {
    font-family: var(--font-display) !important;
    font-weight: 800 !important;
    letter-spacing: -0.035em !important;
    color: var(--text-primary) !important;
}

body :where(.brand-title):not(#pmc-root *) {
    font-size: 20px !important;
    line-height: 1.08 !important;
}

body :where(.brand-title span):not(#pmc-root *) {
    color: var(--accent) !important;
    font-weight: 600 !important;
}

body :where(.brand-sub, .topbar-subtitle):not(#pmc-root *) {
    margin-top: 1px !important;
    color: var(--text-muted) !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

body :where(.hero-title, .hero-greeting):not(#pmc-root *) {
    font-size: clamp(28px, 8vw, 54px) !important;
    line-height: 0.98 !important;
    letter-spacing: -0.055em !important;
}

body :where(.page-title):not(#pmc-root *) {
    font-size: 22px !important;
    line-height: 1.1 !important;
}

body :where(.section-title):not(#pmc-root *) {
    font-size: 19px !important;
    line-height: 1.1 !important;
    letter-spacing: -0.03em !important;
}

body :where(.portal-card-title, .card-title, .status-body h3, .tracker-panel h3, .announcement-panel h3, .tap-card h3):not(#pmc-root *) {
    font-size: 13px !important;
    line-height: 1.22 !important;
    letter-spacing: -0.01em !important;
}

body :where(p, .subtitle, .description, .step-desc, .empty-text, .card-desc, .portal-card-desc, .hero-copy, .corner-desc, .tracker-panel p, .announcement-panel p, .tap-card p):not(#pmc-root *) {
    color: var(--text-body) !important;
    font-size: 12px !important;
    line-height: 1.45 !important;
}

body :where(.hero-copy):not(#pmc-root *) {
    font-size: 14px !important;
    line-height: 1.6 !important;
}

body :where(.section, section):not(#pmc-root *) {
    scroll-margin-top: 84px;
}

body :where(.section-head, .quick-card-header, .page-header-copy):not(#pmc-root *) {
    margin-bottom: 10px !important;
}

body :where(.section-kicker, .quick-card-kicker):not(#pmc-root *) {
    display: block !important;
    padding: 0 !important;
    margin-bottom: 4px !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    letter-spacing: 0.1em !important;
    text-transform: uppercase !important;
}

body :where(.status-chip, .portal-card-kicker, .visit-label, .quota-chip, .badge-chip, .pill, .tag, .chip):not(#pmc-root *) {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: auto !important;
    background: var(--accent-soft) !important;
    color: var(--accent) !important;
    border: 1px solid rgba(92, 127, 114, 0.16) !important;
    border-radius: 999px !important;
    padding: 7px 10px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    letter-spacing: 0.02em !important;
    text-transform: none !important;
}

body :where(.topbar):not(#pmc-root *) {
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: var(--text-primary) !important;
}

body :where(.top-bar, .app-header, .header, .navbar, .mini-topbar, .topbar-portal):not(#pmc-root *) {
    background: rgba(255, 255, 255, 0.78) !important;
    border: 1px solid rgba(17, 17, 17, 0.08) !important;
    border-radius: 0 0 18px 18px !important;
    box-shadow: var(--shadow-soft) !important;
    -webkit-backdrop-filter: blur(18px) !important;
    backdrop-filter: blur(18px) !important;
    color: var(--text-primary) !important;
}

body :where(.topbar-portal-inner, .nav-container, .topbar-inner, .header-inner):not(#pmc-root *) {
    width: min(100%, 860px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
}

body :where(.app, .main-content, .content, .page-wrap, .container, .screen, .page-body, .feedback-container, .fc-container, .visit-app, .app-wrapper):not(#pmc-root *) {
    width: min(100%, 860px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

body :where(.hero-card, .page-hero, .hero-section, .profile-header, .welcome-card):not(#pmc-root *) {
    border: 1px solid var(--line-soft) !important;
    border-radius: 24px !important;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(240, 242, 236, 0.86)) !important;
    box-shadow: var(--shadow-hard) !important;
    overflow: hidden !important;
}

body :where(.card, .portal-card, .stat-box, .date-card, .time-card, .slot-card, .form-card, .result-card, .document-card, .notification-card, .article-card, .question-card, .visit-card, .tracker-card, .calendar-card, .medication-card, .lab-card, .record-card, .feedback-card, .settings-card, .empty-state, .status-panel, .corner-panel, .tracker-panel, .announcement-panel, .tap-card, .schedule-card, .appointment-card, .menu-card, .dash-card, .status-card):not(#pmc-root *) {
    background: rgba(255, 255, 255, 0.82) !important;
    border: 1px solid var(--line-soft) !important;
    border-radius: 18px !important;
    box-shadow: var(--shadow-soft) !important;
    color: var(--text-primary) !important;
}

body :where(.portal-card, .form-card, .result-card, .profile-header, .status-panel, .corner-panel, .tracker-panel, .announcement-panel):not(#pmc-root *) {
    padding: 14px !important;
}

body :where(.tap-card, .date-card, .time-card, .slot-card, .menu-card, .article-card, .document-card, .notification-card, .portal-card, .schedule-card, .appointment-card):not(#pmc-root *) {
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease !important;
}

body :where(.tap-card, .date-card, .time-card, .slot-card, .menu-card, .article-card, .document-card, .notification-card, .portal-card, .schedule-card, .appointment-card):active:not(#pmc-root *) {
    transform: scale(0.97) !important;
}

body :where(.tap-card:hover, .date-card:hover, .time-card:hover, .slot-card:hover, .menu-card:hover, .article-card:hover, .document-card:hover, .notification-card:hover, .portal-card:hover):not(#pmc-root *) {
    border-color: var(--line-strong) !important;
    box-shadow: 0 12px 26px rgba(17, 17, 17, 0.08) !important;
}

body :where(.icon, .card-icon, .doc-card-icon, .status-icon):not(#pmc-root *) {
    border-radius: 13px !important;
    background: var(--surface-muted) !important;
}

body :where(button, .btn, .button, .portal-button, .primary-btn, .primary-action, .submit-btn, .action-btn, .btn-submit, .book-btn, .btn-confirm, .save-btn, .download-btn, .footer-subscribe-button):not(#pmc-root *) {
    border-radius: 14px !important;
    font-family: var(--font-main) !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    letter-spacing: 0 !important;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
}

body :where(.portal-button, .primary-btn, .primary-action, .submit-btn, .btn-submit, .btn-primary, .book-btn, .btn-confirm, .save-btn, button[type="submit"]):not(#pmc-root *) {
    background: var(--text-primary) !important;
    color: #ffffff !important;
    border: 1px solid var(--text-primary) !important;
    box-shadow: none !important;
}

body :where(.portal-button, .primary-btn, .primary-action, .submit-btn, .btn-submit, .btn-primary, .book-btn, .btn-confirm, .save-btn, button[type="submit"]):active:not(#pmc-root *) {
    transform: scale(0.97) !important;
}

body :where(.ghost-action, .secondary-btn, .btn-secondary, .portal-button-ghost, .back-btn, .topbar-back, .visit-back, .icon-btn, .circle-btn, .avatar, .btn-cancel, .cancel-btn, .btn-google):not(#pmc-root *) {
    background: rgba(255, 255, 255, 0.86) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--line-strong) !important;
    box-shadow: var(--shadow-soft) !important;
}

body :where(.icon-btn, .circle-btn, .avatar, .topbar-back, .back-btn):not(#pmc-root *) {
    border-radius: 14px !important;
}

body :where(.star-btn):not(#pmc-root *) {
    border-radius: 14px !important;
    background: rgba(255, 255, 255, 0.86) !important;
    border: 1px solid var(--line-soft) !important;
    color: var(--amber) !important;
}

body :where(input, textarea, select, .portal-input, .portal-textarea, .portal-select):not(#pmc-root *) {
    border-radius: 14px !important;
    border: 1px solid var(--line-strong) !important;
    background: #fbfbf8 !important;
    color: var(--text-primary) !important;
    font-family: var(--font-main) !important;
    font-size: 13px !important;
    box-shadow: none !important;
}

body :where(input, textarea, select, .portal-input, .portal-textarea, .portal-select):focus:not(#pmc-root *) {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(92, 127, 114, 0.14) !important;
    outline: none !important;
}

body :where(label, .portal-label, .field label):not(#pmc-root *) {
    color: var(--text-muted) !important;
    font-size: 11px !important;
    font-weight: 800 !important;
}

body :where(.bottom-nav, .mobile-nav, nav[aria-label="Navigasi bawah"]):not(#pmc-root *) {
    position: fixed !important;
    left: 50% !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px) !important;
    transform: translateX(-50%) !important;
    width: min(520px, calc(100% - 24px)) !important;
    z-index: 40 !important;
    background: rgba(255, 255, 255, 0.78) !important;
    border: 1px solid rgba(17, 17, 17, 0.1) !important;
    border-radius: 24px !important;
    box-shadow: 0 18px 42px rgba(17, 17, 17, 0.13) !important;
    padding: 8px !important;
    -webkit-backdrop-filter: blur(20px) !important;
    backdrop-filter: blur(20px) !important;
}

body :where(.bottom-nav .nav-item, .mobile-nav .nav-item):not(#pmc-root *) {
    border: 0 !important;
    border-radius: 17px !important;
    background: transparent !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    min-height: 0 !important;
    box-shadow: none !important;
}

body :where(.nav-item.active, .bottom-nav .active, .mobile-nav .active):not(#pmc-root *) {
    background: var(--text-primary) !important;
    color: #ffffff !important;
}

body :where(.modal-card, .bottom-sheet, .sheet-panel, .popup-card, .modal-content):not(#pmc-root *) {
    background: rgba(255, 255, 255, 0.96) !important;
    border: 1px solid var(--line-soft) !important;
    border-radius: 24px !important;
    box-shadow: var(--shadow-hard) !important;
}

body :where(.loading, .empty-state, .skeleton):not(#pmc-root *) {
    color: var(--text-muted) !important;
}

body :where(.toast, .alert-success, .success-message):not(#pmc-root *) {
    border-radius: 999px !important;
    background: var(--text-primary) !important;
    color: #ffffff !important;
    font-size: 12px !important;
    font-weight: 800 !important;
}

@media (max-width: 640px) {
    body {
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }

    body :where(.app, .main-content, .content, .page-wrap, .container, .screen, .page-body, .feedback-container, .fc-container, .visit-app, .app-wrapper):not(#pmc-root *) {
        padding-left: max(14px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(14px, env(safe-area-inset-right, 0px)) !important;
    }

    body :where(.page-hero, .hero-card, .hero-section):not(#pmc-root *) {
        border-radius: 24px !important;
    }

    body :where(.card, .portal-card, .stat-box, .date-card, .time-card, .slot-card, .profile-header, .form-card, .result-card, .document-card, .notification-card, .article-card, .question-card, .visit-card, .tracker-card, .calendar-card, .medication-card, .lab-card, .record-card, .feedback-card, .settings-card, .empty-state, .status-panel, .corner-panel, .tracker-panel, .announcement-panel, .tap-card, .schedule-card, .appointment-card, .menu-card, .dash-card, .status-card):not(#pmc-root *) {
        border-radius: 18px !important;
    }
}

/* ===========================================================================
   Final Shell Normalization
   Force consistent header rhythm, cleaner paragraph measure, and remove older
   landing-style footers from all portal pages.
   ========================================================================== */

body :where(.site-footer, footer.site-footer, .page-footer, .portal-footer, .footer-card-frame, .site-footer-inner, .site-footer-bottom):not(#pmc-root *) {
    display: none !important;
}

body.portal-header-normalized :where(.portal-legacy-header):not(#pmc-root *) {
    display: none !important;
}

body :where(.portal-unified-header):not(#pmc-root *) {
    position: sticky !important;
    top: env(safe-area-inset-top, 0px) !important;
    z-index: 34 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 14px !important;
    padding: 10px 0 12px !important;
    margin-bottom: 14px !important;
}

body :where(.portal-unified-brand):not(#pmc-root *) {
    display: block !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

body :where(.portal-unified-back):not(#pmc-root *) {
    border-radius: 14px !important;
    border: 1px solid var(--line-strong) !important;
    background: rgba(255, 255, 255, 0.86) !important;
    color: var(--text-primary) !important;
    min-height: 40px !important;
    padding: 0 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    font-family: var(--font-main) !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    box-shadow: var(--shadow-soft) !important;
}

body :where(.visit-topbar, .mini-topbar, .topbar, .topbar-portal):not(#pmc-root *) {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 14px !important;
    padding: 10px 0 12px !important;
    margin-bottom: 14px !important;
}

body :where(.mini-topbar, .visit-topbar, .topbar-portal):not(#pmc-root *) {
    position: sticky !important;
    top: env(safe-area-inset-top, 0px) !important;
    z-index: 30 !important;
}

body :where(.topbar-inner, .topbar-portal-inner):not(#pmc-root *) {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    width: 100% !important;
    padding: 0 !important;
}

body :where(.topbar-title, .page-header h1, .step-title, .login-heading, .history-title, .visit-title):not(#pmc-root *) {
    font-family: var(--font-display) !important;
    font-size: 19px !important;
    line-height: 1.08 !important;
    letter-spacing: -0.03em !important;
    color: var(--text-primary) !important;
}

body :where(.page-header, .page-header-copy):not(#pmc-root *) {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
    margin: 4px 0 12px !important;
    padding: 0 2px !important;
    text-align: left !important;
}

body :where(.page-header .icon-wrap):not(#pmc-root *) {
    width: 38px !important;
    height: 38px !important;
    border-radius: 13px !important;
    display: grid !important;
    place-items: center !important;
    background: var(--surface-muted) !important;
    color: var(--accent) !important;
    margin-bottom: 2px !important;
}

body :where(.page-header p, .step-desc, .login-subtitle, .visit-intro, .portal-card-desc, .section-note, .brand-sub):not(#pmc-root *) {
    max-width: 34ch !important;
    text-wrap: pretty;
}

body :where(.page-header p, .step-desc, .login-subtitle, .visit-intro, .portal-card-desc):not(#pmc-root *) {
    margin: 0 !important;
    font-size: 12px !important;
    line-height: 1.55 !important;
    color: var(--text-body) !important;
}

body :where(.page-header p br, .step-desc br, .login-subtitle br, .visit-intro br):not(#pmc-root *) {
    display: none !important;
}

body :where(.feedback-container, .fc-container, .visit-app, .content, .main-content, .page-wrap, .screen):not(#pmc-root *) {
    padding-top: 6px !important;
}

body :where(.back-btn, .visit-back, .topbar-back):not(#pmc-root *) {
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    padding: 0 12px !important;
    min-height: 40px !important;
    white-space: nowrap !important;
}

body :where(.back-btn i, .visit-back i, .topbar-back i):not(#pmc-root *) {
    font-size: 13px !important;
}

body :where(.brand-sub, .login-foot, .forgot-link, .char-count, small, .field small):not(#pmc-root *) {
    color: var(--text-muted) !important;
}

body :where(.login-foot, .char-count, small, .field small):not(#pmc-root *) {
    font-size: 11px !important;
    line-height: 1.45 !important;
}

@media (max-width: 640px) {
    body :where(.page-header p, .step-desc, .login-subtitle, .visit-intro, .portal-card-desc, .brand-sub):not(#pmc-root *) {
        max-width: none !important;
    }
}
