:root {
  color-scheme: light;
  --bg: #0b0b0d;
  --panel: #ffffff;
  --panel-2: #f3f3f5;
  --ink: #0b0b0d;
  --ink-2: #19191d;
  --text: #141416;
  --muted: #65656f;
  --line: #dedee5;
  --green: #ff2b93;
  --pink: #ff2b93;
  --amber: #a86100;
  --red: #d3234a;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.18);
}

html {
  min-height: 100%;
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
  touch-action: manipulation;
}

button {
  border: 1px solid #cfcfd7;
  background: #fff;
  color: var(--text);
  border-radius: 7px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

button:hover {
  border-color: var(--pink);
  color: var(--pink);
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.app {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
  padding: calc(18px + env(safe-area-inset-top)) env(safe-area-inset-right) calc(28px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid #25252b;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.titleBlock {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.t2Mark {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
}

.t2Mark::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  bottom: 11px;
  width: 7px;
  border-radius: 0 4px 4px 0;
  background: var(--pink);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--pink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 34px;
}

.topbar h1 {
  color: #fff;
}

h2 {
  font-size: 19px;
}

.totalBox {
  min-width: 260px;
  padding: 14px 18px;
  border-radius: 8px;
  border-left: 7px solid var(--pink);
  background: #fff;
  color: var(--ink);
  text-align: right;
}

.totalBox span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.totalBox strong {
  display: block;
  margin-top: 4px;
  font-size: 30px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: start;
}

.mainPanel,
.sidePanel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.mainPanel {
  padding: 16px;
}

.sidePanel {
  position: sticky;
  top: 12px;
  top: calc(12px + env(safe-area-inset-top));
  padding: 14px;
  max-height: calc(100vh - 24px);
  max-height: calc(100vh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
}

.uploadGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.dropZone {
  min-height: 160px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 2px dashed #c9c9d2;
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
  text-align: center;
}

.dropZone.dragover {
  border-color: var(--pink);
  background: #fff0f7;
}

.dropZone input {
  display: none;
}

.dropIcon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.dropTitle {
  font-weight: 800;
}

.dropHint,
.statusLine span,
.fieldLabel,
.rowDetail {
  color: var(--muted);
  font-size: 13px;
}

.statusPanel {
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.statusLine,
.sectionHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rowActions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.rowActions button {
  white-space: nowrap;
}

.statusLine strong {
  color: var(--pink);
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eeeeF2;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--pink);
  transition: width 160ms ease;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar button:first-child,
#parseBtn,
#addRowBtn,
#copyBtn,
#hourModalSubmit,
#rttPremiumModalSubmit {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.toolbar button:first-child:hover,
#parseBtn:hover,
#addRowBtn:hover,
#copyBtn:hover,
#hourModalSubmit:hover,
#rttPremiumModalSubmit:hover {
  border-color: var(--pink);
  background: var(--pink);
  color: #fff;
}

.fieldLabel {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

#rawText,
.answerText {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfbfc;
  color: var(--text);
}

#rawText {
  min-height: 180px;
  margin-bottom: 18px;
}

.answerText {
  min-height: 130px;
  margin: 10px 0 12px;
  font-size: 13px;
}

.compact {
  align-items: end;
}

.tableWrap {
  width: 100%;
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rowsTable {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

.rowsTable th,
.rowsTable td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.rowsTable th {
  background: var(--ink);
  font-size: 12px;
  text-transform: uppercase;
  color: #fff;
}

.rowsTable tr:last-child td {
  border-bottom: 0;
}

.rowsTable input,
.rowsTable select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #d4d4dc;
  border-radius: 7px;
  padding: 8px;
  background: #fff;
}

.rowsTable input:focus,
.rowsTable select:focus,
#rawText:focus,
.answerText:focus,
.settingsGrid .planNumber input:focus,
.numberGrid input:focus,
.modalField input:focus,
.modalField select:focus {
  outline: 2px solid rgba(255, 43, 147, 0.22);
  border-color: var(--pink);
}

.nameInput {
  min-width: 320px;
}

.numInput {
  min-width: 90px;
}

.payoutCell {
  min-width: 150px;
  font-weight: 800;
  color: var(--pink);
}

.removeBtn {
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--red);
}

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

.summaryItem {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfc;
}

.summaryItem strong {
  color: var(--pink);
}

.summaryMeta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.settings {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}

.settings summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}

.settingsGrid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.settingsGrid label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settingsGrid label.isDisabled {
  color: var(--muted);
  opacity: 0.55;
}

.settingsGrid .planNumber {
  display: grid;
  align-items: stretch;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.settingsGrid .planNumber input {
  width: 100%;
  min-height: 36px;
  border: 1px solid #d4d4dc;
  border-radius: 7px;
  padding: 8px;
}

.focusBrandBox,
.vmrPlanBox {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfc;
}

.vmrTargetToggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 800;
}

.vmrPlanNumbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.focusBrandHeader {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 800;
}

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

.chipGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.brandChip {
  min-height: 38px;
  padding: 8px 12px;
}

.brandChip.isActive {
  border-color: var(--pink);
  background: var(--pink);
  color: #fff;
}

.numberGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

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

.numberGrid input {
  width: 100%;
  min-height: 36px;
  border: 1px solid #d4d4dc;
  border-radius: 7px;
  padding: 8px;
}

.wideButton {
  width: 100%;
  margin-top: 12px;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  padding: calc(18px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  background: rgba(11, 11, 13, 0.72);
}

.modalOverlay[hidden] {
  display: none;
}

.modalDialog {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.rttModalDialog {
  width: min(780px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
}

.modalField {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.modalField input,
.modalField select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #d4d4dc;
  border-radius: 7px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

.rttModalTop {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rttPremiumPreview {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7f8;
}

.rttPremiumPreview span,
.rttPremiumPreview small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rttPremiumPreview strong {
  color: var(--pink);
  font-size: 28px;
  line-height: 1;
}

.rttTaskGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.rttFieldset {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfc;
}

.rttFieldset legend {
  padding: 0 4px;
  color: var(--ink);
  font-weight: 800;
}

.rttFieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.rttFieldset .compactField {
  display: grid;
  align-items: stretch;
  gap: 6px;
}

.modalActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.emptyRows {
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1120px) {
  .workspace,
  .uploadGrid {
    grid-template-columns: 1fr;
  }

  .sidePanel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 680px) {
  .app {
    width: min(1600px, calc(100vw - 20px));
    padding-top: 10px;
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-bottom: 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

  .titleBlock {
    align-items: flex-start;
  }

  .totalBox {
    min-width: 0;
    text-align: left;
  }

  .toolbar,
  .sectionHeader {
    align-items: stretch;
    flex-direction: column;
  }

  .rowActions {
    justify-content: flex-start;
    width: 100%;
  }

  .rowActions button {
    flex: 1 1 130px;
  }

  .modalActions {
    flex-direction: column-reverse;
  }

  .rttModalTop,
  .rttTaskGrid {
    grid-template-columns: 1fr;
  }

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