@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,500&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ============================================================ */
/* ROOT VARIABLES */
/* ============================================================ */
:root {
    --ink: #1F3A3D;
    --ink-2: #28494D;
    --paper: #F7F2EA;
    --paper-alt: #EFE6D3;
    --card: #FFFDF9;
    --rose: #C1666B;
    --rose-deep: #A64D53;
    --rose-tint: #F2DEDD;
    --sage: #748C77;
    --sage-tint: #DEE7DE;
    --amber: #C98A2E;
    --amber-tint: #736854;
    --charcoal: #3b4e54;
    --line: #DDD2BA;
    --white: #FFFDF9;
    --radius: 4px;
    --clinic-bg-img: url("../img/clinic-bg.jpg");
    --shadow: 0 1px 2px rgba(31,58,61,0.06), 0 6px 20px -8px rgba(31,58,61,0.18);

    --pink-light: #fdf2f5;
    --pink-pastel: #fce4ec;
    --pink-primary: #c1666b;
    --pink-dark: #a85459;
    --pink-text: #8a4a4a;
    --pink-sub: #5a3a3a;
    --pink-border: rgba(193, 102, 107, 0.10);
    --pink-border-card: rgba(193, 102, 107, 0.06);
    --pink-shadow: rgba(193, 102, 107, 0.18);
    --pink-ring-bg: #f0d0d4;

    --brown-pastel: #e8d5c8;
    --brown-dark: #2d1a10;
    --brown-text: #6b4a3a;
    --brown-border: rgba(139, 107, 90, 0.06);
    --brown-shadow: rgba(139, 107, 90, 0.14);

    --grey-text: #8a7f6f;
    --grey-light: #a8a29e;
}

/* ============================================================ */
/* RESET & BASE */
/* ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { overflow-x: hidden; }
body {
    background: var(--paper);
    color: var(--charcoal);
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}
/* Global responsive image safety-net.
   Any component that needs a fixed size still wins because
   its own selector is more specific than this generic rule. */
img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}
table { max-width: 100%; }
.mono { font-family: 'IBM Plex Mono', monospace; }
h1, h2, h3, h4 {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 .3em 0;
    letter-spacing: -0.01em;
}
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--rose-tint); }
:focus-visible { outline: 2px solid var(--rose-deep); outline-offset: 2px; }

/* ============================================================ */
/* UTILITY */
/* ============================================================ */
.hidden { display: none !important; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5em;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--paper);
    padding: .72em 1.3em;
    border-radius: var(--radius);
    font-size: .92rem;
    font-weight: 600;
    transition: transform .12s ease, background .15s ease;
}
.btn:hover { background: var(--ink-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-rose { background: var(--rose); border-color: var(--rose); }
.btn-rose:hover { background: var(--rose-deep); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--paper-alt); }
.btn-ghost-white {
    background: rgba(255, 255, 255, .14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .35);
}
.btn-ghost-white:hover { background: rgba(255, 255, 255, .24); color: #fff; }
.btn-sm { padding: .45em .9em; font-size: .8rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none !important; }

.tag {
    display: inline-flex;
    align-items: center;
    gap: .4em;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .68rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: .28em .6em;
    border-radius: 2px;
    border: 1px solid currentColor;
}
.tag-ok { color: var(--sage); background: var(--sage-tint); border-color: transparent; }
.tag-warn { color: var(--amber); background: var(--amber-tint); border-color: transparent; }
.tag-alert { color: var(--rose-deep); background: var(--rose-tint); border-color: transparent; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.field { margin-bottom: 1.1em; }
.field label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: .4em;
    letter-spacing: .01em;
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: .65em .8em;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
    font-size: .92rem;
    color: var(--charcoal);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--rose-deep); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1em; }
.hint { font-size: .76rem; color: #6b6157; margin-top: .35em; }
.divider { height: 1px; background: var(--line); margin: 1.4em 0; border: none; }

/* ============================================================ */
/* STAMP */
/* ============================================================ */
.stamp {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: .62rem;
    text-align: center;
    line-height: 1.15;
    transform: rotate(-6deg);
    letter-spacing: .02em;
    position: relative;
}
.stamp::before {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px dashed currentColor;
    border-radius: 50%;
    opacity: .55;
}
.stamp-t1 { color: var(--sage); }
.stamp-t2 { color: var(--amber); }
.stamp-t3 { color: var(--rose-deep); }

/* ============================================================ */
/* LANDING PAGE */
/* ============================================================ */
#view-landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
#view-landing::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--clinic-bg-img);
    background-size: cover;
    background-position: center;
    filter: blur(7px) brightness(.6) saturate(1.05);
    transform: scale(1.1);
    z-index: -2;
}
#view-landing::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(247, 242, 234, .9) 0%, rgba(247, 242, 234, .94) 55%, rgba(247, 242, 234, .97) 100%);
    z-index: -1;
}
.landing-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.3em 3em;
    border-bottom: 1px solid var(--line);
}
.brand {
    display: flex;
    align-items: center;
    gap: .6em;
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--ink);
}
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    padding: 2px;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}
.landing-nav-actions { display: flex; gap: .8em; }

.hero {
    flex: 1;
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 3em;
    align-items: center;
    padding: 4em 3em;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}
.hero-eyebrow {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .72rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--rose-deep);
    margin-bottom: 1em;
}
.hero h1 { font-size: 3rem; line-height: 1.05; max-width: 11em; }
.hero p {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #4a423a;
    max-width: 34em;
    margin: 1.1em 0 1.8em;
}
.hero-actions { display: flex; gap: 1em; align-items: center; flex-wrap: wrap; }

.ledger-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.6em;
    position: relative;
}
.ledger-card .ribbon {
    position: absolute;
    top: -10px;
    right: 28px;
    width: 26px;
    height: 52px;
    background: var(--rose);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
}
.ledger-title {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #8a7f6f;
    margin-bottom: .9em;
}
.ledger-row {
    display: flex;
    justify-content: space-between;
    padding: .6em 0;
    border-bottom: 1px dashed var(--line);
    font-size: .88rem;
}
.ledger-row:last-child { border-bottom: none; }
.ledger-row b { font-family: 'IBM Plex Mono', monospace; color: var(--ink); }

.week-track { display: flex; gap: 3px; margin-top: 1em; }
.week-tick { flex: 1; height: 8px; background: var(--paper-alt); border-radius: 1px; }
.week-tick.on { background: var(--rose); }

.feature-strip { background: var(--ink); color: var(--paper); padding: 3em; }
.feature-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2em;
}
.feature-grid .fi { border-top: 1px solid rgba(247, 242, 234, .25); padding-top: 1em; }
.feature-grid .fi h4 { color: var(--paper); font-size: .98rem; }
.feature-grid .fi p { font-size: .82rem; color: #c9d3d0; line-height: 1.5; margin: .4em 0 0; }

.compare-section { padding: 3.5em 3em; max-width: 1200px; margin: 0 auto; }
.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
    margin-top: 1.5em;
}
.compare-table th, .compare-table td {
    padding: .8em 1em;
    border: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
.compare-table th {
    background: var(--paper-alt);
    font-family: 'IBM Plex Mono', monospace;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.compare-table td.self { background: var(--rose-tint); font-weight: 600; }

.landing-footer {
    padding: 2em 3em;
    border-top: 1px solid var(--line);
    font-size: .78rem;
    color: #8a7f6f;
    display: flex;
    justify-content: space-between;
}

/* ============================================================ */
/* AUTH SCREENS */
/* ============================================================ */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2em;
}
.auth-box {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.4em;
}
.auth-box .brand { margin-bottom: 1.6em; }
.otp-boxes { display: flex; gap: .5em; margin: 1em 0; }
.otp-boxes input {
    width: 2.6em;
    text-align: center;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.1rem;
    padding: .5em 0;
}
.demo-note {
    background: var(--amber-tint);
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: .8em 1em;
    font-size: .8rem;
    color: #6b4d19;
    margin: 1em 0;
}
.switch-line {
    text-align: center;
    font-size: .85rem;
    margin-top: 1.2em;
    color: #6b6157;
}
.switch-line a {
    color: var(--rose-deep);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

/* ============================================================ */
/* APP SHELL — SATU SCROLLBAR SAHAJA (page-level) */
/* ============================================================ */
#app-shell {
    display: none;
    min-height: 100vh;
    /* No grid needed any more — the sidebar is position:fixed
       (see .sidebar below) and .main gets a matching margin-left
       instead. Grid + position:sticky was the cause of the sidebar
       "running out" and leaving blank space on long pages: a sticky
       item capped at height:100vh detaches once you scroll past
       that first screen, because align-items:start never stretched
       its box to match the (much taller) main content. */
}
#app-shell.active {
    display: block;
}

/* ===== SIDEBAR — fixed to the viewport, always visible, NO scrollbar ===== */
.sidebar {
    background: linear-gradient(165deg, #7A3E52 0%, #5C2E3E 100%);
    color: var(--paper);
    padding: 1em 1em .8em;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: 230px;
    height: 100vh;
    overflow: hidden;            /* ✅ TIADA SCROLL langsung */
    scrollbar-width: none;
    -ms-overflow-style: none;
    z-index: 500;
}
.sidebar::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}
.sidebar .brand {
    color: #fff;
    margin-bottom: .6em;
    font-size: 1.05rem;
    gap: .5em;
}
.sidebar .brand-mark { width: 28px; height: 28px; }
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .55em;
    padding: .4em .3em .7em;
    margin-bottom: .6em;
    border-bottom: 1px solid rgba(255, 255, 255, .18);
}
.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--rose-deep);
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-user-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-user-name {
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.2;
}
.sidebar-user-role {
    color: rgba(255, 255, 255, .65);
    font-size: .65rem;
}
.nav-group { margin-bottom: .7em; }
.nav-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .58rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255, 255, 255, .55);
    margin: 0 0 .35em .5em;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: .55em;
    padding: .38em .55em;
    border-radius: var(--radius);
    font-size: .78rem;
    color: rgba(255, 255, 255, .85);
    margin-bottom: .08em;
    text-decoration: none;
    transition: background .15s ease;
}
.nav-item i {
    font-size: .9rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}
.nav-item:hover { background: rgba(255, 255, 255, .12); cursor: pointer; }
.nav-item.active {
    /* highlight lut sinar (bukan putih penuh) supaya belon di belakang masih nampak */
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-weight: 700;
    box-shadow: inset 3px 0 0 #ffc9d4, 0 6px 16px -10px rgba(0, 0, 0, .35);
    backdrop-filter: blur(2px);
}
.nav-item.active i { color: #ffc9d4; }
.sidebar-foot {
    margin-top: auto;
    padding-top: .55em;
    border-top: 1px solid rgba(255, 255, 255, .18);
}
.who {
    font-size: .68rem;
    color: rgba(255, 255, 255, .75);
    margin-bottom: .4em;
    line-height: 1.3;
}
.who b {
    color: #fff;
    font-size: .7rem;
    display: block;
    margin-bottom: .1em;
}
.sidebar-foot .btn {
    padding: .42em .8em;
    font-size: .74rem;
    line-height: 1.2;
}

/* ===== SIDEBAR EMERGENCY — COMPACT ===== */
.sidebar-emergency {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #dc3545;
    border-radius: 10px;
    padding: 8px 10px;
    margin: 16px 0 12px 0;
}
.sidebar-emergency .emergency-list { line-height: 1.8; }
.sidebar-emergency .emergency-tel { text-decoration: none; }
.sidebar-emergency .emergency-tel:hover span,
.sidebar-emergency .emergency-tel:hover strong { color: #dc3545 !important; text-decoration: underline; }
.sidebar-emergency .emergency-header {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
}
.sidebar-emergency .emergency-header i { color: #dc3545; font-size: 13px; }
.sidebar-emergency .emergency-header span {
    font-weight: 700;
    font-size: 11.5px;
    color: #dc3545;
}
.sidebar-emergency ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 10.5px;
    line-height: 1.55;
}
.sidebar-emergency ul li i {
    width: 16px;
    color: #dc3545;
    font-size: 10.5px;
}
.sidebar-emergency ul li strong { color: var(--ink); }

/* ===== MAIN — natural flow, page scrolls ===== */
.main {
    padding: 2.2em 2.6em;
    margin-left: 230px;
    /* NO overflow-y, NO height: 100vh */
}

/* Mobile menu toggle — hidden by default (desktop); the
   @media (max-width: 900px) block further down switches this to
   display:flex. This base rule MUST stay ABOVE that media query in
   the file so the mobile override actually wins the cascade (two
   rules of equal specificity: later source order wins — if this were
   below the media query instead, display:none would always win and
   the button would never appear on phones). */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1002;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: #7A3E52;
    color: #fff;
    font-size: 1.2rem;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0,0,0,.25);
    cursor: pointer;
}
/* CSS-drawn 3-line icon that sits behind the <i class="bi bi-list">.
   If the Bootstrap Icons webfont fails to load (slow/blocked network
   on a phone), this still renders so the button is never invisible. */
.mobile-menu-toggle::before {
    content: "";
    position: absolute;
    left: 11px; top: 12px;
    width: 20px; height: 2px;
    background: #fff;
    box-shadow: 0 6px 0 #fff, 0 12px 0 #fff;
}
.mobile-menu-toggle i { position: relative; z-index: 1; }
.mobile-menu-toggle[aria-expanded="true"]::before { display: none; }

.main-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.8em;
    background: linear-gradient(120deg, var(--rose-deep) 0%, var(--rose) 55%, #C88A5A 130%);
    color: #fff;
    padding: 1.9em 2.1em;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 26px 50px -24px rgba(166, 77, 83, .45);
}
.main-head::before {
    content: "";
    position: absolute;
    top: -70px;
    right: -50px;
    width: 230px;
    height: 230px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    pointer-events: none;
}
.main-head::after {
    content: "";
    position: absolute;
    bottom: -90px;
    left: 28%;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .07);
    pointer-events: none;
}
.main-head > div { position: relative; z-index: 1; }
.main-head h2 { color: #fff; margin: 0; font-size: 1.5rem; font-family: 'Fraunces', serif; }
.main-head p {
    color: rgba(255, 255, 255, .85);
    font-size: .92rem;
    margin: .35em 0 0;
    max-width: 44em;
}
.main-head .stamp {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .4);
    backdrop-filter: blur(4px);
}
.main-head .stamp::before { border-color: rgba(255, 255, 255, .5); }
.main-head-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: .7em;
    flex-wrap: wrap;
    align-items: center;
}
.pill-btn {
    display: inline-flex;
    align-items: center;
    gap: .5em;
    padding: .55em 1.3em;
    border-radius: 30px;
    font-size: .85rem;
    font-weight: 700;
    text-decoration: none;
    border: 1.5px solid rgba(255, 255, 255, .5);
    color: #fff;
    background: rgba(255, 255, 255, .12);
    backdrop-filter: blur(4px);
    transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), background .2s ease;
}
.pill-btn:hover { background: rgba(255, 255, 255, .22); transform: translateY(-2px); color: #fff; }
.pill-btn.solid { background: #fff; color: var(--rose-deep); border-color: #fff; }
.pill-btn.solid:hover { background: #fff; color: var(--rose-deep); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4em; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.4em; }
.stat-card { padding: 1.3em 1.4em; }
.stat-card .k {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.9rem;
    color: var(--ink);
    font-weight: 600;
}
.stat-card .l {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #8a7f6f;
    margin-top: .3em;
}

/* ============================================================ */
/* RING CARD */
/* ============================================================ */
.ring-card { padding: 1.4em 1.2em; text-align: center; }
.ring-wrap {
    position: relative;
    width: 104px;
    height: 104px;
    margin: 0 auto .6em;
}
.ring-wrap svg { transform: rotate(-90deg); width: 104px; height: 104px; }
.ring-wrap .ring-bg { fill: none; stroke: var(--line); stroke-width: 9; }
.ring-wrap .ring-fg {
    fill: none;
    stroke-width: 9;
    stroke-linecap: round;
    transition: stroke-dashoffset .8s ease;
}
.ring-wrap .ring-txt {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--ink);
}
.ring-card .l { font-size: .78rem; color: #6b6157; font-weight: 600; }

/* ============================================================ */
/* SECTION CARD */
/* ============================================================ */
.section-card { padding: 1.6em 1.7em; margin-bottom: 1.4em; }
.section-card h3 { font-size: 1.1rem; display: flex; align-items: center; gap: .5em; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
    margin-top: 1em;
}
table.data-table th, table.data-table td {
    padding: .6em .7em;
    border-bottom: 1px solid var(--line);
    text-align: left;
}
table.data-table th {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #8a7f6f;
}
table.data-table tr:hover td { background: var(--paper-alt); }
.empty-state { padding: 2em; text-align: center; color: #8a7f6f; font-size: .88rem; }

/* ============================================================ */
/* DANGER ALERT */
/* ============================================================ */
.danger-alert-box {
    background: linear-gradient(120deg, #E4383F, #C1252C);
    color: #fff;
    border-radius: 18px;
    padding: 1.3em 1.6em;
    margin-bottom: 1.6em;
    box-shadow: 0 20px 40px -18px rgba(196, 30, 40, .5);
    animation: dangerPulse 2.2s ease-in-out infinite;
}
@keyframes dangerPulse {
    0%, 100% {
        box-shadow: 0 20px 40px -18px rgba(196, 30, 40, .5), 0 0 0 0 rgba(228, 56, 63, .5);
    }
    50% {
        box-shadow: 0 20px 40px -18px rgba(196, 30, 40, .5), 0 0 0 10px rgba(228, 56, 63, 0);
    }
}
.danger-alert-row {
    display: flex;
    align-items: center;
    gap: .8em;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: .6em;
}
.danger-alert-row:last-of-type { margin-bottom: .8em; }
.danger-alert-row i { font-size: 1.5rem; flex-shrink: 0; }
.danger-alert-hint {
    font-size: .8rem;
    color: rgba(255, 255, 255, .85);
    margin: 0;
    padding-top: .7em;
    border-top: 1px dashed rgba(255, 255, 255, .3);
}

/* ============================================================ */
/* TABS, CHART, CHAT, KICK */
/* ============================================================ */
.tabs {
    display: flex;
    gap: .3em;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.3em;
}
.tab {
    padding: .6em 1em;
    font-size: .85rem;
    font-weight: 600;
    color: #8a7f6f;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}
.tab.active { color: var(--rose-deep); border-color: var(--rose-deep); }
.chart-wrap { height: 220px; position: relative; }
.pill-list { display: flex; flex-wrap: wrap; gap: .5em; }

.tri-card { padding: 1.4em; display: flex; gap: 1em; align-items: flex-start; }
.tri-card p { font-size: .87rem; line-height: 1.55; color: #4a423a; margin: .5em 0 0; }

.chat-box { display: flex; flex-direction: column; height: 520px; }
.chat-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 1em 0;
    display: flex;
    flex-direction: column;
    gap: .8em;
}
.msg {
    max-width: 78%;
    padding: .7em 1em;
    border-radius: 10px;
    font-size: .88rem;
    line-height: 1.5;
}
.msg.bot {
    background: var(--paper-alt);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}
.msg.user {
    background: var(--rose);
    color: var(--white);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}
.chat-suggest { display: flex; flex-wrap: wrap; gap: .5em; margin: .6em 0 1em; }
.suggest-chip {
    border: 1px solid var(--line);
    background: var(--white);
    padding: .4em .8em;
    border-radius: 20px;
    font-size: .78rem;
}
.suggest-chip:hover { background: var(--paper-alt); }
.chat-input-row {
    display: flex;
    gap: .6em;
    border-top: 1px solid var(--line);
    padding-top: 1em;
}
.chat-input-row input {
    flex: 1;
    padding: .7em .9em;
    border: 1px solid var(--line);
    border-radius: 20px;
}

.kick-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 3px solid var(--rose);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 1em auto;
    background: var(--rose-tint);
}
.kick-circle .n {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 2.4rem;
    color: var(--rose-deep);
    font-weight: 700;
}
.kick-circle .l {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--rose-deep);
}

#toast {
    position: fixed;
    bottom: 1.5em;
    right: 1.5em;
    background: var(--ink);
    color: var(--paper);
    padding: 1em 1.3em;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: .85rem;
    max-width: 340px;
    z-index: 999;
    transform: translateY(140%);
    transition: transform .3s ease;
}
#toast.show { transform: translateY(0); }

.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(34, 40, 42, .5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 900;
    padding: 2em;
}
.modal-bg.show { display: flex; }
.modal-box {
    background: var(--card);
    border-radius: var(--radius);
    max-width: 620px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2em;
    box-shadow: var(--shadow);
}
.modal-close {
    float: right;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #8a7f6f;
}

/* ============================================================ */
/* ADDITIONS FOR PHP PAGES */
/* ============================================================ */
.alert-box {
    background: var(--rose-tint);
    border: 1px solid var(--rose);
    color: var(--rose-deep);
    padding: .9em 1.1em;
    border-radius: var(--radius);
    font-size: .85rem;
    margin-bottom: 1.2em;
}
.success-box {
    background: var(--sage-tint);
    border: 1px solid var(--sage);
    color: #2f4a33;
    padding: .9em 1.1em;
    border-radius: var(--radius);
    font-size: .85rem;
    margin-bottom: 1.2em;
}
.tabs a.tab { color: #8a7f6f; text-decoration: none; }
.tabs a.tab.active { color: var(--rose-deep); }
.nav-item { text-decoration: none; }
a.btn { text-decoration: none; }
form.inline { display: inline; }

/* ============================================================ */
/* ===== MOTHER PAGES (PINK PASTEL) ===== */
/* ============================================================ */
.mother-header {
    background:
        linear-gradient(135deg, rgba(193,102,107,.10), rgba(116,140,119,.10)),
        #EFE6D3;
    border-radius: 20px;
    padding: 1.2rem 1.8rem;
    margin-bottom: 1.4rem;
    border: 1px solid #DDD2BA;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}
.mother-header .header-bg-img {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 200px;
    background: url('https://images.pexels.com/photos/7484673/pexels-photo-7484673.jpeg?auto=compress&cs=tinysrgb&h=200&w=300&fit=crop') right center/cover no-repeat;
    opacity: 0.10;
    border-radius: 0 20px 20px 0;
}
.mother-header .header-text { position: relative; z-index: 1; }
.mother-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}
.mother-header h2 i { color: var(--pink-primary); }
.mother-header p { color: var(--grey-text); margin: 0.2rem 0 0; font-size: 0.92rem; }
.mother-header .header-icon {
    font-size: 2.2rem;
    color: var(--pink-primary);
    opacity: 0.4;
    position: relative;
    z-index: 1;
}
.mother-header .header-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.card-pink {
    background: var(--pink-pastel);
    border-radius: 16px;
    padding: 1.4rem 1.6rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--pink-border-card);
    margin-bottom: 1.4rem;
}
.card-pink h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card-pink h3 i { color: var(--pink-primary); }

.card-brown {
    background: var(--brown-pastel);
    border-radius: 16px;
    padding: 1.4rem 1.6rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--brown-border);
    margin-bottom: 1.4rem;
    color: var(--brown-dark);
}
.card-brown h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card-brown h3 i { color: #8b6b5a; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.4rem;
}
.stat-card-pink {
    border-radius: 16px;
    padding: 1rem 1.2rem;
    background: var(--pink-pastel);
    border: 1px solid rgba(193, 102, 107, 0.08);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    min-height: 120px;
    color: var(--pink-sub);
}
.stat-card-pink:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 16px 40px var(--pink-shadow);
    z-index: 5;
}
.stat-card-pink .stat-bg-img {
    position: absolute;
    right: -20px;
    bottom: -20px;
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: 16px;
    opacity: 0.50;
    transition: opacity 0.3s ease;
}
.stat-card-pink:hover .stat-bg-img { opacity: 0.75; }
.stat-card-pink .stat-icon {
    font-size: 1.6rem;
    opacity: 0.3;
    float: right;
    position: relative;
    z-index: 1;
    color: var(--pink-primary);
}
.stat-card-pink .stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    position: relative;
    z-index: 1;
    color: var(--pink-text);
}
.stat-card-pink .stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0.1rem 0 0.05rem;
    position: relative;
    z-index: 1;
    color: var(--pink-sub);
}
.stat-card-pink .stat-sub {
    font-size: 0.7rem;
    opacity: 0.7;
    position: relative;
    z-index: 1;
    color: #5a3a3a;
}

.ring-card-pink {
    background: var(--pink-pastel);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--pink-border-card);
    text-align: center;
}
.ring-wrap-pink .ring-bg { fill: none; stroke: var(--pink-ring-bg); stroke-width: 10; }
.ring-wrap-pink .ring-fg {
    fill: none;
    stroke: var(--pink-primary);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.week-track-wrap {
    background: var(--pink-pastel);
    border-radius: 16px;
    padding: 1rem 1.4rem;
    border: 1px solid var(--pink-border-card);
    margin-bottom: 1.4rem;
}
.week-track-wrap h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.week-track-wrap h3 i { color: var(--pink-primary); }
.week-track-pink { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.week-track-pink .week-tick {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background: var(--pink-ring-bg);
    flex-shrink: 0;
    transition: background 0.3s ease;
}
.week-track-pink .week-tick.on { background: var(--pink-primary); }
.week-track-pink .week-tick.current {
    background: var(--pink-dark);
    box-shadow: 0 0 0 3px rgba(193, 102, 107, 0.25);
}
.week-track-wrap .hint { margin-top: 0.4rem; font-size: 0.75rem; color: var(--grey-light); }

.buku-bar {
    background: linear-gradient(135deg, #fdf2f5, #fce4ec);
    border-radius: 16px;
    padding: 0.8rem 1.4rem;
    margin-bottom: 1.4rem;
    border: 1px dashed rgba(193, 102, 107, 0.20);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
}
.buku-bar .buku-note { display: flex; align-items: center; gap: 0.8rem; }
.buku-bar .buku-note .buku-img { width: 32px; height: 32px; object-fit: contain; opacity: 0.5; }
.buku-bar .buku-note p { margin: 0; font-size: 0.72rem; color: var(--grey-text); line-height: 1.4; }
.buku-bar .buku-note p strong { color: var(--ink); }
.buku-bar .quick-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.buku-bar .quick-actions .qa-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.8rem;
    border-radius: 30px;
    background: var(--white);
    border: 1px solid rgba(193, 102, 107, 0.12);
    text-decoration: none;
    color: var(--ink);
    font-size: 0.7rem;
    font-weight: 500;
    transition: all 0.25s ease;
}
.buku-bar .quick-actions .qa-btn:hover {
    background: var(--pink-pastel);
    border-color: var(--pink-primary);
    transform: translateY(-1px);
}
.buku-bar .quick-actions .qa-btn i { font-size: 0.9rem; color: var(--pink-primary); }
.buku-bar .quick-actions .qa-btn.primary {
    background: var(--pink-primary);
    color: var(--white);
    border-color: var(--pink-primary);
}
.buku-bar .quick-actions .qa-btn.primary i { color: var(--white); }
.buku-bar .quick-actions .qa-btn.primary:hover { background: var(--pink-dark); }

.alert-danger {
    background: #fef3f2;
    border-left: 4px solid #dc3545;
    border-radius: 12px;
    padding: 0.7rem 1.2rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}
.alert-danger i { color: #dc3545; font-size: 1.1rem; }
.alert-danger span { font-size: 0.88rem; color: #721c24; }

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.8rem;
}
.health-item-brown {
    border-radius: 14px;
    padding: 0.8rem 1rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
    min-height: 100px;
    border: 1px solid var(--brown-border);
    background: var(--brown-pastel);
    color: var(--brown-dark);
}
.health-item-brown:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 12px 32px var(--brown-shadow);
    z-index: 5;
}
.health-item-brown .hi-img {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 10px;
    opacity: 0.15;
    transition: opacity 0.3s ease;
}
.health-item-brown:hover .hi-img { opacity: 0.25; }
.health-item-brown .hi-value {
    font-size: 1.2rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
    color: var(--brown-dark);
}
.health-item-brown .hi-change { font-size: 0.7rem; font-weight: 600; position: relative; z-index: 1; }
.health-item-brown .hi-change.up { color: #2e7d32; }
.health-item-brown .hi-change.down { color: #c62828; }
.health-item-brown .hi-change.stable { color: #f57f17; }
.health-item-brown .hi-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.7;
    position: relative;
    z-index: 1;
    color: var(--brown-text);
}
.health-item-brown .hi-status { font-size: 0.65rem; font-weight: 600; position: relative; z-index: 1; }
.health-item-brown .hi-status.good { color: #2e7d32; }
.health-item-brown .hi-status.warning { color: #f57f17; }
.health-item-brown .hi-status.danger { color: #c62828; }

.btn-rose-pink {
    background: var(--pink-primary);
    color: var(--white);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
}
.btn-rose-pink:hover {
    background: var(--pink-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(193, 102, 107, 0.25);
    color: var(--white);
}
.btn-rose-pink-sm { padding: 0.4rem 0.9rem; font-size: 0.75rem; }

.btn-ghost-pink {
    background: transparent;
    color: var(--pink-text);
    border: 1px solid rgba(193, 102, 107, 0.20);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-ghost-pink:hover {
    background: var(--pink-pastel);
    border-color: var(--pink-primary);
    color: var(--pink-primary);
}
.btn-ghost-pink-sm { padding: 0.3rem 0.7rem; font-size: 0.7rem; }

.data-table-pink { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table-pink th {
    text-align: left;
    font-weight: 600;
    color: var(--pink-text);
    padding: 0.5rem 0.3rem;
    border-bottom: 2px solid rgba(193, 102, 107, 0.15);
}
.data-table-pink td {
    padding: 0.5rem 0.3rem;
    border-bottom: 1px solid rgba(193, 102, 107, 0.08);
    color: var(--ink);
}
.data-table-pink tr:last-child td { border-bottom: none; }
.data-table-pink tr:hover td { background: rgba(252, 228, 236, 0.3); }

.tabs-pink {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    background: var(--pink-pastel);
    padding: 4px;
    border-radius: 12px;
}
.tabs-pink .tab-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    background: transparent;
    color: var(--pink-text);
    border: none;
    cursor: pointer;
}
.tabs-pink .tab-btn:hover { background: rgba(255, 255, 255, 0.5); color: var(--pink-primary); }
.tabs-pink .tab-btn.active {
    background: var(--pink-primary);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(193, 102, 107, 0.25);
}

.field-pink { margin-bottom: 0.8rem; }
.field-pink label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--pink-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 4px;
}
.field-pink input, .field-pink select, .field-pink textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1.5px solid rgba(193, 102, 107, 0.20);
    border-radius: 10px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: var(--white);
    color: var(--ink);
}
.field-pink input:focus, .field-pink select:focus, .field-pink textarea:focus {
    border-color: var(--pink-primary);
    box-shadow: 0 0 0 4px rgba(193, 102, 107, 0.10);
    outline: none;
}
.field-pink input::placeholder, .field-pink textarea::placeholder { color: #b5a998; }
.field-pink .hint { font-size: 0.7rem; color: var(--grey-light); margin-top: 4px; }
.field-pink .hint i { color: var(--pink-primary); }
.field-row-pink { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }

.legend-box-pink {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
}
.legend-box-pink .item { display: flex; align-items: center; gap: 6px; }
.legend-box-pink .color-box {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 4px;
}
.legend-box-pink .color-green { background: #d4edda; border: 1px solid #28a745; }
.legend-box-pink .color-yellow { background: #fff3cd; border: 1px solid #ffc107; }
.legend-box-pink .color-red { background: #f8d7da; border: 1px solid #dc3545; }

.status-cell {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
}
.status-green { background: #d4edda; color: #155724; }
.status-yellow { background: #fff3cd; color: #856404; }
.status-red { background: #f8d7da; color: #721c24; }

.empty-state { text-align: center; padding: 30px 20px; color: var(--grey-light); }
.empty-state i { font-size: 2.5rem; color: #d5c0c4; display: block; margin-bottom: 8px; }

.chart-wrap {
    height: 200px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 10px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.4rem;
}

.tri-badge {
    display: inline-block;
    padding: 0.25rem 1.2rem;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--pink-pastel);
    color: var(--pink-primary);
}
.tri-badge.secondary { background: #e9ecef; color: var(--grey-text); margin-left: 0.4rem; }

.dash-pregnancy {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1.2rem;
    margin-bottom: 1.4rem;
}
.dash-pregnancy-img {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    overflow: hidden;
    border-radius: 16px;
    background: var(--pink-pastel);
    border: 1px solid var(--pink-border-card);
}
.dash-pregnancy-img img {
    width: 100%;
    height: 100%;
    min-height: 130px;
    max-height: 200px;
    object-fit: cover;
    border-radius: 12px;
}

/* ============================================================ */
/* RESPONSIVE */
/* ============================================================ */

/* Tablet / iPad range (e.g. iPad portrait 768–1024, small laptops).
   Keep the sidebar but make it narrower and let content grids
   drop to 2 columns so cards + images don't get squeezed/overlap. */
@media (max-width: 1100px) and (min-width: 901px) {
    .sidebar { width: 190px; }
    .main { margin-left: 190px; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .feature-grid { grid-template-columns: 1fr 1fr; }
    .dash-pregnancy { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    .hero { grid-template-columns: 1fr; }
    .feature-grid { grid-template-columns: 1fr 1fr; }
    #app-shell.active { display: block; }
    .mobile-menu-toggle { display: flex; }
    .main { margin-left: 0; }

    /* Mobile: sidebar BOLEH scroll (perlu sebab full-height) */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 250px;
        max-width: 80vw;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform .3s cubic-bezier(.25,.46,.45,.94);
        overflow-y: auto;
        scrollbar-width: thin;
        -ms-overflow-style: auto;
    }
    .sidebar::-webkit-scrollbar { display: block; width: 6px; }
    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,.25);
        border-radius: 3px;
    }
    .sidebar::-webkit-scrollbar-track { background: transparent; }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 12px 0 32px rgba(0,0,0,.3);
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 1000;
        opacity: 0;
        transition: opacity .3s ease;
    }
    .sidebar-overlay.active { display: block; opacity: 1; }

    /* Mobile: spacing sederhana — lapang sikit dari asal, tapi semua
       (termasuk butang Log out) MUAT dalam satu skrin tanpa scroll. */
    .sidebar { padding: .8em 1em .6em; }
    .sidebar .brand { display: none; }          /* logo dah ada dalam header atas */
    .sidebar-user {
        padding: .3em .3em clamp(.5em, 1.1vh, .8em);
        margin-bottom: clamp(.5em, 1.1vh, .8em);
    }
    .nav-label { margin-bottom: clamp(.3em, .7vh, .55em); }
    .nav-item {
        padding: clamp(4.8px, calc(4.6vh - 26px), 12px) .7em;   /* ikut tinggi skrin: isi ruang, tanpa scroll */
        margin-bottom: clamp(.05em, .2vh, .2em);
        font-size: .84rem;
    }
    .nav-item i { font-size: .98rem; }
    .nav-group { margin-bottom: .3em; }
    .sidebar-emergency { margin: clamp(6px, 1.2vh, 14px) 0 clamp(6px, 1vh, 12px) 0; padding: 10px 12px !important; }
    .sidebar-emergency > div:first-child { margin-bottom: 4px !important; }
    /* nombor kecemasan 2 kolum -> jimat ruang, tak perlu scroll */
    .sidebar-emergency .emergency-list {
        display: grid; grid-template-columns: 1fr 1fr; column-gap: 6px; line-height: 1.9;
    }
    .sidebar-emergency .emergency-list li { white-space: nowrap; }
    .sidebar-emergency .emergency-list li:last-child { grid-column: 1 / -1; }  /* nombor panjang ambil satu baris penuh */
    .sidebar-emergency > div:last-child { margin-top: 2px !important; padding-top: 4px !important; }
    .sidebar-foot { padding-top: .6em; }
    .sidebar-foot .who { margin-bottom: .4em; }

    .main { padding-top: 4.2rem; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .dash-pregnancy { grid-template-columns: 1fr; }
    .dash-pregnancy-img img { min-height: 100px; max-height: 160px; }
}

.sidebar-overlay { display: none; }

@media (max-width: 768px) {
    table.data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .mother-header {
        padding: 1rem 1.2rem;
        flex-direction: column;
        text-align: center;
    }
    .mother-header .header-bg-img { width: 100%; opacity: 0.06; }
    .buku-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .buku-bar .buku-note { justify-content: center; }
    .buku-bar .quick-actions { justify-content: center; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card-pink .stat-bg-img { width: 120px; height: 120px; opacity: 0.35; }
    .week-track-pink .week-tick { width: 12px; height: 12px; }
    .main { padding: 1rem 1.2rem; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .field-row-pink { grid-template-columns: 1fr; }
    .tabs-pink .tab-btn { font-size: 0.7rem; padding: 0.4rem 0.8rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .mother-header h2 { font-size: 1.2rem; }
    .buku-bar .quick-actions .qa-btn { font-size: 0.65rem; padding: 0.25rem 0.6rem; }
    .stat-card-pink .stat-bg-img { width: 100px; height: 100px; opacity: 0.30; }
    .week-track-pink .week-tick { width: 10px; height: 10px; }
    .data-table-pink { font-size: 0.75rem; }
    .card-pink, .card-brown { padding: 1rem; }
    .dash-pregnancy-img img { min-height: 80px; max-height: 120px; }
    .tabs-pink .tab-btn { font-size: 0.65rem; padding: 0.3rem 0.6rem; }
}
/* ============================================================
   LANGUAGE SWITCHER (EN / BM) — used in the sidebar footer
   ============================================================ */
.lang-switcher{
  display: flex; background: #fff; border-radius: 30px;
  padding: 3px; gap: 2px; width: fit-content;
}
.lang-switcher-btn{
  display: inline-flex; align-items: center; justify-content: center;
  padding: .4em .85em; border-radius: 24px; font-size: .68rem; font-weight: 700;
  color: #7A3E52; text-decoration: none; transition: background .2s ease, color .2s ease;
}
.lang-switcher-btn:hover{ background: #f3e6ea; }
.lang-switcher-btn.active{ background: #7A3E52; color: #fff; }


/* ===================================================================
   HEADER ATAS APP (mobile) — butang menu tak lagi terapung sendirian
   =================================================================== */
.app-topbar { display: none; }

@media (max-width: 900px) {
    .app-topbar {
        display: flex;
        align-items: center;
        gap: .8em;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 60px;
        padding: 0 14px;
        z-index: 1003;                 /* atas sidebar & overlay */
        background: linear-gradient(135deg, #7A3E52 0%, #5C2E3E 100%);
        box-shadow: 0 6px 18px -8px rgba(0,0,0,.35);
    }
    /* butang menu kini duduk DALAM header */
    .app-topbar .mobile-menu-toggle {
        position: static;
        display: flex;
        width: 40px; height: 40px;
        border-radius: 10px;
        background: rgba(255,255,255,.14);
        border: 1px solid rgba(255,255,255,.22);
        box-shadow: none;
        flex-shrink: 0;
    }
    .app-topbar .mobile-menu-toggle::before { display: none; }
    .app-topbar .mobile-menu-toggle:hover { background: rgba(255,255,255,.24); }

    .app-topbar-brand {
        display: flex; align-items: center; gap: .6em;
        text-decoration: none; color: #fff; min-width: 0;
    }
    .app-topbar-brand img {
        width: 34px; height: 34px; border-radius: 50%;
        background: #fff; padding: 2px; object-fit: contain; flex-shrink: 0;
    }
    .app-topbar-brand b {
        display: block; font-family: 'Fraunces', serif; font-size: 1.05rem; line-height: 1.1; color: #fff;
    }
    .app-topbar-brand span {
        display: block; font-size: .72rem; color: rgba(255,255,255,.75);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }

    /* sidebar mobile muncul BAWAH header, bukan menutupnya */
    .sidebar {
        top: 60px !important;
        height: calc(100vh - 60px) !important;
    }
    .sidebar-overlay { top: 60px; }

    /* ruang untuk header supaya kandungan (contoh: mesej berjaya) tak terlindung */
    .main { padding-top: calc(60px + 1.2rem) !important; }
}


/* ===================================================================
   SIDEBAR: 3 belon berwarna (statik, cuma bergoyang) — hiasan sahaja
   Duduk di ruang kosong sebelah kanan menu bawah, di belakang tulisan.
   =================================================================== */
.nav-group { position: relative; }
.nav-group .nav-item { position: relative; z-index: 1; }
/* Belon hanya dipapar dalam MOBILE (sidebar desktop kekal kemas) */
.sidebar-balloons { display: none; }
@media (max-width: 900px) {
    .sidebar-balloons { display: block; }
}
.sidebar-balloons {
    position: absolute;
    right: 2px;
    bottom: -4px;
    width: 74px;
    height: 118px;
    z-index: 0;
    pointer-events: none;
    opacity: .92;
}
.sidebar-balloons svg { width: 100%; height: 100%; overflow: visible; }
.sidebar-balloons .bln {
    transform-box: fill-box;
    transform-origin: 50% 100%;               /* goyang dari hujung tali */
    animation: sbBalloonSway 3.6s ease-in-out infinite;
}
.sidebar-balloons .bln-2 { animation-duration: 4.2s; animation-delay: -1.2s; }
.sidebar-balloons .bln-3 { animation-duration: 3.2s; animation-delay: -2.1s; }
@keyframes sbBalloonSway {
    0%, 100% { transform: rotate(-5deg); }
    50%      { transform: rotate(5deg); }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar-balloons .bln { animation: none; }
}


/* ===================================================================
   SIDEBAR: hati terapung naik perlahan di latar (macam menu index)
   Pudar & di belakang semua tulisan — tak ganggu bacaan.
   =================================================================== */
.sidebar > *:not(.sidebar-hearts) { position: relative; z-index: 1; }
.sidebar-hearts {
    position: absolute; inset: 0;
    overflow: hidden; pointer-events: none; z-index: 0;
}
.sidebar-hearts i {
    position: absolute; bottom: -40px; opacity: 0;
    color: #ffd1dc;
    animation: sbHeartRise 16s linear infinite;
}
.sidebar-hearts i:nth-child(1) { left: 8%;  font-size: 1.1rem; animation-delay: 0s;   animation-duration: 17s; }
.sidebar-hearts i:nth-child(2) { left: 26%; font-size: .8rem;  animation-delay: 4s;   animation-duration: 14s; color: #fff; }
.sidebar-hearts i:nth-child(3) { left: 46%; font-size: 1.4rem; animation-delay: 8s;   animation-duration: 19s; }
.sidebar-hearts i:nth-child(4) { left: 66%; font-size: .9rem;  animation-delay: 2s;   animation-duration: 15s; color: #f7b6c4; }
.sidebar-hearts i:nth-child(5) { left: 84%; font-size: 1.2rem; animation-delay: 11s;  animation-duration: 18s; }
.sidebar-hearts i:nth-child(6) { left: 16%; font-size: 1rem;   animation-delay: 13s;  animation-duration: 16s; color: #fff; }
.sidebar-hearts i:nth-child(7) { left: 58%; font-size: .75rem; animation-delay: 6s;   animation-duration: 13s; }
.sidebar-hearts i:nth-child(8) { left: 76%; font-size: 1.3rem; animation-delay: 15s;  animation-duration: 20s; color: #f7b6c4; }
@keyframes sbHeartRise {
    0%   { transform: translate(0, 0) rotate(-8deg) scale(.9); opacity: 0; }
    10%  { opacity: .16; }
    50%  { transform: translate(14px, -55vh) rotate(8deg) scale(1); }
    90%  { opacity: .16; }
    100% { transform: translate(-8px, -110vh) rotate(-6deg) scale(1.05); opacity: 0; }
}
/* mobile: animasi cuma jalan bila sidebar dibuka (jimat bateri) */
@media (max-width: 900px) {
    .sidebar:not(.open) .sidebar-hearts i { animation-play-state: paused; }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar-hearts { display: none; }
}


/* ===================================================================
   MOBILE: bila menu dibuka, header atas HILANG (tak bertindih)
   dan sidebar ambil tinggi penuh skrin dengan butang X sendiri.
   =================================================================== */
.sidebar-close { display: none; }
@media (max-width: 900px) {
    .app-topbar { transition: transform .3s cubic-bezier(.25,.46,.45,.94); }
    body.menu-open .app-topbar { transform: translateY(-100%); }

    body.menu-open .sidebar {
        top: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
    }
    body.menu-open .sidebar-overlay { top: 0; }

    .sidebar-close {
        display: flex; align-items: center; justify-content: center;
        position: absolute !important; top: 12px; right: 12px; z-index: 5 !important;
        width: 36px; height: 36px; border-radius: 10px;
        background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
        color: #fff; font-size: 1rem; cursor: pointer;
        transition: background .2s ease, transform .2s ease;
    }
    .sidebar-close:hover { background: rgba(255,255,255,.26); transform: rotate(90deg); }
    /* ruang supaya nama pengguna tak bertindih dengan butang X */
    .sidebar-user { padding-right: 46px !important; }
}

/* ===================================================================
   SIDEBAR: animasi "timbul" bila hover menu (Health Records, Kick Counter...)
   =================================================================== */
.nav-item {
    transition: background .2s ease, transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s ease;
}
.nav-item i { transition: transform .3s cubic-bezier(.34,1.56,.64,1); }
.nav-item:hover {
    transform: translateX(5px) translateY(-2px);
    box-shadow: 0 8px 18px -10px rgba(0,0,0,.45);
}
.nav-item:hover i { transform: scale(1.25) rotate(-8deg); }
.nav-item.active:hover { transform: translateY(-2px); }
.nav-item:active { transform: scale(.97); }
@media (prefers-reduced-motion: reduce) {
    .nav-item, .nav-item i { transition: none; }
    .nav-item:hover, .nav-item:hover i { transform: none; }
}


/* ===================================================================
   DESKTOP / TABLET LANDSCAPE: spacing sidebar ikut tinggi skrin.
   Skrin tinggi -> lebih lapang; skrin rendah -> rapat sikit.
   Sasaran: butang Log out SENTIASA kelihatan tanpa scroll.
   =================================================================== */
@media (min-width: 901px) {
    .sidebar { overflow-y: auto; }                 /* keselamatan saja; normalnya tak perlu scroll */
    .sidebar .brand { margin-bottom: clamp(.3em, calc(1.6vh - 6px), 1em); }
    .sidebar-user {
        padding: .3em .3em clamp(.4em, calc(1.4vh - 4px), 1em);
        margin-bottom: clamp(.3em, calc(1.4vh - 4px), 1em);
    }
    .nav-label { margin-bottom: clamp(.2em, calc(.9vh - 3px), .6em); }
    .nav-item {
        padding: clamp(4px, calc(2.8vh - 15px), 15px) .6em;
        margin-bottom: clamp(1px, calc(.7vh - 3px), 6px);
    }
    .nav-group { margin-bottom: clamp(.2em, calc(1vh - 4px), .8em); }
    .sidebar-emergency {
        margin: clamp(4px, calc(2vh - 10px), 22px) 0 clamp(4px, calc(1.6vh - 8px), 16px) 0 !important;
        padding: clamp(8px, calc(1.4vh - 1px), 14px) 12px !important;
    }
    .sidebar-emergency .emergency-list { line-height: clamp(1.5, calc(1.15 + .05vh), 1.95); }
    .sidebar-foot { padding-top: clamp(.35em, calc(1vh - 3px), .8em); }
}
/* skrin landskap rendah (contoh laptop 1366x768): nombor kecemasan 2 kolum */
@media (min-width: 901px) and (max-height: 720px) {
    .sidebar-emergency .emergency-list {
        display: grid; grid-template-columns: 1fr 1fr; column-gap: 4px; line-height: 1.7;
    }
    .sidebar-emergency .emergency-list li { white-space: nowrap; font-size: 11px; }
    .sidebar-emergency .emergency-list li:last-child { grid-column: 1 / -1; }
}

/* ===================================================================
   MOBILE (potret): animasi hover menu lebih lembut — tak terlalu menonjol
   =================================================================== */
@media (max-width: 900px) {
    .nav-item:hover {
        transform: translateX(3px) translateY(-1px);
        box-shadow: 0 4px 10px -8px rgba(0,0,0,.4);
    }
    .nav-item:hover i { transform: scale(1.1) rotate(-4deg); }
    .nav-item.active:hover { transform: translateY(-1px); }
}


/* Header mobile: satu baris (garis tiga + logo + tajuk halaman) */
@media (max-width: 900px) {
    .app-topbar {
        flex-direction: column; align-items: stretch;
        height: auto !important; padding: 0 !important; gap: 0 !important;
    }
    .app-topbar-row { display: flex; align-items: center; gap: .8em; height: 60px; padding: 0 14px; }
}


/* Cetak: header atas mobile, butang menu & hiasan sidebar tak dicetak (semua halaman) */
@media print {
    .app-topbar, .sidebar-overlay, .sidebar-hearts, .sidebar-close,
    .mobile-menu-toggle, .kick-toast { display: none !important; }
    .main { padding-top: 0 !important; }
}


/* ===================================================================
   SIDEBAR FOOT: butang EN/BM di ATAS nama pengguna & lebih besar,
   butang Log keluar lebih besar supaya mudah nampak & ditekan
   =================================================================== */
.sidebar-lang { margin: .1em 0 .55em; }
.sidebar-lang .lang-switcher { width: 100%; padding: 4px; box-shadow: 0 4px 12px -6px rgba(0,0,0,.35); }
.sidebar-lang .lang-switcher-btn { flex: 1; font-size: .82rem; padding: .5em .6em; letter-spacing: .04em; }
.sidebar-foot .who { margin-bottom: .55em; }
.sidebar-foot .btn.sidebar-logout {
    display: flex; align-items: center; justify-content: center; gap: .45em;
    padding: .62em .8em; font-size: .86rem; font-weight: 700; border-radius: 10px;
}
.sidebar-foot .btn.sidebar-logout i { font-size: 1rem; }
/* skrin rendah: rapatkan sikit supaya Log keluar tetap kelihatan tanpa scroll */
@media (max-height: 640px) {
    .sidebar-lang { margin-bottom: .35em; }
    .sidebar-lang .lang-switcher-btn { padding: .4em .6em; }
    .sidebar-foot .who { margin-bottom: .35em; }
    .sidebar-foot .btn.sidebar-logout { padding: .5em .8em; }
}

/* ===================================================================
   HEADER MOBILE: logo MamaAI di TENGAH, butang menu kekal di kiri
   =================================================================== */
@media (max-width: 900px) {
    .app-topbar-row { position: relative; justify-content: flex-start; }
    .app-topbar-row .app-topbar-brand {
        position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
        max-width: calc(100% - 120px);
    }
    .app-topbar-row .app-topbar-brand > div { text-align: left; min-width: 0; }
}


/* Sidebar: nama pengguna lebih besar & jelas */
.sidebar-foot .who { font-size: .76rem; }
.sidebar-foot .who b { font-size: .86rem; letter-spacing: .01em; margin-bottom: .2em; }
@media (max-height: 640px) {
    .sidebar-foot .who { font-size: .7rem; }
    .sidebar-foot .who b { font-size: .78rem; }
    .sidebar-lang { margin-bottom: .25em; }
}
@media (max-height: 640px) { .sidebar-foot { padding-top: .3em !important; } }
@media (min-width: 901px) and (max-height: 640px) { .sidebar-emergency { margin-top: 2px !important; margin-bottom: 2px !important; } }


/* Sidebar ADMIN: 4 belon diikat pada garis putih (atas bahagian bawah sidebar),
   bergoyang macam ditiup angin — hiasan sahaja, tak boleh ditekan */
.sidebar-balloons-wind {
    position: relative; z-index: 0; pointer-events: none;
    width: 110px; height: 150px;
    margin: auto auto -3px;              /* simpulan betul-betul atas garis putih */
    flex-shrink: 1; min-height: 0;
}
.sidebar-balloons-wind + .sidebar-foot { margin-top: 0; }
.sidebar-balloons-wind svg { width: 100%; height: 100%; overflow: visible; display: block; }
/* seluruh ikatan bergoyang dari simpulan (pada garis) */
.sidebar-balloons-wind .wind-bunch {
    transform-box: view-box; transform-origin: 60px 158px;
    animation: windBunch 5.5s ease-in-out infinite;
}
@keyframes windBunch {
    0%   { transform: rotate(-4deg); }
    20%  { transform: rotate(7deg); }
    35%  { transform: rotate(3deg); }
    55%  { transform: rotate(9deg); }
    75%  { transform: rotate(-2deg); }
    100% { transform: rotate(-4deg); }
}
/* setiap belon terapung & berpusing sendiri-sendiri */
.sidebar-balloons-wind .wb { transform-box: view-box; transform-origin: 60px 158px; }
.sidebar-balloons-wind .wb-1 { animation: windOne 3.2s ease-in-out infinite; }
.sidebar-balloons-wind .wb-2 { animation: windOne 3.8s ease-in-out -1.1s infinite reverse; }
.sidebar-balloons-wind .wb-3 { animation: windOne 2.9s ease-in-out -.6s infinite; }
.sidebar-balloons-wind .wb-4 { animation: windOne 4.2s ease-in-out -2s infinite reverse; }
@keyframes windOne {
    0%, 100% { transform: rotate(-3deg) translateY(0); }
    50%      { transform: rotate(4deg) translateY(-4px); }
}
@media (max-height: 700px) { .sidebar-balloons-wind { width: 80px; height: 110px; } }
@media (max-height: 600px) { .sidebar-balloons-wind { display: none; } .sidebar-balloons-wind + .sidebar-foot { margin-top: auto; } }
@media (prefers-reduced-motion: reduce) { .sidebar-balloons-wind * { animation: none !important; } }
.sidebar-user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role i { font-size: .9em; margin-right: .15em; }
