:root {
    --bg: #eef1ff;
    --card: #ffffff;
    --primary: #5b5ce8;
    --primary-strong: #4949d8;
    --cyan: #46c7e8;
    --lavender: #e9ebff;
    --text: #17223b;
    --muted: #7c86a2;
    --border: #e5e8f4;
    --danger: #dc2626;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    background: linear-gradient(135deg, #ececff, #f7f9ff);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}
.eyebrow, .kicker { color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.muted { color: var(--muted); }
a { color: inherit; }

.guest-shell { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.auth-page { width: 100%; max-width: 440px; }
.auth-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 30px;
    box-shadow: 0 24px 70px rgba(68, 75, 140, .18);
}
.auth-brand-mark, .brand-mark, .profile-avatar, .doctor-chip span {
    background: linear-gradient(135deg, var(--cyan), var(--primary));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 900;
}
.auth-brand-mark { width: 74px; height: 74px; border-radius: 22px; margin-bottom: 18px; letter-spacing: .08em; }
.auth-panel h2 { margin: 0 0 10px; font-size: 28px; line-height: 1.12; }
.auth-form { display: grid; gap: 14px; margin-top: 22px; }
label { color: #34405c; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 13px;
    margin-top: 7px;
    color: var(--text);
    background: #fff;
    font-size: 15px;
}
textarea { min-height: 96px; resize: vertical; }
.check { display: flex; gap: 9px; align-items: center; }
.check input { width: auto; margin: 0; }

.button, .ghost-button {
    border: 0;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    min-height: 44px;
    padding: 11px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(91, 92, 232, .22);
}
.button-secondary { background: var(--lavender); color: var(--primary-strong); box-shadow: none; }
.button-danger { background: var(--danger); }
.auth-submit { width: 100%; }
.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.auth-link {
    color: var(--primary-strong);
    font-size: 13px;
    font-weight: 900;
    text-decoration: none;
}
.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.table-actions form {
    margin: 0;
}
.link-button {
    border: 0;
    background: transparent;
    color: var(--primary-strong);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    padding: 0;
}
.link-button.danger {
    color: var(--danger);
}

.app-shell {
    min-height: 100vh;
    width: min(100%, 1320px);
    margin: 0 auto;
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
.sidebar {
    background: rgba(255,255,255,.88);
    border: 1px solid var(--border);
    border-radius: 26px;
    padding: 14px;
    display: none;
    gap: 14px;
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; }
.brand strong { display: block; font-size: 15px; }
.brand small, .doctor-chip small { color: var(--muted); }
.sidebar-label { display: none; color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.side-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.side-nav a, .mobile-actions a {
    border-radius: 16px;
    background: #f4f6ff;
    color: var(--muted);
    text-decoration: none;
    padding: 12px;
    font-weight: 800;
    text-align: center;
}

.side-nav a {
    align-items: center;
    justify-content: center;
}
.side-nav a span {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: #fff;
    color: var(--primary);
    display: grid;
    place-items: center;
    margin: 0 auto 6px;
}

.side-nav a svg,
.mobile-actions a svg {
    display: block;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.side-nav a:focus-visible,
.mobile-actions a:focus-visible,
.side-logout:focus-visible {
    outline: 3px solid rgba(91, 92, 232, .25);
    outline-offset: 3px;
}
.side-nav a.active, .mobile-actions a.active { background: var(--primary); color: #fff; }
.side-logout { width: 100%; border: 0; background: #f4f6ff; color: var(--muted); border-radius: 16px; padding: 12px; font-weight: 800; cursor: pointer; }
.logout-form { margin: 0; }

.content-shell {
    background: rgba(255,255,255,.58);
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 28px;
    overflow: hidden;
}
.topbar { padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-back {
    border: 0;
    border-radius: 14px;
    background: rgba(255,255,255,.78);
    color: #5556e8;
    min-width: 44px;
    height: 44px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(80, 86, 160, .08);
}
.topbar-back svg { width: 20px; height: 20px; }
.topbar h1 { margin: 0; font-size: 22px; }
.doctor-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 8px 10px;
    text-decoration: none;
}
.doctor-chip span { width: 38px; height: 38px; border-radius: 50%; }
.doctor-chip span img {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}
.doctor-chip strong { display: block; font-size: 13px; white-space: nowrap; }
.mobile-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 14px 14px; }
.main-content { padding: 0 18px 22px; }

.welcome-grid { display: grid; gap: 14px; margin-bottom: 16px; }
.welcome-card {
    min-height: 138px;
    border-radius: 18px;
    background: linear-gradient(135deg, #5d5ee9, #6b6cf1);
    color: #fff;
    padding: 24px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    overflow: hidden;
}
.welcome-card .eyebrow, .welcome-card p { color: rgba(255,255,255,.82); }
.welcome-card h2 { margin: 0 0 10px; font-size: clamp(24px, 4vw, 34px); }
.hero-doctors { display: none; gap: 10px; align-items: end; }
.hero-doctors span { width: 52px; height: 118px; border-radius: 26px 26px 10px 10px; background: rgba(255,255,255,.28); }
.hero-doctors span:nth-child(2) { height: 145px; background: rgba(70,199,232,.8); }
.profile-card, .action-card, .form-card, .detail-card, .table-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 14px 36px rgba(78, 85, 148, .08);
}
.profile-card { display: grid; place-items: center; text-align: center; gap: 8px; }
.profile-avatar { width: 64px; height: 64px; border-radius: 50%; }
.quick-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.action-card { text-decoration: none; display: grid; gap: 8px; }
.action-card span { width: 46px; height: 46px; border-radius: 14px; background: var(--lavender); color: var(--primary); display: grid; place-items: center; font-weight: 900; }
.action-card strong { font-size: 19px; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.page-head h2 { margin: 0; font-size: 24px; }
.pill { border: 1px solid var(--border); border-radius: 999px; padding: 8px 11px; background: #fff; color: var(--muted); font-size: 13px; }
.form-card { display: grid; gap: 18px; }
.form-section { border-top: 1px solid var(--border); padding-top: 16px; }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-section h3 { margin: 0 0 12px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 13px; }
.certificate-form .form-section { scroll-margin-top: 18px; }
.segmented-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
.segmented-control label {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    min-width: 0;
    line-height: 1.15;
}
.segmented-control input { width: auto; margin: 0; flex: 0 0 auto; }
.segmented-control--patient {
    grid-template-columns: 1fr;
}
.segmented-control--patient label {
    min-height: 54px;
    justify-content: flex-start;
    text-align: left;
    padding: 12px 14px;
}
.exploration-field label { display: grid; gap: 8px; }
.exploration-field select, .exploration-field textarea { margin-top: 0; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.medicine-row { display: grid; grid-template-columns: 1fr; gap: 10px; border: 1px dashed var(--border); border-radius: 14px; padding: 12px; margin-bottom: 12px; position: relative; }
.medicine-remove {
    justify-self: end;
    border: 1px solid #fecaca;
    background: #fff7f7;
    color: var(--danger);
    border-radius: 999px;
    padding: 7px 10px;
    font-weight: 900;
    cursor: pointer;
}
.medicine-remove:hover { background: #fee2e2; }

.quick-text { display: flex; flex-wrap: wrap; gap: 9px; margin: 8px 0 14px; }
.quick-text button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 8px 10px;
    color: var(--primary);
    font-weight: 800;
    cursor: pointer;
}
.custom-quick { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 12px; }
.custom-quick input { margin-top: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.checks label { border: 1px solid var(--border); border-radius: 999px; padding: 8px 10px; background: #fff; font-size: 13px; }
.clinical-options {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}
.clinical-options > div {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fbfcff;
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
.clinical-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 12px;
    background: #fff;
    padding: 9px 10px;
    border: 1px solid var(--border);
}
.clinical-options input { width: auto; margin: 0; }
.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.section-title-row h3 { margin: 0; }
.icon-ai-button {
    width: 36px;
    height: 36px;
    border: 1px solid #dce5ff;
    border-radius: 12px;
    background: #fff;
    color: var(--primary);
    box-shadow: 0 8px 18px rgba(70, 199, 232, .16);
    display: grid;
    place-items: center;
    padding: 0;
    cursor: pointer;
}
.icon-ai-button svg { width: 20px; height: 20px; }
.icon-ai-button:hover { color: var(--cyan); transform: translateY(-1px); }
.switch-row {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fbfcff;
    padding: 12px 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.switch-row span { display: inline-flex; align-items: center; gap: 8px; color: var(--primary); }
.switch-row input[type="checkbox"] {
    width: 46px;
    height: 26px;
    margin: 0;
    appearance: none;
    border-radius: 999px;
    background: #d9def1;
    position: relative;
    padding: 0;
    border: 0;
}
.switch-row input[type="checkbox"]::after {
    content: "";
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 3px;
    left: 3px;
    box-shadow: 0 2px 6px rgba(23, 34, 59, .18);
    transition: transform .18s ease;
}
.switch-row input[type="checkbox"]:checked { background: linear-gradient(135deg, var(--cyan), var(--primary)); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(20px); }
.switch-row em { font-style: normal; font-weight: 900; min-width: 20px; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(23, 34, 59, .32);
    display: grid;
    place-items: center;
    padding: 24px;
    backdrop-filter: blur(8px);
}
.modal-backdrop[hidden] { display: none; }
.signature-modal {
    width: min(96vw, 760px);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 28px;
    box-shadow: 0 26px 80px rgba(23, 34, 59, .22);
    position: relative;
}
.signature-modal h3 { margin: 0 0 8px; font-size: 24px; }
.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #f4f6ff;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
}
.signature-pad-wrap {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fbfcff;
    padding: 10px;
    margin-top: 14px;
}
.signature-pad {
    width: 100%;
    height: 260px;
    border-radius: 14px;
    background: #fff;
    border: 1px dashed #cfd6ea;
    touch-action: none;
    display: block;
}
.signature-pad-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.signature-actions { display: grid; gap: 10px; margin-top: 16px; }
.signature-choice {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    color: var(--text);
    padding: 12px;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(78, 85, 148, .07);
}
.signature-choice strong { display: block; font-size: 15px; }
.signature-choice span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.signature-choice:hover { border-color: #c4ccff; color: var(--primary-strong); }
.sign-trigger { width: fit-content; }
.modal-open .sidebar,
.modal-open .mobile-actions {
    display: none !important;
}
.saved-signatures {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}
.saved-signatures[hidden] { display: none; }
.saved-signature-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px;
    background: #fbfcff;
}
.saved-signature-item button {
    border: 0;
    border-radius: 10px;
    background: #f4f6ff;
    color: var(--text);
    padding: 9px 10px;
    text-align: left;
    font-weight: 800;
    cursor: pointer;
}
.saved-signature-item .saved-signature-delete {
    color: #b42318;
    background: #fff1f1;
}
.sticky-actions {
    position: static;
    bottom: auto;
    z-index: 6;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    backdrop-filter: none;
}
.sticky-actions .button { flex: 1 1 100%; }

.offline-banner, .flash-success, .flash-error { border-radius: 14px; padding: 12px; margin-bottom: 14px; }
.offline-banner { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }
.setup-banner {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
    margin-bottom: 16px;
    display: grid;
    gap: 10px;
    box-shadow: 0 14px 36px rgba(78, 85, 148, .08);
}
.setup-banner strong { display: block; }
.setup-banner small { color: var(--muted); }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.preview-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    min-height: 360px;
    overflow: hidden;
    box-shadow: 0 14px 36px rgba(78, 85, 148, .08);
}
.preview-box iframe { width: 100%; min-height: 620px; border: 0; background: #fff; }
.preview-box img { display: block; width: 100%; height: auto; }
.preview-box p { padding: 18px; }
.code-editor {
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.45;
    min-height: 520px;
    white-space: pre;
}
.template-editor-grid { display: grid; gap: 14px; }
.template-live-preview iframe { min-height: 520px; }
.table-card { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { text-align: left; border-bottom: 1px solid var(--border); padding: 11px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }

.history-toolbar {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 10px;
    box-shadow: 0 14px 36px rgba(78, 85, 148, .06);
}
.history-toolbar input { margin-top: 0; }
.prescription-history {
    display: grid;
    gap: 14px;
}
.rx-history-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 14px 36px rgba(78, 85, 148, .08);
    position: relative;
    overflow: hidden;
}
.rx-history-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--cyan), var(--primary));
}
.rx-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #d9dce8;
    font-family: Georgia, "Times New Roman", serif;
}
.rx-history-header > div {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.rx-mark {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    background: #f7f8ff;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-weight: 900;
}
.rx-history-header strong {
    font-size: 18px;
    color: #111;
    overflow-wrap: anywhere;
}
.rx-history-header time {
    color: var(--muted);
    white-space: nowrap;
}
.rx-history-lines {
    display: grid;
    gap: 10px;
    margin: 14px 0;
}
.rx-line {
    display: grid;
    grid-template-columns: 94px 1fr;
    align-items: end;
    gap: 8px;
}
.rx-line span {
    color: #111;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.rx-line strong {
    min-height: 22px;
    border-bottom: 1px solid #c9ccd7;
    padding-bottom: 3px;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.rx-history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}
.rx-history-meta span {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 10px;
    color: var(--muted);
    background: #fbfcff;
    font-size: 12px;
    font-weight: 800;
}
.rx-history-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

@media (min-width: 760px) {
    .app-shell { grid-template-columns: 190px 1fr; padding: 28px; }
    .sidebar { display: grid; align-content: start; padding: 18px; }
    .sidebar-label { display: block; }
    .side-nav { grid-template-columns: 1fr; }
    .mobile-actions { display: none; }
    .main-content { padding: 0 24px 24px; }
    .topbar { padding: 24px; }
    .welcome-grid { grid-template-columns: 1fr 210px; }
    .hero-doctors { display: flex; }
    .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .setup-banner { grid-template-columns: 1fr auto; align-items: center; }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .segmented-control--patient { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .segmented-control--patient label { justify-content: center; text-align: center; }
    .medicine-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .medicine-remove { grid-column: 1 / -1; }
    .clinical-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .template-editor-grid { grid-template-columns: minmax(0, 1fr) minmax(320px, .85fr); align-items: stretch; }
    .clinical-options > div { align-content: start; }
    .sticky-actions { position: static; background: transparent; border: 0; padding: 0; backdrop-filter: none; }
    .sticky-actions .button { flex: 0 1 auto; }
    .prescription-history { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rx-history-actions { grid-template-columns: auto auto; justify-content: end; }
}

@media (min-width: 1080px) {
    .app-shell { grid-template-columns: 220px 1fr; }
    .form-grid.form-grid--compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Visual refresh v21: hospital dashboard layout */
body {
    background:
        linear-gradient(90deg, rgba(193, 199, 249, .78) 0 70%, rgba(212, 216, 255, .78) 70% 100%),
        #d9ddff;
}

.app-shell {
    width: min(100%, 1180px);
    min-height: 100vh;
    padding: 14px 14px 100px;
    gap: 0;
    position: relative;
}

.content-shell {
    border-radius: 28px;
    background: rgba(246, 247, 255, .9);
    border: 1px solid rgba(255,255,255,.82);
    box-shadow: 0 28px 80px rgba(75, 80, 166, .16);
    overflow: visible;
}

.topbar {
    padding: 24px 24px 12px;
}

.topbar h1 {
    font-size: clamp(22px, 3vw, 30px);
    color: #151934;
}

.doctor-chip {
    border-radius: 24px;
    padding: 9px 12px;
    box-shadow: 0 14px 34px rgba(80, 86, 160, .08);
}

.doctor-chip span {
    background: linear-gradient(135deg, #58d1e8, #5b5ce8);
}

.main-content {
    padding: 0 18px 22px;
}

.sidebar {
    background: linear-gradient(180deg, #6667f0, #5657e4);
    border: 0;
    box-shadow: 0 24px 50px rgba(65, 70, 204, .24);
}

.brand {
    color: #fff;
}

.brand small {
    color: rgba(255,255,255,.72);
}

.brand-mark {
    background: rgba(255,255,255,.18);
    color: #fff;
}

.side-nav a {
    background: transparent;
    color: rgba(255,255,255,.76);
    padding: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 7px;
    text-align: center;
    border-radius: 20px;
    min-height: 62px;
    transition: transform .18s ease, color .18s ease, background .18s ease;
}

.side-nav a span {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: rgba(255,255,255,.12);
    color: #fff;
    display: grid;
    place-items: center;
    margin: 0;
    transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.side-nav a svg,
.mobile-actions svg,
.settings-tile svg,
.side-logout svg {
    width: 24px;
    height: 24px;
    stroke-width: 2.15;
}

.side-nav a em {
    font-style: normal;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.1;
}

.side-nav a.active span {
    background: rgba(255,255,255,.28);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}

.side-nav a.active {
    background: transparent;
    color: #fff;
}

.side-nav a:hover,
.side-nav a:focus-visible {
    color: #fff;
    transform: translateY(-1px);
}

.side-nav a:hover span,
.side-nav a:focus-visible span {
    background: rgba(255,255,255,.22);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}

.side-logout {
    display: grid;
    justify-items: center;
    gap: 6px;
    color: #fff;
    background: transparent;
}

.side-logout svg {
    width: 26px;
    height: 26px;
}

.side-logout span {
    font-size: 11px;
}

.mobile-actions {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 14px;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    border-radius: 26px;
    background: rgba(255,255,255,.92);
    border: 1px solid rgba(229,232,244,.9);
    box-shadow: 0 18px 50px rgba(75, 80, 166, .24);
    backdrop-filter: blur(16px);
    transition: transform .24s ease, opacity .24s ease;
    will-change: transform, opacity;
}

.mobile-actions.is-hidden {
    transform: translateY(calc(100% + 28px));
    opacity: 0;
    pointer-events: none;
}

.mobile-actions a {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 4px;
    border-radius: 20px;
    min-height: 58px;
    padding: 8px 4px;
    color: #8a91ad;
    background: transparent;
    text-decoration: none;
    font-size: 11px;
    font-weight: 900;
    transition: transform .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
}

.mobile-actions a svg {
    margin: 0 auto;
}

.mobile-actions a:hover,
.mobile-actions a:focus-visible {
    color: #5556e8;
    background: #f4f6ff;
    transform: translateY(-1px);
}

.mobile-actions a.active {
    color: #fff;
    background: linear-gradient(135deg, #6667f0, #5556e8);
    box-shadow: 0 12px 24px rgba(86, 87, 228, .22);
}

.medical-dashboard {
    display: grid;
    gap: 18px;
}

.medical-dashboard--simple {
    max-width: 860px;
}

.dashboard-main-panel,
.dashboard-profile-panel,
.settings-hub {
    min-width: 0;
}

.dashboard-hero {
    min-height: 124px;
    border-radius: 22px;
    padding: 26px;
    background: linear-gradient(135deg, #6263ee, #696af2);
    color: #fff;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 18px 40px rgba(87, 88, 226, .22);
}

.dashboard-hero p {
    margin: 0 0 8px;
    font-size: clamp(24px, 4vw, 30px);
}

.dashboard-hero span {
    color: rgba(255,255,255,.82);
    font-weight: 700;
}

.hero-orbit {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    border: 18px solid rgba(255,255,255,.62);
    border-left-color: transparent;
    transform: rotate(-30deg);
}

.dashboard-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 28px 0 14px;
}

.dashboard-section-head h2 {
    margin: 0;
    font-size: 18px;
}

.dashboard-section-head span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

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

.report-card {
    min-height: 132px;
    border-radius: 18px;
    background: #fff;
    color: #151934;
    text-decoration: none;
    padding: 16px;
    display: grid;
    align-content: center;
    justify-items: start;
    gap: 8px;
    box-shadow: 0 14px 34px rgba(80, 86, 160, .08);
}

.report-card small {
    color: #a3a9bd;
    font-weight: 700;
}

.report-card strong {
    font-size: 18px;
}

.report-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 950;
}

.report-icon-blue { background: linear-gradient(135deg, #6263ee, #4f80ff); }
.report-icon-cyan { background: linear-gradient(135deg, #56d4e0, #50bfd6); }
.report-icon-pink { background: linear-gradient(135deg, #ff5b82, #ff4778); }
.report-icon-purple { background: linear-gradient(135deg, #5587ff, #6263ee); }

.report-grid--simple .report-icon svg {
    width: 22px;
    height: 22px;
}

.timeline-card {
    margin-top: 26px;
    border-radius: 18px;
    background: #fff;
    padding: 16px;
    box-shadow: 0 14px 34px rgba(80, 86, 160, .08);
}

.timeline-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.timeline-head button {
    border: 0;
    background: transparent;
    font-size: 26px;
    color: #151934;
}

.timeline-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    text-align: center;
}

.timeline-days div {
    border-radius: 14px;
    padding: 7px 3px;
    color: #8a91ad;
}

.timeline-days .active {
    background: #f0f1ff;
    color: #5b5ce8;
}

.timeline-days small,
.timeline-days strong {
    display: block;
}

.timeline-lanes {
    position: relative;
    min-height: 134px;
    margin-top: 16px;
    border-top: 1px solid #eef0f8;
}

.lane {
    position: absolute;
    left: 6%;
    right: 44%;
    top: 24px;
    border-radius: 16px;
    padding: 12px 14px;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 900;
}

.lane-pink {
    left: 54%;
    right: 4%;
    top: 24px;
    background: #ff4f7d;
}

.lane-cyan {
    left: 28%;
    right: 18%;
    top: 84px;
    background: #55d0df;
}

.lane-primary { background: #6263ee; }

.dashboard-profile-panel {
    border-radius: 24px;
    background: rgba(255,255,255,.84);
    padding: 24px;
    text-align: center;
    box-shadow: 0 14px 34px rgba(80, 86, 160, .08);
    position: relative;
}

.profile-notification {
    position: absolute;
    right: 22px;
    top: 18px;
    color: #ff4f7d;
    font-size: 30px;
}

.profile-portrait {
    width: 92px;
    height: 92px;
    margin: 26px auto 14px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 25%, #fff 0 4px, transparent 5px),
        linear-gradient(135deg, #58d1e8, #5b5ce8);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 28px;
    font-weight: 950;
    box-shadow: 0 0 0 8px #f1f2ff, 0 0 0 11px #6263ee;
}

.dashboard-profile-panel > strong {
    display: block;
    font-size: 18px;
}

.dashboard-profile-panel > span {
    color: var(--muted);
    font-size: 13px;
}

.profile-list {
    display: grid;
    gap: 10px;
    margin: 26px 0;
    text-align: left;
}

.profile-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 16px;
    background: #f7f8ff;
    padding: 12px 14px;
}

.profile-list small {
    color: var(--muted);
    font-weight: 800;
}

.profile-chart {
    min-height: 160px;
    border-radius: 22px;
    background: linear-gradient(135deg, #6263ee, #4d4fdd);
    color: #fff;
    display: grid;
    place-items: center;
    align-content: center;
    position: relative;
    overflow: hidden;
}

.profile-chart strong {
    font-size: 30px;
}

.profile-chart span {
    color: rgba(255,255,255,.76);
    font-weight: 800;
}

.profile-chart i {
    position: absolute;
    left: -10%;
    right: -10%;
    bottom: 34px;
    height: 54px;
    background: none;
    border-bottom: 4px solid #ff6384;
    border-radius: 50%;
    transform: rotate(-6deg);
}

.settings-hub {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.settings-tile {
    min-height: 154px;
    border-radius: 22px;
    background: #fff;
    border: 1px solid rgba(229,232,244,.9);
    text-decoration: none;
    color: #151934;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 14px;
    box-shadow: 0 14px 34px rgba(80, 86, 160, .08);
}

.settings-tile span {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #6263ee, #58d1e8);
}

.settings-tile strong {
    font-size: 17px;
}

.medicine-row label {
    position: relative;
}

.medicine-row label.field-compact {
    font-size: 0;
}

.medicine-row label.field-compact input,
.medicine-row label.field-compact textarea,
.medicine-row label.field-compact small {
    font-size: 14px;
}

.medicine-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    display: grid;
    gap: 6px;
    max-height: 260px;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(75, 80, 166, .18);
}

.medicine-suggestions button {
    border: 0;
    border-radius: 12px;
    background: #f7f8ff;
    color: var(--text);
    padding: 9px 10px;
    text-align: left;
    cursor: pointer;
}

.medicine-suggestions strong,
.medicine-suggestions span {
    display: block;
}

.medicine-suggestions span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.presentation-help,
.presentation-options,
.signature-soft-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.presentation-help {
    display: block;
    color: #8b95a7;
    font-size: 11px;
    line-height: 1.35;
    font-style: italic;
    font-weight: 500;
}

.presentation-options button,
.signature-soft-actions button,
.signature-soft-actions a {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--primary);
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

@media (min-width: 760px) {
    .app-shell {
        grid-template-columns: 98px 1fr;
        padding: 58px 36px;
    }

    .sidebar {
        display: grid;
        grid-template-rows: auto 1fr auto;
        width: 98px;
        min-height: calc(100vh - 116px);
        border-radius: 28px;
        padding: 22px 14px;
        justify-items: center;
        z-index: 3;
        align-content: initial;
    }

    .brand span:not(.brand-mark),
    .side-nav a em,
    .side-logout span {
        display: none;
    }

    .brand-mark {
        width: 54px;
        height: 54px;
        border-radius: 18px;
    }

    .side-nav {
        grid-template-columns: 1fr;
        align-content: start;
        gap: 24px;
        margin-top: 52px;
    }

    .logout-form {
        align-self: end;
    }

    .content-shell {
        margin-left: -24px;
        padding-left: 56px;
        min-height: calc(100vh - 116px);
        border-radius: 26px;
    }

    .mobile-actions {
        display: none;
    }

    .main-content {
        padding: 0 24px 28px 0;
    }

    .medical-dashboard {
        grid-template-columns: minmax(0, 1fr) 280px;
        gap: 28px;
    }

    .medical-dashboard--simple {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .report-grid--simple {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .settings-hub {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1080px) {
    .app-shell {
        grid-template-columns: 110px 1fr;
    }

    .sidebar {
        width: 110px;
    }

    .content-shell {
        padding-left: 70px;
    }

    .medical-dashboard {
        grid-template-columns: minmax(0, 1fr) 300px;
    }

    .medical-dashboard--simple {
        grid-template-columns: minmax(0, 1fr);
    }
}

.dashboard-counts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.dashboard-count-card {
    min-width: 0;
    border-radius: 18px;
    background: rgba(255,255,255,.92);
    border: 1px solid rgba(229,232,244,.92);
    box-shadow: 0 14px 34px rgba(80, 86, 160, .08);
    color: #151934;
    display: grid;
    gap: 2px;
    padding: 15px 16px;
    text-decoration: none;
}

.dashboard-count-card span {
    color: #5556e8;
    font-size: 28px;
    font-weight: 950;
    line-height: 1;
}

.dashboard-count-card strong {
    font-size: 15px;
}

.dashboard-count-card small {
    color: #8a91ad;
    font-size: 12px;
    font-weight: 800;
}

.mobile-home-logout {
    display: none;
}

@media (max-width: 759px) {
    html {
        scroll-padding-bottom: 96px;
    }

    body {
        background: linear-gradient(180deg, #dfe3ff 0, #f5f7ff 38%, #f8f9ff 100%);
    }

    .app-shell {
        display: block;
        width: 100%;
        min-height: 100vh;
        padding: 10px 10px 104px;
    }

    .sidebar {
        display: none;
    }

    .content-shell {
        border-radius: 24px;
        background: rgba(248,249,255,.94);
        box-shadow: 0 18px 48px rgba(75, 80, 166, .12);
        overflow: visible;
    }

    .topbar {
        align-items: flex-start;
        gap: 10px;
        padding: 14px 14px 8px;
    }

    .topbar-title {
        gap: 8px;
        min-width: 0;
    }

    .topbar h1 {
        font-size: 21px;
        line-height: 1.08;
        word-break: normal;
    }

    .eyebrow {
        font-size: 10px;
        line-height: 1.2;
        max-width: 190px;
    }

    .topbar-back {
        min-width: 40px;
        height: 40px;
        border-radius: 14px;
        padding: 0 10px;
    }

    .topbar-back span {
        display: none;
    }

    .doctor-chip {
        flex: 0 0 auto;
        border-radius: 18px;
        gap: 8px;
        padding: 6px;
    }

    .doctor-chip span {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }

    .doctor-chip div {
        display: none;
    }

    .main-content {
        padding: 0 12px 18px;
    }

    .medical-dashboard {
        gap: 14px;
    }

    .medical-dashboard--simple {
        max-width: none;
    }

    .mobile-home-logout {
        display: flex;
        justify-content: flex-end;
        margin: -2px 0 8px;
    }

    .mobile-home-logout button {
        min-height: 34px;
        border: 1px solid rgba(138,145,173,.22);
        border-radius: 999px;
        background: rgba(255,255,255,.58);
        color: #8a91ad;
        box-shadow: none;
        cursor: pointer;
        font-size: 12px;
        font-weight: 900;
        padding: 7px 12px;
    }

    .dashboard-hero {
        min-height: 112px;
        border-radius: 22px;
        padding: 20px;
        align-items: flex-end;
    }

    .dashboard-hero p {
        font-size: 24px;
        line-height: 1.08;
        max-width: 260px;
    }

    .dashboard-hero span {
        display: block;
        font-size: 14px;
        line-height: 1.35;
        max-width: 250px;
    }

    .dashboard-counts {
        gap: 10px;
        margin-top: 10px;
    }

    .dashboard-count-card {
        border-radius: 16px;
        padding: 13px 14px;
    }

    .dashboard-count-card span {
        font-size: 25px;
    }

    .dashboard-section-head {
        margin: 20px 0 10px;
    }

    .report-grid,
    .report-grid--simple,
    .quick-grid,
    .settings-hub {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .report-card {
        min-height: 86px;
        border-radius: 18px;
        grid-template-columns: auto minmax(0, 1fr);
        align-content: center;
        align-items: center;
        gap: 8px 12px;
        padding: 14px;
    }

    .report-card small,
    .report-card strong {
        grid-column: 2;
    }

    .report-card small {
        align-self: end;
    }

    .report-card strong {
        align-self: start;
        font-size: 17px;
    }

    .report-icon {
        grid-row: 1 / span 2;
        width: 46px;
        height: 46px;
        border-radius: 16px;
    }

    .form-card,
    .detail-card,
    .table-card,
    .profile-card,
    .action-card,
    .history-toolbar {
        border-radius: 18px;
        padding: 14px;
    }

    .form-grid,
    .form-grid.form-grid--compact,
    .medicine-row,
    .clinical-options {
        grid-template-columns: 1fr;
    }

    input,
    select,
    textarea {
        min-height: 46px;
        font-size: 16px;
    }

    textarea {
        min-height: 92px;
    }

    .button-row,
    .detail-actions,
    .form-actions,
    .signature-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .button,
    button,
    .link-button {
        min-height: 44px;
    }

    .table-card {
        margin-left: -2px;
        margin-right: -2px;
        padding: 10px;
    }

    table {
        min-width: 560px;
    }

    th,
    td {
        padding: 10px 8px;
    }

    .mobile-actions {
        left: 10px;
        right: 10px;
        bottom: 10px;
        gap: 4px;
        padding: 7px;
        border-radius: 24px;
        box-shadow: 0 18px 42px rgba(68, 75, 140, .18);
    }

    .mobile-actions a {
        min-height: 54px;
        border-radius: 18px;
        font-size: 10px;
        gap: 3px;
        padding: 7px 2px;
    }

    .mobile-actions svg {
        width: 22px;
        height: 22px;
    }
}
