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

body {
  min-height: 100vh;
  background: #f0f4f8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 24px 16px;
  position: relative;
}

/* Arizona Urology watermark background */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    linear-gradient(135deg, rgba(27,58,107,0.04) 0%, rgba(245,166,35,0.04) 100%);
  pointer-events: none;
  z-index: 0;
}

.card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 32px rgba(27,58,107,0.12);
  padding: 36px 32px;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.upload-card { max-width: 680px; }

/* Clinic banner at top of card */
.clinic-banner {
  background: linear-gradient(135deg, #1b3a6b 0%, #2557a7 100%);
  margin: -36px -32px 24px -32px;
  padding: 18px 24px;
  border-radius: 16px 16px 0 0;
  text-align: center;
}

.clinic-banner-name {
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.3;
}

.clinic-banner-sub {
  color: #f5a623;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 3px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.card-header { text-align: center; margin-bottom: 28px; }

.logo {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, #1b3a6b, #2557a7);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}

.success-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}

.card-header h1 { font-size: 1.35rem; font-weight: 700; color: #111827; margin-bottom: 4px; }
.card-header p  { font-size: 0.875rem; color: #6b7280; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: #374151; margin-bottom: 6px; }

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #d1d5db; border-radius: 8px;
  font-size: 0.9rem; color: #111827;
  outline: none; transition: border-color .15s;
}
input:focus { border-color: #1b3a6b; }

.field-error { display: block; font-size: 0.75rem; color: #dc2626; margin-top: 4px; min-height: 16px; }

.btn {
  width: 100%; padding: 12px;
  border: none; border-radius: 10px;
  font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #1b3a6b, #2557a7);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { opacity: .88; }
.btn-outline {
  background: #fff; color: #1b3a6b;
  border: 1.5px solid #1b3a6b; margin-top: 10px;
}
.btn-outline:hover:not(:disabled) { background: #f0f4f8; }

.alert { padding: 11px 14px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 16px; display: none; }
.alert:not(:empty) { display: block; }
.alert-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

.footer-link { text-align: center; font-size: 0.82rem; color: #6b7280; margin-top: 20px; }
.footer-link a { color: #1b3a6b; font-weight: 600; text-decoration: none; }

.hipaa-notice {
  margin-top: 20px;
  font-size: 0.75rem; color: #9ca3af;
  text-align: center; line-height: 1.6;
  position: relative; z-index: 1;
}

.badge {
  display: inline-block;
  background: #1b3a6b; color: #fff;
  border-radius: 99px; padding: 3px 10px;
  font-size: 0.7rem; font-weight: 600;
}

/* OTP inputs */
.otp-group { display: flex; gap: 8px; justify-content: center; margin: 20px 0; }
.otp-input {
  width: 48px; height: 54px; text-align: center;
  font-size: 1.4rem; font-weight: 700; color: #111827;
  border: 1.5px solid #d1d5db; border-radius: 10px; outline: none;
}
.otp-input:focus { border-color: #1b3a6b; }

/* Password rules */
.pwd-rules { list-style: none; margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.pwd-rules li {
  font-size: 0.72rem; padding: 2px 8px;
  border-radius: 99px; background: #f3f4f6; color: #9ca3af;
}
.pwd-rules li.ok { background: #dcfce7; color: #16a34a; }

/* User badge */
.user-badge {
  background: #f0f4f8;
  border-radius: 10px; padding: 14px 16px;
  text-align: center; font-size: 0.85rem;
  color: #1b3a6b; font-weight: 600;
  margin-bottom: 20px;
}

/* Portal header */
.portal-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}
.portal-brand { font-weight: 700; color: #1b3a6b; font-size: 1rem; flex: 1; }
.portal-user  { font-size: 0.82rem; color: #6b7280; }
.portal-sign-out {
  font-size: 0.78rem; color: #1b3a6b; background: none;
  border: 1px solid #1b3a6b; border-radius: 6px;
  padding: 4px 10px; cursor: pointer; font-weight: 600;
}

/* Mode cards */
.mode-select { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.mode-card {
  border: 1.5px solid #d1d5db; border-radius: 12px;
  padding: 16px 12px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mode-card.active { border-color: #1b3a6b; background: #f0f4f8; }
.mode-card svg { display: block; margin: 0 auto 10px; }
.mode-title { font-size: 0.85rem; font-weight: 600; color: #1b3a6b; margin-bottom: 2px; }
.mode-desc  { font-size: 0.72rem; color: #9ca3af; }

/* Upload area */
.upload-area {
  border: 2px dashed #d1d5db; border-radius: 12px;
  padding: 28px 20px; text-align: center; cursor: pointer;
  margin-bottom: 16px; transition: border-color .15s;
}
.upload-area:hover { border-color: #1b3a6b; }
.upload-area svg { display: block; margin: 0 auto 10px; }
.upload-area p { font-size: 0.85rem; color: #6b7280; }

input[type="file"] { display: none; }

.file-list { list-style: none; margin-bottom: 12px; }
.file-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: #f9fafb; border-radius: 8px; margin-bottom: 6px;
  font-size: 0.82rem; color: #374151;
}

.progress-bar-wrap { height: 6px; background: #e5e7eb; border-radius: 99px; margin-bottom: 10px; display: none; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #1b3a6b, #f5a623); border-radius: 99px; width: 0; transition: width .3s; }
.upload-status { font-size: 0.82rem; color: #374151; margin-bottom: 12px; min-height: 18px; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* Stored files */
.stored-panel { display: none; }
.stored-loading, .stored-empty { text-align: center; font-size: 0.85rem; color: #9ca3af; padding: 20px 0; }
.stored-list { list-style: none; max-height: 240px; overflow-y: auto; margin-bottom: 12px; }
.stored-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; font-size: 0.82rem; color: #374151;
}
.stored-list li:hover { background: #f9fafb; }
.stored-list .file-meta { margin-left: auto; font-size: 0.72rem; color: #9ca3af; }

/* Chat */
.chat-section { border-top: 1px solid #e5e7eb; margin-top: 20px; padding-top: 20px; }
.chat-section h2 { font-size: 1rem; font-weight: 700; color: #111827; margin-bottom: 14px; }

.chat-tabs { display: flex; gap: 4px; margin-bottom: 16px; background: #f3f4f6; border-radius: 10px; padding: 4px; }
.chat-tab-btn {
  flex: 1; padding: 8px 6px; border: none; border-radius: 8px;
  background: transparent; font-size: 0.8rem; font-weight: 600;
  color: #6b7280; cursor: pointer;
}
.chat-tab-btn.active { background: #fff; color: #1b3a6b; box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.chat-tab-panel { display: none; }
.chat-tab-panel.active { display: block; }

.chat-file-select {
  width: 100%; padding: 9px 12px; border: 1.5px solid #d1d5db;
  border-radius: 8px; font-size: 0.85rem; color: #374151;
  margin-bottom: 12px; outline: none;
}
.chat-file-select:focus { border-color: #1b3a6b; }

.chat-messages { min-height: 80px; max-height: 320px; overflow-y: auto; margin-bottom: 12px; }
.chat-bubble { padding: 10px 14px; border-radius: 10px; font-size: 0.85rem; line-height: 1.55; margin-bottom: 8px; }
.chat-bubble.user { background: linear-gradient(135deg, #1b3a6b, #2557a7); color: #fff; margin-left: 20%; }
.chat-bubble.ai   { background: #f3f4f6; color: #111827; margin-right: 20%; }
.chat-bubble.loading { background: #f3f4f6; color: #9ca3af; font-style: italic; }

.textarea-with-mic { position: relative; }
.chat-textarea {
  width: 100%; padding: 10px 44px 10px 14px;
  border: 1.5px solid #d1d5db; border-radius: 10px;
  font-size: 0.875rem; color: #111827; resize: none;
  font-family: inherit; outline: none;
}
.chat-textarea:focus { border-color: #1b3a6b; }

.mic-btn {
  position: absolute; right: 10px; bottom: 10px;
  background: #f3f4f6; border: none; border-radius: 6px;
  width: 28px; height: 28px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.mic-btn.listening { background: #fee2e2; }

.chat-send-btn { margin-top: 10px; }
.chat-hint { font-size: 0.72rem; color: #9ca3af; margin-top: 8px; text-align: center; }

.all-files-info { font-size: 0.82rem; color: #6b7280; margin-bottom: 12px; }
.all-btn-row { display: flex; gap: 10px; margin-top: 10px; }
.all-btn-row .btn { flex: 1; }

.all-results { margin-top: 16px; }
.all-result-card { background: #f9fafb; border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.all-result-card .file-label { font-size: 0.72rem; font-weight: 600; color: #1b3a6b; margin-bottom: 6px; }
.all-result-card .answer { font-size: 0.85rem; color: #111827; line-height: 1.55; }

.stored-actions-row { display: flex; gap: 10px; margin-top: 10px; }

.file-count { font-size: 0.75rem; color: #6b7280; margin-top: 6px; }
