/* Goal tracking (tracker idea_team_goals). Own file for the same reason
   goals.js is: styles.css is written by several sessions at once.
   Every colour is a --sv-* token: the dashboard repaints .crm-record-panel
   via --sv-surface and the Navy/Cream toggle swaps only those tokens, so a
   hardcoded hex renders wrong in one of the two themes.
   ⚠ styles.css has a GLOBAL input/select rule (width:100%, 12px padding,
   white background). The form fields below restate what they need. */

.goals-panel {
  display: grid;
  gap: 12px;
  color: var(--sv-text);
}

.goal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.goal-head h3 {
  margin: 0;
  color: var(--sv-heading);
}

.goal-head p {
  margin: 2px 0 0;
  color: var(--sv-text-muted);
  font-size: 0.86rem;
}

.goal-year-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 800;
}

.goal-year-nav span {
  min-width: 112px;
  text-align: center;
}

.goal-card {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  background: var(--sv-surface-2);
  border: 1px solid var(--sv-line);
  border-radius: 8px;
  min-width: 0;
}

.goal-card-private {
  border-left: 4px solid var(--sv-accent);
}

.goal-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.goal-card-head h4 {
  margin: 0;
  color: var(--sv-heading);
  font-size: 1rem;
}

.goal-private-note {
  margin: 0;
  color: var(--sv-text);
  font-size: 0.84rem;
  font-weight: 700;
}

.goal-sub,
.goal-empty {
  margin: 0;
  color: var(--sv-text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.goal-empty {
  color: var(--sv-text);
}

.goal-warn {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--sv-positive-line);
  border-radius: 6px;
  background: var(--sv-positive-bg);
  color: var(--sv-positive-strong);
  font-size: 0.82rem;
}

.goal-status {
  margin: 0;
  color: var(--sv-heading);
  font-size: 0.86rem;
  font-weight: 700;
}

.goal-status.error {
  color: var(--sv-positive-label);
}

.goal-bar-row {
  display: grid;
  gap: 6px;
}

.goal-bar-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  font-size: 0.88rem;
}

.goal-bar-label strong {
  color: var(--sv-heading);
}

.goal-bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: var(--sv-surface);
  border: 1px solid var(--sv-line);
  overflow: hidden;
}

.goal-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--sv-accent);
  border-radius: 999px;
}

.goal-bar-pace {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 2px;
  background: var(--sv-text);
  opacity: 0.75;
}

.goal-state {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--sv-neutral-pill-line);
  background: var(--sv-neutral-pill-bg);
  color: var(--sv-neutral-pill-text);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.goal-state.is-done,
.goal-state.is-ahead {
  border-color: var(--sv-accent);
  color: var(--sv-heading);
}

.goal-state.is-behind {
  border-color: var(--sv-positive-line);
  background: var(--sv-positive-bg);
  color: var(--sv-positive-strong);
}

.goal-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
}

.goal-form label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.goal-form label span {
  color: var(--sv-text-muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.goal-form input,
.goal-form select {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--sv-line);
  border-radius: 6px;
  background: var(--sv-surface);
  color: var(--sv-text);
  font: inherit;
  font-size: 0.9rem;
}

.goal-form-wide,
.goal-form-actions,
.goal-form > .goal-sub {
  grid-column: 1 / -1;
}

.goal-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.goal-year-line .link-button {
  margin-left: 4px;
}

.goal-tiers {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.goal-tier {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--sv-line);
  border-radius: 6px;
  background: var(--sv-surface);
}

.goal-tier > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.goal-tier strong {
  color: var(--sv-heading);
}

.goal-tier span,
.goal-tier em {
  font-size: 0.82rem;
}

.goal-tier em {
  color: var(--sv-text-muted);
  font-style: normal;
}

.goal-tier .goal-tier-form {
  flex: 1 1 100%;
}

.goal-tier-actions {
  display: inline-flex;
  gap: 10px;
}

.goal-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--sv-line);
  border-radius: 6px;
}

.goal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.goal-table th,
.goal-table td {
  padding: 7px 10px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--sv-line);
  color: var(--sv-text);
}

.goal-table th[scope="row"],
.goal-table thead th:first-child {
  text-align: left;
}

.goal-table thead th {
  color: var(--sv-text-muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.goal-flag {
  margin-left: 4px;
  color: var(--sv-positive-label);
  font-size: 0.74rem;
  font-weight: 800;
}

/* Dashboard home when nothing is set (Matt, 2026-10-15): one slim bar that
   sends the user to the Goals page, instead of an empty editor. */
.goals-setup-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--sv-surface-2);
  border: 1px solid var(--sv-line);
  border-left: 4px solid var(--sv-accent);
  border-radius: 8px;
  color: var(--sv-text);
  font-weight: 700;
}

.goals-summary .goal-head .secondary-button {
  flex-shrink: 0;
}

/* Tier rule: [units] [And/Or] [sales] [commission] on one line (2026-10-15). */
.goal-tier-rule {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.goal-tier-rule label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

@media (max-width: 720px) {
  .goal-tier-rule {
    grid-template-columns: 1fr;
  }
}

/* Agents by reward level (2026-10-15): each level is a button that expands to
   who reached it, then who is within 10%. Broker and office manager only. */
.goal-levels {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.goal-level {
  border: 1px solid var(--sv-line);
  border-radius: 6px;
  background: var(--sv-surface);
}

.goal-level-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  color: var(--sv-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.goal-level-name {
  display: grid;
  flex: 1 1 200px;
  gap: 2px;
  min-width: 0;
}

.goal-level-name strong {
  color: var(--sv-heading);
}

.goal-level-name span {
  color: var(--sv-text-muted);
  font-size: 0.82rem;
}

.goal-level-caret {
  color: var(--sv-text-muted);
}

.goal-level-body {
  display: grid;
  gap: 6px;
  padding: 0 12px 12px;
}

.goal-level-body h5 {
  margin: 6px 0 0;
  color: var(--sv-heading);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.goal-level-names {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.goal-level-names li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: 0.86rem;
}

.goal-level-names span {
  color: var(--sv-text-muted);
}

/* One line under each agent on the office manager's agent list. */
.goal-agent-line {
  color: var(--sv-text-muted);
  font-size: 0.8rem;
}

/* Office milestones inside the office goal card (2026-10-15). */
.goal-milestones {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--sv-line);
}

.goal-milestones h5 {
  margin: 0;
  color: var(--sv-heading);
  font-size: 0.86rem;
  text-transform: uppercase;
}

/* The date bar (2026-10-15): the current goal year and the date it resets. */
.goal-date-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 10px 14px;
  background: var(--sv-surface-2);
  border: 1px solid var(--sv-line);
  border-left: 4px solid var(--sv-accent);
  border-radius: 8px;
  color: var(--sv-text);
  font-size: 0.88rem;
}

.goal-date-bar-label {
  color: var(--sv-text-muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.goal-date-bar strong {
  color: var(--sv-heading);
}

.goal-date-bar .secondary-button {
  margin-left: auto;
}
