:root {
  color-scheme: light;
  --color-text: #1a1a1a;
  --color-muted: #5c5c5c;
  --color-bg: #f7f8fa;
  --color-surface: #ffffff;
  --color-border: #d9dee7;
  --color-accent: #1f4f8f;
  --font-sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

.container {
  width: min(1100px, 100% - 2rem);
  margin-inline: auto;
}

.site-header,
.site-footer {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.site-footer {
  border-top: 1px solid var(--color-border);
  border-bottom: none;
  margin-top: 2rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.95rem;
  color: var(--color-muted);
}

.site-user a {
  color: var(--color-accent);
  text-decoration: none;
}

.site-user a:hover {
  text-decoration: underline;
}

.auth-panel {
  max-width: 32rem;
  padding: 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.auth-panel h2 {
  margin-top: 0;
}

.auth-error {
  color: #9b1c1c;
  background: #fdecec;
  border: 1px solid #f5c2c2;
  padding: 0.75rem 1rem;
  border-radius: 6px;
}

.auth-button {
  display: inline-block;
  padding: 0.65rem 1rem;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
}

.auth-button:hover {
  filter: brightness(1.05);
}

.site-title {
  margin: 0;
  padding: 1rem 0;
  font-size: 1.25rem;
  color: var(--color-accent);
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.site-title a:hover {
  text-decoration: underline;
}

main.container {
  padding: 2rem 0;
}

.placeholder {
  color: var(--color-muted);
}

.admin-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.button-secondary {
  background: #fff;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}

.bulk-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.status-warning {
  background: #fff3cd;
  color: #664d03;
}

.admin-header h2 {
  margin: 0;
}

.admin-subpanel {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.admin-workflow {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding-left: 2rem;
}

.admin-workflow li {
  padding-left: 0.35rem;
}

.admin-workflow form {
  display: inline;
}

.admin-workflow .muted {
  margin: 0.5rem 0 0;
}

.button,
.admin-form button[type="submit"] {
  display: inline-block;
  padding: 0.65rem 1rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
.admin-form button[type="submit"]:hover {
  filter: brightness(1.05);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.table-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.table-actions form {
  margin: 0;
}

.link-button {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.admin-form {
  display: grid;
  gap: 1rem;
  max-width: 32rem;
}

.admin-form label {
  display: grid;
  gap: 0.35rem;
}

.admin-form input,
.admin-form select {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
}

.form-error,
.flash-error {
  color: #9b1c1c;
  background: #fdecec;
  border: 1px solid #f5c2c2;
  padding: 0.75rem 1rem;
  border-radius: 6px;
}

.flash-success {
  color: #0f5132;
  background: #d1e7dd;
  border: 1px solid #badbcc;
  padding: 0.75rem 1rem;
  border-radius: 6px;
}

.flash-warning {
  color: #664d03;
  background: #fff3cd;
  border: 1px solid #ffe69c;
  padding: 0.75rem 1rem;
  border-radius: 6px;
}

.flash-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  gap: 0.5rem;
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.status-active {
  background: #d1e7dd;
  color: #0f5132;
}

.status-inactive {
  background: #f8d7da;
  color: #842029;
}

.plain-list {
  padding-left: 1.25rem;
}

.muted {
  color: var(--color-muted);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-top: 1rem;
}

.funnel-salesperson-picker {
  margin-top: 0;
  margin-bottom: 1.5rem;
  padding-top: 0;
  border-top: none;
}

.funnel-salesperson-picker .inline-form {
  margin-top: 0;
}

.funnel-salesperson-picker label {
  display: grid;
  gap: 0.35rem;
}

.funnel-salesperson-picker select {
  min-width: 16rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
}

.form-actions {
  margin-top: 0.5rem;
}

.stage-form h3 {
  margin-top: 1.75rem;
}

.stage-form input[type="number"] {
  width: 6rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
}

.funnel-report h3 {
  margin-top: 1.75rem;
}

.pipeline-board {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  overflow: hidden;
}

.pipeline-board-header,
.pipeline-board-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.95fr);
  align-items: stretch;
}

.pipeline-board-header {
  background: #f3f6fb;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
}

.pipeline-board-row {
  border-bottom: 1px solid var(--color-border);
  min-height: 3.25rem;
}

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

.pipeline-board-total {
  background: #f3f6fb;
  font-weight: 600;
}

.pipeline-board-funnel-total {
  min-height: 3.25rem;
}

.pipeline-board-stats {
  display: grid;
  grid-template-columns: minmax(6rem, 1.4fr) 4rem 6.5rem 5.5rem 7rem;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-right: 1px solid var(--color-border);
}

.pipeline-board-stats-head {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.pipeline-board-stats .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pipeline-board-funnel-head,
.pipeline-board-funnel {
  display: grid;
  grid-template-columns: 1fr 6.5rem 1fr;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: linear-gradient(180deg, #f7f9fc 0%, #f1f5fa 100%);
  position: relative;
}

.pipeline-board-funnel-head {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stage-funnel-legend-left {
  text-align: right;
  padding-right: 0.25rem;
}

.stage-funnel-legend-center {
  text-align: center;
}

.stage-funnel-legend-right {
  text-align: left;
  padding-left: 0.25rem;
}

.stage-funnel-zone {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 1.35rem;
  position: relative;
  z-index: 1;
}

.stage-funnel-zone-left {
  justify-content: flex-end;
}

.stage-funnel-zone-right {
  justify-content: flex-start;
}

.stage-funnel-bar {
  display: block;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.stage-funnel-bar-revenue {
  background: linear-gradient(270deg, #2a5f9e 0%, #1f4f8f 100%);
  border-radius: 6px 1px 1px 6px;
  clip-path: polygon(10% 0, 100% 0, 100% 100%, 10% 100%, 0 50%);
}

.stage-funnel-bar-weighted {
  background: linear-gradient(90deg, #3d7a6a 0%, #2f6b5c 100%);
  border-radius: 1px 6px 6px 1px;
  clip-path: polygon(0 0, 90% 0, 100% 50%, 90% 100%, 0 100%);
}

.stage-funnel-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  text-align: center;
  min-height: 2.55rem;
  padding: 0.25rem 0.35rem;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(31, 79, 143, 0.2);
  border-radius: 6px;
  position: relative;
  z-index: 1;
}

.stage-funnel-stage-name {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--color-text);
  max-width: 6.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-funnel-deals {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
}

@media (max-width: 960px) {
  .pipeline-board-header,
  .pipeline-board-row {
    grid-template-columns: 1fr;
  }

  .pipeline-board-stats {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    grid-template-columns: minmax(5rem, 1.5fr) 3.5rem 5.5rem 4.5rem 6rem;
  }
}

.funnel-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.funnel-calc-table th[scope="row"] {
  font-weight: 600;
  text-align: left;
  color: var(--color-text);
  background: transparent;
}

.funnel-calc-table thead th:not(:first-child),
.funnel-calc-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.funnel-callout {
  font-size: 1.05rem;
  margin: 1rem 0;
}

.funnel-deals-required {
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  margin-right: 0.15rem;
}

.rollup-report h3 {
  margin-top: 1.75rem;
}

.rollup-summary,
.rollup-section {
  margin-top: 1.5rem;
}

.rollup-table th[scope="row"] {
  font-weight: 600;
  text-align: left;
}

.rollup-table thead th:not(:first-child),
.rollup-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rollup-table td:first-child,
.rollup-table th:first-child {
  text-align: left;
}

.org-hierarchy-table .org-table-name {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding-left: calc(var(--org-depth, 0) * 1.5rem);
}

.org-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.org-tree-children {
  list-style: none;
  margin: 0.25rem 0 0.35rem 0;
  padding-left: 1.75rem;
  border-left: 2px solid var(--color-border);
  margin-left: 0.85rem;
}

.org-tree-summary,
.org-tree-leaf,
.org-tree-row {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.75rem;
  padding: 0.45rem 0;
  text-align: left;
}

.org-tree-row,
.org-tree-leaf {
  width: 100%;
}

.org-tree-branch {
  width: 100%;
}

.org-tree-name {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.org-tree-metrics {
  flex: 0 0 auto;
  margin-left: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.org-toggle {
  flex: 0 0 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-accent);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.org-toggle:hover {
  background: #f3f6fb;
}

.org-tree-toggle-spacer {
  flex: 0 0 1.75rem;
  width: 1.75rem;
}

.rollup-incomplete-detail {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.manager-deals-note {
  margin-top: 0.85rem;
}

.org-tree-summary {
  cursor: pointer;
}

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

.button-secondary:hover {
  background: #f3f6fb;
}
