/* ══════════════════════════════════════════════
   OKR Tracker — Design System CSS
   Based on style_guide.py design tokens
   ══════════════════════════════════════════════ */

/* -- CSS Variables (Design Tokens) -- */
:root {
  /* Brand */
  --primary: #6366f1;
  --primary-light: #8b5cf6;
  --primary-lighter: #a855f7;
  --primary-bg: #f1f0fb;
  --primary-bg-hover: #e8e5f5;
  --primary-border: #d4d0e8;
  --primary-shadow: rgba(99, 102, 241, 0.25);
  --primary-shadow-light: rgba(99, 102, 241, 0.06);
  --primary-shadow-hover: rgba(99, 102, 241, 0.12);
  --primary-glow: rgba(99, 102, 241, 0.35);

  /* Semantic */
  --success: #22c55e;
  --warning: #eab308;
  --warning-amber: #f59e0b;
  --danger: #ef4444;
  --danger-dark: #dc2626;

  /* Text */
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-light: #8b8fa3;

  /* Backgrounds */
  --bg-card: #ffffff;
  --bg-app-start: #f0f4ff;
  --bg-app-mid: #faf5ff;
  --bg-app-end: #fff1f2;
  --bg-sidebar-start: #f8f7ff;
  --bg-sidebar-mid: #f3f0ff;
  --bg-sidebar-end: #faf5ff;
  --bg-note: #faf9ff;
  --bg-progress-track: #e8e0f0;

  /* Borders */
  --border-default: #e2e8f0;
  --border-light: #e2e0f0;
  --border-input: #d4d0e8;
  --border-button: #d1d5db;
  --border-dashed: #c7c4e0;

  /* Radius */
  --radius: 10px;
  --radius-nav: 8px;

  /* Shadows */
  --shadow-card: 0 2px 8px rgba(99, 102, 241, 0.06);
  --shadow-card-hover: 0 4px 16px rgba(99, 102, 241, 0.12);
  --shadow-button: 0 2px 8px rgba(99, 102, 241, 0.25);
  --shadow-button-hover: 0 4px 16px rgba(99, 102, 241, 0.35);

  /* Gradients */
  --gradient-app: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 50%, #fff1f2 100%);
  --gradient-sidebar: linear-gradient(180deg, #f8f7ff 0%, #f3f0ff 50%, #faf5ff 100%);
  --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-brand: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
}

/* -- Reset & Base -- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gradient-app);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.5;
}

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


.nav-item.active {
  background: var(--gradient-primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}


/* -- Buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-family: inherit;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  padding: 8px 20px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-button);
}

.btn-primary:hover {
  box-shadow: var(--shadow-button-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-button);
  padding: 5px 14px;
  font-size: 0.75rem;
}

.btn-secondary:hover {
  background: rgba(0,0,0,0.04);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: white;
  padding: 6px 16px;
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: var(--danger-dark);
}

.btn-sm {
  padding: 4px 12px;
  font-size: 0.72rem;
}

/* Primary-action buttons that should stand out (1.5x of btn-sm).
   Use on top-level CRUD entry points: + Add Objective, + Key Result, Submit Update. */

/* Secondary-action buttons that should fade into the background (75% of btn-sm).
   Use on demoted CRUD: Edit / Delete on each KR card. */

.btn-block { width: 100%; justify-content: center; }

/* -- Cards -- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}


.pill-btn.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-button);
}

.pill-btn:not(.active) {
  background: var(--primary-bg);
  color: var(--text-primary);
}

.pill-btn:not(.active):hover {
  background: var(--primary-bg-hover);
}

/* -- OKR Tabs -- */
.okr-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 0;
}

.okr-tab {
  padding: 10px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: grab;
  transition: all 0.2s ease;
  border: none;
  font-family: inherit;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.okr-tab:active { cursor: grabbing; }
.okr-tab.dragging { opacity: 0.5; }
.okr-tab.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }

.okr-tab.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-button);
}

.okr-tab:not(.active) {
  background: var(--primary-bg);
  color: var(--text-primary);
}

.okr-tab:not(.active):hover {
  background: var(--primary-bg-hover);
}


/* -- OKR Card -- */
.okr-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  box-shadow: var(--shadow-card);
  padding: 0;
  margin-bottom: 24px;
}


.okr-pct {
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 800;
  margin-left: 16px;
  white-space: nowrap;
}


/* Right-aligned action button inside the pills row (e.g. + Key Result).
   margin-left:auto pushes it to the far right while still wrapping cleanly
   on narrow viewports. */


/* -- KR Card -- */
.kr-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}


.kr-name {
  font-size: clamp(0.8rem, 1.2vw, 0.95rem);
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.kr-pct {
  font-size: clamp(0.95rem, 1.8vw, 1.3rem);
  font-weight: 800;
  margin-left: 12px;
}


.kr-metric:last-child,
.kr-metric:last-child .kr-metric-label,

.kr-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Secondary action row — sits below the Notes section of each KR card.
   Right-aligned, subtly separated from the notes block above. */


/* -- Chart container -- */
.chart-container {
  width: 100%;
  height: 160px;
  margin: 8px 0;
}


/* The toggle now sits inline in the KR action row, so it must not stretch.
   (It previously had width:100% from when it owned its own section — that was
   forcing the whole action row to wrap onto four lines.) */
.notes-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: none;
  border: none;
  width: auto;
  flex: none;
  text-align: left;
  white-space: nowrap;
}

.notes-list { margin-top: 8px; }

.note-card {
  background: var(--bg-note);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
}

.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.note-author {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.note-timestamp {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.note-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.note-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.note-input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--border-input);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  min-height: 36px;
}

.note-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
  outline: none;
}

/* -- Forms -- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid var(--border-input);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: inherit;
  background: white;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
  outline: none;
}

/* -- Modal -- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

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

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* -- Login page -- */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--gradient-app);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.12);
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo img {
  width: 100%;
  max-width: 180px;
}

.login-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.checkbox-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* -- Flash messages -- */
.flash-msg {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.85rem;
  font-weight: 500;
}

.flash-msg.error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.flash-msg.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.flash-msg.info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* -- Admin panel -- */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.user-row {
  display: grid;
  grid-template-columns: 2.5fr 1.5fr 1fr 0.8fr;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-default);
}

.user-row:last-child { border-bottom: none; }

.user-name { font-weight: 600; color: var(--text-primary); font-size: 0.9rem; }
.user-email { font-size: 0.8rem; color: var(--text-muted); }

.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
}

.role-Admin { background: rgba(99,102,241,0.1); color: #6366f1; }
.role-Manager { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.role-TeamMember { background: rgba(148,163,184,0.1); color: #94a3b8; }


/* -- Empty state -- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  border: 2px dashed var(--border-dashed);
  border-radius: var(--radius);
  margin: 24px 0;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* -- Account page -- */
.account-card {
  max-width: 500px;
}

.account-info {
  padding: 20px;
  border-bottom: 1px solid var(--border-default);
}

.account-info-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.account-info-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* -- Email panel -- */
.email-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}

.email-tab {
  padding: 8px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.2s;
}

.email-tab.active {
  background: var(--gradient-primary);
  color: white;
}

.email-tab:not(.active) {
  background: var(--primary-bg);
  color: var(--text-primary);
}

.email-tab:not(.active):hover {
  background: var(--primary-bg-hover);
}

.email-panel-content {
  background: white;
  border: 1px solid var(--border-default);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: 24px;
}

/* -- Toast notifications -- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}


.toast.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.toast.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}


@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}


@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.5; }
  100% { transform: scale(0.8); opacity: 1; }
}

/* -- Responsive -- */
@media (max-width: 1024px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card { padding: 12px 14px; }
  .metric-value { font-size: 1.35rem; }
  .metric-label { font-size: 0.68rem; }
  .btn-primary { padding: 6px 14px; font-size: 0.8rem; }
  .pill-btn { font-size: 0.72rem; padding: 5px 12px; }
  .okr-tab { padding: 8px 12px; font-size: 0.78rem; }
  .user-row { grid-template-columns: 2fr 1.5fr 1fr 0.8fr; }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .sidebar.mobile-open {
    display: flex;
    width: 100%;
    max-width: 280px;
    z-index: 200;
  }

  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
  }

  .mobile-overlay.active { display: block; }

  .main-content {
    margin-left: 0;
    padding: 16px;
  }

  .filter-bar {
    margin: -16px -16px 16px -16px;
    padding: 12px 16px;
  }

  .metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  .mobile-hamburger {
    display: block !important;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 110;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: var(--shadow-button);
  }

  .okr-header { flex-direction: column; }
  .okr-pct { margin-left: 0; margin-top: 8px; }
  .kr-metrics { grid-template-columns: 1fr; }
  .user-row { grid-template-columns: 1fr; gap: 8px; }
  .modal { margin: 16px; }
}


/* -- Confirm dialog -- */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1100;
  justify-content: center;
  align-items: center;
}

.confirm-overlay.active { display: flex; }

.confirm-dialog {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  text-align: center;
}

.confirm-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.confirm-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* -- Scrollbar -- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--primary-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* -- Loading overlay -- */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(4px);
  z-index: 3000;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 16px;
}

.loading-overlay.active { display: flex; }

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--primary-bg);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay .loading-message {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* -- Required field indicator -- */
.required::after {
  content: " *";
  color: var(--danger);
  font-weight: 700;
}

/* -- Input error state -- */
.input-error,
.form-input.input-error,
.form-select.input-error,
.form-textarea.input-error,
.note-input.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* -- Category dot colors -- */
.cat-dot-Corporate { background: #6366f1; }
.cat-dot-Growth { background: #22c55e; }
.cat-dot-Operations { background: #f59e0b; }
.cat-dot-Development { background: #3b82f6; }
.cat-dot-Finance { background: #ef4444; }

/* ══════════════════════════════════════════════
   Recent Activity drawer (right side)
   ══════════════════════════════════════════════ */


.activity-drawer {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 340px;
  max-height: calc(100vh - 32px);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px var(--primary-shadow-hover);
  z-index: 99;
  overflow: hidden;
  display: none;
  flex-direction: column;
}
.activity-drawer.open {
  display: flex;
}
.activity-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
}
.activity-drawer-title {
  font-size: 0.95rem;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.activity-drawer-count {
  font-size: 0.68rem;
  background: #ede9fe;
  color: #6d28d9;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.btn-read-all {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s;
}
.btn-read-all:hover {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary);
}
.activity-drawer-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.activity-drawer-close:hover {
  background: var(--primary-bg);
  color: var(--text-primary);
}
.activity-drawer-body {
  overflow-y: auto;
  padding: 10px 12px 14px 12px;
  flex: 1;
}
.activity-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 24px 8px;
}
.activity-item {
  background: var(--bg-note);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 9px 11px;
  margin-bottom: 8px;
}
.activity-row1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.activity-author {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-primary);
}
.activity-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.activity-action {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.35;
}
.activity-tag {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #eef2ff;
  color: #4f46e5;
  padding: 1px 6px;
  border-radius: 6px;
  margin: 0 2px;
}
.activity-detail {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-style: italic;
  line-height: 1.4;
  word-break: break-word;
}


@media (max-width: 1100px) {
  .activity-drawer,
  .activity-toggle { display: none; }
  .main-content.with-activity { padding-right: 32px; }
}

/* ══════════════════════════════════════════════════════════
   FOCUS BOARD LAYOUT (Direction C)
   Top app bar + objective drawer + detail pane.
   Overrides the older sidebar/tab layout above.
   ══════════════════════════════════════════════════════════ */

:root {
  --ink: #141721;
  --ink-2: #4d5566;
  --ink-3: #8b93a4;
  --surface-c: #ffffff;
  --soft: #f8f9fb;
  --sunk: #eef0f4;
  --page: #f4f5f7;
  --line: #e3e6ec;
  --line-2: #d2d7e0;
  --brand: #5145cd;
  --brand-soft: #eeecfb;
  --brand-line: #cfc9f5;
  --ok: #0e8a52;
  --ok-soft: #e6f6ee;
  --warn: #b0770b;
  --warn-soft: #fcf4e4;
  --bad: #c9302c;
  --bad-soft: #fbeeed;
  --rc: 10px;
  --appbar-h: 56px;
  --drawer-w: 360px;
}
@media (max-width: 1279px) { :root { --drawer-w: 310px; } }
@media (max-width: 640px)  { :root { --appbar-h: 52px; } }

body:has(.shell) {
  background: var(--page);
  color: var(--ink);
  overflow: hidden;
}

/* ── App bar ─────────────────────────────────────────── */
.appbar {
  height: var(--appbar-h);
  background: var(--surface-c);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; position: relative; z-index: 60;
}
.ab-brand { display: flex; align-items: center; gap: 10px; flex: none; text-decoration: none; color: var(--ink); }
.ab-brand:hover { text-decoration: none; }
.ab-logo { height: 22px; width: auto; max-width: 132px; object-fit: contain; flex: none; display: block; }
.ab-wordmark {
  font-size: 15px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap;
  padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--line);
}
.ab-quarter {
  appearance: none; border: 1px solid var(--line-2); background: var(--soft);
  border-radius: 8px; padding: 5px 26px 5px 11px; font: inherit; font-size: 13px;
  font-weight: 650; cursor: pointer; color: var(--ink); flex: none; margin-left: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' fill='none' stroke='%238b93a4' stroke-width='2'%3E%3Cpath d='M2.5 4L5.5 7L8.5 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.ab-spacer { flex: 1; }
.ab-nav { display: flex; align-items: center; gap: 3px; flex: none; }
.ab-div { width: 1px; height: 24px; background: var(--line); margin: 0 5px; flex: none; }
.ab-btn {
  height: 34px; min-width: 34px; padding: 0 9px; border-radius: 8px; border: none;
  background: none; color: var(--ink-2); display: inline-flex; align-items: center;
  justify-content: center; gap: 7px; cursor: pointer; transition: 0.12s;
  font: inherit; font-size: 13px; font-weight: 600; position: relative; text-decoration: none;
}
.ab-btn:hover { background: var(--sunk); color: var(--ink); text-decoration: none; }
.ab-btn.on { background: var(--brand-soft); color: var(--brand); }
.ab-label { display: inline; }
@media (max-width: 1100px) { .ab-label { display: none; } }
.ab-badge {
  position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px;
  border-radius: 8px; background: var(--bad); color: #fff; font-size: 9.5px;
  font-weight: 750; display: grid; place-items: center; padding: 0 4px;
}
.ab-burger { display: none; }
.ab-account { position: relative; }
.ab-avatar {
  width: 31px; height: 31px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #5145cd, #9333ea); color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none;
}
.ab-menu {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; min-width: 200px;
  background: var(--surface-c); border: 1px solid var(--line); border-radius: var(--rc);
  box-shadow: 0 10px 32px rgba(20,23,33,0.14); padding: 6px; z-index: 70;
}
.ab-menu.open { display: block; }
.ab-menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.ab-menu-name { font-size: 13.5px; font-weight: 680; }
.ab-menu-role { font-size: 11.5px; color: var(--ink-3); }
.ab-menu-item {
  display: block; padding: 7px 10px; border-radius: 7px; font-size: 13.5px;
  font-weight: 560; color: var(--ink-2); text-decoration: none;
}
.ab-menu-item:hover { background: var(--sunk); color: var(--ink); text-decoration: none; }
.ab-menu-item.danger { color: var(--bad); }
.ab-menu-only { display: none; }
.ab-menu-scrim { display: none; position: fixed; inset: 0; z-index: 55; }
.ab-menu-scrim.on { display: block; }

/* ── Shell ───────────────────────────────────────────── */
.shell { display: flex; height: calc(100vh - var(--appbar-h)); position: relative; }

/* ── Objective drawer ────────────────────────────────── */
.drawer {
  width: var(--drawer-w); flex: none; background: var(--surface-c);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0;
}
.dw-top { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.dw-title {
  font-size: 11px; font-weight: 760; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); margin-bottom: 11px;
}
.dw-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.dw-stat-l {
  font-size: 9.5px; font-weight: 760; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3);
}
.dw-stat-v {
  font-size: 18px; font-weight: 740; letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums; line-height: 1.2; color: var(--ink);
}
.dw-time { margin-top: 12px; }
.tbar { height: 5px; border-radius: 3px; background: var(--sunk); overflow: hidden; margin-top: 5px; }
.tbar i { display: block; height: 100%; background: var(--line-2); }
.dw-time-note { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }

/* Category chips wrap onto as many rows as needed — never scroll sideways */
.dw-cats {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.cchip {
  border: 1px solid var(--line-2); background: var(--surface-c); border-radius: 16px;
  padding: 3.5px 11px; font: inherit; font-size: 12px; font-weight: 620;
  color: var(--ink-2); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; transition: 0.12s;
}
.cchip:hover { background: var(--soft); }
.cchip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.cdot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; flex: none; }

.dw-list { flex: 1; overflow-y: auto; padding: 8px; -webkit-overflow-scrolling: touch; }
.dw-empty, .note-empty {
  padding: 22px 14px; text-align: center; color: var(--ink-3); font-size: 13px;
}
.oitem {
  border: 1px solid transparent; border-radius: var(--rc);
  padding: 11px 12px 11px 20px; margin-bottom: 4px; cursor: pointer;
  transition: 0.12s; position: relative;
}
.oitem:hover { background: var(--soft); }
.oitem.sel { background: var(--brand-soft); border-color: var(--brand-line); }
.oitem.dragging { opacity: 0.45; }
.grip {
  position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); opacity: 0; cursor: grab; transition: 0.12s;
}
.oitem:hover .grip { opacity: 1; }
.oi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.oi-title { font-size: 13.5px; font-weight: 620; letter-spacing: -0.01em; line-height: 1.35; min-width: 0; }
.oi-pct { font-size: 14.5px; font-weight: 740; font-variant-numeric: tabular-nums; flex: none; letter-spacing: -0.025em; }
.oi-meta {
  display: flex; align-items: center; gap: 7px; margin-top: 5px;
  font-size: 11.5px; color: var(--ink-3); flex-wrap: wrap;
}
.obar { height: 4px; border-radius: 2px; background: var(--sunk); margin-top: 8px; position: relative; }
.obar i { display: block; height: 100%; border-radius: 2px; }
.pacemark {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--ink); opacity: 0.35; border-radius: 1px;
}
.pacemark.labeled { top: -3px; bottom: -3px; opacity: 0.4; }
.pacemark.labeled::after {
  content: 'pace'; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 760; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.hbadge {
  font-size: 9.5px; font-weight: 760; padding: 1.5px 6px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.h-on { background: var(--ok-soft); color: var(--ok); }
.h-risk { background: var(--warn-soft); color: var(--warn); }
.h-off { background: var(--bad-soft); color: var(--bad); }
.dw-foot { padding: 10px; border-top: 1px solid var(--line); }
.add-obj {
  width: 100%; border: 1px dashed var(--line-2); background: none; border-radius: var(--rc);
  padding: 9px; font: inherit; font-size: 13px; font-weight: 640; color: var(--ink-2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 7px; transition: 0.12s;
}
.add-obj:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.drawer-scrim {
  display: none; position: fixed; inset: var(--appbar-h) 0 0;
  background: rgba(20,23,33,0.42); z-index: 28;
}
.drawer-scrim.on { display: block; }

/* ── Detail pane ─────────────────────────────────────── */
.detail {
  flex: 1; min-width: 0; overflow-y: auto; background: var(--page);
  -webkit-overflow-scrolling: touch;
}
.okr-card { background: none; border: none; box-shadow: none; padding: 0; margin: 0; }
.okr-head {
  background: var(--surface-c); border-bottom: 1px solid var(--line);
  padding: 18px clamp(16px, 2.2vw, 28px) 0;
}
.back-to-list {
  display: none; align-items: center; gap: 6px; background: none; border: none;
  font: inherit; font-size: 13px; font-weight: 650; color: var(--brand);
  cursor: pointer; padding: 0; margin-bottom: 10px;
}
.okr-head-top { display: flex; gap: clamp(16px, 2.5vw, 28px); align-items: flex-start; flex-wrap: wrap; }
.okr-head-main { flex: 1 1 320px; min-width: 0; }
.okr-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 9px; }
.tag {
  font-size: 11px; font-weight: 680; padding: 2px 8px; border-radius: 5px;
  background: var(--sunk); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 5px;
}
.okr-h1 {
  font-size: clamp(19px, 2.1vw, 24px); font-weight: 710;
  letter-spacing: -0.027em; line-height: 1.24; color: var(--ink); margin: 0;
}
.okr-desc { font-size: 13.5px; color: var(--ink-2); margin-top: 6px; max-width: 70ch; }
.okr-head-score { flex: 0 0 auto; text-align: right; min-width: 150px; }
.okr-pct {
  font-size: clamp(30px, 3.4vw, 38px); font-weight: 750; letter-spacing: -0.038em;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.okr-delta { font-size: 12px; font-weight: 640; margin-top: 4px; }
.bigbar { height: 8px; border-radius: 4px; background: var(--sunk); margin-top: 11px; position: relative; }
.bigbar i { display: block; height: 100%; border-radius: 4px; }
.okr-tabs { display: flex; gap: 2px; margin-top: 16px; overflow-x: auto; scrollbar-width: none; }
.okr-tabs::-webkit-scrollbar { display: none; }
.otab {
  border: none; background: none; padding: 9px 14px; font: inherit; font-size: 13.5px;
  font-weight: 640; color: var(--ink-3); cursor: pointer;
  border-bottom: 2px solid transparent; transition: 0.12s;
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
}
.otab:hover { color: var(--ink); }
.otab.on { color: var(--brand); border-bottom-color: var(--brand); }
.otab-count {
  font-size: 11px; font-weight: 720; background: var(--sunk); color: var(--ink-2);
  border-radius: 9px; padding: 1px 6px;
}
.otab.on .otab-count { background: var(--brand); color: #fff; }
.okr-body { padding: 18px clamp(16px, 2.2vw, 28px) 70px; }
.opanel { display: none; }
.opanel.on { display: block; }
.flex-sp { flex: 1; }

/* ── Key result cards ────────────────────────────────── */
.kr-toolbar { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; flex-wrap: wrap; }
.kr-toolbar-l {
  font-size: 11px; font-weight: 760; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3);
}
.kr-card {
  background: var(--surface-c); border: 1px solid var(--line); border-radius: var(--rc);
  padding: 15px 17px; margin-bottom: 9px; transition: 0.12s;
}
.kr-card:hover { border-color: var(--line-2); }
.kr-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.kr-top-main { min-width: 0; flex: 1 1 220px; }
.kr-name { font-size: 15px; font-weight: 650; letter-spacing: -0.012em; color: var(--ink); }
.kr-meta { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.kr-desc {
  font-size: 12.5px; color: var(--ink-2); margin-top: 5px;
  padding-left: 9px; border-left: 2px solid var(--line-2);
}
.kr-score { flex: none; text-align: right; }
.kr-pct { font-size: 19px; font-weight: 740; font-variant-numeric: tabular-nums; letter-spacing: -0.025em; }
.kr-delta { font-size: 11px; font-weight: 620; color: var(--ink-3); margin-top: 1px; }
.kbar { height: 6px; border-radius: 3px; background: var(--sunk); margin: 14px 0 12px; position: relative; }
.kbar i { display: block; height: 100%; border-radius: 3px; }
.kr-values { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.kv-l {
  font-size: 9.5px; font-weight: 760; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3);
}
.kv-v { font-size: 16px; font-weight: 690; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kv-right { text-align: right; }
.kr-actions {
  display: flex; align-items: center; gap: 8px; margin-top: 13px;
  padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap;
}

/* ── Buttons (scoped to the new shell) ───────────────── */
.shell .btn {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface-c); color: var(--ink);
  padding: 6px 13px; font: inherit; font-size: 13px; font-weight: 630;
  cursor: pointer; transition: 0.12s; white-space: nowrap; box-shadow: none;
}
.shell .btn:hover { background: var(--soft); border-color: var(--line-2); box-shadow: none; transform: none; }
.shell .btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.shell .btn-primary:hover { background: #443ab5; border-color: #443ab5; }
.shell .btn-sm { padding: 3.5px 9px; font-size: 11.5px; border-radius: 6px; }
.shell .btn-danger { color: var(--bad); border-color: #f3c9c7; background: var(--surface-c); }
.shell .btn-danger:hover { background: var(--bad-soft); }
.notes-toggle {
  flex: none; width: auto; white-space: nowrap;
  background: none; border: none; font: inherit; font-size: 12.5px; font-weight: 630;
  color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center;
  gap: 6px; padding: 0; white-space: nowrap;
}
.notes-toggle:hover { color: var(--brand); }

/* ── Notes ───────────────────────────────────────────── */
.shell .notes-list { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.shell .note-form { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.shell .note-input {
  flex: 1 1 240px; border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 12px;
  font: inherit; font-size: 13.5px; resize: vertical; min-height: 38px;
  background: var(--surface-c); color: var(--ink);
}
.shell .note-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.shell .note-card {
  background: var(--surface-c); border: 1px solid var(--line); border-radius: var(--rc);
  padding: 12px 15px; margin-bottom: 8px;
}
.shell .note-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.shell .note-author { font-weight: 670; color: var(--ink); }
.shell .note-timestamp { color: var(--ink-3); }
.shell .note-text { font-size: 13.5px; color: var(--ink-2); }

/* ── History table ───────────────────────────────────── */
.hist-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--rc); background: var(--surface-c);
}
.hist { min-width: 520px; }
.hrow {
  display: grid; grid-template-columns: 1fr 120px 120px 90px; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--line); font-size: 13px; align-items: center;
}
.hrow:last-child { border-bottom: none; }
.hrow.head {
  background: var(--soft); font-size: 10.5px; font-weight: 740;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3);
}
.hkr { font-weight: 580; }
.hnum { text-align: right; font-variant-numeric: tabular-nums; font-weight: 620; }

/* ── Activity drawer inside the shell ────────────────── */
.shell .activity-drawer {
  position: fixed; top: var(--appbar-h); right: 0; bottom: 0; width: min(330px, 88vw);
  background: var(--surface-c); border-left: 1px solid var(--line);
  transform: translateX(102%); transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 45; display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(20,23,33,0.10);
}
.shell .activity-drawer.open { transform: none; }
.shell .activity-drawer-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.shell .activity-drawer-title { font-size: 13px; font-weight: 700; letter-spacing: -0.01em; }
.shell .activity-drawer-body { flex: 1; overflow-y: auto; padding: 4px 16px 20px; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1023px) {
  .ab-burger { display: inline-flex; }
  .drawer {
    position: fixed; top: var(--appbar-h); bottom: 0; left: 0;
    width: min(340px, 86vw); z-index: 30;
    transform: translateX(-102%); transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 34px rgba(20,23,33,0.14);
  }
  .drawer.open { transform: none; }
}

@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
  .ab-wordmark { display: none; }
  .appbar { gap: 5px; padding: 0 8px; }
  /* The wordmark logo is very wide (1640x216) — cap it hard so the avatar fits */
  .ab-logo { height: 18px; max-width: 96px; }
  .ab-quarter { margin-left: 0; font-size: 12px; padding: 5px 20px 5px 7px; }
  .ab-btn { min-width: 32px; height: 32px; padding: 0 6px; }
  .ab-div { margin: 0 1px; }
  /* Secondary destinations move into the account menu */
  .ab-opt { display: none; }
  .ab-menu-only { display: block; }

  /* True master/detail — one pane at a time */
  .drawer {
    position: static; transform: none; width: 100%;
    box-shadow: none; border-right: none; display: flex;
  }
  .shell.showing-detail .drawer { display: none; }
  .detail { display: none; }
  .shell.showing-detail .detail { display: block; }
  .drawer-scrim { display: none !important; }
  .back-to-list { display: inline-flex; }

  .okr-head-score { text-align: left; flex-basis: 100%; min-width: 0; }
  .kr-card { padding: 13px 14px; }
  .kr-score { text-align: left; }
  .kr-toolbar-l { display: none; }
  .kr-toolbar { gap: 6px; }
  .kr-toolbar .btn-sm,
  .kr-actions .btn-sm { flex: 1 1 auto; justify-content: center; }
}

/* ── Simple pages (Admin / Reports / Account) under the app bar ── */
.page-shell {
  height: calc(100vh - var(--appbar-h));
  overflow-y: auto;
  background: var(--page);
  -webkit-overflow-scrolling: touch;
}
.page-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 32px) 70px;
}
body:has(.page-shell) { background: var(--page); overflow: hidden; }
@media (max-width: 640px) {
  .page-main { padding: 18px 14px 60px; }
}

/* Admin user rows need room for four actions before they stack */
.page-main .user-row { grid-template-columns: 2.2fr 1.2fr 0.9fr auto; }
@media (max-width: 860px) {
  .page-main .user-row { grid-template-columns: 1fr; gap: 10px; }
  .page-main .user-row > div:last-child { justify-content: flex-start; }
}

/* Trend charts must never push the card wider than its column */
.kr-card .chart-container { max-width: 100%; overflow: hidden; margin-top: 12px; }
.kr-card .chart-container .js-plotly-plot,
.kr-card .chart-container .plot-container { max-width: 100%; }

/* Most recent note, always visible on a KR card. The rest sit behind the
   Notes toggle so cards stay short as threads grow. */
.note-latest {
  margin-top: 12px;
  padding: 10px 13px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand-line);
  border-radius: var(--rc);
}
.note-latest-label {
  font-size: 9.5px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-bottom: 5px;
}
.note-latest .note-meta {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px; margin-bottom: 3px; flex-wrap: wrap;
}
.note-latest .note-author { font-weight: 670; color: var(--ink); }
.note-latest .note-timestamp { color: var(--ink-3); }
.note-latest .note-text { font-size: 13.5px; color: var(--ink-2); }

/* The objective Notes tab is already an expanded view — no top divider. */
.shell .notes-list-open { margin-top: 0; padding-top: 0; border-top: none; }
