: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;
}

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

/* The HTML `hidden` attribute defaults to `display: none` in the user-agent
   stylesheet. Author CSS that sets `display: flex/grid/etc.` overrides it.
   This rule restores hidden's "unconditional hide" semantics so toggling
   `el.hidden = true` works regardless of the element's display value. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--body-font);
    background: linear-gradient(135deg, #f0f4ff 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-blue); 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: rgba(13,144,79,0.08); color: var(--color-green);
    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: rgba(26,115,232,0.08); color: var(--color-blue);
    font-size: 0.8rem; font-weight: 500; margin-bottom: 24px;
    border: 1px solid rgba(26,115,232,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, #1a73e8, #8b5cf6);
    -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-blue);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.12);
}
.auth-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;
}
.auth-warning .material-icons-outlined { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.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-blue); color: white;
    box-shadow: 0 2px 10px rgba(26,115,232,0.25);
}
.cta-primary:hover { background: var(--color-blue-strong); transform: translateY(-1px); box-shadow: 0 4px 18px rgba(26,115,232,0.35); }
.cta-primary:disabled { background: var(--color-text-secondary); cursor: not-allowed; transform: none; box-shadow: none; }
.cta-secondary {
    background: white; color: var(--color-blue);
    border: 1px solid var(--color-border);
}
.cta-secondary:hover { background: var(--color-surface); border-color: var(--color-blue); }
.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; }

/* ═══════ 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: rgba(26,115,232,0.08); color: var(--color-blue);
}
.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(217,48,37,0.06); border: 1px solid rgba(217,48,37,0.18);
    font-size: 0.78rem; color: var(--color-red); line-height: 1.55;
}
.auth-disclaimer strong { font-weight: 500; }

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

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

.upload-zone {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 2px dashed var(--color-border);
    border-radius: 14px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--color-blue); background: rgba(26,115,232,0.04);
}
.upload-icon {
    font-size: 40px !important; color: var(--color-blue); margin-bottom: 8px;
}
.upload-title { font-weight: 500; font-size: 0.95rem; margin-bottom: 4px; }
.upload-hint { font-size: 0.8rem; color: var(--color-text-secondary); line-height: 1.5; }

.upload-form {
    background: rgba(255,255,255,0.7);
    border: 1px solid var(--color-border); border-radius: 12px;
    padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}
.upload-form label { display: flex; flex-direction: column; gap: 4px; }
.upload-form label span { font-size: 0.78rem; color: var(--color-text-secondary); font-weight: 500; }
.upload-form select, .upload-form input {
    padding: 8px 10px; border-radius: 6px; border: 1px solid var(--color-border);
    font-size: 0.88rem; font-family: var(--body-font);
    background: white;
}

.upload-progress {
    background: rgba(255,255,255,0.85);
    border: 1px solid var(--color-blue); border-radius: 12px;
    padding: 14px 16px;
}
.upload-progress-text {
    font-size: 0.85rem; color: var(--color-text); margin-bottom: 8px; font-weight: 500;
}
.upload-progress-bar {
    height: 6px; background: var(--color-surface); border-radius: 999px; overflow: hidden;
}
.upload-progress-bar > div {
    height: 100%; width: 0%; background: linear-gradient(90deg, var(--color-blue), var(--color-purple));
    transition: width 0.2s ease;
}

.sidebar-section {
    background: rgba(255,255,255,0.7); border: 1px solid var(--color-border);
    border-radius: 12px; padding: 14px 16px;
}
.sidebar-section h3 {
    font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--color-text-secondary); margin-bottom: 12px;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
    padding: 5px 11px; border-radius: 999px; border: 1px solid var(--color-border);
    background: white; font-size: 0.78rem; cursor: pointer;
    font-family: var(--body-font); color: var(--color-text-secondary);
    transition: all 0.15s ease;
}
.filter-chip:hover { color: var(--color-text); }
.filter-chip.active {
    background: var(--color-blue); color: white; border-color: var(--color-blue);
}
.sidebar-stats { font-size: 0.85rem; color: var(--color-text-secondary); }
.sidebar-stats .stat-row {
    display: flex; justify-content: space-between; padding: 4px 0;
}
.sidebar-stats .stat-row strong { color: var(--color-text); font-weight: 500; }

/* ═══════ CONTENT ═══════ */
.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; }

.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
    display: grid;
    grid-template-columns: 40px 1fr auto auto auto;
    gap: 14px; align-items: center;
    padding: 14px 16px; border-radius: 10px;
    background: white; border: 1px solid var(--color-border);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.file-row:hover { border-color: var(--color-blue); box-shadow: 0 2px 12px rgba(0,0,0,0.05); }
.file-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(26,115,232,0.08); color: var(--color-blue);
}
.file-icon.cat-imaging { background: rgba(139,92,246,0.08); color: var(--color-purple); }
.file-icon.cat-lab { background: rgba(13,144,79,0.08); color: var(--color-green); }
.file-icon.cat-ehr { background: rgba(227,116,0,0.08); color: var(--color-amber); }
.file-icon.cat-note { background: rgba(217,48,37,0.08); color: var(--color-red); }
.file-icon .material-icons-outlined { font-size: 22px; }
.file-meta-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.file-name {
    font-weight: 500; font-size: 0.95rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-meta-sub {
    font-size: 0.78rem; color: var(--color-text-secondary);
    display: flex; gap: 10px; flex-wrap: wrap;
}
.file-cid {
    font-family: 'SF Mono', 'Roboto Mono', Menlo, Consolas, monospace;
    font-size: 0.72rem; color: var(--color-text-secondary);
    padding: 4px 8px; background: var(--color-surface); border-radius: 6px;
    cursor: pointer;
    max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-cid:hover { color: var(--color-blue); }
.file-size {
    font-size: 0.82rem; color: var(--color-text-secondary);
    white-space: nowrap;
}
.file-actions { display: flex; gap: 4px; }
.action-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid var(--color-border);
    background: white; cursor: pointer;
    color: var(--color-text-secondary);
    transition: all 0.15s ease;
}
.action-btn:hover { color: var(--color-blue); border-color: var(--color-blue); }
.action-btn.danger:hover { color: var(--color-red); border-color: var(--color-red); }
.action-btn .material-icons-outlined { font-size: 18px; }

.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: 720px; max-height: 80vh;
    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: 16px 24px; overflow-y: auto;
}
.audit-row {
    display: grid; grid-template-columns: 110px 80px 1fr 120px;
    gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.85rem;
    align-items: center;
}
.audit-row:last-child { border-bottom: none; }
.audit-action {
    text-transform: uppercase; font-size: 0.7rem; font-weight: 700;
    padding: 2px 8px; border-radius: 999px;
    background: var(--color-surface); color: var(--color-text-secondary);
    text-align: center;
}
.audit-action.upload { background: rgba(13,144,79,0.1); color: var(--color-green); }
.audit-action.delete { background: rgba(217,48,37,0.1); color: var(--color-red); }
.audit-action.login, .audit-action.signup { background: rgba(26,115,232,0.1); color: var(--color-blue); }
.audit-time { font-size: 0.78rem; color: var(--color-text-secondary); font-family: 'SF Mono', monospace; }
.audit-email { font-size: 0.85rem; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-ip { font-size: 0.78rem; color: var(--color-text-secondary); font-family: 'SF Mono', monospace; text-align: right; }

/* ═══════ 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; }
    .file-row { grid-template-columns: 40px 1fr auto; }
    .file-cid, .file-size { display: none; }
}
@media (max-width: 600px) {
    .auth-card, .auth-aside { padding: 24px; }
    .auth-card h1 { font-size: 1.6rem; }
    .top-bar { padding: 0 12px; height: 56px; }
}
