:root {
  --orange:   #E76127;
  --blue:     #006880;
  --gray:     #333333;
  --gray-mid: #6B6B6B;
  --gray-soft: #888;
  --white:    #FFFFFF;
  --rule:     #E5E5E5;
  --bg-soft:  #FAFAFA;
  --pause:    #F5F5F5;

  --green:    #95C93D;
  --skyblue:  #48C1E1;
  --pink:     #D41A69;
  --yellow:   #F4C430;
  --purple:   #6E40A2;
  --teal:     #00A99D;
  --red:      #E04848;
  --gray-cat: #999999;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Avenir Next', Avenir, 'Century Gothic', 'Lucida Sans', Tahoma, sans-serif;
  color: var(--gray);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--white);
  border-bottom: 2px solid var(--blue);
}
.topbar .iv-logo { height: 36px; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}
.title {
  color: var(--blue);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.topbar-btn {
  background: var(--white);
  border: 1px solid var(--rule);
  color: var(--gray);
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar-btn:hover { border-color: var(--blue); color: var(--blue); }
.topbar-count {
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
}

.sync-status {
  font-size: 12px;
  color: var(--gray-mid);
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
}
.sync-status.ok { color: #2e7d32; background: #f1f8e9; border-color: #c5e1a5; }
.sync-status.degraded { color: #b26500; background: #fff7e6; border-color: #ffd093; }
.sync-status.error { color: #b71c1c; background: #ffebee; border-color: #ef9a9a; }

/* Banner */
.banner {
  background: #fff7e6;
  border-bottom: 1px solid #ffd093;
  color: #874c00;
  padding: 10px 28px;
  font-size: 13px;
  line-height: 1.4;
}

/* Tabbar */
.tabbar {
  display: flex;
  gap: 4px;
  padding: 10px 28px 0;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--rule);
}
.tab {
  background: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gray-mid);
  cursor: pointer;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tab:hover { color: var(--blue); }
.tab.active {
  background: var(--white);
  border-color: var(--rule);
  color: var(--blue);
}
.tab-count {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-mid);
}
.tab.active .tab-count { background: #f4fafb; border-color: #b9dde2; color: var(--blue); }

.view { display: none; }
.view.active { display: block; }

/* Annual view */
.annual-view {
  padding: 18px 28px 32px;
}
.hint {
  color: var(--gray-mid);
  font-size: 13px;
  margin: 0 0 14px;
}
.hint strong { color: var(--gray); }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
}

.month {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px 12px 10px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
}
.month-name {
  font-weight: 800;
  color: var(--blue);
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.month-add {
  background: none;
  border: 1px dashed var(--rule);
  color: var(--gray-mid);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  letter-spacing: 0.03em;
  text-transform: none;
  font-weight: 500;
}
.month-add:hover { color: var(--blue); border-color: var(--blue); background: #f4fafb; }

.card-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 30px;
}

.card {
  background: var(--white);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--gray-cat);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1.35;
  cursor: grab;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  user-select: none;
  transition: box-shadow 0.12s, transform 0.06s;
}
.card:hover {
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.card:active { cursor: grabbing; transform: scale(0.99); }
.card.sortable-ghost { opacity: 0.45; }
.card.sortable-chosen { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.card-title { flex: 1; word-break: break-word; }
.card-step-count {
  font-size: 10px;
  color: var(--gray-soft);
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 1px 7px;
  letter-spacing: 0.04em;
}

.card.cat-gaps-core           { border-left-color: var(--blue); }
.card.cat-tycard-regular      { border-left-color: var(--green); }
.card.cat-tycard-ls           { border-left-color: var(--yellow); }
.card.cat-tycard-staff        { border-left-color: var(--teal); }
.card.cat-newsletter-regional { border-left-color: var(--skyblue); }
.card.cat-ace                 { border-left-color: var(--purple); }
.card.cat-gp                  { border-left-color: var(--pink); }
.card.cat-admin               { border-left-color: var(--gray-cat); }

/* Legend */
.legend {
  margin-top: 22px;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--gray-mid);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cat-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.cat-dot.cat-gaps-core           { background: var(--blue); }
.cat-dot.cat-tycard-regular      { background: var(--green); }
.cat-dot.cat-tycard-ls           { background: var(--yellow); }
.cat-dot.cat-tycard-staff        { background: var(--teal); }
.cat-dot.cat-newsletter-regional { background: var(--skyblue); }
.cat-dot.cat-ace                 { background: var(--purple); }
.cat-dot.cat-gp                  { background: var(--pink); }
.cat-dot.cat-admin               { background: var(--gray-cat); }

/* Drill down */
.drill-down {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: stretch;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 24px;
}
.drill-down-panel {
  background: var(--white);
  border-radius: 10px;
  max-width: 960px;
  width: 100%;
  margin: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  padding: 20px 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.drill-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 14px;
}
.back-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  padding: 0;
  cursor: pointer;
  align-self: flex-start;
}
.back-btn:hover { text-decoration: underline; }

.drill-title-wrap { display: flex; flex-direction: column; gap: 10px; }
.drill-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--blue);
  border: 1px solid transparent;
  padding: 4px 6px;
  border-radius: 4px;
  margin: 0;
  font-family: inherit;
  width: 100%;
}
.drill-title:hover { border-color: var(--rule); }
.drill-title:focus { outline: none; border-color: var(--blue); background: #f4fafb; }

.drill-meta {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--gray-mid);
  align-items: center;
  flex-wrap: wrap;
}
.drill-meta label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.drill-meta select {
  font-family: inherit;
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--white);
}
.delete-btn {
  margin-left: auto;
  background: none;
  border: 1px solid #efb3b3;
  color: #b04545;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.delete-btn:hover { background: #fdecec; }

.delivery-date-label input[type="date"] {
  font-family: inherit;
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--white);
  margin-left: 6px;
}
.placeholder-note {
  margin: 4px 0 0;
  font-size: 12px;
  color: #874c00;
  background: #fff7e6;
  border-left: 3px solid #ffd093;
  padding: 5px 10px;
  border-radius: 2px;
}

.drill-body h2 {
  font-size: 16px;
  color: var(--gray);
  margin: 0 0 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.drill-body h3 { font-size: 13px; color: var(--gray-mid); margin: 18px 0 6px; text-transform: uppercase; letter-spacing: 0.05em; }

.steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}
.step {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 6px 8px;
}
.step .grip {
  color: var(--gray-soft);
  cursor: grab;
  font-size: 14px;
  padding: 0 4px;
}
.step input[type="date"] {
  font-family: inherit;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  width: 142px;
}
.step input[type="text"] {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.step .step-delete {
  background: none;
  border: none;
  color: var(--gray-soft);
  font-size: 16px;
  cursor: pointer;
  padding: 0 6px;
}
.step .step-delete:hover { color: var(--red); }
.step .step-assignee {
  font-family: inherit;
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--white);
  max-width: 130px;
}
.assignee-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  color: var(--white);
}
.assignee-swatch.hidden { display: none; }
.step.step-violation { border-color: #ef9a9a; background: #fff3f3; }
.step.step-violation input[type="date"] { color: var(--red); border-color: #ef9a9a; }
.step .step-warn { color: var(--red); font-size: 14px; padding: 0 4px; }

.add-step-btn {
  align-self: flex-start;
  background: var(--white);
  border: 1px dashed var(--blue);
  color: var(--blue);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
}
.add-step-btn:hover { background: #f4fafb; }

.notes-label { margin-top: 16px; }
#drill-notes {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
#drill-notes:focus { outline: none; border-color: var(--blue); }

/* PM view */
.pm-view { padding: 18px 28px 32px; }
.pm-toolbar {
  display: flex;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.pm-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--gray-mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pm-filter input[type="text"],
.pm-filter select {
  font-family: inherit;
  font-size: 13px;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  min-width: 220px;
}
.pm-filter.pm-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--gray);
}
.pm-filter.pm-checkbox span { text-transform: none; }

.pm-table-wrap {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
.pm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.pm-table th {
  text-align: left;
  background: var(--bg-soft);
  padding: 9px 12px;
  font-weight: 700;
  color: var(--gray-mid);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--rule);
}
.pm-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
.pm-table tr:last-child td { border-bottom: none; }
.pm-table tr.pm-undated td { background: #fafaf7; }
.pm-table tr:hover td { background: #f4fafb; }

.pm-table tr.pm-parent td {
  background: #f8fbfc;
  border-bottom: 2px solid var(--rule);
}
.pm-table tr.pm-parent:hover td { background: #ecf5f7; }
.pm-table tr.pm-parent .event-link { font-weight: 700; font-size: 14px; color: var(--blue); }
.pm-table tr.pm-parent .step-text { font-style: italic; color: var(--gray-mid); background: transparent; }
.pm-table tr.pm-parent.pm-placeholder .col-date input { color: #b26500; }

.pm-table tr.pm-step .col-event { padding-left: 28px; position: relative; }
.pm-table tr.pm-step .step-prefix {
  position: absolute;
  left: 12px;
  color: var(--gray-soft);
  font-size: 14px;
}
.pm-table tr.pm-step .event-link { font-weight: 500; color: var(--gray-mid); font-size: 12px; }
.pm-table tr.pm-step .event-link:hover { color: var(--blue); }

.pm-table tr.pm-violation .col-date input { color: var(--red); border-color: #ef9a9a; }
.pm-table tr.pm-violation td { background: #fff3f3; }
.pm-table tr.pm-violation:hover td { background: #ffe9e9; }
.pm-table .pm-warn {
  color: var(--red);
  font-size: 14px;
  margin-left: 8px;
  cursor: help;
}

.step-readonly { background: transparent !important; cursor: default; }
.step-readonly:focus { outline: none; border-color: transparent !important; }

/* Team overlay */
.team-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 90;
  overflow-y: auto;
  padding: 60px 24px;
}
.team-panel {
  background: var(--white);
  border-radius: 10px;
  max-width: 480px;
  width: 100%;
  padding: 22px 26px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.team-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.team-header h2 {
  margin: 0;
  font-size: 16px;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.team-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--gray-soft);
  cursor: pointer;
  padding: 0 6px;
}
.team-close:hover { color: var(--gray); }
.team-list { display: flex; flex-direction: column; gap: 6px; }
.team-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  border: 1px solid var(--rule);
}
.team-row .team-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.team-row input {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--white);
}
.team-row input:focus { outline: none; border-color: var(--blue); }
.team-row .team-delete {
  background: none;
  border: none;
  color: var(--gray-soft);
  font-size: 16px;
  cursor: pointer;
}
.team-row .team-delete:hover { color: var(--red); }
.team-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
}
.team-add-row input {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.team-add-row input:focus { outline: none; border-color: var(--blue); }
.team-add-btn {
  background: var(--blue);
  color: var(--white);
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.team-add-btn:hover { background: #00566b; }
.team-add-btn:disabled { background: var(--gray-soft); cursor: not-allowed; }

/* Assignee dropdown + initials */
.drill-meta select#drill-assignee { min-width: 160px; }
.card-assignee {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
  letter-spacing: 0;
}
.card-assignee.unassigned {
  background: var(--bg-soft);
  color: var(--gray-soft);
  border: 1px dashed var(--rule);
}

.pm-table .col-assignee { width: 140px; }
.pm-table .col-assignee select {
  font-family: inherit;
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  max-width: 130px;
}
.pm-table .col-assignee select:hover { border-color: var(--rule); background: var(--white); }
.pm-table .col-assignee select:focus { outline: none; border-color: var(--blue); }
.pm-table .col-assignee .assignee-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.col-date    { width: 162px; }
.col-month   { width: 110px; color: var(--gray-mid); }
.col-cat     { width: 150px; }
.col-actions { width: 70px; text-align: right; }
.col-event   { font-weight: 600; }

.pm-table input[type="date"] {
  font-family: inherit;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  width: 142px;
}
.pm-table input[type="date"]:hover { border-color: var(--rule); }
.pm-table input[type="date"]:focus { outline: none; border-color: var(--blue); background: var(--white); }

.pm-table .step-text {
  font-family: inherit;
  font-size: 13px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 6px;
  background: transparent;
}
.pm-table .step-text:hover { border-color: var(--rule); }
.pm-table .step-text:focus { outline: none; border-color: var(--blue); background: var(--white); }

.pm-table .event-link {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  padding: 0;
}
.pm-table .event-link:hover { text-decoration: underline; }

.pm-table .cat-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pm-table .row-delete {
  background: none;
  border: none;
  color: var(--gray-soft);
  cursor: pointer;
  font-size: 15px;
}
.pm-table .row-delete:hover { color: var(--red); }

.pm-empty {
  text-align: center;
  color: var(--gray-mid);
  font-style: italic;
  padding: 28px 0;
}

/* Category-pill colors mirror card border */
.cat-pill.cat-gaps-core           { background: #e5f1f4; color: #004a5b; }
.cat-pill.cat-tycard-regular      { background: #ecf8d6; color: #4a7a16; }
.cat-pill.cat-tycard-ls           { background: #fdf6df; color: #8c6500; }
.cat-pill.cat-tycard-staff        { background: #d7f4f1; color: #036b62; }
.cat-pill.cat-newsletter-regional { background: #e0f4fb; color: #08607a; }
.cat-pill.cat-ace                 { background: #ecdef7; color: #4b1f7b; }
.cat-pill.cat-gp                  { background: #fbe0ec; color: #911247; }
.cat-pill.cat-admin               { background: var(--bg-soft); color: var(--gray-mid); }
