/* Enrico Dashboard — Mobile-first light/beige theme */

:root {
  --bg: #f5f0e8;
  --surface: #ffffff;
  --surface-hover: #f0ebe3;
  --border: #e0d8cc;
  --text: #1a1a1a;
  --text-dim: #666;
  --text-muted: #999;
  --accent: #2563eb;
  --red: #dc2626;
  --yellow: #d97706;
  --green: #059669;
  --orange: #ea580c;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--safe-bottom) + 16px);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Auth Screen ---- */

.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
}

.auth-screen h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-screen .subtitle {
  color: var(--text-dim);
  margin-bottom: 40px;
  font-size: 15px;
}

.auth-screen .pin-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.auth-screen input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 24px;
  letter-spacing: 8px;
  text-align: center;
  padding: 14px;
  outline: none;
  width: 100%;
}

.auth-screen input:focus {
  border-color: var(--accent);
}

.auth-screen input::placeholder {
  letter-spacing: 2px;
  font-size: 16px;
  color: var(--text-muted);
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  padding: 14px 24px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
  transition: opacity 0.15s;
}

.btn:active { opacity: 0.7; }

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

.auth-error {
  color: var(--red);
  font-size: 14px;
  margin-top: 8px;
  min-height: 20px;
}

/* ---- Dashboard ---- */

.dashboard {
  padding: 0 16px;
}

/* Context strip */
.context-strip {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: calc(var(--safe-top) + 12px) 0 12px;
  border-bottom: 1px solid var(--border);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

.context-strip .greeting {
  font-size: 22px;
  font-weight: 700;
}

.context-strip .meta {
  display: flex;
  gap: 12px;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 2px;
}

.context-strip .next-event {
  color: var(--accent);
  font-weight: 600;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* Attention card */
.card.attention {
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.06);
}

.attention-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.attention-item:last-child { border-bottom: none; }

.attention-item .title {
  font-size: 14px;
  flex: 1;
}

.attention-item .badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-overdue { background: rgba(220, 38, 38, 0.1); color: var(--red); }
.badge-blocked { background: rgba(217, 119, 6, 0.1); color: var(--yellow); }

/* Timeline */
.timeline-event {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.timeline-event:last-child { border-bottom: none; }

.timeline-event .time {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 65px;
  flex-shrink: 0;
}

.timeline-event .event-title {
  font-size: 14px;
  flex: 1;
}

.timeline-event .cal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.cal-dot.work { background: var(--accent); }
.cal-dot.personal { background: var(--green); }
.cal-dot.family { background: var(--yellow); }
.cal-dot.tripit { background: var(--orange); }
.cal-dot.mallika-tripit { background: var(--orange); opacity: 0.6; }

.timeline-event.fyi { opacity: 0.5; }

.timeline-now {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
}

.timeline-now::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
}

.timeline-now::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--red);
}

/* Task board */
.task-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.task-tab {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.task-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.task-tab .count {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 4px;
}

.task-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.task-item:last-child { border-bottom: none; }

.task-item .task-title {
  font-size: 14px;
  margin-bottom: 4px;
}

.task-item .task-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.task-item .task-meta .overdue { color: var(--red); }

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

.task-actions button {
  font-size: 13px;
  padding: 8px 16px;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: opacity 0.15s;
}

.task-actions button:active { opacity: 0.6; }
.task-actions button:disabled { opacity: 0.4; }

.task-actions button.done-btn { border-color: rgba(5, 150, 105, 0.3); color: var(--green); }
.task-actions button.defer-btn { border-color: rgba(217, 119, 6, 0.3); color: var(--yellow); }

/* Health cards */
.health-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

.health-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 140px;
  flex-shrink: 0;
}

.health-card .label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.health-card .value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.health-card .unit {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 400;
}

.health-card .sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.health-card .value.red { color: var(--red); }
.health-card .value.yellow { color: var(--yellow); }
.health-card .value.green { color: var(--green); }

/* Inbox */
.inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.inbox-header .chevron {
  color: var(--text-dim);
  transition: transform 0.2s;
}

.inbox-header .chevron.open { transform: rotate(180deg); }

.inbox-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.inbox-item:last-child { border-bottom: none; }

.inbox-item .summary {
  font-size: 14px;
}

.inbox-item .inbox-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Pull to refresh indicator */
.refresh-indicator {
  text-align: center;
  padding: 12px;
  color: var(--text-dim);
  font-size: 13px;
  display: none;
}

.refresh-indicator.visible { display: block; }

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Stale indicator */
.stale-notice {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px;
}

/* Empty state */
.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 20px;
}

/* Refresh button */
.refresh-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 20px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.3s;
  flex-shrink: 0;
}

.refresh-btn:active { color: var(--accent); }
.refresh-btn.spinning { animation: spin 0.8s linear infinite; }

/* Change feed */
.card-changes { border-color: rgba(37, 99, 235, 0.3); background: rgba(37, 99, 235, 0.05); }

.change-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.change-item:last-child { border-bottom: none; }
.change-icon { font-family: monospace; color: var(--accent); min-width: 16px; text-align: center; flex-shrink: 0; }
.change-detail { flex: 1; color: var(--text); }

.dismiss-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.dismiss-btn:active { opacity: 0.6; }

/* Staleness badges */
.badge-aging {
  background: rgba(217, 119, 6, 0.1);
  color: var(--yellow);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 6px;
}

.badge-stale {
  background: rgba(220, 38, 38, 0.1);
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 6px;
}

/* Task view toggle */
.task-view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.tvt-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tvt-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Task rows (shared) */
.task-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.task-row-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.task-row-id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  flex-shrink: 0;
}

.task-row-title {
  flex: 1;
  font-size: 14px;
  line-height: 1.3;
}

.task-row-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
  padding-left: 22px;
  line-height: 1.4;
}

.status-icon {
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 3px;
}

.status-icon.active { color: var(--green); }
.status-icon.overdue { color: var(--red); }
.status-icon.blocked { color: var(--red); opacity: 0.7; }
.status-icon.time-gated { color: var(--yellow); }

.task-quick-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 4px;
}

.quick-done, .quick-defer {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding: 0;
}

.quick-done { color: var(--green); }
.quick-done:active { background: rgba(5, 150, 105, 0.15); }
.quick-defer { color: var(--yellow); }
.quick-defer:active { background: rgba(217, 119, 6, 0.15); }
.quick-done:disabled, .quick-defer:disabled { opacity: 0.3; }

.owner-badge {
  font-size: 11px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  white-space: nowrap;
}

.lane-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.3px;
}

.lane-badge.lane-peeyush { background: rgba(37, 99, 235, 0.1); color: var(--accent); }
.lane-badge.lane-enrico { background: rgba(5, 150, 105, 0.1); color: var(--green); }
.lane-badge.lane-waiting { background: rgba(217, 119, 6, 0.1); color: var(--yellow); }
.lane-badge.lane-backlog { background: rgba(0,0,0,0.05); color: var(--text-muted); }

.next-action-text {
  color: var(--text-muted);
  font-style: italic;
}

/* Project view */
.project-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.project-chevron {
  font-size: 10px;
  color: var(--text-muted);
  width: 14px;
  text-align: center;
}

.project-name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

.project-count {
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(0,0,0,0.05);
  padding: 1px 7px;
  border-radius: 10px;
}

.overdue-count {
  font-size: 11px;
  color: var(--red);
  font-weight: 600;
}

.project-tasks {
  padding-left: 14px;
}

.show-more-btn {
  display: block;
  width: 100%;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--accent);
  font-size: 13px;
  padding: 8px;
  margin-top: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.show-more-btn:active { opacity: 0.6; }

/* Task admin */

.task-edit {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
}

.task-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.task-field label {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 60px;
  flex-shrink: 0;
}

.task-input, .task-select {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  font-family: inherit;
}

.task-input:focus, .task-select:focus {
  border-color: var(--accent);
}

.task-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.task-save-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.task-save-btn:active { opacity: 0.7; }
.task-save-btn:disabled { opacity: 0.4; }

.task-cancel-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.task-cancel-btn:active { opacity: 0.6; }

/* ---- Context strip layout (replaces inline flex row) ---- */
.context-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.context-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.context-left .greeting {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-hamburger {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 18px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}
.nav-hamburger:active { color: var(--accent); }

/* ---- Task jump bar ---- */
.task-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.task-jump-input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  font-family: inherit;
}
.task-jump-input:focus { border-color: var(--accent); }
.task-jump-input:disabled { opacity: 0.5; }
.task-jump-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 16px;
  min-width: 38px;
  height: 36px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.task-jump-btn:active { opacity: 0.6; }
.task-jump-btn:disabled { opacity: 0.4; }
.task-jump-error {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--red);
  margin-top: 2px;
}

@keyframes jumpFlash {
  0%   { background: rgba(37, 99, 235, 0.20); }
  100% { background: transparent; }
}
.task-row.jump-flash {
  animation: jumpFlash 1.4s ease-out;
  border-radius: 6px;
}

/* ---- Nav drawer / backdrop ---- */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 150;
}
.nav-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  width: 240px;
  max-width: 80vw;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 200;
  padding: calc(var(--safe-top) + 16px) 0 calc(var(--safe-bottom) + 16px);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.nav-drawer.open { transform: translateX(0); }

.nav-drawer-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.nav-drawer-list { display: flex; flex-direction: column; }
.nav-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 48px;
}
.nav-row:last-child { border-bottom: none; }
.nav-row:active { background: var(--surface-hover); }
.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: var(--text-dim);
  flex-shrink: 0;
}
.nav-label { flex: 1; }
.nav-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-hover);
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
}

/* ---- Act on it button ---- */
.quick-act {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding: 0;
  color: var(--accent);
}
.quick-act:active { background: rgba(37, 99, 235, 0.15); }
.quick-act:disabled { opacity: 0.3; }

.act-btn {
  background: none;
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  min-height: 36px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.act-btn:active { opacity: 0.7; }
.act-btn:disabled { opacity: 0.4; }
