:root {
    --body-font: 'Google Sans Text', 'Google Sans', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --display-font: 'Google Sans', 'Google Sans Text', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --color-text: #202124;
    --color-text-secondary: #5f6368;
    --color-border: #dadce0;
    --color-surface: #f8f9fa;
    --color-surface-elev: #ffffff;
    --color-blue: #1a73e8;
    --color-blue-strong: #1557b0;
    --color-green: #0d904f;
    --color-amber: #e37400;
    --color-red: #d93025;
    --color-purple: #8b5cf6;
    --color-teal: #00695c;
    --color-teal-soft: rgba(0, 105, 92, 0.08);
}

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

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--body-font);
    background: linear-gradient(135deg, #effaf6 0%, #e8f0fe 50%, #f5f0ff 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--color-text);
    line-height: 1.5;
    letter-spacing: 0.1px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { font-family: var(--display-font); letter-spacing: -0.5px; }

/* ═══════ TOP BAR ═══════ */
.top-bar {
    position: sticky; top: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; height: 64px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--color-border);
}
.logo-area { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-area img { width: 32px; height: 32px; border-radius: 8px; }
.logo-area span {
    color: var(--color-text); font-size: 1.1rem; font-weight: 500;
    font-family: var(--display-font);
}
.logo-area em {
    font-style: normal; color: var(--color-teal); font-weight: 500;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.hospital-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 999px;
    background: var(--color-teal-soft); color: var(--color-teal);
    font-size: 0.85rem; font-weight: 500;
}
.hospital-badge .material-icons-outlined { font-size: 16px; }
.icon-btn {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: transparent; border: none; cursor: pointer;
    color: var(--color-text-secondary);
    transition: background 0.12s ease;
}
.icon-btn:hover { background: var(--color-surface); }
.icon-btn .material-icons-outlined { font-size: 22px; }

/* ═══════ AUTH VIEW ═══════ */
.auth-view {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 48px; max-width: 1200px;
    margin: 0 auto; padding: 64px 32px;
    align-items: start;
}
.auth-card, .auth-aside {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 36px;
}
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 16px; border-radius: 999px;
    background: var(--color-teal-soft); color: var(--color-teal);
    font-size: 0.8rem; font-weight: 500; margin-bottom: 24px;
    border: 1px solid rgba(0,105,92,0.15);
}
.chip .material-icons-outlined { font-size: 16px; }
.auth-card h1 {
    font-size: 2rem; font-weight: 500; line-height: 1.15;
    letter-spacing: -1px; margin-bottom: 16px;
    background: linear-gradient(135deg, var(--color-teal), var(--color-blue));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.subtitle {
    font-size: 0.95rem; color: var(--color-text-secondary);
    line-height: 1.7; margin-bottom: 28px;
}

.auth-tabs {
    display: flex; gap: 4px; padding: 4px;
    background: var(--color-surface); border-radius: 10px;
    margin-bottom: 24px;
}
.auth-tab {
    flex: 1; padding: 10px 16px;
    background: transparent; border: none; cursor: pointer;
    font-family: var(--display-font); font-size: 0.9rem; font-weight: 500;
    color: var(--color-text-secondary); border-radius: 8px;
    transition: all 0.15s ease;
}
.auth-tab.active { background: white; color: var(--color-text); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.auth-tab:hover:not(.active) { color: var(--color-text); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; }
.auth-form label span {
    font-size: 0.82rem; font-weight: 500; color: var(--color-text-secondary);
}
.auth-form input, .auth-form select {
    padding: 12px 14px; border-radius: 8px; border: 1px solid var(--color-border);
    font-size: 0.95rem; font-family: var(--body-font);
    background: white; color: var(--color-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-form input:focus, .auth-form select:focus {
    outline: none; border-color: var(--color-teal);
    box-shadow: 0 0 0 3px rgba(0,105,92,0.12);
}
.auth-error {
    color: var(--color-red); font-size: 0.85rem; margin-top: 4px;
}

.cta-btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    padding: 12px 24px; border-radius: 8px; font-size: 0.95rem;
    font-weight: 500; text-decoration: none; transition: all 0.2s;
    border: none; cursor: pointer;
    font-family: var(--display-font);
}
.cta-primary {
    background: var(--color-teal); color: white;
    box-shadow: 0 2px 10px rgba(0,105,92,0.25);
}
.cta-primary:hover { background: #00574b; transform: translateY(-1px); box-shadow: 0 4px 18px rgba(0,105,92,0.32); }
.cta-primary:disabled { background: var(--color-text-secondary); cursor: not-allowed; transform: none; box-shadow: none; }
.cta-secondary {
    background: white; color: var(--color-teal);
    border: 1px solid var(--color-border);
}
.cta-secondary:hover { background: var(--color-surface); border-color: var(--color-teal); }
.cta-danger {
    background: white; color: var(--color-red);
    border: 1px solid var(--color-border);
}
.cta-danger:hover { background: rgba(217,48,37,0.06); border-color: var(--color-red); }
.cta-btn .material-icons-outlined { font-size: 20px; }

.link-btn {
    background: none; border: none; padding: 0;
    color: var(--color-teal); cursor: pointer;
    font-family: var(--display-font); font-size: 0.82rem; font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

/* ═══════ AUTH ASIDE ═══════ */
.auth-aside h2 {
    font-size: 1.35rem; font-weight: 500; margin-bottom: 20px;
}
.auth-features { list-style: none; display: flex; flex-direction: column; gap: 20px; margin-bottom: 24px; }
.auth-features li { display: flex; gap: 14px; }
.auth-features li > .material-icons-outlined {
    flex-shrink: 0; width: 40px; height: 40px;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 22px; background: var(--color-teal-soft); color: var(--color-teal);
}
.auth-features li:nth-child(2) > .material-icons-outlined { background: rgba(139,92,246,0.08); color: var(--color-purple); }
.auth-features li:nth-child(3) > .material-icons-outlined { background: rgba(13,144,79,0.08); color: var(--color-green); }
.auth-features li:nth-child(4) > .material-icons-outlined { background: rgba(227,116,0,0.08); color: var(--color-amber); }
.auth-features li strong {
    display: block; font-weight: 500; font-size: 0.95rem; margin-bottom: 4px;
}
.auth-features li p {
    font-size: 0.85rem; color: var(--color-text-secondary); line-height: 1.55;
}
.auth-disclaimer {
    padding: 14px 16px; border-radius: 10px;
    background: rgba(227,116,0,0.06); border: 1px solid rgba(227,116,0,0.18);
    font-size: 0.78rem; color: var(--color-amber); line-height: 1.55;
}
.auth-disclaimer strong { font-weight: 500; }

/* ═══════ APP VIEW ═══════ */
.app-view {
    display: grid; grid-template-columns: 360px 1fr;
    gap: 24px; max-width: 1400px;
    margin: 0 auto; padding: 24px 32px 64px;
}

.sidebar { display: flex; flex-direction: column; gap: 16px; }

.sidebar-card {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 18px 18px 20px;
}
.sidebar-section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.sidebar-section-header h3 {
    font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--color-text-secondary);
}

/* ─── Handshake card ─── */
.handshake-card { padding-bottom: 22px; }
.handshake-header {
    display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px;
}
.handshake-header > .material-icons-outlined {
    flex-shrink: 0; width: 40px; height: 40px;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    background: var(--color-teal-soft); color: var(--color-teal);
}
.handshake-header h3 { font-size: 1.02rem; font-weight: 500; margin-bottom: 2px; }
.handshake-header p { font-size: 0.82rem; color: var(--color-text-secondary); }

.handshake-actor {
    display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px;
}
.handshake-actor span {
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--color-text-secondary);
}
.handshake-actor select {
    padding: 9px 12px; border-radius: 8px; border: 1px solid var(--color-border);
    font-size: 0.88rem; background: white; font-family: var(--body-font);
}

.qr-canvas {
    width: 100%; aspect-ratio: 1; max-width: 240px;
    margin: 0 auto 14px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    padding: 14px;
    overflow: hidden;
}
.qr-canvas img, .qr-canvas canvas { width: 100% !important; height: 100% !important; }
.qr-canvas-lg { max-width: 320px; }

.handshake-code {
    text-align: center;
    font-family: 'SF Mono', 'Roboto Mono', Menlo, Consolas, monospace;
    font-size: 1.6rem; letter-spacing: 6px; font-weight: 700;
    color: var(--color-text); margin-bottom: 10px;
}

.handshake-meta {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.78rem; color: var(--color-text-secondary);
}

.handshake-status {
    margin-top: 14px; padding: 10px 12px;
    background: rgba(13,144,79,0.08); color: var(--color-green);
    border-radius: 8px; font-size: 0.85rem;
    display: flex; align-items: center; gap: 8px;
}
.handshake-status .material-icons-outlined { font-size: 18px; }

/* ─── Profile summary ─── */
.profile-summary {
    font-size: 0.85rem; color: var(--color-text-secondary);
    display: flex; flex-direction: column; gap: 6px;
}
.profile-summary .row { display: flex; justify-content: space-between; gap: 8px; }
.profile-summary .row strong {
    color: var(--color-text); font-weight: 500;
    text-align: right; max-width: 65%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ─── Dependents ─── */
.dependents-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.dependents-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px; border-radius: 8px; background: var(--color-surface);
    font-size: 0.85rem;
}
.dependents-list li small { color: var(--color-text-secondary); margin-left: 6px; }
.dependents-list .dep-remove {
    background: none; border: none; cursor: pointer; color: var(--color-text-secondary);
    width: 24px; height: 24px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
}
.dependents-list .dep-remove:hover { color: var(--color-red); background: white; }
.dependents-list .dep-remove .material-icons-outlined { font-size: 16px; }
.dependents-empty { font-size: 0.82rem; color: var(--color-text-secondary); font-style: italic; }

/* ═══════ CONTENT (prescription list) ═══════ */
.content {
    background: rgba(255,255,255,0.6);
    border: 1px solid var(--color-border); border-radius: 16px;
    padding: 24px 28px; min-height: 60vh;
}
.content-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.content-header h2 { font-size: 1.5rem; font-weight: 500; margin-bottom: 4px; }
.content-subtitle { font-size: 0.85rem; color: var(--color-text-secondary); }
.content-actions { display: flex; gap: 8px; }

.rx-list { display: flex; flex-direction: column; gap: 12px; }

.rx-group {
    background: white; border: 1px solid var(--color-border);
    border-radius: 14px; overflow: hidden;
}
.rx-group-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    font-size: 0.85rem; color: var(--color-text-secondary);
    flex-wrap: wrap; gap: 8px;
}
.rx-group-header .doctor-line { display: flex; align-items: center; gap: 8px; }
.rx-group-header .doctor-line strong { color: var(--color-text); font-weight: 500; }
.rx-group-header .group-actions { display: flex; gap: 8px; }
.rx-group-header .rx-badge {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    padding: 3px 8px; border-radius: 999px; letter-spacing: 0.5px;
    background: var(--color-teal-soft); color: var(--color-teal);
}
.rx-group-header .rx-badge.dispensed { background: rgba(13,144,79,0.1); color: var(--color-green); }
.rx-group-header .rx-badge.dependent { background: rgba(139,92,246,0.08); color: var(--color-purple); }

.rx-items { display: flex; flex-direction: column; }
.rx-item {
    display: grid; grid-template-columns: 44px 1fr auto;
    gap: 14px; align-items: center;
    padding: 14px 18px; border-top: 1px solid var(--color-border);
}
.rx-item:first-child { border-top: none; }
.rx-item .rx-icon {
    width: 44px; height: 44px; border-radius: 10px;
    background: var(--color-teal-soft); color: var(--color-teal);
    display: flex; align-items: center; justify-content: center;
}
.rx-item .rx-icon .material-icons-outlined { font-size: 22px; }
.rx-item .rx-main .medication {
    font-weight: 500; font-size: 1rem; margin-bottom: 2px;
}
.rx-item .rx-main .schedule {
    font-size: 0.82rem; color: var(--color-text-secondary);
}
.rx-item .rx-main .instructions {
    font-size: 0.78rem; color: var(--color-text-secondary);
    font-style: italic; margin-top: 4px;
}
.rx-item .rx-action {
    display: flex; gap: 6px; align-items: center;
}
.rx-item .rx-action .cta-btn {
    padding: 8px 14px; font-size: 0.82rem;
}
.rx-item.is-dispensed .rx-icon { background: rgba(13,144,79,0.1); color: var(--color-green); }

.empty-state {
    text-align: center; padding: 60px 24px; color: var(--color-text-secondary);
}
.empty-state .material-icons-outlined { font-size: 48px; opacity: 0.5; }
.empty-state h3 { margin: 12px 0 6px; font-weight: 500; }

/* ═══════ MODAL ═══════ */
.modal {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.modal-card {
    background: white; border-radius: 16px;
    width: 100%; max-width: 520px; max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px; border-bottom: 1px solid var(--color-border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 500; }
.modal-body {
    padding: 20px 24px 24px; overflow-y: auto;
}
.modal-form { display: flex; flex-direction: column; gap: 14px; }
.modal-form label { display: flex; flex-direction: column; gap: 5px; }
.modal-form label span { font-size: 0.78rem; color: var(--color-text-secondary); font-weight: 500; }
.modal-form input, .modal-form select {
    padding: 11px 13px; border-radius: 8px; border: 1px solid var(--color-border);
    font-size: 0.92rem; font-family: var(--body-font); background: white;
}
.modal-form input:focus, .modal-form select:focus {
    outline: none; border-color: var(--color-teal);
    box-shadow: 0 0 0 3px rgba(0,105,92,0.12);
}
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px;
}

.dispense-body { text-align: center; }
.dispense-medication { font-weight: 500; font-size: 1.05rem; margin-bottom: 16px; }
.dispense-token {
    font-family: 'SF Mono', 'Roboto Mono', Menlo, Consolas, monospace;
    font-size: 0.78rem; color: var(--color-text-secondary);
    margin: 12px 0 6px; word-break: break-all;
    padding: 8px 12px; background: var(--color-surface); border-radius: 8px;
}
.dispense-expiry { font-size: 0.85rem; color: var(--color-text-secondary); margin-bottom: 16px; }
.dispense-warning {
    display: flex; gap: 10px; padding: 12px 14px;
    background: rgba(227,116,0,0.08); border: 1px solid rgba(227,116,0,0.2);
    border-radius: 8px;
    color: var(--color-amber); font-size: 0.82rem; line-height: 1.5;
    text-align: left;
}
.dispense-warning .material-icons-outlined { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

/* ═══════ TOAST ═══════ */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--color-text); color: white;
    padding: 12px 20px; border-radius: 10px;
    font-size: 0.88rem; font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    z-index: 2000;
    max-width: 90%;
}
.toast.error { background: var(--color-red); }
.toast.success { background: var(--color-green); }

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 960px) {
    .auth-view { grid-template-columns: 1fr; padding: 32px 16px; gap: 24px; }
    .app-view { grid-template-columns: 1fr; padding: 16px; }
}
@media (max-width: 600px) {
    .auth-card, .auth-aside { padding: 24px; }
    .auth-card h1 { font-size: 1.6rem; }
    .top-bar { padding: 0 12px; height: 56px; }
    .rx-item { grid-template-columns: 1fr; }
    .rx-item .rx-icon { display: none; }
}
