/* Global UI vars */
:root {
  --cp-alpha-hex: 20;
  /* hex alpha for selected counterparty background (e.g. 20 = ~12.5%) */
  --ui-scale: 1;
  --ui-font: 14px;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: #111;
  height: 100vh;
  overflow: hidden;
  font-size: var(--ui-font);
}

/* 3-level UI scaling */
body[data-scale="0"] {
  --ui-font: 14px;
  --ui-scale: 1;
}

body[data-scale="1"] {
  --ui-font: 12px;
  --ui-scale: 0.92;
}

body[data-scale="2"] {
  --ui-font: 11px;
  --ui-scale: 0.86;
}

a {
  text-decoration: none;
  color: #0a58ca;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-bottom: 1px solid #ddd;
  height: calc(52px * var(--ui-scale));
  box-sizing: border-box;
  gap: 10px;
  background: #e9f2ff;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar__user {
  font-weight: 700;
  opacity: 0.85;
}

.btn {
  padding: calc(6px * var(--ui-scale)) calc(10px * var(--ui-scale));
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
}

.mini-btn.month-edit {
  padding: 5px 10px 6px;
  min-width: 62px;
}

.btn:disabled {
  opacity: .6;
  cursor: default;
}

.btn--danger {
  border-color: #ff8f8f;
  color: #b00020;
}

.mini-btn {
  padding: 1px 5px 3px;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.add-to-month {
  border: 1px solid #0b7a0b;
  color: #0b7a0b;
  display: none;
  /* shown only while editing a month */
}

.remove-from-month {
  display: none;
}

body[data-edit-month="1"] #cpList .cp-item.can-remove .remove-from-month {
  display: inline-block;
}

body[data-edit-month="1"] #cpList .cp-item.can-add .add-to-month {
  display: inline-block;
}

.cp-actions {
  display: none;
  gap: calc(6px * var(--ui-scale));
  margin: calc(8px * var(--ui-scale)) 0;
}

body[data-edit-month="1"] .cp-actions {
  display: flex;
}

.mini-btn:disabled {
  opacity: .6;
  cursor: default;
}

.mini-btn--danger {
  border-color: #ff8f8f;
  color: #b00020;
}

.muted {
  color: #777;
  font-size: calc(12px * var(--ui-scale));
}

.mini-select {
  padding: calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale));
  border: 1px solid #ccc;
  border-radius: 10px;
  background: #fff;
  font-size: calc(12px * var(--ui-scale));
}

.month-col__head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Report modal */
.modal-card.report {
  width: min(1200px, 96vw);
  max-height: 90vh;
}



.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}
.report-table thead {
  position: sticky;
  top: -10px;
  z-index: 100;
}

.report-table th, .report-table td {
  border: 1px solid #777;
  padding: calc(6px * var(--ui-scale)) calc(8px * var(--ui-scale));
  vertical-align: top;
}

.report-th {
  background: #ddd;
  font-weight: 800;
}

.report-row-break td {
  background: #ffeded;
  border-left: none;
  border-right: none;
  border-bottom: none;
  height: 8px;
  padding: 0;
}

.report-cell-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.report-subrow {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.report-subname {
  opacity: 0.85;
}

.report-subval {
  font-variant-numeric: tabular-nums;
}

.report-subtotal {
  margin-top: 2px;
  border-top: 1px solid #eee;
  padding-top: 2px;
}

.report-summary {
  margin-top: calc(10px * var(--ui-scale));
  display: flex;
  gap: calc(20px * var(--ui-scale));
  flex-wrap: wrap;
}

.report-summary__groups {
  flex: 1 1 420px;
}

.report-summary__totals {
  flex: 0 0 280px;
}

.report-sum-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
}

.report-sum-name {
  opacity: 0.85;
}

.report-sum-val {
  font-variant-numeric: tabular-nums;
}

.report-sum-row--all .report-sum-val,
.report-sum-row--all .report-sum-name {
  font-weight: 900;
}

.report-row--contractor .report-td--name {
  font-weight: 800;
}

.razdelitel {
  width: 1px;
  height: 20px;
  background: #ccc;
  margin: 0 15px;
}

.layout {
  display: flex;
  height: calc(100vh - calc(52px * var(--ui-scale)));
  overflow: hidden;
}

.left {
  width: 300px;
  flex: 0 0 300px;
  border-right: 1px solid #ddd;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fdfbec59;
}

.right {
  flex: 1;
  padding: 0px;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f4fce8;
  padding-bottom: 10px;
}

input, select {
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 10px;
  box-sizing: border-box;
  background: #f5f5f5;
}

#modalCp .input {
  margin-top: 4px;
}

.textarea {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 10px;
  box-sizing: border-box;
}

.checkbox {
  display: flex;
  align-items: flex-end;
}

.cp-list {
  overflow: auto;
  border: 1px solid #eee;
  flex: 1;
}

.cp-item {
  padding: 6px 10px;
  border-bottom: 1px solid #ccc;
  cursor: pointer;
}

.cp-item:hover {
  background: #fafafa;
}

.cp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cp-name {
  font-weight: 600;
}

.cp-item--separator .cp-name {
  font-style: italic;
  opacity: .8;
}

.months-wrap {
  flex: 1;
  overflow: auto;
  /* border: 1px solid #eee; */
  border-radius: 10px;
  display: flex;
  gap: 20px;
  padding: 10px 7px;
  box-sizing: border-box;
}

.month-col {
  flex: 0 0 300px;
  border-radius: 15px;
  background: #fff;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  box-shadow: 3px 3px 10px #0003;
  justify-content: space-between;
  background: #f3f3f3;
  border: 2px solid #ccb7ac;
}

.month-col__prefoot {
  flex: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.month-col.is-hidden-col {
  display: none;
}

.month-col.is-center {
  flex-basis: 400px;
  background: rgba(0, 0, 0, 0.02);
}

.month-col.is-current {
  background: rgba(0, 0, 0, 0.03);
}

.month-col.is-editable {
  outline-offset: -2px;
}

.month-col__head {
  padding: 10px;
  /* border-bottom: 1px solid #eee; */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.month-col__title {
  font-weight: 800;
  text-transform: uppercase;
  color: #1b4ba6;
  font-size: 18px;
}

.is-current .month-col__title {
  color: #ff6c00;
}

.month-col__list {
  padding: 10px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.month-col__foot {
  padding: 10px;
  border-top: 1px solid #f7e8da;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 5px solid #ccb7ac;
  border-radius: 0 0 13px 13px;
  margin-top: 10px;
}

.is-current .month-col__foot {
  border: 5px solid #ff6c0075;
}

.month-total__row.month-total__row--grand {
  color: #b00020;
  font-size: 16px;
}

.divider {
  height: 10px;
  /* background: #eee; */
  margin: 8px 0;
}

.cell-card {
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 10px;
  background: #ffffffc4;
  box-shadow: 2px 2px 5px #0003;
}

.is-editable .cell-card {
  border: 1px solid red;
}

.cell-card.contracter {
  background: #7b262617;
}

.cell-card--hidden {
  background: #fcfcfc;
  opacity: .65;
}

/* Separator blocks (visual spacers) */
.cell-card.is-separator {
  background: #ffffffa8;
}

.cell-card.is-separator .cell-lines,
.cell-card.is-separator .line--total {
  display: none;
}

.cell-card.is-separator .cell-card__name {
  opacity: .8;
  font-style: italic;
}

.cell-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.cell-card__name {
  font-weight: 800;
  line-height: 1.1;
}

.cell-card__actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.cell-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  line-height: 14px;
}

.cell-lines sup {
  font-size: 10px;
}

.line {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  align-items: center;
}

.line--total {
  border-top: 1px solid #eee;
  padding-top: 6px;
  margin-top: 6px;
  font-weight: 800;
}

.line--total .total-value {
  font-size: 14px;
  font-weight: bold;
  margin-right: 10px;
}

.line--income .label, .line--income .value {
  color: #0b7a0b;
}

.line--expense .label, .line--expense .value {
  color: #b00020;
}

.line--withhold .label, .line--withhold .value, .month-group.all_taxes {
  color: #ff7633;
}

.line--withhold {
  border-top: 1px solid #eee;
  padding-top: 6px;
  margin-top: 6px;
}

.hours-input {
  width: 2.6ch;
  padding: 4px 6px;
  border: 1px solid #ddd;
  border-radius: 8px;
  text-align: right;
  ;
  width: 3.4ch;
}

.hours-input.ok {
  border-color: #0b7a0b;
}

.hours-input.err {
  border-color: #b00020;
}

.cell-card.is-collapsed .cell-lines {
  display: none;
}

.cell-card.is-collapsed .cell-toggle {
  transform: rotate(-90deg);
}

.cell-toggle {
  transition: transform .15s ease;
}

.month-groups {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.month-group {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: #444;
}

.month-group__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.month-group__val {
  font-variant-numeric: tabular-nums;
}

.month-total {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 14px;
}

.month-total__label {
  font-size: 12px;
}

.month-total__row--grand .month-total__label {
  text-transform: uppercase;
  font-weight: bold;
  font-size: 16px;
}

.month-total__value {
  font-variant-numeric: tabular-nums;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.month-nav__side {
  width: 60px;
}

.input--jump {
  width: 100%;
  padding: 6px 8px;
}

.month-nav__hint {
  white-space: nowrap;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-card {
  width: 520px;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}

.modal-card.wide {
  width: 760px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
}

.modal-head button {
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
}

.modal-body {
  padding: 10px 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 90vh;
  overflow: auto;
}

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

.form-grid--snap {
  grid-template-columns: 1fr 1fr 1fr;
}

.section-head {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: center;
  grid-gap: 10px;
  margin-top: 20px;
  text-transform: uppercase;
}

.pay-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pay-row {
  display: grid;
  grid-template-columns: 1fr 120px 150px 60px;
  gap: 8px;
  align-items: center;
  position: relative;
}

.pay-row::before {
  content: "|";
  position: absolute;
  top: -13px;
  left: 8px;
  font-size: 11px;
  color: #bbb;
}

.pay-row input {
  width: 100%;
}

.pay-row .pay-group {
  width: auto;
}

.pay-row .del {
  text-align: right;
}

/* color hints in edit popups */
.pay-row--income input, .pay-row--income select, .pay-row--income label {
  color: #15803d;
}

.pay-row--expense input, .pay-row--expense select, .pay-row--expense label {
  color: #b91c1c;
}

.group-flag {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: #555;
  white-space: nowrap;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.err-text {
  color: #b00020;
  font-size: 13px;
}

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

/* v7 tweaks */
.month-col.is-center {
  flex-basis: 420px;
  background: #f3f3f3;
}

.month-col.is-editable {
  flex-basis: 420px;
}

.month-col.is-editable .month-col__head {
  background: #df0028;
  color: #fff;
  border-radius: 13px;
}

.month-col.is-editable .month-col__title {
  color: #fff;
}

.month-col.is-editable .month-edit {
  background: #b00020;
  border-color: #fff;
  color: #fff;
}

.month-col.is-current {
  background: rgb(255, 242, 219);
  border: 2px solid #ffb576;
}

.month-col.is-current.is-center {
  background: rgb(255, 242, 219);
  /* outline-color: rgb(255, 242, 219); */
}

.cell-card__name {
  font-weight: 800;
  font-size: 18px;
}

.line--total {
  font-weight: 400;
  font-size: 12px;
  display: flex;
  align-items: baseline;
}

.total-label {
  font-weight: 600;
  text-transform: uppercase;
  display: none;
}

.is-center .total-label {
  display: inline;
}

.total-hours {
  margin-left: auto;
  color: #666;
  font-size: 12px;
}

.gap {
  height: 5px;
}

.vis-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 10px;
}

.vis-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

/* v8 totals visibility */
.month-col:not(.is-center) .total-hours {
  display: none;
}

.month-col:not(.is-center) .hours-cost {
  display: none;
}

.month-col .total-turnover {
  color: #15803d;
  margin-right: 5px;
}

.month-col .total-expense {
  color: #b91c1c;
  margin-right: 5px;
}

/* green-ish */
.month-col .line--income .value {
  color: #15803d;
}

.month-col .line--expense .value {
  color: #b91c1c;
}

/* custom dialogs */
.modal-card.dialog {
  width: 360px;
}

.modal-card.dialog .modal-body {
  padding: 14px;
}

.top-logo {
  height: 22px;
  display: block;
}

/* custom dialog */
.modal-card.dialog {
  width: 360px;
}

.modal-card.dialog .modal-actions {
  justify-content: flex-end;
}

.top-logo {
  height: 20px;
  display: block;
}

/* === ТОЛЬКО МЕСЯЦЫ === */
.months,
.months-wrap {
  scrollbar-width: thin;
  /* Firefox */
  scrollbar-color: #ccc #fff;
  /* thumb / track */
}

.form-grid {
  margin-bottom: 30px;
}

.form-grid label {
  color: #777;
}

.actions-list {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
}

.mini-btn.pay-del {
  font-size: 15px;
  color: red;
}
