* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f0eb; color: #1e293b;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

.app { display: flex; height: 100vh; height: 100dvh; }

/* ======== Login page ======== */
.login-body {
  background: linear-gradient(135deg, #1a1a2e 0%, #2a1230 100%);
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: #faf7f4;
  border-radius: 16px;
  padding: 40px 32px;
  max-width: 380px; width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.login-logo {
  width: 64px; height: 64px;
  border-radius: 12px;
  margin-bottom: 16px;
}
.login-title {
  font-size: 24px; font-weight: 700;
  color: #1e293b; margin-bottom: 8px;
}
.login-subtitle {
  font-size: 14px; color: #64748b;
  margin-bottom: 28px;
}
.google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 20px;
  background: #fff; color: #1e293b;
  border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 15px; font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
}
.google-btn:hover {
  border-color: #C41230;
  box-shadow: 0 2px 8px rgba(196,18,48,0.1);
}
.login-error {
  margin-top: 16px;
  font-size: 13px; color: #C41230;
  min-height: 18px;
}

/* ======== Sidebar ======== */
.sidebar {
  width: 260px; background: #1a1a2e; color: #e2e8f0;
  display: flex; flex-direction: column; flex-shrink: 0;
  z-index: 20; transition: transform 0.25s;
}
.sidebar-header {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 20px 16px; border-bottom: 1px solid #2a2a45;
}
.logo-img {
  width: 40px; height: 40px; object-fit: contain; border-radius: 8px;
}
.user-badge {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: #2a2a45;
  border-radius: 8px;
  padding: 6px 8px;
}
.user-badge:empty { display: none; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover;
}
.user-avatar-initial {
  display: flex; align-items: center; justify-content: center;
  background: #C41230; color: #fff;
  font-size: 13px; font-weight: 700;
}
.user-name {
  flex: 1; min-width: 0;
  font-size: 12px; color: #e2e8f0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-signout {
  width: 100%;
  padding: 10px 16px;
  background: #fff;
  color: #C41230;
  border: 1px solid #C41230;
  border-radius: 8px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-signout:hover {
  background: #C41230;
  color: #fff;
}

.btn-notify {
  width: 100%;
  padding: 10px 16px;
  background: #C41230;
  color: #fff;
  border: 1px solid #C41230;
  border-radius: 8px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-notify:hover { background: #a30e28; }
.btn-notify:disabled {
  background: #efe9e3;
  color: #94a3b8;
  border-color: #e8e0d8;
  cursor: not-allowed;
}
.btn-notify-on {
  background: #fff;
  color: #C41230;
}
.btn-notify-on:hover { background: #fce8ec; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: none; background: transparent;
  color: #b0b0cc; border-radius: 8px; cursor: pointer;
  font-size: 14px; text-align: left; transition: all 0.15s;
}
.nav-item:hover { background: #2a2a45; color: white; }
.nav-item.active { background: #C41230; color: white; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-count {
  background: #2a2a45; color: #b0b0cc; font-size: 11px;
  padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.nav-item.active .nav-count { background: rgba(255,255,255,0.2); color: white; }
.nav-divider { height: 1px; background: #2a2a45; margin: 12px 4px; }
.nav-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: #6b6b8a; padding: 4px 12px 8px; font-weight: 600;
}

.time-filter { padding: 0 12px 8px; }
.time-filter-label {
  font-size: 13px; color: #e2e8f0; font-weight: 500;
  margin-bottom: 8px; text-align: center;
}
.time-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; background: #2a2a45;
  border-radius: 2px; outline: none; cursor: pointer;
}
.time-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #C41230; cursor: pointer;
  box-shadow: 0 0 0 2px rgba(196, 18, 48, 0.2);
  transition: transform 0.1s;
}
.time-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.time-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #C41230; cursor: pointer; border: none;
  box-shadow: 0 0 0 2px rgba(196, 18, 48, 0.2);
}

.keywords-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 4px; }
.keyword-pill {
  display: inline-block; background: #2a2a45; color: #e2e8f0;
  font-size: 12px; padding: 4px 10px; border-radius: 12px; font-weight: 500;
}
.keywords-empty { font-size: 12px; color: #6b6b8a; font-style: italic; padding: 2px 12px 4px; }

.sidebar-footer {
  padding: 12px 8px; border-top: 1px solid #2a2a45;
  display: flex; flex-direction: column; gap: 4px;
}
.btn-sidebar {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px; border: none; background: transparent;
  color: #8888a8; border-radius: 6px; cursor: pointer;
  font-size: 13px; transition: all 0.15s;
}
.btn-sidebar:hover { background: #2a2a45; color: white; }
.btn-sidebar.scanning { color: #e85a70; }

/* ======== Main ======== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.mobile-bar { display: none; }

.main-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: #faf7f4; border-bottom: 1px solid #e8e0d8; flex-shrink: 0;
}
.header-left { display: flex; align-items: baseline; gap: 12px; }
.header-left h2 { font-size: 20px; font-weight: 700; }
.job-total { font-size: 13px; color: #94a3b8; }

.scan-badge {
  font-size: 12px; color: #C41230; background: #fce8ec;
  padding: 3px 10px; border-radius: 12px; font-weight: 500;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.header-right { display: flex; align-items: center; gap: 16px; }
.search-box {
  display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #e8e0d8; border-radius: 8px; padding: 6px 12px;
}
.search-icon { font-size: 14px; color: #94a3b8; }
.search-box input {
  border: none; background: none; outline: none; font-size: 13px; width: 200px; color: #1e293b;
}
.last-updated { font-size: 11px; color: #94a3b8; }

/* ======== Job Grid ======== */
.job-grid {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px; align-content: start;
}
.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 80px 20px; color: #94a3b8;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: #64748b; margin-bottom: 8px; }
.empty-state p { font-size: 14px; max-width: 400px; margin: 0 auto; line-height: 1.5; }

/* ======== Job Card ======== */
.job-card {
  background: #faf7f4; border-radius: 12px; padding: 16px;
  border: 1px solid #e8e0d8; cursor: pointer; transition: all 0.2s;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0; word-wrap: break-word; overflow-wrap: anywhere;
}
.job-card:hover {
  border-color: #C41230; box-shadow: 0 4px 12px rgba(196,18,48,0.1); transform: translateY(-2px);
}
.job-card.unseen { border-left: 4px solid #C41230; }
.job-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.job-card-title { font-size: 15px; font-weight: 600; color: #1e293b; line-height: 1.3; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.job-card-dismiss {
  background: none; border: none; color: #cbd5e1; cursor: pointer;
  font-size: 18px; padding: 0 4px; line-height: 1;
}
.job-card-dismiss:hover { color: #ef4444; }
.job-card-company { font-size: 14px; color: #C41230; font-weight: 500; }
.job-card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: #64748b; }
.meta-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: #efe9e3; padding: 3px 8px; border-radius: 4px;
}
.posted-tag { background: #fce8ec; color: #9b0f28; font-weight: 500; }
.source-tag { color: white; font-weight: 600; font-size: 11px; }
.source-tag-icon {
  background: #faf7f4 !important;
  color: #1e293b !important;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 4px;
  border: 1px solid #e8e0d8;
}
.source-icon { width: 16px; height: 16px; object-fit: contain; border-radius: 3px; }
.nav-icon-img { width: 18px; height: 18px; object-fit: contain; border-radius: 3px; flex-shrink: 0; }
.site-check-icon { width: 18px; height: 18px; object-fit: contain; border-radius: 3px; }
.job-card-description {
  font-size: 13px; color: #64748b; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.job-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: auto; padding-top: 8px; border-top: 1px solid #efe9e3;
}
.job-card-time { font-size: 11px; color: #94a3b8; }
.job-card-apply {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; background: #C41230; color: white; border: none;
  border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer;
}
.job-card-apply:hover { background: #a30e28; }

/* ======== Sidebar overlay (mobile only) ======== */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 19; /* Below sidebar (20), above main content */
}
.sidebar-overlay.open { display: block; }

/* ======== Settings Panel ======== */
.settings-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 30;
}
.settings-overlay.open { display: block; }

.settings-panel {
  position: fixed; top: 0; right: -420px; width: 420px; height: 100vh;
  background: #faf7f4; z-index: 31; display: flex; flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15); transition: right 0.3s;
}
.settings-panel.open { right: 0; }

.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid #e8e0d8;
}
.settings-header h2 { font-size: 18px; font-weight: 700; }
.settings-close {
  background: none; border: none; font-size: 24px; color: #94a3b8;
  cursor: pointer; padding: 0 4px;
}
.settings-close:hover { color: #1e293b; }

.settings-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.setting-group { margin-bottom: 24px; }
.setting-group h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.setting-desc { font-size: 13px; color: #64748b; margin-bottom: 12px; }

.kw-input-row { display: flex; gap: 8px; margin-bottom: 10px; }
.kw-input-row input {
  flex: 1; padding: 8px 12px; border: 1px solid #e8e0d8;
  border-radius: 8px; font-size: 14px; outline: none; background: #fff;
}
.kw-input-row input:focus { border-color: #C41230; }

.kw-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.kw-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fce8ec; color: #9b0f28; padding: 5px 12px;
  border-radius: 20px; font-size: 13px; font-weight: 500;
}
.kw-tag button {
  background: none; border: none; color: #d4a0aa; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0;
}
.kw-tag button:hover { color: #ef4444; }
.kw-empty { font-size: 13px; color: #94a3b8; font-style: italic; }

.input-full {
  width: 100%; padding: 8px 12px; border: 1px solid #e8e0d8;
  border-radius: 8px; font-size: 14px; outline: none; background: #fff;
}
.input-full:focus { border-color: #C41230; }

.setting-steps {
  font-size: 13px; color: #475569; margin: 0 0 12px 18px; line-height: 1.7;
}
.setting-steps code {
  background: #efe9e3; padding: 1px 5px; border-radius: 3px;
  font-size: 12px; color: #C41230;
}
.setting-steps a { color: #C41230; }

.cred-callout {
  background: #fce8ec;
  border: 1px solid #f4c5cf;
  color: #7a0a1f;
  font-size: 12px;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
}
.cred-callout strong { color: #C41230; }
.cred-callout em { font-style: italic; }
.cred-callout a { color: #C41230; font-weight: 500; }

.site-checks { display: flex; flex-direction: column; gap: 10px; }
.site-check {
  display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px;
}
.site-check input { width: 18px; height: 18px; accent-color: #C41230; }
.site-check-dot { width: 10px; height: 10px; border-radius: 50%; }

.interval-row { display: flex; align-items: center; gap: 16px; }
.interval-row input[type="range"] { flex: 1; accent-color: #C41230; }
#intervalVal { font-size: 14px; font-weight: 600; color: #C41230; min-width: 50px; }

.settings-footer {
  padding: 16px 24px; border-top: 1px solid #e8e0d8;
  display: flex; align-items: center; gap: 12px;
}
.btn { padding: 8px 16px; border: none; border-radius: 8px; font-size: 14px; cursor: pointer; }
.btn-sm { padding: 8px 14px; font-size: 13px; background: #C41230; color: white; border: none; border-radius: 8px; cursor: pointer; }
.btn-sm:hover { background: #a30e28; }
.btn-primary { background: #C41230; color: white; font-weight: 500; }
.btn-primary:hover { background: #a30e28; }
.save-msg { font-size: 13px; color: #22c55e; font-weight: 500; }

/* ======== Responsive ======== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    height: 100vh; height: 100dvh;
    transform: translateX(-100%);
    width: 280px; max-width: 85vw;
  }
  .sidebar.open { transform: translateX(0); }

  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px; background: #1a1a2e; color: white;
    flex-shrink: 0;
  }
  .mobile-logo {
    width: 36px; height: 36px; object-fit: contain; border-radius: 6px;
  }
  .hamburger {
    background: none; border: none; color: white;
    font-size: 26px; cursor: pointer; padding: 8px 12px;
    min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
  }

  .main { width: 100%; min-width: 0; }
  .main-header {
    flex-direction: column; gap: 10px; align-items: stretch;
    padding: 12px 16px;
  }
  .header-left { flex-wrap: wrap; gap: 8px 12px; }
  .header-right { flex-wrap: wrap; width: 100%; }
  .search-box { flex: 1; min-width: 0; }
  .search-box input { width: 100%; min-width: 0; }
  .last-updated { display: none; }

  .job-grid {
    grid-template-columns: 1fr; padding: 12px; gap: 12px;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Settings panel: full screen with safe-area padding for notched phones */
  .settings-panel {
    width: 100%; right: -100%;
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .settings-header {
    padding: 16px 20px;
    position: sticky; top: 0;
    background: #faf7f4; z-index: 2;
    border-bottom: 1px solid #e8e0d8;
  }
  .settings-close {
    font-size: 32px; padding: 8px 12px;
    min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
    color: #1e293b;
  }
  .settings-body { padding: 16px 20px; }
  .settings-footer {
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  }

  /* Larger touch targets for sidebar buttons */
  .btn-sidebar { padding: 12px; font-size: 14px; }
  .nav-item { padding: 12px; font-size: 14px; }

  /* Job card: tighter spacing on small screens */
  .job-card { padding: 14px; }
  .job-card-title { font-size: 14px; }
  .job-card-meta { gap: 6px; }
  .meta-tag { font-size: 11px; padding: 3px 7px; }
}

@media (max-width: 480px) {
  .main-header { padding: 10px 12px; }
  .header-left h2 { font-size: 18px; }
  .job-grid { padding: 10px; gap: 10px; }
  .job-card { padding: 12px; }
  .job-card-meta { gap: 5px; }
}
