@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #1b7252;
  --primary-2: #2f9770;
  --primary-soft: #e8f6f0;
  --blue: #1e3a5f;
  --blue-2: #2563eb;
  --bg: #f7f8fa;
  --cream: #faf8f4;
  --white: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #c0392b;
  --warning: #b45309;
  --sidebar: 272px;
  --radius: 18px;
  --shadow: 0 18px 48px rgba(15, 23, 42, .08);
}
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; }
.small { font-size: .82rem; color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* Admin */
.admin-body { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: linear-gradient(180deg, #123452, #0f2b45); color: white; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-brand { padding: 26px 22px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid rgba(255,255,255,.10); }
.brand-mark { width: 40px; height: 40px; border-radius: 14px; background: rgba(255,255,255,.14); display: grid; place-items: center; font-weight: 700; font-size: 1.5rem; }
.sidebar-brand h1 { font-family: 'DM Serif Display', serif; font-size: 1.18rem; line-height: 1; }
.sidebar-brand p { opacity: .65; font-size: .75rem; margin-top: 5px; }
.sidebar nav { padding: 16px 12px; flex: 1; }
.nav-section { display: block; font-size: .68rem; font-weight: 700; color: rgba(255,255,255,.42); letter-spacing: .12em; padding: 10px 12px 7px; }
.nav-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: rgba(255,255,255,.74); padding: 11px 12px; border-radius: 12px; font-size: .92rem; transition: .16s ease; margin-bottom: 3px; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.13); color: white; }
.nav-link .icon { width: 22px; text-align: center; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,.10); }
.admin-info { padding: 12px; color: rgba(255,255,255,.7); font-size: .82rem; }
.admin-info strong { color: white; display: block; margin-bottom: 4px; }
.btn-logout { display: block; text-align: center; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.10); color: white; text-decoration: none; font-size: .86rem; }
.btn-logout:hover { background: rgba(255,255,255,.18); }
.main { margin-left: var(--sidebar); width: calc(100% - var(--sidebar)); padding: 32px 38px 46px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.page-title h2 { font-family: 'DM Serif Display', serif; font-size: 2rem; font-weight: 400; letter-spacing: -.02em; }
.page-title p { color: var(--muted); margin-top: 4px; font-size: .94rem; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 8px 28px rgba(15, 23, 42, .04); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.stat-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); font-size: 1.25rem; }
.stat-val { font-size: 2rem; font-weight: 700; letter-spacing: -.04em; }
.stat-label { color: var(--muted); font-size: .86rem; margin-top: 2px; }
.card { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(15, 23, 42, .04); overflow: hidden; margin-bottom: 22px; }
.card-header { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.card-header h3 { font-size: 1.02rem; font-weight: 700; }
.card-body { padding: 22px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th { padding: 13px 16px; text-align: left; background: #f8fafc; border-bottom: 1px solid var(--line); font-size: .74rem; color: var(--muted); letter-spacing: .07em; font-weight: 800; text-transform: uppercase; }
td { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; font-size: .9rem; vertical-align: middle; }
tr:hover td { background: #fcfcfd; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr auto; gap: 10px; width: 100%; align-items: end; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-weight: 700; font-size: .86rem; }
input, select, textarea { width: 100%; border: 2px solid var(--line); background: white; color: var(--text); border-radius: 12px; padding: 12px 14px; font-family: 'DM Sans', sans-serif; font-size: .94rem; outline: none; transition: .16s; }
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-2); box-shadow: 0 0 0 4px rgba(37, 99, 235, .08); }
.hint { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.btn { border: 0; border-radius: 12px; padding: 10px 16px; font-family: 'DM Sans', sans-serif; font-weight: 700; font-size: .88rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: .16s ease; white-space: nowrap; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: #25517e; transform: translateY(-1px); }
.btn-green { background: var(--primary); color: white; }
.btn-green:hover { background: var(--primary-2); transform: translateY(-1px); }
.btn-ghost { background: #f1f5f9; color: var(--text); }
.btn-ghost:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-outline { background: white; color: var(--blue); border: 1px solid var(--line); }
.btn-outline:hover { border-color: var(--blue); }
.btn-sm { padding: 7px 11px; font-size: .78rem; border-radius: 10px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: .75rem; font-weight: 800; white-space: nowrap; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.alert { border-radius: 14px; padding: 14px 16px; margin-bottom: 18px; font-size: .91rem; border: 1px solid transparent; }
.alert-ok { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.alert-erro { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.whatsapp-box { background: #ecfdf5; border: 1px solid #bbf7d0; border-radius: 16px; padding: 18px; display: grid; gap: 12px; margin-bottom: 20px; }
.copy-area { width: 100%; min-height: 90px; padding: 12px; border-radius: 12px; border: 1px solid #bbf7d0; background: white; font-family: 'DM Sans', sans-serif; }
.drop-zone { border: 2px dashed #cbd5e1; border-radius: 16px; padding: 36px 20px; text-align: center; background: #f8fafc; cursor: pointer; transition: .16s; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--blue-2); background: #eff6ff; }
.drop-zone input[type=file] { display: none; }
.dz-icon { font-size: 2.4rem; margin-bottom: 10px; }
.file-preview { display: none; gap: 12px; align-items: center; padding: 12px 14px; background: #f0fdf4; border-radius: 12px; margin-top: 10px; }
.file-preview.show { display: flex; }
.file-preview-icon { font-size: 1.7rem; }
.file-preview-name { font-weight: 800; }
.file-preview-size { font-size: .78rem; color: var(--muted); }
.empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty .emoji { font-size: 3rem; display: block; margin-bottom: 12px; opacity: .55; }

/* Login and patient */
.login-body, .patient-body { background: radial-gradient(circle at 16% 0%, rgba(27,114,82,.10), transparent 28%), var(--cream); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px; }
.login-card { width: min(510px, 100%); background: rgba(255,255,255,.78); backdrop-filter: blur(18px); border: 1px solid rgba(226,232,240,.85); border-radius: 26px; box-shadow: var(--shadow); padding: 36px; }
.login-card h1 { font-family: 'DM Serif Display', serif; font-size: 2.2rem; font-weight: 400; }
.login-card p { color: var(--muted); margin-top: 6px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--primary-soft); padding: 6px; border-radius: 16px; margin: 26px 0; }
.tab { border: 0; background: transparent; border-radius: 12px; padding: 12px; color: var(--muted); font-weight: 700; cursor: pointer; }
.tab.active { background: white; color: var(--primary); box-shadow: 0 8px 20px rgba(15,23,42,.08); }
.admin-link { display: block; text-align: center; color: var(--primary); margin-top: 22px; text-decoration: none; font-weight: 700; }
.patient-header { height: 76px; background: rgba(255,255,255,.86); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; padding: 0 38px; position: sticky; top: 0; z-index: 10; }
.patient-brand { display: flex; gap: 12px; align-items: center; font-family: 'DM Serif Display', serif; font-size: 1.35rem; color: var(--primary); }
.patient-brand .mark { width: 38px; height: 38px; border-radius: 14px; background: var(--primary-soft); display: grid; place-items: center; font-family: 'DM Sans', sans-serif; font-weight: 800; }
.patient-user { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .9rem; }
.patient-main { max-width: 1120px; margin: 0 auto; padding: 34px 28px 48px; }
.hero { border-radius: 28px; background: linear-gradient(135deg, #1b7252, #40a87d); color: white; padding: 34px 36px; position: relative; overflow: hidden; margin-bottom: 24px; }
.hero::after { content: '📋'; position: absolute; right: 36px; top: 18px; font-size: 7rem; opacity: .12; transform: rotate(-8deg); }
.hero h2 { font-family: 'DM Serif Display', serif; font-weight: 400; font-size: 2rem; }
.hero p { opacity: .82; margin-top: 8px; max-width: 620px; }
.exam-list { display: grid; gap: 14px; }
.exam-row { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; box-shadow: 0 8px 25px rgba(15,23,42,.04); }
.exam-file { width: 52px; height: 52px; border-radius: 16px; background: var(--primary-soft); display: grid; place-items: center; font-size: 1.5rem; }
.exam-title { font-size: 1.02rem; font-weight: 800; }
.exam-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: .84rem; margin-top: 6px; }
.exam-actions { display: flex; gap: 8px; }

@media (max-width: 980px) {
  .sidebar { position: static; width: 100%; height: auto; }
  .admin-body { display: block; }
  .main { margin-left: 0; width: 100%; padding: 22px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .page-header, .patient-header { flex-direction: column; height: auto; align-items: flex-start; padding: 18px; }
  .cards, .form-grid, .filters { grid-template-columns: 1fr; }
  .login-card { padding: 26px; }
  .exam-row { grid-template-columns: 1fr; }
  .exam-actions { width: 100%; }
  .exam-actions .btn { flex: 1; }
}
