:root {
    --brand: #1d4e9e;
    --brand-dark: #153b78;
}

* { -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', sans-serif;
    background: #dfe3ec;
}
html.dark body { background: #0b1220; }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #b6bfd0; border-radius: 10px; }
html.dark ::-webkit-scrollbar-thumb { background: #3b4558; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* cards */
.card {
    background: #fff;
    border-radius: 1.5rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .08);
}
html.dark .card { background: #1a2232; box-shadow: none; border: 1px solid #263044; }

.soft { background: #f4f5f7; }
html.dark .soft { background: #222c3f; }

/* nav pills */
.nav-pill {
    display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left;
    padding: .72rem 1rem; border-radius: 1rem;
    font-size: .875rem; font-weight: 500; white-space: nowrap;
    color: var(--brand); transition: all .2s ease;
}
html.dark .nav-pill { color: #a9c4f0; }
.nav-pill:hover { background: rgba(29, 78, 158, .08); }
.nav-pill.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -6px rgba(29, 78, 158, .7); }

/* buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .6rem 1.1rem; border-radius: 999px; font-size: .85rem; font-weight: 600;
    transition: all .15s ease; cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #eef0f4; color: #374151; }
.btn-ghost:hover { background: #e2e6ed; }
html.dark .btn-ghost { background: #2a354a; color: #e5e7eb; }
html.dark .btn-ghost:hover { background: #34425c; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.6rem; height: 2.6rem; border-radius: 999px; background: #fff; color: #1f2937;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06); transition: transform .15s;
}
.icon-btn:hover { transform: translateY(-1px); }
html.dark .icon-btn { background: #1a2232; color: #e5e7eb; border: 1px solid #263044; }

.input {
    width: 100%; padding: .6rem 1rem; border-radius: 999px; font-size: .875rem;
    background: #fff; border: 1px solid #e3e6ec; outline: none; color: inherit;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 158, .15); }
html.dark .input { background: #1a2232; border-color: #2c3850; }

/* badges */
.badge { font-size: .7rem; font-weight: 600; padding: .2rem .65rem; border-radius: 999px; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #e5e7eb; color: #374151; }
html.dark .badge-green { background: #14532d; color: #bbf7d0; }
html.dark .badge-yellow { background: #713f12; color: #fde68a; }
html.dark .badge-red { background: #7f1d1d; color: #fecaca; }
html.dark .badge-blue { background: #1e3a8a; color: #bfdbfe; }
html.dark .badge-gray { background: #374151; color: #e5e7eb; }

/* view transition */
.view { animation: viewIn .35s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* heart */
.heart-beat { transform-origin: 50% 70%; animation: beat 1.2s ease-in-out infinite; }
@keyframes beat {
    0%, 100% { transform: scale(1); }
    12% { transform: scale(1.035); }
    24% { transform: scale(1); }
    36% { transform: scale(1.02); }
}
.ecg-line { stroke-dasharray: 400; stroke-dashoffset: 400; animation: ecg 2.4s linear infinite; }
@keyframes ecg { to { stroke-dashoffset: 0; } }
.glass { background: rgba(255, 255, 255, .55); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, .6); }
html.dark .glass { background: rgba(34, 44, 63, .6); border-color: rgba(255, 255, 255, .08); }

/* medication & day chips */
.med-row { display: flex; align-items: center; gap: .75rem; padding: .55rem .9rem .55rem .55rem; border-radius: 999px;
    background: #f4f5f7; border: 1px solid #e8eaee; cursor: pointer; transition: all .2s; }
html.dark .med-row { background: #222c3f; border-color: #2c3850; }
.med-row:hover { transform: translateX(3px); }
.med-row.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.med-row .ico { width: 2.4rem; height: 2.4rem; border-radius: 999px; background: #fff; display: grid; place-items: center; color: var(--brand); flex-shrink: 0; }
html.dark .med-row .ico { background: #1a2232; }

.day-chip { flex: 1; min-width: 3.2rem; padding: .6rem 0; border-radius: .9rem; background: #f4f5f7; text-align: center; font-size: .78rem; cursor: pointer; transition: all .2s; }
html.dark .day-chip { background: #222c3f; }
.day-chip b { display: block; font-size: .95rem; }
.day-chip.active { background: var(--brand); color: #fff; }

.dept-card { position: relative; overflow: hidden; cursor: pointer; transition: all .2s; }
.dept-card.active { background: #e6e8ec; }
html.dark .dept-card.active { background: #2a354a; }
.dept-card:hover { transform: translateY(-3px); }

.avatar { display: grid; place-items: center; border-radius: 999px; color: #fff; font-weight: 700; flex-shrink: 0;
    background: linear-gradient(135deg, #3b82f6, #1d4e9e); }

/* table */
.tbl { width: 100%; font-size: .875rem; border-collapse: separate; border-spacing: 0 .4rem; }
.tbl th { text-align: left; padding: .5rem 1rem; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: #6b7280; font-weight: 600; }
.tbl td { padding: .75rem 1rem; background: #f7f8fa; }
html.dark .tbl td { background: #222c3f; }
.tbl td:first-child { border-radius: 999px 0 0 999px; }
.tbl td:last-child { border-radius: 0 999px 999px 0; }

/* calendar */
.fc { font-size: .85rem; }
.fc .fc-button-primary { background: var(--brand); border-color: var(--brand); border-radius: 999px; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background: var(--brand-dark); border-color: var(--brand-dark); }
html.dark .fc { color: #e5e7eb; --fc-border-color: #2c3850; --fc-page-bg-color: #1a2232; --fc-neutral-bg-color: #222c3f; --fc-today-bg-color: rgba(59,130,246,.15); }
html.dark .fc a { color: #e5e7eb; }

/* guide */
.faq summary { cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq[open] summary ion-icon { transform: rotate(180deg); }
kbd { background: #eef0f4; border: 1px solid #d9dde5; border-bottom-width: 2px; padding: .05rem .45rem; border-radius: .4rem; font-size: .75rem; font-family: inherit; }
html.dark kbd { background: #2a354a; border-color: #3b4a66; }

/* sweetalert */
.swal2-popup { border-radius: 1.5rem !important; font-family: 'Inter', sans-serif !important; }
html.dark .swal2-popup { background: #1a2232; color: #e5e7eb; }
html.dark .swal2-title, html.dark .swal2-html-container { color: #e5e7eb !important; }
.swal-field { text-align: left; font-size: .8rem; font-weight: 600; margin: .7rem 1rem 0; }
.swal-field .input { margin-top: .25rem; border-radius: .9rem; }

/* vertical menu (left) */
.side-nav { transform: translateX(-100%); transition: transform .3s ease; }
.nav-pill ion-icon { font-size: 1.25rem; flex-shrink: 0; }
#navBackdrop { opacity: 0; pointer-events: none; transition: opacity .3s ease; }
body.nav-open #navBackdrop { opacity: 1; pointer-events: auto; }
body.nav-open { overflow: hidden; }
body.nav-open .side-nav { transform: none; }
@media (min-width: 1024px) {
    .side-nav { transform: none; }
    body.nav-open { overflow: auto; }
}

/* mobile polish */
@media (max-width: 640px) {
    .icon-btn { width: 2.4rem; height: 2.4rem; }
    .card { border-radius: 1.25rem; }
    .btn { padding: .55rem .95rem; }
    .tbl th, .tbl td { padding-left: .7rem; padding-right: .7rem; white-space: nowrap; }
    .fc .fc-toolbar { flex-direction: column; gap: .5rem; }
    .fc .fc-toolbar-title { font-size: 1.1rem; }
    .swal2-popup { width: 92% !important; }
}