@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --navy: #0D224D;
  --navy-light: #162d5e;
  --navy-muted: #1a3468;
  --blue: #0093D0;
  --blue-hover: #007ab8;
  --blue-subtle: rgba(0, 147, 208, 0.08);
  --green: #709E40;
  --green-bg: rgba(112, 158, 64, 0.1);
  --green-border: #709E40;
  --yellow: #E5A100;
  --yellow-bg: rgba(229, 161, 0, 0.08);
  --yellow-border: #E5A100;
  --red: #D04040;
  --red-bg: rgba(208, 64, 64, 0.06);
  --red-border: #D04040;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e6ec;
  --border-light: #eef1f5;
  --text: #1a2332;
  --text-secondary: #5a6577;
  --text-muted: #8b95a5;
  --font: 'Open Sans', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --radius: 6px;
  --shadow-sm: 0 1px 3px rgba(13, 34, 77, 0.06);
  --shadow-md: 0 4px 16px rgba(13, 34, 77, 0.08);
  --shadow-lg: 0 8px 32px rgba(13, 34, 77, 0.12);
  --transition: 150ms ease;
}

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

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy);
  background-image:
    radial-gradient(ellipse at 30% 50%, rgba(0, 147, 208, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(112, 158, 64, 0.1) 0%, transparent 50%);
}

.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--navy);
  border-radius: 12px;
  margin-bottom: 20px;
}

.login-logo svg { width: 28px; height: 28px; }

.login-card h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.login-card .login-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 400;
  margin-bottom: 32px;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 24px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.login-btn:hover { background: var(--blue-hover); }
.login-btn:active { transform: scale(0.98); }

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 16px;
}

/* ============================================
   APP SHELL
   ============================================ */

#app-shell { display: none; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 52px;
  padding: 0 24px;
  background: var(--navy);
  color: white;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--blue);
  border-radius: 6px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.topbar-title span {
  font-weight: 300;
  opacity: 0.6;
  margin-left: 2px;
}

/* Topbar nav tabs */
.topbar-nav {
  display: flex;
  gap: 2px;
  margin-left: 32px;
}

.topbar-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  transition: all var(--transition);
}

.topbar-nav a:hover { color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.06); }
.topbar-nav a.active { color: white; background: rgba(255,255,255,0.1); }
.topbar-nav a svg { width: 15px; height: 15px; opacity: 0.7; }

.topbar-spacer { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 400;
  opacity: 0.8;
}

.topbar-user button {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
  padding: 4px 12px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.topbar-user button:hover {
  border-color: rgba(255,255,255,0.4);
  color: white;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

main {
  padding: 20px 24px 40px;
  max-width: 100%;
}

/* ============================================
   TOOLBAR (Filters, Search, Actions)
   ============================================ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-right: 2px;
}

.filter-select {
  appearance: none;
  padding: 6px 28px 6px 10px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235a6577' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--transition);
}

.filter-select:hover { border-color: var(--blue); }
.filter-select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-subtle); }

.search-input {
  padding: 6px 10px 6px 32px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 220px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%238b95a5' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  transition: border-color var(--transition), width var(--transition);
}

.search-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-subtle); width: 280px; }

.toolbar-spacer { flex: 1; }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}

.btn svg { width: 14px; height: 14px; }

.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  padding: 6px 8px;
}
.btn-ghost:hover { color: var(--blue); background: var(--blue-subtle); }

.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #618a37; }

/* Row count badge */
.row-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 20px;
}

/* ============================================
   DATA TABLE
   ============================================ */

.table-wrapper {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow-x: auto;
  overflow-y: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1400px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--blue);
  user-select: none;
  cursor: pointer;
  transition: color var(--transition);
}

thead th:hover { color: white; }

thead th.sorted-asc::after,
thead th.sorted-desc::after {
  margin-left: 3px;
  font-size: 8px;
  opacity: 0.6;
  vertical-align: middle;
}
thead th.sorted-asc::after { content: '▲'; }
thead th.sorted-desc::after { content: '▼'; }

/* Status indicator column */
thead th:first-child { width: 5px; min-width: 5px; max-width: 5px; padding: 0; }

tbody tr {
  transition: background var(--transition);
}

tbody tr:nth-child(even) { background: rgba(244, 246, 249, 0.5); }
tbody tr:hover { background: var(--blue-subtle); }

/* Status border cell — the first td IS the colored bar */
tbody td:first-child {
  width: 5px;
  min-width: 5px;
  max-width: 5px;
  padding: 0;
  border-bottom: none;
}

tbody tr.status-reviewed td:first-child { background: var(--green-border); }
tbody tr.status-auto td:first-child { background: var(--yellow-border); }
tbody tr.status-unclassified td:first-child { background: var(--red-border); }

tbody td {
  padding: 6px 10px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--transition);
}

/* (status indicator td:first-child is styled above with the status indicators) */

/* Project title column */
td.col-project {
  font-weight: 600;
  color: var(--navy);
  max-width: 320px;
}

/* Pill styles for brand, type, dept */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.pill-brand {
  background: rgba(13, 34, 77, 0.08);
  color: var(--navy);
}

.pill-type {
  background: rgba(0, 147, 208, 0.08);
  color: var(--blue);
}

/* Date columns */
td.col-date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: -0.2px;
}

/* Basecamp link */
.bc-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  border-radius: 4px;
  transition: all var(--transition);
}

.bc-link:hover { color: var(--blue); background: var(--blue-subtle); }
.bc-link svg { width: 14px; height: 14px; }

/* ============================================
   INLINE EDITING
   ============================================ */

td.editable { cursor: pointer; position: relative; }
td.editable:hover { background: rgba(0, 147, 208, 0.04); }

td.editing {
  padding: 4px 8px;
  background: white !important;
  box-shadow: inset 0 0 0 2px var(--blue);
  border-radius: 2px;
}

td.editing input,
td.editing select {
  width: 100%;
  padding: 4px 6px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
}

td.editing input[type="date"] {
  font-family: var(--mono);
  font-size: 12px;
}

/* Save flash animation */
@keyframes saveFlash {
  0% { background: rgba(112, 158, 64, 0.2); }
  100% { background: transparent; }
}

td.just-saved { animation: saveFlash 800ms ease-out; }

@keyframes errorFlash {
  0% { background: rgba(208, 64, 64, 0.15); }
  100% { background: transparent; }
}

td.save-error { animation: errorFlash 800ms ease-out; }

/* ============================================
   WEEKLY SUMMARY VIEW
   ============================================ */

.summary-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.summary-controls label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.summary-controls input[type="date"] {
  font-family: var(--mono);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.summary-controls input[type="date"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-subtle);
}

.toggle-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle-group button {
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-group button:not(:last-child) { border-right: 1px solid var(--border); }
.toggle-group button.active { background: var(--navy); color: white; }
.toggle-group button:hover:not(.active) { background: var(--bg); }

.summary-table-wrapper {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow-x: auto;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table th {
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 16px;
  text-align: center;
  white-space: nowrap;
}

.summary-table th:first-child { text-align: left; min-width: 180px; padding-left: 20px; }

.summary-table td {
  padding: 10px 16px;
  font-size: 14px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--mono);
  font-weight: 500;
  white-space: nowrap;
}

.summary-table td:first-child {
  text-align: left;
  font-family: var(--font);
  font-weight: 600;
  color: var(--navy);
  min-width: 180px;
  padding-left: 20px;
}

.summary-table tr:nth-child(even) { background: rgba(244, 246, 249, 0.5); }

.summary-table td.total-cell {
  font-weight: 700;
  color: var(--navy);
  background: rgba(13, 34, 77, 0.03);
}

.summary-table tr.total-row td {
  font-weight: 700;
  color: var(--navy);
  background: rgba(13, 34, 77, 0.04);
  border-top: 2px solid var(--navy);
}

/* Bloom copy success toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--navy);
  color: white;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px);
  opacity: 0;
  transition: all 300ms ease;
  z-index: 200;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.toast.toast-success { border-left: 4px solid var(--green); }
.toast.toast-error { border-left: 4px solid var(--red); }

/* ============================================
   ADD FROM BASECAMP MODAL
   ============================================ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 34, 77, 0.5);
  backdrop-filter: blur(4px);
  z-index: 150;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 200ms ease-out;
}

@keyframes modalIn {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  transition: all var(--transition);
}

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

.modal-body { padding: 24px; }

.modal-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.modal-input-group input {
  flex: 1;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.modal-input-group input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-subtle);
}

.modal-preview {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  display: none;
}

.modal-preview.has-data { display: block; }

.modal-preview-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}

.modal-preview-grid dt {
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
  padding-top: 2px;
}

.modal-preview-grid dd { color: var(--text); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}

/* ============================================
   LOADING & EMPTY STATES
   ============================================ */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
}

.loader {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state p { font-size: 13px; }

/* ============================================
   VIEW TRANSITIONS
   ============================================ */

.view { animation: fadeIn 200ms ease-out; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .topbar { padding: 0 12px; }
  .topbar-title span { display: none; }
  .topbar-nav { margin-left: 16px; gap: 0; }
  .topbar-nav a { padding: 6px 8px; font-size: 12px; }
  main { padding: 12px; }
  .toolbar { gap: 8px; }
  .search-input { width: 160px; }
  .search-input:focus { width: 200px; }
}
