* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #eef2ec;
    --bg-deep: #e5ece3;
    --surface: rgba(255, 255, 255, 0.94);
    --surface-strong: #ffffff;
    --surface-muted: #f6f8f4;
    --ink: #1f2925;
    --muted: #66706b;
    --line: #d4ddd4;
    --teal: #0f766e;
    --teal-deep: #0d5f59;
    --green: #2e8b57;
    --sand: #efe4bf;
    --red: #b43a4f;
    --charcoal: #24312d;
    --shadow: 0 18px 42px rgba(36, 49, 45, 0.12);
    --shadow-soft: 0 10px 26px rgba(36, 49, 45, 0.08);
    --glow: 0 0 0 1px rgba(15, 118, 110, 0.08), 0 22px 50px rgba(15, 118, 110, 0.08);
    --radius-xl: 24px;
    --radius-lg: 18px;
}

html,
body {
    min-height: 100%;
}

body {
    color: var(--ink);
    font-family: "Aptos", "Segoe UI", "Trebuchet MS", sans-serif;
    background:
        radial-gradient(circle at 50% 0%, rgba(43, 126, 170, 0.12), transparent 24%),
        radial-gradient(circle at 12% 10%, rgba(15, 118, 110, 0.1), transparent 18%),
        linear-gradient(180deg, #f8fbfe 0%, #edf3f6 58%, #e6edf2 100%);
}

body.modal-open {
    overflow: hidden;
}

body[data-page="admin"] {
    background:
        radial-gradient(circle at top right, rgba(36, 49, 45, 0.08), transparent 24%),
        linear-gradient(90deg, rgba(36, 49, 45, 0.05) 0 1px, transparent 1px 72px),
        linear-gradient(180deg, #f8faf8 0%, #edf1ee 58%, #dde6e0 100%);
}

body[data-page="generator"][data-theme="dark"] {
    --bg: #08111a;
    --bg-deep: #0d1721;
    --surface: rgba(15, 23, 33, 0.92);
    --surface-strong: #111b26;
    --surface-muted: #162432;
    --ink: #ecf3fb;
    --muted: #8ba0b5;
    --line: rgba(120, 149, 176, 0.16);
    --teal: #2aa198;
    --teal-deep: #5cd2c4;
    --green: #2e9f7c;
    --sand: #e8cf8d;
    --red: #e16b84;
    --charcoal: #dfeaf4;
    --shadow: 0 24px 64px rgba(0, 0, 0, 0.34);
    --shadow-soft: 0 18px 38px rgba(0, 0, 0, 0.24);
    --glow: 0 0 0 1px rgba(83, 210, 194, 0.1), 0 24px 56px rgba(20, 109, 141, 0.18);
    background:
        radial-gradient(circle at 16% 10%, rgba(49, 173, 184, 0.14), transparent 18%),
        radial-gradient(circle at 88% 8%, rgba(45, 160, 124, 0.12), transparent 16%),
        linear-gradient(180deg, #07111b 0%, #0b1620 55%, #111d29 100%);
}

body[data-page="admin"] {
    --line: rgba(122, 148, 171, 0.18);
    --surface: rgba(12, 18, 26, 0.9);
    --surface-strong: #111923;
    --surface-muted: #162230;
    --ink: #ecf3fb;
    --muted: #8ca0b5;
    --shadow-soft: 0 18px 38px rgba(2, 8, 18, 0.32);
    --shadow: 0 24px 64px rgba(2, 8, 18, 0.42);
    --glow: 0 0 0 1px rgba(73, 179, 160, 0.12), 0 24px 56px rgba(10, 108, 138, 0.18);
    background:
        radial-gradient(circle at 18% 12%, rgba(45, 150, 190, 0.12), transparent 20%),
        radial-gradient(circle at 88% 10%, rgba(57, 181, 147, 0.12), transparent 18%),
        linear-gradient(180deg, #07111b 0%, #0c1620 52%, #111d29 100%);
}

button,
input,
select,
a {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.15;
}

.login-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(100%, 440px);
    display: grid;
    gap: 22px;
    padding: 34px;
    border: 1px solid rgba(36, 49, 45, 0.12);
    border-radius: 12px;
    background: var(--surface);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

.brand-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--charcoal), var(--teal));
    color: #fff;
    font-size: 1.1rem;
    font-weight: 900;
}

.eyebrow {
    margin-bottom: 6px;
    color: var(--teal);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.login-panel h1,
.generator-topbar h1,
.topbar h1 {
    font-size: clamp(1.7rem, 2vw, 2.1rem);
    line-height: 1.08;
}

.login-copy {
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.55;
}

.login-form,
.controls,
.medicine-list,
.settings-grid {
    display: grid;
    gap: 16px;
}

.input-group {
    min-width: 0;
}

.input-group label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.88rem;
    font-weight: 800;
}

.input-group input,
.input-group select {
    width: 100%;
    min-height: 48px;
    padding: 11px 14px;
    border: 1px solid #c9d3ca;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.input-group.field-missing input,
.input-group.field-missing select,
.field-missing .radio-group {
    border-color: rgba(180, 58, 79, 0.6);
    box-shadow: 0 0 0 4px rgba(180, 58, 79, 0.12);
    background: linear-gradient(180deg, #fffefe, #fff5f7);
}

.input-group.field-missing label,
.field-missing > label,
.field-missing .medicine-badge {
    color: #a42d45;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 52px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 7px;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: #ebf1ec;
    color: var(--charcoal);
    cursor: pointer;
}

.text-link {
    justify-self: start;
    color: var(--teal-deep);
    font-weight: 800;
}

.form-error {
    min-height: 20px;
    color: var(--red);
    font-size: 0.9rem;
    font-weight: 800;
}

.field-error {
    margin-top: 8px;
    color: #a42d45;
    font-size: 0.84rem;
    font-weight: 800;
}

.inline-hint {
    min-height: 48px;
    display: flex;
    align-items: center;
    color: var(--teal-deep);
    font-size: 0.9rem;
    font-weight: 800;
}

.user-create-bar .inline-hint {
    grid-column: 1 / -2;
    min-height: auto;
    padding-top: 2px;
}

.btn,
.icon-btn {
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn:hover:not(:disabled),
.icon-btn:hover,
.nav-item:hover {
    transform: translateY(-1px);
}

.btn {
    min-height: 48px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 900;
    letter-spacing: 0.01em;
}

.btn-wide {
    width: 100%;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #24312d 0%, #31453f 100%);
    box-shadow: var(--shadow-soft);
}

.btn-success {
    color: #fff;
    background: linear-gradient(135deg, var(--green) 0%, var(--teal) 100%);
    box-shadow: var(--shadow-soft);
}

.btn-secondary {
    color: #fff;
    background: linear-gradient(135deg, #22403b, #2b5750);
    box-shadow: 0 12px 24px rgba(34, 64, 59, 0.16);
}

.btn-ghost,
.icon-btn {
    background: #edf2ee;
    color: var(--ink);
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    font-weight: 900;
}

.danger-btn {
    color: var(--red);
}

.generator-shell {
    width: min(100% - 32px, 1260px);
    margin: 0 auto;
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    position: relative;
    background: rgba(243, 248, 251, 0.88);
    border-left: 1px solid rgba(55, 90, 122, 0.08);
    border-right: 1px solid rgba(55, 90, 122, 0.08);
    box-shadow: 0 22px 60px rgba(37, 68, 92, 0.12);
}

body[data-page="admin"] .app-shell {
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(10, 17, 25, 0.94), rgba(13, 21, 31, 0.98));
}

body[data-page="admin"] .sidebar {
    background:
        linear-gradient(180deg, rgba(8, 14, 21, 0.98), rgba(12, 20, 29, 0.96));
    border-right: 1px solid rgba(120, 149, 176, 0.14);
    box-shadow: 18px 0 48px rgba(0, 0, 0, 0.22);
}

body[data-page="admin"] .sidebar-brand strong,
body[data-page="admin"] .sidebar-brand span,
body[data-page="admin"] .nav-item,
body[data-page="admin"] .user-chip strong,
body[data-page="admin"] .user-chip small,
body[data-page="admin"] .sidebar-footer,
body[data-page="admin"] .topbar h1,
body[data-page="admin"] .topbar span,
body[data-page="admin"] .topbar strong,
body[data-page="admin"] .panel-heading h2,
body[data-page="admin"] .section-title h2,
body[data-page="admin"] .setting-block h3,
body[data-page="admin"] .table-row,
body[data-page="admin"] .input-group label {
    color: #ecf3fb;
}

body[data-page="admin"] .sidebar-brand span,
body[data-page="admin"] .user-chip small,
body[data-page="admin"] .topbar .eyebrow,
body[data-page="admin"] .panel-heading .eyebrow,
body[data-page="admin"] .section-title p,
body[data-page="admin"] .setting-block p,
body[data-page="admin"] .table-row small,
body[data-page="admin"] .table-head {
    color: #8ca0b5;
}

body[data-page="admin"] .nav-item {
    border-color: transparent;
    background: rgba(255, 255, 255, 0.02);
}

body[data-page="admin"] .nav-item.active {
    color: #eaf8f5;
    background: linear-gradient(135deg, rgba(36, 122, 117, 0.34), rgba(24, 78, 120, 0.34));
    border-color: rgba(91, 206, 188, 0.26);
    box-shadow: inset 0 0 0 1px rgba(154, 231, 218, 0.06);
}

body[data-page="admin"] .workspace {
    background:
        radial-gradient(circle at top, rgba(69, 168, 203, 0.08), transparent 24%),
        linear-gradient(180deg, rgba(11, 19, 29, 0.92), rgba(12, 20, 31, 0.98));
}

body[data-page="admin"] .topbar {
    background:
        linear-gradient(180deg, rgba(13, 23, 34, 0.94), rgba(14, 24, 36, 0.88));
    border-bottom: 1px solid rgba(120, 149, 176, 0.14);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
}

body[data-page="admin"] .status-strip > div {
    border-color: rgba(111, 146, 178, 0.18);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

body[data-page="admin"] .status-strip span {
    color: #8ca0b5;
}

body[data-page="admin"] .user-create-bar,
body[data-page="admin"] .users-table,
body[data-page="admin"] .setting-block {
    border: 1px solid rgba(111, 146, 178, 0.14);
    background:
        linear-gradient(180deg, rgba(18, 28, 40, 0.94), rgba(14, 22, 33, 0.96));
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

body[data-page="admin"] .input-group input,
body[data-page="admin"] .input-group select {
    border-color: rgba(109, 143, 175, 0.16);
    background: rgba(8, 14, 22, 0.82);
    color: #eef4fb;
}

body[data-page="admin"] .input-group input::placeholder {
    color: #7f96ad;
}

body[data-page="admin"] .input-group input:focus,
body[data-page="admin"] .input-group select:focus {
    border-color: #35a2b5;
    box-shadow: 0 0 0 4px rgba(53, 162, 181, 0.14);
}

body[data-page="admin"] .password-toggle,
body[data-page="admin"] .btn-ghost,
body[data-page="admin"] .icon-btn {
    background: rgba(255, 255, 255, 0.06);
    color: #eef4fb;
}

body[data-page="admin"] .btn-primary {
    background: linear-gradient(135deg, #163149 0%, #1f5e69 100%);
}

body[data-page="admin"] .btn-success {
    background: linear-gradient(135deg, #1b7c69 0%, #27957e 100%);
}

body[data-page="admin"] .user-create-bar {
    position: relative;
    overflow: hidden;
}

body[data-page="admin"] .user-create-bar::before,
body[data-page="admin"] .users-table::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(64, 176, 198, 0.05), transparent 28%, rgba(68, 214, 170, 0.04));
    pointer-events: none;
}

.generator-shell::before {
    content: "";
    position: absolute;
    inset: 104px 0 0;
    background:
        radial-gradient(circle at 20% 0%, rgba(63, 148, 193, 0.08), transparent 28%),
        radial-gradient(circle at 100% 20%, rgba(46, 139, 87, 0.08), transparent 24%);
    pointer-events: none;
}

body[data-page="generator"][data-theme="dark"] .login-panel,
body[data-page="generator"][data-theme="dark"] .generator-shell,
body[data-page="generator"][data-theme="dark"] .form-card,
body[data-page="generator"][data-theme="dark"] .pdf-viewer,
body[data-page="generator"][data-theme="dark"] .preview-empty,
body[data-page="generator"][data-theme="dark"] .info,
body[data-page="generator"][data-theme="dark"] .medicine-item,
body[data-page="generator"][data-theme="dark"] .cpf-notice,
body[data-page="generator"][data-theme="dark"] .form-alert {
    border-color: rgba(111, 146, 178, 0.16);
    color: #ecf3fb;
}

body[data-page="generator"][data-theme="dark"] .login-panel,
body[data-page="generator"][data-theme="dark"] .generator-shell,
body[data-page="generator"][data-theme="dark"] .form-card,
body[data-page="generator"][data-theme="dark"] .medicine-item,
body[data-page="generator"][data-theme="dark"] .preview-empty,
body[data-page="generator"][data-theme="dark"] .pdf-viewer {
    background:
        linear-gradient(180deg, rgba(16, 26, 38, 0.96), rgba(12, 20, 31, 0.98));
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.28);
}

body[data-page="generator"][data-theme="dark"] .generator-shell {
    border-left-color: rgba(111, 146, 178, 0.12);
    border-right-color: rgba(111, 146, 178, 0.12);
}

body[data-page="generator"][data-theme="dark"] .generator-shell::before {
    background:
        radial-gradient(circle at 20% 0%, rgba(63, 148, 193, 0.1), transparent 28%),
        radial-gradient(circle at 100% 20%, rgba(46, 139, 87, 0.08), transparent 24%);
}

body[data-page="generator"][data-theme="dark"] .generator-topbar {
    background: linear-gradient(90deg, #0d2439 0%, #13424c 100%);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.28);
}

body[data-page="generator"][data-theme="dark"] .generator-topbar-actions {
    gap: 14px;
}

body[data-page="generator"][data-theme="dark"] .status-strip > div {
    border-color: rgba(120, 149, 176, 0.14);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

body[data-page="generator"][data-theme="dark"] .section-title h2,
body[data-page="generator"][data-theme="dark"] .preview-empty strong,
body[data-page="generator"][data-theme="dark"] .input-group label,
body[data-page="generator"][data-theme="dark"] .medicine-title,
body[data-page="generator"][data-theme="dark"] .info span {
    color: #ecf3fb;
}

body[data-page="generator"][data-theme="dark"] .section-title p,
body[data-page="generator"][data-theme="dark"] .preview-empty p,
body[data-page="generator"][data-theme="dark"] .info,
body[data-page="generator"][data-theme="dark"] .cpf-notice p,
body[data-page="generator"][data-theme="dark"] .medicine-validation {
    color: #8ba0b5;
}

body[data-page="generator"][data-theme="dark"] .input-group input,
body[data-page="generator"][data-theme="dark"] .input-group select,
body[data-page="generator"][data-theme="dark"] .btn-ghost,
body[data-page="generator"][data-theme="dark"] .icon-btn,
body[data-page="generator"][data-theme="dark"] .password-toggle {
    background: rgba(7, 14, 22, 0.8);
    border-color: rgba(111, 146, 178, 0.14);
    color: #eef4fb;
}

body[data-page="generator"][data-theme="dark"] .input-group input::placeholder {
    color: #7f96ad;
}

body[data-page="generator"][data-theme="dark"] .input-group input:focus,
body[data-page="generator"][data-theme="dark"] .input-group select:focus {
    border-color: #35a2b5;
    box-shadow: 0 0 0 4px rgba(53, 162, 181, 0.14);
}

body[data-page="generator"][data-theme="dark"] .radio-group {
    border-color: rgba(111, 146, 178, 0.14);
    background: linear-gradient(180deg, rgba(7, 14, 22, 0.82), rgba(11, 18, 28, 0.92));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

body[data-page="generator"][data-theme="dark"] .radio-option {
    color: #8ea5bb;
}

body[data-page="generator"][data-theme="dark"] .radio-option-text::before {
    border-color: rgba(125, 152, 178, 0.4);
    background: rgba(255, 255, 255, 0.04);
}

body[data-page="generator"][data-theme="dark"] .radio-option input:checked + .radio-option-text {
    color: #dff7f5;
}

body[data-page="generator"][data-theme="dark"] .radio-option input:checked + .radio-option-text::before {
    border-color: rgba(92, 210, 196, 0.92);
    background: rgba(92, 210, 196, 0.12);
    box-shadow: inset 0 0 0 4px #5cd2c4;
}

body[data-page="generator"][data-theme="dark"] .radio-option:has(input:checked) {
    border-color: rgba(92, 210, 196, 0.18);
    background: linear-gradient(135deg, rgba(25, 72, 78, 0.72), rgba(20, 54, 69, 0.76));
    box-shadow: 0 14px 28px rgba(6, 24, 32, 0.34);
}

body[data-page="generator"][data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg, #17324b 0%, #205562 100%);
}

body[data-page="generator"][data-theme="dark"] .btn-secondary {
    background: linear-gradient(135deg, #1d4b52, #25656c);
}

body[data-page="generator"][data-theme="dark"] .btn-success {
    background: linear-gradient(135deg, #1d8b73 0%, #27957e 100%);
    box-shadow: 0 14px 28px rgba(18, 108, 88, 0.26);
}

body[data-page="generator"][data-theme="dark"] .medicine-badge {
    background: rgba(58, 205, 184, 0.12);
    color: #7de0cf;
}

body[data-page="generator"][data-theme="dark"] .cpf-notice {
    background: linear-gradient(135deg, rgba(42, 161, 152, 0.12), rgba(43, 126, 170, 0.12));
}

body[data-page="generator"][data-theme="dark"] .cpf-notice strong,
body[data-page="generator"][data-theme="dark"] .form-alert strong {
    color: #f1f7fd;
}

body[data-page="generator"][data-theme="dark"] .form-alert {
    background: linear-gradient(135deg, rgba(79, 28, 40, 0.78), rgba(83, 49, 31, 0.72));
}

body[data-page="generator"][data-theme="dark"] .quota-alert {
    background: linear-gradient(135deg, rgba(14, 74, 73, 0.8), rgba(20, 63, 92, 0.78));
}

body[data-page="generator"][data-theme="dark"] .quota-alert strong,
body[data-page="generator"][data-theme="dark"] .quota-alert p,
body[data-page="generator"][data-theme="dark"] .quota-alert i {
    color: #dff7f5;
}

body[data-page="generator"][data-theme="dark"] .preview-empty-icon {
    background: rgba(42, 161, 152, 0.12);
    color: #72ddd0;
}

body[data-page="generator"][data-theme="dark"] .info {
    background: linear-gradient(180deg, rgba(16, 26, 38, 0.96), rgba(12, 20, 31, 0.98));
    border-top-color: rgba(111, 146, 178, 0.12);
}

body[data-page="generator"][data-theme="dark"] .info p {
    background: rgba(255, 255, 255, 0.04);
}

body[data-page="generator"][data-theme="dark"] .posology-panel {
    background:
        linear-gradient(180deg, rgba(45, 145, 179, 0.08), rgba(45, 145, 179, 0) 42%),
        linear-gradient(180deg, rgba(16, 26, 38, 0.96), rgba(12, 20, 31, 0.98));
}

body[data-page="generator"][data-theme="dark"] .medicine-item {
    position: relative;
    overflow: hidden;
}

body[data-page="generator"][data-theme="dark"] .medicine-item::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(42, 161, 152, 0.04), transparent 38%, rgba(40, 111, 157, 0.05));
    pointer-events: none;
}

body[data-page="generator"][data-theme="dark"] .action-bar {
    padding-top: 10px;
}

body[data-page="generator"][data-theme="dark"] .action-bar .btn {
    min-width: 170px;
    border: 1px solid rgba(110, 146, 176, 0.12);
}

body[data-page="generator"][data-theme="dark"] .preview-empty {
    border-style: solid;
    border-color: rgba(73, 180, 183, 0.16);
    background:
        radial-gradient(circle at top, rgba(42, 161, 152, 0.1), transparent 42%),
        linear-gradient(180deg, rgba(16, 26, 38, 0.98), rgba(11, 18, 28, 0.98));
}

body[data-page="generator"][data-theme="dark"] #pdfCanvas,
body[data-page="generator"][data-theme="dark"] #previewCanvas {
    background: #0c1520;
    box-shadow: 0 24px 54px rgba(0, 0, 0, 0.38);
}

body[data-page="generator"][data-theme="dark"] #previewCanvas {
    border-color: rgba(66, 206, 166, 0.42);
}

body[data-page="generator"][data-theme="dark"] .preview-banner {
    background: rgba(10, 20, 31, 0.92);
    border: 1px solid rgba(110, 146, 176, 0.12);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.generator-topbar,
.topbar,
.panel-heading,
.status-strip,
.medicine-title,
.posology-header,
.action-bar,
.info,
.sidebar-brand,
.sidebar-footer,
.user-chip,
.row-actions,
.session-actions,
.mode-badge {
    display: flex;
    align-items: center;
}

.generator-topbar {
    justify-content: space-between;
    gap: 24px;
    padding: 24px 32px;
    z-index: 20;
    background: linear-gradient(90deg, #224f7d 0%, #2f7e7a 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0 0 0 0;
    color: #fff;
    box-shadow: 0 10px 34px rgba(34, 79, 125, 0.18);
}

.generator-topbar .eyebrow,
.generator-topbar h1,
.generator-topbar span,
.generator-topbar strong,
.generator-topbar a,
.generator-topbar button {
    color: inherit;
}

.generator-topbar .eyebrow {
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.08em;
}

.generator-topbar h1 {
    font-size: clamp(2rem, 2.8vw, 2.45rem);
}

.generator-topbar-actions {
    display: grid;
    gap: 12px;
    justify-items: end;
}

.status-strip {
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.status-strip.compact {
    justify-content: flex-end;
}

.status-strip > div {
    min-width: 122px;
    min-height: 56px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: none;
    backdrop-filter: blur(10px);
}

.status-strip span {
    display: block;
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.78rem;
}

.status-strip strong {
    display: block;
    margin-top: 2px;
    font-size: 0.96rem;
}

.mode-badge {
    min-height: 44px;
    gap: 8px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 224, 164, 0.5);
    background: rgba(255, 244, 214, 0.92);
    color: #8b560e;
    font-weight: 900;
    box-shadow: 0 12px 24px rgba(44, 34, 12, 0.12);
}

.session-actions {
    gap: 8px;
}

.manager-only-link {
    display: inline-flex;
}

.generator-layout {
    display: block;
    min-width: 0;
    position: relative;
}

.controls {
    min-width: 0;
    padding: 28px;
}

.form-card,
.user-create-bar,
.setting-block {
    border: 1px solid #cbd8e5;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(250, 252, 254, 0.98));
    box-shadow: 0 10px 22px rgba(58, 88, 112, 0.06);
    padding: 22px;
}

.form-card:hover,
.setting-block:hover,
.user-create-bar:hover,
.users-table:hover {
    box-shadow: var(--glow);
}

.section-title {
    display: grid;
    gap: 4px;
    margin-bottom: 18px;
}

.section-title h2,
.panel-heading h2 {
    font-size: 1.18rem;
    color: #123761;
}

.section-title p,
.setting-block p {
    color: #56708b;
    line-height: 1.45;
}

.patient-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1.3fr) minmax(220px, 1.15fr) minmax(104px, 0.45fr) minmax(190px, 0.8fr);
    gap: 14px;
    align-items: end;
}

.patient-grid.model-cpf {
    grid-template-columns: minmax(220px, 1.25fr) minmax(220px, 1.15fr) minmax(220px, 0.9fr);
}

.cpf-field {
    min-width: 210px;
}

.cpf-notice {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
    padding: 16px 18px;
    border: 1px solid rgba(13, 95, 89, 0.18);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.1), rgba(43, 126, 170, 0.08));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.cpf-notice i {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, #0f766e, #2f7e7a);
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.2);
}

.cpf-notice strong {
    display: block;
    margin-bottom: 4px;
    color: #124540;
    font-size: 0.98rem;
}

.cpf-notice p {
    color: #31504c;
    line-height: 1.45;
}

.radio-group {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 6px;
    border: 1px solid rgba(36, 49, 45, 0.08);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(237, 242, 238, 0.96), rgba(230, 237, 232, 0.9));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.radio-group label,
.radio-option {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: #425466;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.radio-group label:hover,
.radio-option:hover {
    transform: translateY(-1px);
}

.radio-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-option-text {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.radio-option-text::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid rgba(72, 90, 110, 0.45);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 0 0 3px transparent;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.radio-option input:checked + .radio-option-text::before {
    border-color: rgba(15, 118, 110, 0.9);
    background: #dff5f1;
    box-shadow: inset 0 0 0 4px #0f766e;
}

.radio-option input:checked + .radio-option-text {
    color: #0d5f59;
}

.radio-option:has(input:checked) {
    border-color: rgba(15, 118, 110, 0.22);
    background: linear-gradient(135deg, rgba(217, 244, 242, 0.96), rgba(225, 244, 236, 0.96));
    box-shadow: 0 10px 20px rgba(15, 118, 110, 0.12);
}

.posology-panel {
    background:
        linear-gradient(180deg, rgba(83, 158, 201, 0.07), rgba(83, 158, 201, 0) 46%),
        rgba(255, 255, 255, 0.98);
}

.posology-header,
.panel-heading {
    justify-content: space-between;
    gap: 16px;
}

.medicine-item {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid #d6e0eb;
    border-radius: 16px;
    background: linear-gradient(180deg, #f9fcff, #f3f8fc);
}

.medicine-item.field-missing {
    border-color: rgba(180, 58, 79, 0.4);
    background: linear-gradient(180deg, #fffafb, #fff3f6);
    box-shadow: 0 18px 32px rgba(180, 58, 79, 0.08);
}

.medicine-title {
    justify-content: space-between;
    gap: 12px;
}

.medicine-badge {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border-radius: 999px;
    background: #d9f4f2;
    color: #15706a;
    font-size: 0.84rem;
    font-weight: 900;
}

.medicine-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(100px, 148px);
    gap: 14px;
}

.medicine-name-shell {
    position: relative;
}

.medicine-name-shell input {
    padding-right: 122px;
}

.medicine-status-chip {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    min-height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 900;
    white-space: nowrap;
}

.medicine-status-chip.valid {
    background: #dff5e7;
    color: #187144;
}

.medicine-status-chip.warning {
    background: #fff1d8;
    color: #9b5b06;
}

.medicine-status-chip.invalid {
    background: #fde3e8;
    color: #9a2940;
}

.medicine-validation {
    min-height: 22px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #5f7285;
}

.medicine-validation.valid {
    color: #187144;
}

.medicine-validation.warning {
    color: #9b5b06;
}

.medicine-validation.invalid {
    color: #9a2940;
}

.medicine-validation.loading {
    color: #1b5683;
}

.medicine-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(27, 86, 131, 0.18);
    border-top-color: #1b5683;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.remove-medicine {
    border: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--red);
    font-weight: 800;
    cursor: pointer;
}

.action-bar {
    gap: 12px;
    flex-wrap: wrap;
    padding: 6px 0 0;
}

.form-alert {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    border: 1px solid rgba(180, 58, 79, 0.18);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(253, 227, 232, 0.96), rgba(255, 243, 234, 0.94));
    box-shadow: 0 14px 30px rgba(180, 58, 79, 0.08);
}

.quota-alert {
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.14), rgba(43, 126, 170, 0.12));
    border-color: rgba(42, 161, 152, 0.2);
}

.quota-alert strong,
.quota-alert p,
.quota-alert i {
    color: var(--teal-deep);
}

.form-alert i {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #b43a4f, #d16e3c);
    color: #fff;
    box-shadow: 0 10px 22px rgba(180, 58, 79, 0.22);
}

.form-alert strong {
    display: block;
    margin-bottom: 4px;
    color: #84263b;
}

.form-alert p {
    color: #7f3f31;
    line-height: 1.45;
}

.btn-attention {
    animation: pulseAttention 1.4s ease-in-out infinite;
    box-shadow: 0 16px 30px rgba(180, 58, 79, 0.22);
}

.pdf-viewer {
    min-height: 0;
    position: relative;
    margin: 0 28px 28px;
    padding: 28px 28px 22px;
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        linear-gradient(180deg, rgba(232, 240, 247, 0.96), rgba(240, 245, 250, 0.96));
    border-top: 1px solid #dbe5ef;
    flex-direction: column;
    border-radius: 0 0 18px 18px;
}

.preview-empty {
    min-height: 380px;
    width: min(100%, 820px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    text-align: center;
    color: var(--muted);
    background:
        radial-gradient(circle at top, rgba(15, 118, 110, 0.12), transparent 44%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(243, 248, 244, 0.98));
    border: 1px dashed rgba(15, 118, 110, 0.18);
    border-radius: 22px;
    box-shadow: 0 18px 40px rgba(58, 88, 112, 0.08);
}

.preview-empty strong {
    color: var(--text);
    font-size: 1.05rem;
}

.preview-empty p {
    margin: 0;
    max-width: 320px;
    line-height: 1.5;
}

.preview-empty-icon {
    width: 72px;
    height: 72px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
    color: var(--teal);
    background: rgba(15, 118, 110, 0.12);
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.14);
}

#pdfCanvas,
#previewCanvas {
    max-width: min(100%, 820px);
    height: auto;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 22px 48px rgba(58, 88, 112, 0.14);
}

#previewCanvas {
    border: 3px solid rgba(46, 139, 87, 0.42);
}

.preview-banner {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 999px;
    background: rgba(31, 41, 37, 0.9);
    color: #fff;
    font-weight: 900;
    box-shadow: 0 10px 24px rgba(31, 41, 37, 0.18);
}

.loading {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2600;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(5, 12, 21, 0.62);
    backdrop-filter: blur(12px);
}

.loading-card {
    min-width: min(92vw, 340px);
    padding: 30px 28px 26px;
    border-radius: 28px;
    border: 1px solid rgba(113, 230, 216, 0.2);
    background:
        radial-gradient(circle at top, rgba(66, 194, 184, 0.16), transparent 56%),
        linear-gradient(180deg, rgba(15, 27, 42, 0.98), rgba(8, 15, 26, 0.98));
    box-shadow: 0 28px 72px rgba(0, 0, 0, 0.42);
    display: grid;
    justify-items: center;
    text-align: center;
}

.spinner {
    width: 74px;
    height: 74px;
    margin: 0 0 18px;
    border: 4px solid rgba(218, 235, 232, 0.18);
    border-top: 4px solid #8df3e4;
    border-right: 4px solid #2dc3c5;
    border-radius: 50%;
    box-shadow: 0 0 0 9px rgba(54, 199, 186, 0.08);
    animation: spin 0.82s linear infinite;
}

.loading p {
    margin: 0;
    color: #eefcff;
    font-size: 1.04rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.info {
    gap: 22px;
    flex-wrap: wrap;
    padding: 14px 28px 22px;
    background: linear-gradient(180deg, rgba(239, 245, 250, 0.92), rgba(234, 241, 247, 0.96));
    border-top: 1px solid #dbe5ef;
    color: #597086;
}

.info p {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.66);
    box-shadow: inset 0 0 0 1px rgba(36, 49, 45, 0.05);
}

.info p {
    display: flex;
    gap: 8px;
}

.info span {
    color: #1b5683;
    font-weight: 900;
}

#quotaStatusCard {
    min-width: 170px;
}

#quotaStatusCard small {
    display: block;
    margin-top: 2px;
    color: inherit;
    opacity: 0.82;
    font-size: 0.77rem;
    line-height: 1.3;
}

.quota-status-exhausted {
    border-color: rgba(225, 107, 132, 0.24) !important;
    background: linear-gradient(180deg, rgba(106, 34, 51, 0.32), rgba(73, 26, 41, 0.28)) !important;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
    min-height: 100vh;
    position: sticky;
    top: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 22px;
    padding: 22px;
    background:
        linear-gradient(180deg, rgba(252, 253, 252, 0.96), rgba(242, 247, 243, 0.94));
    border-right: 1px solid var(--line);
    backdrop-filter: blur(16px);
    box-shadow: 12px 0 36px rgba(36, 49, 45, 0.04);
}

.sidebar-brand {
    gap: 12px;
}

.sidebar-brand strong {
    display: block;
    font-size: 1.05rem;
}

.sidebar-brand span,
.user-chip small,
.table-row small {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
}

.nav-list {
    display: grid;
    gap: 8px;
    align-content: start;
}

.nav-item {
    width: 100%;
    min-height: 46px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    color: var(--ink);
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.nav-item.active {
    background: linear-gradient(135deg, #eef7f1, #e4f0ea);
    border-color: #b9d4c6;
    color: var(--teal-deep);
}

.sidebar-footer {
    justify-content: space-between;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.user-chip {
    gap: 10px;
    min-width: 0;
}

.user-chip > span {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #e2eee8;
    color: var(--teal-deep);
    font-weight: 900;
}

.workspace {
    min-width: 0;
    display: grid;
    grid-template-rows: auto 1fr;
}

.topbar {
    justify-content: space-between;
    gap: 24px;
    padding: 24px 30px;
    position: sticky;
    top: 0;
    z-index: 20;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(244, 248, 245, 0.92));
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
    box-shadow: 0 10px 24px rgba(36, 49, 45, 0.04);
}

.panel-view {
    display: none;
    min-width: 0;
}

.panel-view.active {
    display: block;
}

.panel-heading {
    padding: 28px 30px 18px;
}

.user-create-bar {
    margin: 0 30px 18px;
    display: grid;
    grid-template-columns: minmax(140px, 1fr) minmax(160px, 1fr) minmax(110px, 0.7fr) minmax(130px, 0.75fr) minmax(90px, 0.42fr) minmax(120px, 0.55fr) auto;
    gap: 12px;
    align-items: end;
}

.users-table {
    margin: 0 30px 30px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-strong);
    box-shadow: var(--shadow-soft);
}

.table-row:not(.table-head):hover {
    background: linear-gradient(90deg, rgba(15, 118, 110, 0.04), rgba(15, 118, 110, 0.01));
}

.table-row {
    display: grid;
    grid-template-columns: minmax(190px, 1.25fr) 120px 110px 120px 150px minmax(270px, 1.3fr);
    gap: 12px;
    align-items: center;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
}

.table-row:last-child {
    border-bottom: 0;
}

.table-head {
    background: linear-gradient(180deg, #eef5f1, #e8efea);
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 900;
    text-transform: uppercase;
}

.row-actions {
    gap: 6px;
    flex-wrap: wrap;
}

.user-main-cell strong {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.owner-badge {
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(255, 211, 116, 0.14);
    color: #f4c35b;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

mark {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 900;
}

mark.ok {
    background: #dff3e5;
    color: #156341;
}

mark.danger {
    background: #fde3e8;
    color: #92233a;
}

mark.neutral {
    background: rgba(130, 146, 165, 0.14);
    color: #9eb0c1;
}

.presence-online {
    box-shadow: 0 0 0 1px rgba(72, 218, 156, 0.08), 0 0 18px rgba(72, 218, 156, 0.18);
}

.presence-offline {
    box-shadow: inset 0 0 0 1px rgba(164, 179, 196, 0.06);
}

.role-btn:not(:disabled) {
    color: #69d4c2;
}

body[data-page="admin"] .table-head {
    background: linear-gradient(180deg, rgba(17, 29, 42, 0.98), rgba(14, 24, 36, 0.98));
    color: #7f96ad;
}

body[data-page="admin"] .table-row {
    border-bottom-color: rgba(111, 146, 178, 0.1);
}

body[data-page="admin"] .table-row:not(.table-head):hover {
    background: linear-gradient(90deg, rgba(46, 154, 173, 0.09), rgba(31, 91, 120, 0.03));
}

body[data-page="admin"] .user-row-online {
    box-shadow: inset 4px 0 0 #39b596;
}

body[data-page="admin"] #usersMessage {
    color: #9ecfca;
}

#usersMessage {
    margin: 0 30px 12px;
}

.settings-grid {
    padding: 0 30px 30px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.setting-block {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 18px;
}

.setting-block h3,
.section-title h2,
.panel-heading h2 {
    letter-spacing: 0;
}

.setting-block h3 {
    margin-bottom: 6px;
}

.plan-mode-inline-card,
.quota-inline-card,
.edit-quota-card {
    grid-column: 1 / -1;
    border: 1px solid rgba(111, 146, 178, 0.14);
    border-radius: 22px;
    padding: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.02));
}

.plan-mode-header {
    display: grid;
    gap: 4px;
}

.plan-mode-header strong {
    color: var(--ink);
    font-size: 1rem;
}

.plan-mode-header p {
    color: var(--muted);
    line-height: 1.5;
}

.quota-inline-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.quota-inline-header strong {
    display: block;
    margin-bottom: 4px;
    font-size: 1rem;
}

.quota-inline-header p {
    color: var(--muted);
    line-height: 1.5;
}

.plan-mode-copy {
    margin-top: 12px;
    color: var(--muted);
    line-height: 1.45;
}

.plan-mode-selector {
    margin-top: 14px;
}

.quota-inline-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: minmax(180px, 280px) minmax(220px, 360px);
    gap: 16px;
    align-items: end;
}

.switch-field {
    flex-shrink: 0;
}

.quota-stats-card {
    min-height: 48px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(111, 146, 178, 0.14);
    background: rgba(255, 255, 255, 0.03);
    display: grid;
    align-content: center;
    gap: 4px;
}

.quota-stats-card span,
.quota-stats-card small {
    color: var(--muted);
}

.quota-stats-card strong {
    color: var(--ink);
    font-size: 1rem;
}

.quota-stats-card-create {
    min-height: 84px;
}

.quota-row-panel {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(42, 161, 152, 0.16);
    background: linear-gradient(180deg, rgba(42, 161, 152, 0.08), rgba(42, 161, 152, 0.04));
    display: grid;
    gap: 3px;
}

.quota-row-panel strong {
    color: var(--ink);
    font-size: 0.82rem;
}

.quota-row-panel small {
    color: var(--muted);
    line-height: 1.35;
}

.quota-row-panel b {
    color: var(--ink);
    font-weight: 900;
}

.quota-row-panel-muted {
    border-color: rgba(111, 146, 178, 0.14);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.quota-row-panel-danger {
    border-color: rgba(225, 107, 132, 0.24);
    background: linear-gradient(180deg, rgba(225, 107, 132, 0.12), rgba(225, 107, 132, 0.06));
}

.model-switch {
    display: inline-grid;
    grid-template-columns: repeat(4, minmax(108px, 150px));
    gap: 8px;
}

.model-option {
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid #c7d2c8;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font-weight: 900;
    cursor: pointer;
}

.model-option.active {
    color: var(--teal-deep);
    background: #e3f1eb;
    border-color: var(--teal);
}

body[data-page="admin"] .model-switch {
    width: min(100%, 620px);
    justify-content: end;
}

body[data-page="admin"] .model-option {
    border-color: rgba(116, 146, 176, 0.2);
    background: linear-gradient(180deg, rgba(20, 30, 43, 0.96), rgba(11, 18, 30, 0.98));
    color: #d8e5f2;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 12px 28px rgba(2, 10, 18, 0.24);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

body[data-page="admin"] .model-option:hover {
    transform: translateY(-1px);
    border-color: rgba(92, 208, 195, 0.42);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 36px rgba(1, 10, 16, 0.34);
}

body[data-page="admin"] .model-option.active {
    color: #042227;
    border-color: rgba(116, 252, 228, 0.68);
    background: linear-gradient(135deg, #e8fff6, #85e7d3 55%, #4fb9c8);
    box-shadow: 0 18px 38px rgba(32, 191, 164, 0.22);
}

.switch {
    position: relative;
    width: 62px;
    height: 34px;
    display: inline-flex;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #c9d3ca;
    transition: background 0.18s ease;
}

.switch-slider::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 5px 12px rgba(31, 41, 37, 0.16);
    transition: transform 0.18s ease;
}

.switch input:checked + .switch-slider {
    background: var(--teal);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(28px);
}

.guard-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(16, 22, 20, 0.84);
    z-index: 1300;
}

.guard-card {
    width: min(100%, 360px);
    padding: 24px;
    border-radius: 12px;
    background: var(--surface-strong);
    text-align: center;
    box-shadow: var(--shadow);
}

.guard-card h2 {
    margin-bottom: 10px;
}

.medicine-modal {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(19, 35, 52, 0.48);
    backdrop-filter: blur(8px);
}

.medicine-modal-card {
    width: min(100%, 640px);
    max-height: min(80vh, 760px);
    overflow: auto;
    border-radius: 24px;
    border: 1px solid rgba(27, 86, 131, 0.14);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(246, 250, 253, 0.98));
    box-shadow: 0 26px 70px rgba(30, 54, 76, 0.22);
    padding: 24px;
}

.medicine-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.medicine-modal-header h2 {
    color: #123761;
    font-size: 1.4rem;
}

.medicine-modal-copy {
    margin-bottom: 16px;
    color: #58708a;
    line-height: 1.5;
}

.medicine-modal-options {
    display: grid;
    gap: 10px;
}

.admin-modal {
    position: fixed;
    inset: 0;
    z-index: 2400;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(4, 10, 18, 0.72);
    backdrop-filter: blur(14px);
    overflow-y: auto;
    isolation: isolate;
}

.admin-modal.is-open {
    display: flex !important;
}

.admin-modal-card {
    width: min(100%, 860px);
    max-height: min(86vh, 920px);
    overflow: auto;
    position: relative;
    margin: auto;
    border-radius: 28px;
    border: 1px solid rgba(111, 146, 178, 0.18);
    background:
        radial-gradient(circle at top, rgba(66, 194, 184, 0.14), transparent 42%),
        linear-gradient(180deg, rgba(14, 23, 35, 0.99), rgba(9, 15, 24, 0.99));
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
    padding: 26px;
}

.admin-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.admin-modal-header h2 {
    color: #eef6ff;
    font-size: 1.5rem;
}

.admin-modal-copy {
    color: #8ea5bc;
    line-height: 1.55;
    margin-top: 6px;
}

.admin-modal-form {
    display: grid;
    gap: 18px;
}

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

.edit-renew-card {
    border: 1px solid rgba(111, 146, 178, 0.14);
    border-radius: 24px;
    padding: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.02));
}

.edit-renew-toggle {
    display: inline-grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 14px;
    color: #eef6ff;
    margin-bottom: 8px;
}

.edit-renew-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.edit-renew-toggle .switch-slider {
    position: relative;
    width: 62px;
    height: 34px;
    border-radius: 999px;
    background: #c9d3ca;
    transition: background 0.18s ease;
}

.edit-renew-toggle .switch-slider::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 5px 12px rgba(31, 41, 37, 0.16);
    transition: transform 0.18s ease;
}

.edit-renew-toggle input:checked + .switch-slider {
    background: var(--teal);
}

.edit-renew-toggle input:checked + .switch-slider::before {
    transform: translateX(28px);
}

.renew-grid {
    margin-top: 16px;
}

.admin-modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.danger-outline {
    margin-right: auto;
    color: #ffb5c0;
    border: 1px solid rgba(255, 118, 145, 0.24);
}

.danger-outline:hover {
    background: rgba(255, 92, 126, 0.12);
}

body[data-page="admin"] .admin-modal-card .input-group input,
body[data-page="admin"] .admin-modal-card .input-group select {
    border-color: rgba(109, 143, 175, 0.16);
    background: rgba(8, 14, 22, 0.82);
    color: #ecf3fb;
}

body[data-page="admin"] .admin-modal-card .input-group input:focus,
body[data-page="admin"] .admin-modal-card .input-group select:focus {
    border-color: #35a2b5;
    box-shadow: 0 0 0 4px rgba(53, 162, 181, 0.14);
}

body[data-page="admin"] .admin-modal-card .input-group label,
body[data-page="admin"] .admin-modal-card .eyebrow {
    color: #ecf3fb;
}

body[data-page="admin"] .plan-mode-inline-card,
body[data-page="admin"] .quota-inline-card,
body[data-page="admin"] .edit-quota-card,
body[data-page="admin"] .quota-stats-card {
    border-color: rgba(111, 146, 178, 0.14);
    background: linear-gradient(180deg, rgba(18, 28, 40, 0.72), rgba(14, 22, 33, 0.88));
}

body[data-page="admin"] .plan-mode-header strong,
body[data-page="admin"] .quota-inline-header strong,
body[data-page="admin"] .quota-stats-card strong,
body[data-page="admin"] .quota-row-panel strong,
body[data-page="admin"] .quota-row-panel b {
    color: #ecf3fb;
}

body[data-page="admin"] .plan-mode-header p,
body[data-page="admin"] .quota-inline-header p,
body[data-page="admin"] .plan-mode-copy,
body[data-page="admin"] .quota-stats-card span,
body[data-page="admin"] .quota-stats-card small,
body[data-page="admin"] .quota-row-panel small {
    color: #8ca0b5;
}

body[data-page="admin"] .quota-row-panel {
    border-color: rgba(92, 208, 195, 0.16);
    background: linear-gradient(180deg, rgba(26, 92, 92, 0.24), rgba(17, 40, 54, 0.28));
}

body[data-page="admin"] .quota-row-panel-muted {
    border-color: rgba(111, 146, 178, 0.14);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

body[data-page="admin"] .quota-row-panel-danger {
    border-color: rgba(225, 107, 132, 0.22);
    background: linear-gradient(180deg, rgba(106, 34, 51, 0.36), rgba(73, 26, 41, 0.28));
}

.medicine-option {
    width: 100%;
    padding: 16px 18px;
    border: 1px solid #d4e0eb;
    border-radius: 18px;
    display: grid;
    gap: 5px;
    background: linear-gradient(180deg, #ffffff, #f5f9fc);
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.medicine-option:hover {
    transform: translateY(-1px);
    border-color: #8db3d4;
    box-shadow: 0 12px 28px rgba(50, 88, 120, 0.12);
}

.medicine-option strong {
    color: #123761;
    font-size: 1rem;
}

.medicine-option span {
    color: #61778f;
    line-height: 1.45;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulseAttention {
    0%,
    100% {
        transform: translateY(0);
        filter: saturate(1);
    }
    50% {
        transform: translateY(-1px);
        filter: saturate(1.08);
    }
}

@media (max-width: 1180px) {
    .pdf-viewer {
        min-height: auto;
    }

    .user-create-bar,
    .settings-grid {
        grid-template-columns: 1fr 1fr;
    }

    .quota-inline-grid,
    .admin-modal-grid {
        grid-template-columns: 1fr;
    }

    .table-row {
        grid-template-columns: minmax(170px, 1fr) 100px 100px 110px 130px;
    }

    .table-row > span:last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
        position: static;
        grid-template-rows: auto auto auto;
    }

    .nav-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar,
    .generator-topbar {
        position: static;
    }

    .generator-shell {
        width: 100%;
        margin: 0;
        box-shadow: none;
        border-left: 0;
        border-right: 0;
    }

    .patient-grid,
    .medicine-row,
    .user-create-bar,
    .settings-grid,
    .setting-block,
    .topbar {
        grid-template-columns: 1fr;
    }

    .quota-inline-header {
        flex-direction: column;
        align-items: stretch;
    }

    .medicine-name-shell input {
        padding-right: 14px;
    }

    .medicine-status-chip {
        position: static;
        transform: none;
        margin-top: 10px;
    }

    .medicine-name-shell {
        display: grid;
    }

    .topbar,
    .generator-topbar {
        display: grid;
    }

    .status-strip,
    .status-strip.compact {
        justify-content: flex-start;
    }
}

@media (max-width: 680px) {
    body {
        background: linear-gradient(180deg, #f8faf6 0%, #edf2ed 100%);
    }

    .login-view {
        padding: 16px;
    }

    .login-panel {
        padding: 24px 20px;
    }

    .generator-topbar,
    .controls,
    .pdf-viewer,
    .info,
    .panel-heading {
        padding-left: 16px;
        padding-right: 16px;
    }

    .pdf-viewer {
        margin-left: 0;
        margin-right: 0;
        border-radius: 0;
    }

    .form-card,
    .user-create-bar,
    .setting-block,
    .users-table {
        border-radius: 20px;
    }

    .user-create-bar,
    .users-table,
    #usersMessage,
    .settings-grid {
        margin-left: 16px;
        margin-right: 16px;
    }

    .status-strip > div,
    .mode-badge,
    .action-bar .btn,
    .user-create-bar .btn,
    .manager-only-link {
        width: 100%;
    }

    .action-bar {
        display: grid;
    }

    .nav-list {
        grid-template-columns: 1fr;
    }

    .nav-item {
        justify-content: center;
    }

    .table-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 14px;
    }

    .table-head {
        display: none;
    }

    .table-row:not(.table-head) {
        background: #fff;
    }

    body[data-page="admin"] .table-row:not(.table-head) {
        background: linear-gradient(180deg, rgba(17, 28, 40, 0.98), rgba(12, 20, 31, 0.98));
        border: 1px solid rgba(111, 146, 178, 0.12);
        border-radius: 18px;
        margin-bottom: 12px;
    }

    body[data-page="admin"] .users-table {
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    body[data-page="admin"] .user-main-cell strong,
    body[data-page="admin"] .table-row span,
    body[data-page="admin"] .table-row small {
        color: #ecf3fb;
    }

    body[data-page="admin"] .table-row small,
    body[data-page="admin"] .quota-row-panel small {
        color: #8ca0b5;
    }

    .row-actions {
        padding-top: 4px;
    }

    body[data-page="admin"] .row-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .model-switch {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .pdf-viewer {
        padding-top: 54px;
    }

    #pdfCanvas,
    #previewCanvas {
        width: 100%;
    }
}
