* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
:root {
  --bg: #0f1419;
  --surface: #1c2630;
  --surface-hover: #263340;
  --border: #334455;
  --text: #e4e8ec;
  --text-muted: #8899aa;
  --accent: #d4a855;
  --accent-dim: #3d3020;
  --danger: #ef4444;
  --success: #4ade80;
  --info: #60a5fa;
  --warning: #f59e0b;
  --purple: #a78bfa;
  --pink: #f472b6;
  --teal: #2dd4bf;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
.app {
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2rem 3rem;
}

/* Header - horizontal bar layout for desktop */
header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  position: relative;
}
.app-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  flex-shrink: 0;
}
.header-title {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
header h1 {
  font-size: 1.5rem;
  color: var(--accent);
  line-height: 1.2;
}
.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.sync-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 0.75rem;
  min-height: 1em;
}
.header-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.btn-settings,
.btn-account,
.btn-help {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s;
}
.btn-settings:hover,
.btn-account:hover,
.btn-help:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-account.logged-in {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Controls bar */
.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.controls-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}
.controls .btn-add {
  margin-left: auto;
}
.btn {
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  touch-action: manipulation;
}
.btn-add {
  background: var(--accent);
  color: #1a1a1a;
}
.btn-add:hover {
  background: #e0b866;
}
.btn-cancel {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-save {
  background: var(--accent);
  color: #1a1a1a;
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  font-size: 0.8rem;
  padding: 0.4rem 0.7rem;
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn-edit {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  padding: 0.4rem 0.7rem;
}
.btn-edit:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.hidden {
  display: none !important;
}

/* Company cards - wider grid for desktop */
.companies {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
  flex: 1;
  align-content: start;
}
.company-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.company-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.company-card.status-interviewing::before {
  background: var(--purple);
}
.company-card.status-applied::before {
  background: var(--warning);
}
.company-card.status-researching::before {
  background: var(--info);
}
.company-card.status-offer::before {
  background: var(--success);
}
.company-card.status-rejected::before {
  background: var(--danger);
}
.company-card.status-declined::before {
  background: var(--text-muted);
}
.company-card:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.company-card-name {
  font-size: 1.15rem;
  font-weight: 700;
}
.company-card-role {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}
.company-card-meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
}
.status-badge {
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}
.status-badge.researching {
  background: #1e3a5f;
  color: #60a5fa;
}
.status-badge.applied {
  background: #3b2f1a;
  color: #fbbf24;
}
.status-badge.interviewing {
  background: #2d1b4e;
  color: #a78bfa;
}
.status-badge.offer {
  background: #1a3d2a;
  color: #4ade80;
}
.status-badge.rejected {
  background: #3d1a1a;
  color: #f87171;
}
.status-badge.declined {
  background: #2a2a2a;
  color: #888;
}
.company-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.section-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
}

/* Detail panel */
.detail-panel {
  margin-top: 0;
  flex: 1;
}
.detail-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.detail-back {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.4rem 0;
  touch-action: manipulation;
}
.detail-back:hover {
  text-decoration: underline;
}
.detail-actions {
  display: flex;
  gap: 0.5rem;
}

/* Hero card */
.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.detail-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.detail-hero.status-interviewing::before {
  background: var(--purple);
}
.detail-hero.status-applied::before {
  background: var(--warning);
}
.detail-hero.status-researching::before {
  background: var(--info);
}
.detail-hero.status-offer::before {
  background: var(--success);
}
.detail-hero.status-rejected::before {
  background: var(--danger);
}
.detail-hero.status-declined::before {
  background: var(--text-muted);
}
.hero-name {
  font-size: 1.6rem;
  font-weight: 700;
}
.hero-role {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.hero-meta {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}
.hero-link {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
}
.hero-link:hover {
  text-decoration: underline;
}

/* Dashboard grid - 3 columns on wide screens */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  align-items: start;
}

/* Widget cards */
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  transition: all 0.2s;
  min-width: 0;
}
.widget:hover {
  border-color: #445566;
}
.widget-full {
  grid-column: 1/-1;
}
.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}
.widget-icon {
  font-size: 1rem;
  margin-right: 0.5rem;
}
.widget-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
}
.widget-actions {
  display: flex;
  gap: 0.3rem;
}
.widget-actions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.4;
  transition: opacity 0.2s;
  padding: 0.3rem;
  touch-action: manipulation;
}
.widget-actions button:hover {
  opacity: 1;
}
.widget-body {
  padding: 1rem 1.1rem;
  max-height: 450px;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
}
.widget-body::-webkit-scrollbar {
  width: 4px;
}
.widget-body::-webkit-scrollbar-track {
  background: transparent;
}
.widget-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Widget color accents */
.widget-jd .widget-header {
  border-left: 3px solid var(--info);
}
.widget-product .widget-header {
  border-left: 3px solid var(--teal);
}
.widget-skills .widget-header {
  border-left: 3px solid var(--success);
}
.widget-talking .widget-header {
  border-left: 3px solid var(--accent);
}
.widget-questions .widget-header {
  border-left: 3px solid var(--purple);
}
.widget-culture .widget-header {
  border-left: 3px solid var(--pink);
}
.widget-compensation .widget-header {
  border-left: 3px solid var(--warning);
}
.widget-notes .widget-header {
  border-left: 3px solid var(--text-muted);
}

.widget-jd .widget-title {
  color: var(--info);
}
.widget-product .widget-title {
  color: var(--teal);
}
.widget-skills .widget-title {
  color: var(--success);
}
.widget-talking .widget-title {
  color: var(--accent);
}
.widget-questions .widget-title {
  color: var(--purple);
}
.widget-culture .widget-title {
  color: var(--pink);
}
.widget-compensation .widget-title {
  color: var(--warning);
}
.widget-notes .widget-title {
  color: var(--text-muted);
}

/* Add widget button */
.add-widget {
  grid-column: 1/-1;
  background: none;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  touch-action: manipulation;
}
.add-widget:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.modal-overlay.open {
  display: flex;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 550px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 {
  margin-bottom: 1.25rem;
  font-size: 1.2rem;
}
.modal label {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.modal input,
.modal select,
.modal textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  grid-column: 1/-1;
  font-size: 0.95rem;
}

/* Hero quick links */
.hero-links {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.hero-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border-radius: 5px;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.2s;
}
.hero-link-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.hero-link-btn.call-link {
  border-color: var(--success);
  color: var(--success);
}
.hero-link-btn.call-link:hover {
  background: var(--success);
  color: #000;
}

/* AI analyze button */
.btn-analyze {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  font-size: 0.8rem;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-analyze:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}
.btn-analyze:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Modal wide */
.modal-wide {
  max-width: 700px;
}
.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.settings-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: -0.4rem;
  margin-bottom: 0.85rem;
  font-style: italic;
}

/* Analyze status */
.analyze-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem;
  color: var(--purple);
  font-size: 0.85rem;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 2rem 0 0.5rem;
  margin-top: auto;
  border-top: 1px solid var(--border);
}
.site-footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.site-footer a:hover {
  color: var(--accent);
}

/* Help Modal */
.help-content {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-muted);
}
.help-content h3 {
  color: var(--text);
  font-size: 0.95rem;
  margin: 1.25rem 0 0.5rem;
}
.help-content h3:first-child {
  margin-top: 0;
}
.help-content p {
  margin-bottom: 0.5rem;
}
.help-content ul {
  padding-left: 1.2rem;
  margin-bottom: 0.75rem;
}
.help-content li {
  margin-bottom: 0.3rem;
}
.help-content .help-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
  vertical-align: middle;
}
.help-content .help-badge-gold {
  background: var(--accent-dim);
  color: var(--accent);
}
.help-content .help-badge-purple {
  background: #2d1b4e;
  color: var(--purple);
}

/* Responsive - tablets */
@media (max-width: 1024px) {
  .app {
    padding: 1.5rem 2rem;
  }
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Responsive - mobile */
@media (max-width: 768px) {
  .app {
    padding: 1rem;
  }
  header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-end;
    order: -1;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .widget-full {
    grid-column: 1;
  }
  .companies {
    grid-template-columns: 1fr;
  }
  .modal {
    padding: 1.25rem;
    border-radius: 8px;
    max-height: 95vh;
  }
  header h1 {
    font-size: 1.3rem;
  }
}

/* Wide screens - 3 col grid */
@media (min-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .companies {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  }
}
