* {
  box-sizing: border-box;
}

:root {
  --bg: #f0f4f8;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #666;
  --accent: #1e5fa8;
  --accent-hover: #2872c4;
  --nav-bg: #1a2a4c;
  --border: #d8e2ef;
  --error: #c44;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-top: 56px;
}

.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--nav-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.topnav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.card {
  background: var(--card);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 140px;
}

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input, .field select {
  width: 100%;
}

input[type="text"], input[type="number"], select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

input[type="text"], input[type="number"] {
  flex: 1;
  min-width: 140px;
}

#query {
  min-width: 200px;
}

.query-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.query-label {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.query-toggle {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.query-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

button {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
}

button:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#deleteResumeBtn {
  background: var(--muted);
}

#deleteResumeBtn:hover {
  background: #555;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.hidden {
  display: none !important;
}

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.login-card h1 { margin: 0 0 0.5rem; }
.login-card p { margin: 0 0 1.5rem; }

.login-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

.login-btn:hover { background: var(--accent-hover); }

.account-menu {
  position: relative;
}

.account-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 6px;
  padding: 0.35rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}

.account-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.7);
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 160px;
  overflow: hidden;
  z-index: 300;
}

.account-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 0;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 400;
}

.account-dropdown button:hover {
  background: var(--bg);
  color: var(--accent);
}

.analysis-banner {
  background: var(--card);
  border-radius: 8px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  border-left: 4px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.analysis-banner-body {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.analysis-banner-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.analysis-banner-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--nav-bg);
}

.analysis-banner-salary {
  font-size: 0.9rem;
  color: var(--muted);
}

.analysis-banner-link {
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.analysis-banner-link:hover {
  text-decoration: underline;
}

.analysis-spinner {
  font-size: 0.85rem;
  color: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--nav-bg);
}

.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
}

.back-btn:hover {
  background: var(--bg);
  color: var(--text);
}


.preview {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  max-height: 120px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.jobs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.job-card {
  background: var(--card);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}

.job-card h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.job-card .company {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.job-card .location {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.job-card .score-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.job-card .actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.job-card .actions button {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.bookmarks-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bookmark-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.bookmark-item:last-child {
  border-bottom: none;
}

.bookmark-item .title {
  font-weight: 500;
}

.bookmark-item .company {
  font-size: 0.85rem;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background: var(--card);
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.25rem 0.5rem;
  font-size: 1.25rem;
  line-height: 1;
  background: transparent;
  color: var(--muted);
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg);
}

#modalBody .job-detail-title {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
}

#modalBody .job-detail-company {
  color: var(--muted);
  margin-bottom: 1rem;
}

#modalBody .job-detail-description {
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

#modalBody .score-detail {
  background: var(--bg);
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

#modalBody .strengths, #modalBody .gaps {
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 400;
}

.toast {
  padding: 0.75rem 1.1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toast-in 0.2s ease;
  max-width: 340px;
}

.toast.error   { background: #c0392b; }
.toast.success { background: #1e8a5a; }
.toast.info    { background: var(--accent); }

.toast.fade-out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

.analysis-result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.analysis-result h3 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.analysis-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.analysis-row {
  display: flex;
  gap: 0.75rem;
  font-size: 0.9rem;
  align-items: baseline;
}

.analysis-label {
  font-weight: 600;
  min-width: 120px;
  flex-shrink: 0;
}

.analysis-value {
  color: var(--text);
}

#analyzeBtn {
  background: var(--nav-bg);
}

#analyzeBtn:hover {
  background: #253d6e;
}
