:root {
  --teal: #11808D;
  --teal-dark: #0d6470;
  --slate: #33596f;
  --brown: #4e3629;
  --cream: #F7F6F0;
  --white: #FFFFFF;
  --border: #dedad0;
  --danger: #b23b3b;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--brown);
  font-family: Lato, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

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

h1, h2, h3 { font-weight: 700; color: var(--brown); margin: 0 0 .5em; }

.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--teal);
  letter-spacing: .01em;
}
.brand:hover { text-decoration: none; }

.main-nav { display: flex; align-items: center; gap: 1.1rem; }
.main-nav a { color: var(--slate); font-weight: 400; }
.main-nav a.nav-cta {
  background: var(--teal);
  color: var(--white);
  padding: .4rem .9rem;
  border-radius: var(--radius);
}
.main-nav a.nav-cta:hover { background: var(--teal-dark); text-decoration: none; }
.main-nav .nav-user { color: var(--brown); font-weight: 700; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  padding: 8px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--slate);
  margin: 5px 0;
}

.site-main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

/* Forms / cards */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.form-narrow { max-width: 420px; margin: 2rem auto; }
label { display: block; font-weight: 700; margin: .8rem 0 .3rem; font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=date], textarea, select {
  width: 100%;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  background: var(--white);
  color: var(--brown);
}
textarea { resize: vertical; min-height: 5rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--teal); outline-offset: 1px; }

.btn {
  display: inline-block;
  background: var(--teal);
  color: var(--white);
  border: none;
  padding: .6rem 1.1rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--teal-dark); text-decoration: none; }
.btn.btn-secondary { background: var(--white); color: var(--slate); border: 1px solid var(--slate); }
.btn.btn-secondary:hover { background: #eef3f5; }
.btn.btn-danger { background: var(--danger); }
.btn.btn-danger:hover { background: #8f2e2e; }
.btn.btn-small { padding: .3rem .7rem; font-size: .85rem; }

.error-box {
  background: #fcecec;
  border: 1px solid #e3a9a9;
  color: #7a2323;
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.notice-box {
  background: #edf8fd;
  border: 1px solid #b7dfe9;
  color: #17515a;
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

/* Project list */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.project-tile {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 6px solid var(--teal);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: block;
  color: var(--brown);
}
.project-tile:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.project-tile h3 { color: var(--teal); margin-bottom: .25rem; }
.project-tile p { margin: 0; font-size: .9rem; color: #6b5c50; }
.project-tile .role-badge {
  display: inline-block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--slate);
  border: 1px solid var(--slate);
  border-radius: 3px;
  padding: 1px 6px;
  margin-top: .5rem;
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

/* Project detail layout */
.project-toolbar {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.task-notes-item {
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.task-notes-item:last-child { border-bottom: none; }
.task-notes-head {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  flex-wrap: wrap;
}
.task-notes-title { font-weight: 700; color: var(--brown); cursor: pointer; }
.task-notes-title:hover { text-decoration: underline; }
.task-notes-dates { font-size: .8rem; color: #8a7c6d; }
.task-notes-body {
  margin: .3rem 0 0;
  font-size: .9rem;
  color: #574a3d;
  white-space: pre-wrap;
}
.task-notes-body.empty { color: #b3a89b; font-style: italic; }

.gantt-bar-note-flag {
  margin-left: .35rem;
  opacity: .85;
}

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

/* ---- Gantt ---- */
.gantt-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.gantt {
  display: flex;
  max-height: 70vh;
}
.gantt-labels {
  flex: 0 0 180px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.gantt-labels .gantt-corner {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 .7rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--slate);
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 2;
}
.gantt-label-row {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 .7rem;
  font-size: .85rem;
  border-bottom: 1px solid #f0eee6;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gantt-label-row:hover { background: #f7fbfc; }

.gantt-chart-scroll {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
}
.gantt-chart {
  position: relative;
}
.gantt-header-row {
  display: flex;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 2;
  border-bottom: 1px solid var(--border);
}
.gantt-month-row { display: flex; height: 24px; }
.gantt-day-row { display: flex; height: 28px; }
.gantt-month-cell {
  border-right: 1px solid var(--border);
  font-size: .72rem;
  font-weight: 700;
  color: var(--slate);
  padding-left: 4px;
  line-height: 24px;
  white-space: nowrap;
  overflow: hidden;
}
.gantt-day-cell {
  border-right: 1px solid #f0eee6;
  font-size: .68rem;
  color: #8a7c6d;
  text-align: center;
  line-height: 28px;
  flex: none;
}
.gantt-day-cell.weekend { background: #faf8f2; }
.gantt-day-cell.today { background: #fff3d6; font-weight: 700; color: var(--brown); }

.gantt-body { position: relative; }
.gantt-row-bg {
  height: 40px;
  border-bottom: 1px solid #f0eee6;
  position: relative;
}
.gantt-row-bg.today-col::after { content: none; }

.gantt-bar {
  position: absolute;
  top: 6px;
  height: 28px;
  background: var(--teal);
  border-radius: 5px;
  color: var(--white);
  font-size: .78rem;
  line-height: 28px;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  user-select: none;
  touch-action: none;
}
.gantt-bar:active { cursor: grabbing; }
.gantt-bar .handle {
  position: absolute;
  top: 0;
  width: 14px;
  height: 100%;
  cursor: ew-resize;
}
.gantt-bar .handle.left { left: 0; }
.gantt-bar .handle.right { right: 0; }
.gantt-bar.dragging { opacity: .85; z-index: 5; }

.gantt-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #8a7c6d;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 25, 20, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.3rem;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: space-between; gap: .5rem; margin-top: 1.1rem; }
.modal-actions .right { display: flex; gap: .5rem; }
.field-row { display: flex; gap: .7rem; }
.field-row > div { flex: 1; }

/* Responsive */
@media (max-width: 820px) {
  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: .5rem 1rem 1rem;
    gap: .7rem;
  }
  .main-nav.open { display: flex; }
  .nav-toggle { display: block; }
  .gantt-labels { flex-basis: 130px; }
}

@media (max-width: 560px) {
  .site-main { padding: 1rem .75rem 3rem; }
  .project-grid { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; gap: 0; }
}
