/* Palette — Dark Theme */
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #1e293b;
  --bg-hover: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --red: #ef4444;
  --green: #10b981;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --pink: #ec4899;
  --gray: #6b7280;
  --indigo: #6366f1;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.hidden { display: none !important; }

/* --- Header --- */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 1rem; }
.header-center { display: flex; align-items: center; gap: 0.75rem; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.logo { font-size: 1.35rem; font-weight: 700; color: var(--accent); letter-spacing: -0.5px; }

/* Header stats pills */
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.stat-pill .stat-val { color: var(--text); font-weight: 600; }

/* Workspace switcher */
#workspace-switcher select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

#account-menu { position: relative; }
.dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 200px;
  padding: 0.5rem;
  box-shadow: var(--shadow);
  z-index: 200;
}
.dropdown button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 4px;
}
.dropdown button:hover { background: var(--bg-hover); }

/* --- Tab Bar --- */
#tab-bar {
  display: flex;
  gap: 0;
  padding: 0 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: 0.65rem 1rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Toolbar --- */
#toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
#search-input {
  flex: 0 0 220px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.85rem;
}
#search-input:focus { outline: none; border-color: var(--accent); }
#filter-pills { display: flex; gap: 0.35rem; flex-wrap: wrap; flex: 1; }
.filter-pill {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-pill:hover { border-color: var(--text-muted); }
.filter-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#toolbar-actions { display: flex; gap: 0.5rem; margin-left: auto; }

/* --- Buttons --- */
.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.85rem; padding: 0; }
.btn-link:hover { text-decoration: underline; }

/* --- Content Area --- */
#app-content {
  padding: 1.5rem;
  min-height: calc(100vh - 200px);
}

/* --- Card Grid --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  gap: 0.85rem;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--text-dim); }

.card-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-body { flex: 1; min-width: 0; }
.card-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.15rem; }
.card-sub { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.card-meta { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.25rem; }
.card-note { font-size: 0.75rem; color: var(--text-dim); font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}
.card-actions .btn-sm { min-width: 55px; text-align: center; }

/* Card status indicator */
.card.overdue { border-left: 3px solid var(--red); }
.card.signed { border-left: 3px solid var(--green); }

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* --- Modal --- */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 5vh;
  z-index: 500;
  overflow-y: auto;
}
#modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
#modal.wide { max-width: 720px; }
#modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
#modal-title { font-size: 1.1rem; font-weight: 600; }
#modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
#modal-close:hover { color: var(--text); }
#modal-body { padding: 1.25rem; }

/* Modal form fields */
.form-field { margin-bottom: 1rem; }
.form-field label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-field textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; }

/* View modal */
.view-field { margin-bottom: 0.85rem; }
.view-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.15rem; }
.view-value { font-size: 0.9rem; }
.view-link { color: var(--accent); cursor: pointer; }
.view-link:hover { text-decoration: underline; }

/* --- Toast --- */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease;
}
.toast-success { background: var(--green); color: #fff; }
.toast-error { background: var(--red); color: #fff; }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Dashboard --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.dash-card-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.dash-card-value { font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; }
.dash-section { margin-bottom: 1.5rem; }
.dash-section h3 { font-size: 0.95rem; margin-bottom: 0.75rem; color: var(--text-muted); }

.chart-bar-group {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
  padding-top: 12px;
}
.chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-width: 20px;
  position: relative;
}
.chart-bar-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.alert-list { list-style: none; }
.alert-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.alert-list li:last-child { border-bottom: none; }

/* --- Journal compose --- */
.journal-compose {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.journal-compose textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 80px;
  margin-bottom: 0.5rem;
}
.journal-compose textarea:focus { outline: none; border-color: var(--accent); }

/* --- Resume --- */
.resume-nav { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.resume-nav .btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.resume-preview {
  background: #fff;
  color: #111;
  padding: 2rem;
  border-radius: var(--radius);
  max-width: 650px;
  margin: 0 auto;
  font-family: Helvetica, Arial, sans-serif;
}
.resume-preview h2 { text-align: center; font-size: 1.4rem; margin-bottom: 0.25rem; }
.resume-preview .resume-contact { text-align: center; font-size: 0.8rem; color: #666; margin-bottom: 0.15rem; }
.resume-preview .resume-union { text-align: center; font-size: 0.8rem; color: #666; margin-bottom: 0.5rem; }
.resume-preview .resume-bio { text-align: center; font-size: 0.8rem; color: #444; margin-bottom: 1rem; }
.resume-preview hr { border: none; border-top: 1px solid #ccc; margin: 0.75rem 0; }
.resume-preview h3 { font-size: 0.9rem; margin-bottom: 0.5rem; text-transform: uppercase; color: #333; }
.resume-credit-row { display: flex; justify-content: space-between; padding: 0.15rem 0; font-size: 0.8rem; }
.resume-credit-title { font-weight: 600; }
.resume-credit-detail { color: #666; }
.resume-credit-year { color: #999; min-width: 40px; text-align: right; }

/* Follow-up attempts */
.attempt-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  position: relative;
}
.attempt-card .attempt-remove {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
}
.attempt-header { font-size: 0.8rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-muted); }

/* Delegation indicator */
.delegation-banner {
  background: var(--amber);
  color: #000;
  text-align: center;
  padding: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state p { font-size: 0.95rem; margin-bottom: 0.5rem; }

/* Source breakdown */
.source-list { list-style: none; }
.source-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.source-list li:last-child { border-bottom: none; }
.source-count { font-weight: 600; color: var(--accent); }

/* Responsive */
@media (max-width: 768px) {
  .card-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  #toolbar { flex-direction: column; align-items: stretch; }
  #search-input { flex: 1; }
}
