:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #071126;
  --muted: #63718c;
  --line: #d9e2ef;
  --soft: #f4f7fb;
  --navy: #0f172a;
  --navy-2: #18233a;
  --indigo: #2b3278;
  --blue: #2563eb;
  --blue-2: #0b63f6;
  --violet: #6d4dfc;
  --green: #00a875;
  --amber: #f59e0b;
  --red: #ff3b57;
  --shadow: 0 14px 38px rgba(15, 23, 42, 0.09);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.06);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% -12%, rgba(43, 50, 120, 0.16), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 42%, #eef3fa 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1840px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 16px 0 34px;
}

.topbar,
.toolbar,
.chart-panel,
.cutoff-panel,
.table-panel,
.validation-panel,
.editor-panel,
.activities-panel,
.manual-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 22px 24px;
  border-color: rgba(255, 255, 255, 0.28);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(24, 35, 58, 0.96) 52%, rgba(43, 50, 120, 0.96) 100%);
  color: #fff;
  overflow: hidden;
  position: relative;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto -80px -120px auto;
  width: 300px;
  height: 300px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(109, 77, 252, 0.28), transparent 62%);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: #94a3ff;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  font-weight: 900;
}

h2 {
  font-size: 16px;
}

.source {
  color: #cbd5e1;
  font-size: 13px;
  text-align: right;
  position: relative;
  z-index: 1;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 94px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

.back-link:hover {
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
}

.toolbar label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toolbar input[type="date"] {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  color: var(--text);
  background: #f8fafc;
}

button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: var(--soft);
  color: var(--text);
  text-decoration: none;
}

button:hover {
  border-color: #93b4e8;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.button-primary {
  border-color: #1d4ed8;
  background: linear-gradient(135deg, var(--blue-2), var(--violet));
  color: #fff;
}

.button-danger {
  border-color: #b91c1c;
  background: #dc2626;
  color: #fff;
}

.button-ghost {
  background: #fff;
}

.toggle {
  grid-auto-flow: column;
  align-items: center;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text) !important;
  background: #fff;
}

.week-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 2px 4px;
}

.week-chip {
  flex: 0 0 auto;
  display: grid;
  gap: 2px;
  min-width: 86px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.week-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.week-chip:has(input:checked) {
  border-color: #7aa7ff;
  background: linear-gradient(180deg, #eef5ff 0%, #f8fbff 100%);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.13);
}

.week-chip strong {
  font-size: 12px;
}

.week-chip span {
  color: var(--muted);
  font-size: 11px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.chart-panel,
.cutoff-panel,
.table-panel,
.validation-panel,
.editor-panel,
.activities-panel,
.manual-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.panel-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.chart-panel,
.cutoff-panel,
.editor-panel,
.manual-panel {
  border-color: #dce6f4;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(253, 254, 255, 0.96));
}

.eyebrow.dark {
  color: #6b7a99;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #43516b;
  font-size: 13px;
  font-weight: 700;
}

.legend-swatch {
  width: 18px;
  height: 3px;
  border-radius: 3px;
}

.legend-swatch.bar {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, #ffffff 0%, #ffffff 70%, #fbfdff 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.chart-box {
  position: relative;
  min-width: 1280px;
  height: 600px;
  padding: 14px 16px 8px;
}

.chart {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  background: #fff;
}

.cutoff-panel {
  display: grid;
  gap: 14px;
}

.cutoff-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.cutoff-heading label {
  display: grid;
  gap: 5px;
  min-width: 150px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.cutoff-heading select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  background: #f8fafc;
  color: var(--text);
  font-weight: 800;
}

.cutoff-summary {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 0.9fr) minmax(360px, 1.3fr);
  gap: 14px;
  align-items: stretch;
}

.cutoff-percentages,
.cutoff-spi,
.cutoff-hh {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.cutoff-percentages {
  display: grid;
  gap: 8px;
}

.cutoff-percentages div,
.cutoff-hh div,
.cutoff-spi div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.cutoff-percentages span {
  font-size: 22px;
  font-weight: 900;
}

.cutoff-percentages strong {
  font-size: 24px;
  font-weight: 900;
}

.cutoff-spi {
  display: grid;
  align-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #fffde7, #fff59d);
}

.cutoff-spi h3 {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.05;
  text-align: center;
}

.cutoff-spi span,
.cutoff-spi strong {
  font-size: 18px;
  font-weight: 900;
}

.cutoff-hh {
  display: grid;
  gap: 8px;
  align-content: center;
}

.cutoff-hh span {
  font-size: 18px;
  font-weight: 800;
}

.cutoff-hh strong {
  min-width: 150px;
  font-size: 20px;
  font-weight: 900;
  text-align: right;
}

.planned {
  color: #003f72;
}

.control {
  color: #374151;
}

.earned {
  color: #ff0000;
}

.table-panel,
.validation-panel,
.editor-panel,
.activities-panel,
.manual-panel {
  margin-top: 14px;
}

.chart-table-panel {
  width: 100%;
  margin: 0;
  padding: 0 16px 16px;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.chart-data-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: #fff;
}

.chart-data-table th,
.chart-data-table td {
  height: 24px;
  padding: 2px 5px;
  border: 1px solid #d1d5db;
  color: #374151;
  font-size: 12px;
  line-height: 1.1;
  text-align: right;
  white-space: nowrap;
}

.chart-data-table thead th {
  position: static;
  top: auto;
  z-index: auto;
  background: #fff;
  color: #374151;
  font-weight: 800;
  text-align: center;
}

.chart-data-table th:first-child,
.chart-data-table td:first-child,
.chart-data-table .chart-data-label {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 170px;
  width: 170px;
  background: #fff;
  color: #374151;
  font-weight: 800;
  text-align: left;
}

.chart-data-marker {
  display: inline-block;
  width: 14px;
  margin-right: 5px;
  vertical-align: middle;
}

.chart-data-marker.bar {
  height: 10px;
  border: 1px solid transparent;
}

.chart-data-marker.line {
  height: 0;
  border-top: 3px solid;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) minmax(140px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.editor-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.editor-grid select,
.editor-grid input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

#saveStatus {
  min-height: 18px;
}

.excel-entry-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.excel-scroll {
  overflow: auto;
  max-height: 660px;
  border: 1px solid #111827;
  background: #fff;
}

.excel-grid {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  box-shadow: none;
}

.excel-grid th,
.excel-grid td {
  height: 22px;
  min-width: 72px;
  padding: 1px 3px;
  border-right: 1px solid #111827;
  border-bottom: 1px solid #111827;
  font-size: 11px;
  line-height: 1.15;
  text-align: right;
}

.excel-grid thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #0f4b78;
  color: #fff;
  font-weight: 800;
  text-align: center;
}

.excel-grid thead tr:nth-child(2) th {
  top: 22px;
  background: #cfe8f3;
  color: #0f172a;
  font-weight: 600;
}

.excel-grid .label-col,
.excel-grid .row-label,
.excel-grid .section-row td {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 354px;
  text-align: left;
}

.excel-grid .label-col {
  background: #f8fafc;
}

.excel-grid .section-row td {
  height: 22px;
  background: #fff;
  border-top: 2px solid #111827;
  font-size: 16px;
  font-weight: 900;
}

.excel-grid .section-row.planned td,
.excel-grid tr.planned .row-label {
  color: #003f72;
}

.excel-grid .section-row.earned td,
.excel-grid tr.earned .row-label {
  color: #ff0000;
}

.excel-grid .section-row.control td,
.excel-grid tr.control .row-label {
  color: #6b7280;
}

.excel-grid .section-row.forecast td,
.excel-grid tr.forecast .row-label {
  color: #00a651;
}

.excel-grid tr.visual-blue .row-label,
.excel-grid tr.visual-blue td {
  color: #004ea8;
  font-weight: 800;
}

.excel-grid tr.visual-red .row-label,
.excel-grid tr.visual-red td {
  color: #ff0000;
  font-weight: 800;
}

.excel-grid .row-label {
  background: #f8fafc;
  font-weight: 800;
}

.excel-grid .calculated-row td:not(.row-label) {
  background: #f6f7f9;
}

.excel-grid .editable-row td:not(.row-label) {
  background: #fff;
}

.excel-grid input {
  width: 68px;
  height: 20px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 11px;
  text-align: right;
  outline: 1px solid transparent;
}

.excel-grid input:focus {
  background: #fff7d6;
  outline-color: #f59e0b;
}

.excel-grid .excel-gap td {
  height: 20px;
  background: #fff;
  border-right: 0;
}

.excel-grid .empty-grid {
  min-width: 420px;
  height: 70px;
  text-align: left;
  color: var(--muted);
}

.entry-actions {
  display: flex;
  justify-content: flex-end;
}

.manual-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.manual-grid form {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.manual-grid h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.manual-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.manual-grid input,
.manual-grid select {
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  background: #fff;
  color: var(--text);
}

.manual-grid .inline-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--text);
}

.manual-grid .inline-check input {
  height: auto;
}

#manualStatus {
  min-height: 18px;
}

.is-hidden {
  display: none;
}

.table-scroll {
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--soft);
  border-right: 1px solid var(--soft);
  padding: 7px 9px;
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
}

td input {
  width: 100%;
  min-width: 0;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 6px;
}

.import-validation {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.ok-message {
  margin: 0;
  color: #047857;
  font-weight: 700;
}

.import-validation-item {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.import-validation-item.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: #991b1b;
}

.import-validation-item.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.import-validation-item span {
  font-size: 13px;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
  animation: toast-in 160ms ease-out;
}

.toast span {
  color: var(--muted);
  font-size: 13px;
  white-space: normal;
}

.toast.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.toast.warning {
  border-color: #fde68a;
  background: #fffbeb;
}

.toast.error {
  border-color: #fecaca;
  background: #fff1f2;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-dialog {
  width: min(460px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.25);
  animation: modal-in 140ms ease-out;
}

.wide-modal {
  width: min(980px, 100%);
  max-height: min(820px, calc(100vh - 36px));
  overflow: auto;
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-close {
  width: 32px;
  height: 32px;
  padding: 0;
  font-weight: 800;
}

.modal-dialog h2 {
  margin: 0;
  font-size: 18px;
}

.modal-dialog p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.week-data-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.week-data-grid label,
.week-data-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.week-data-grid input,
.week-data-fields input {
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  color: var(--text);
}

.week-data-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.week-data-fields label {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.week-data-fields label span {
  font-size: 11px;
  text-transform: uppercase;
}

.week-data-fields label.planned {
  color: #003f72;
}

.week-data-fields label.earned {
  color: #ff0000;
}

.week-data-fields label.control {
  color: #6b7280;
}

.week-data-fields label.forecast {
  color: #00a651;
}

.week-data-fields label.visual-blue {
  color: #004ea8;
}

.week-data-fields label.visual-red {
  color: #ff0000;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  min-width: 260px;
  text-align: left;
  background: #fff;
  z-index: 1;
}

thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--muted);
  z-index: 2;
}

thead th:first-child {
  z-index: 3;
}

.validation-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.validation-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.validation-item strong {
  display: block;
  font-size: 12px;
}

.validation-item span {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .shell {
    width: min(100vw - 14px, 1840px);
    padding-top: 10px;
  }

  .topbar,
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .cutoff-summary {
    grid-template-columns: 1fr;
  }

  .cutoff-heading {
    display: grid;
  }

  .source {
    text-align: left;
  }

  .chart-box {
    height: 460px;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .manual-grid {
    grid-template-columns: 1fr;
  }

  .week-data-grid,
  .week-data-fields {
    grid-template-columns: 1fr;
  }
}
