:root {
  --ink: #102620;
  --ink-soft: #425c53;
  --paper: #ffffff;
  --canvas: #f2f6f4;
  --signal: #0a8f70;
  --signal-dark: #087258;
  --signal-pale: #e8f5f0;
  --rule: #dce6e2;
  --warning: #9a6500;
  --warning-pale: #fff4dc;
  --danger: #b34242;
  --danger-pale: #ffeded;
  --quiet: #eef2f4;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color: var(--ink);
  background: var(--canvas);
  font-family: Manrope, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
}

* {
  scrollbar-color: #9cb5ac transparent;
  scrollbar-width: thin;
}

*::selection {
  color: #fff;
  background: var(--signal);
}

body {
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
select,
textarea {
  caret-color: var(--signal);
}

h1,
h2,
h3,
h4 {
  color: var(--ink);
  letter-spacing: -.025em;
  text-wrap: balance;
}

.shell {
  background: var(--canvas);
}

@media (min-width: 801px) {
  .sidebar {
    background: #102620;
    color: #b9cbc4;
    border-right: 0;
    box-shadow: 10px 0 32px rgba(16, 38, 32, .08);
  }

  .sidebar .brand-mark {
    padding: 5px;
    border-radius: 13px;
    background: #fff;
  }

  .sidebar .nav button {
    color: #b9cbc4;
    border: 1px solid transparent;
  }

  .sidebar .nav button:hover:not(.active) {
    color: #fff;
    background: rgba(255, 255, 255, .08);
  }

  .sidebar .nav button.active {
    color: #fff;
    background: var(--signal);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
  }

  .shell.sidebar-expanded .sidebar .brand {
    border-radius: 12px;
    background: #fff;
  }

  .content {
    max-width: 1680px;
    padding: 24px 30px 44px;
  }
}

.main {
  background:
    linear-gradient(90deg, rgba(10, 143, 112, .025) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--canvas);
}

.stats {
  gap: 0;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--paper);
}

.stat {
  min-width: 0;
  padding: 18px 22px;
  border: 0;
  border-right: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
}

.stat:last-child {
  border-right: 0;
}

.stat strong {
  margin: 9px 0 2px;
  color: var(--ink);
  font-size: clamp(22px, 2vw, 30px);
  font-weight: 700;
  letter-spacing: -.03em;
}

.stat-icon {
  color: var(--signal);
  background: var(--signal-pale);
}

.panel {
  border-color: var(--rule);
  border-radius: 14px;
  background: var(--paper);
}

.toolbar {
  min-height: 66px;
  padding: 12px 16px;
  border-color: var(--rule);
  background: #fbfdfc;
}

.search input,
input,
select,
textarea {
  color: var(--ink);
  border-color: #cad8d2;
  border-radius: 9px;
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #9fb8ae;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--signal);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(10, 143, 112, .13);
}

.btn {
  min-height: 42px;
  border-color: #bfd0c9;
  border-radius: 9px;
  color: #28483e;
  background: #fff;
  box-shadow: none;
  transition: transform 150ms var(--ease-out), border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.btn:hover {
  border-color: #8eb2a5;
  background: #f2f8f5;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px) scale(.985);
}

.btn.primary {
  border-color: var(--signal);
  background: var(--signal);
  box-shadow: 0 7px 16px rgba(12, 32, 27, .18);
}

.btn.primary:hover {
  border-color: var(--signal-dark);
  background: var(--signal-dark);
}

.icon-btn {
  transition: transform 150ms var(--ease-out), color 150ms ease, background 150ms ease;
}

.icon-btn:hover {
  color: var(--signal);
  background: var(--signal-pale);
  transform: translateX(2px);
}

.table-wrap {
  scrollbar-gutter: stable;
}

@media (min-width: 801px) {
  .payment-table-wrap {
    overflow-x: hidden;
  }

  .table-wrap > table:not(.payment-table) {
    table-layout: fixed;
    white-space: normal;
  }

  .table-wrap > table:not(.payment-table) th,
  .table-wrap > table:not(.payment-table) td {
    padding-right: 14px;
    padding-left: 14px;
  }
}

table {
  color: var(--ink);
}

th {
  color: #536b62;
  border-color: var(--rule);
  background: #f2f6f4;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .025em;
  text-transform: uppercase;
}

td {
  border-color: #e8efec;
}

tbody tr {
  transition: background 150ms ease, box-shadow 150ms ease;
}

tbody tr:hover {
  background: #f2f8f5;
  box-shadow: inset 1px 0 var(--signal);
}

.cell-title,
.code {
  color: var(--ink);
}

.code {
  color: var(--signal-dark);
}

.tag,
.count-pill {
  color: var(--signal-dark);
  background: var(--signal-pale);
}

.badge {
  border-radius: 999px;
  padding: 5px 9px;
  font-weight: 650;
}

.badge.ok {
  color: #087657;
  background: #e8f6ef;
}

.badge.warn {
  color: var(--warning);
  background: var(--warning-pale);
}

.badge.bad {
  color: var(--danger);
  background: var(--danger-pale);
}

.badge.gray {
  color: #596b73;
  background: var(--quiet);
}

dialog {
  width: min(1440px, calc(100vw - 32px));
  color: var(--ink);
  border-radius: 16px;
  box-shadow: 0 28px 90px rgba(9, 30, 24, .28);
  animation: modal-enter 260ms var(--ease-out) both;
}

dialog::backdrop {
  background: rgba(8, 29, 23, .58);
  backdrop-filter: blur(3px);
}

.modal-head {
  padding: 20px 26px 17px;
  border-color: var(--rule);
}

.modal-head h2 {
  font-size: clamp(21px, 2vw, 28px);
}

.modal-tabs {
  gap: 6px;
  padding: 7px 20px 0;
  background: #fbfdfc;
}

.modal-tabs button {
  min-height: 46px;
  padding: 11px 13px;
  border-radius: 8px 8px 0 0;
  color: #61756d;
  transition: color 150ms ease, background 150ms ease;
}

.modal-tabs button:hover {
  color: var(--ink);
  background: #eef5f2;
}

.modal-tabs button.active {
  color: var(--signal-dark);
  border-color: var(--signal);
  background: #edf7f3;
}

.modal-body {
  padding: 22px 26px 28px;
}

.modal-footer {
  border-color: var(--rule);
  background: #f7faf9;
}

.detail-grid {
  gap: 23px 26px;
}

.detail-grid small,
.field {
  color: #5d736a;
}

.detail-value {
  color: var(--ink);
}

.note-box {
  border: 0;
  border-radius: 12px;
  color: #365048;
  background: #edf4f1;
}

.work-card,
.supplier-agreement,
.employee-card,
.settings-nav {
  border-color: var(--rule);
  border-radius: 12px;
  background: var(--paper);
}

.work-card:hover,
.supplier-agreement:hover,
.employee-card:hover {
  border-color: #90b9aa;
  background: #fbfefc;
  transform: translateY(-1px);
}

.payment-register {
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--paper);
}

.payment-register-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--rule);
}

.payment-register-head h3 {
  font-size: 18px;
}

.payment-register-head p {
  margin-top: 3px;
  color: #647970;
  font-size: 12px;
}

.payment-table-wrap {
  overflow-x: auto;
}

.payment-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  font-size: 11.5px;
}

.payment-table th,
.payment-table td {
  padding: 12px 9px;
  border-right: 1px solid var(--rule);
}

.payment-table th:nth-child(1) { width: 3%; }
.payment-table th:nth-child(2) { width: 11%; }
.payment-table th:nth-child(3) { width: 9%; }
.payment-table th:nth-child(4) { width: 13%; }
.payment-table th:nth-child(5),
.payment-table th:nth-child(6),
.payment-table th:nth-child(7),
.payment-table th:nth-child(8),
.payment-table th:nth-child(9) { width: 10%; }
.payment-table th:nth-child(10) { width: 9%; }
.payment-table th:nth-child(11) { width: 5%; }

.payment-table th:last-child,
.payment-table td:last-child {
  border-right: 0;
}

.payment-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: normal;
}

.payment-table td b {
  display: block;
  max-width: 170px;
  white-space: normal;
}

.payment-index {
  width: 38px;
  color: #71857d;
  text-align: center;
}

.payment-direction {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  line-height: 1.25;
}

.payment-direction svg {
  width: 19px;
  height: 19px;
}

.payment-direction small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 500;
}

.payment-direction-in {
  color: var(--signal-dark);
}

.payment-direction-out {
  color: #176bb0;
}

.payment-basis-cell {
  display: block;
  max-width: 220px;
  white-space: normal;
  line-height: 1.45;
}

.payment-money {
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
}

.payment-table tfoot th,
.payment-table tfoot td {
  padding: 11px 12px;
  color: var(--ink);
  border-top: 1px solid #cbdad4;
  background: #eef4f1;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.payment-table tfoot th {
  text-align: left;
}

.payment-details {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.payment-detail {
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: #fff;
}

.payment-detail summary {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
  transition: background 150ms ease;
}

.payment-detail summary::-webkit-details-marker {
  display: none;
}

.payment-detail summary:hover {
  background: #f2f8f5;
}

.payment-detail-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.payment-detail-title > svg {
  width: 17px;
  color: var(--signal);
  transform: rotate(0deg);
  transition: transform 220ms var(--ease-out);
}

.payment-detail[open] .payment-detail-title > svg {
  transform: rotate(90deg);
}

.payment-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1.35fr;
  border-top: 1px solid var(--rule);
  animation: detail-enter 220ms var(--ease-out) both;
}

.payment-detail-grid section {
  min-width: 0;
  padding: 17px 18px;
  border-right: 1px solid var(--rule);
}

.payment-detail-grid section:last-child {
  border-right: 0;
}

.payment-detail-grid h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .025em;
  text-transform: uppercase;
}

.payment-detail-grid dl,
.payment-detail-grid dd {
  margin: 0;
}

.payment-detail-grid dl {
  display: grid;
  gap: 0;
}

.payment-detail-grid dl > div {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(120px, auto);
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid #edf2f0;
}

.payment-detail-grid dl > div:last-child {
  border-bottom: 0;
}

.payment-detail-grid dt {
  color: #647970;
  font-size: 12px;
}

.payment-detail-grid dd {
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  text-align: right;
  overflow-wrap: anywhere;
}

.payment-detail-action {
  display: flex;
  justify-content: flex-end;
  padding: 10px 14px;
  border-top: 1px solid var(--rule);
  background: #f8fbfa;
}

.login-visual {
  color: #fff;
  border-top: 0;
  background: #102620;
}

.login-copy h1 {
  color: #fff;
  font-size: clamp(44px, 6vw, 78px);
  letter-spacing: -.04em;
}

.login-copy p,
.login-visual footer {
  color: #b5c9c1;
}

.login-visual::after {
  border-color: rgba(10, 143, 112, .2);
  box-shadow: 0 0 0 65px rgba(10, 143, 112, .08), 0 0 0 130px rgba(10, 143, 112, .04);
}

#toast {
  color: #fff;
  border-radius: 10px;
  background: #102620;
  box-shadow: 0 10px 32px rgba(8, 28, 23, .24);
}

.loading {
  color: #51685f;
}

@keyframes modal-enter {
  from {
    opacity: .5;
    transform: translateY(18px) scale(.985);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes detail-enter {
  from {
    opacity: 0;
    transform: translateY(-6px);
    clip-path: inset(0 0 18% 0);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    clip-path: inset(0);
  }
}

@media (max-width: 1100px) {
  .payment-detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .payment-detail-grid section:last-child {
    grid-column: 1 / -1;
    border-top: 1px solid var(--rule);
  }
}

@media (max-width: 800px) {
  body {
    padding-bottom: 72px;
  }

  .sidebar {
    position: fixed;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    z-index: 20;
    height: 58px;
    padding: 6px;
    border: 0;
    border-radius: 16px;
    color: #c5d5cf;
    background: #102620;
    box-shadow: 0 14px 38px rgba(8, 28, 23, .3);
  }

  .sidebar .brand {
    display: none;
  }

  .sidebar .nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
    height: 100%;
    overflow: visible;
  }

  .sidebar .nav button,
  .sidebar .sidebar-tools {
    display: flex;
    min-width: 0;
    height: 46px;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px;
    color: #c5d5cf;
    border-radius: 11px;
  }

  .sidebar .nav button.active {
    color: #fff;
    background: var(--signal);
  }

  .sidebar .nav-label {
    display: block;
    max-width: 76px;
    overflow: hidden;
    font-size: 10px;
    line-height: 1;
    opacity: 1;
  }

  .content {
    padding: 14px 12px 24px;
  }

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

  .stat {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 13px 15px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .stat:last-child {
    border-bottom: 0;
  }

  .stat strong,
  .stat small {
    grid-column: 1;
  }

  .stat-icon {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
  }

  dialog {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
    border-radius: 14px;
  }

  .modal-head,
  .modal-body {
    padding-right: 16px;
    padding-left: 16px;
  }

  .modal-tabs {
    padding-left: 10px;
  }

  .payment-register {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .payment-register-head {
    margin-bottom: 8px;
    padding: 4px 2px 12px;
    border-bottom: 0;
  }

  .payment-table-wrap {
    overflow: visible;
  }

  .payment-table,
  .payment-table tbody,
  .payment-table tr,
  .payment-table td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .payment-table thead,
  .payment-table tfoot,
  .payment-table .payment-index {
    display: none;
  }

  .payment-table tbody {
    display: grid;
    gap: 10px;
  }

  .payment-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    border: 1px solid var(--rule);
    border-radius: 12px;
    background: #fff;
  }

  .payment-table tbody td {
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #edf2f0;
    white-space: normal;
  }

  .payment-table tbody td:nth-child(2),
  .payment-table tbody td:nth-child(3),
  .payment-table tbody td:nth-child(4),
  .payment-table tbody td:nth-child(10),
  .payment-table tbody td:nth-child(11) {
    grid-column: 1 / -1;
  }

  .payment-table tbody td:nth-child(5)::before { content: "С НДС"; }
  .payment-table tbody td:nth-child(6)::before { content: "Без НДС"; }
  .payment-table tbody td:nth-child(7)::before { content: "НДС 22%"; }
  .payment-table tbody td:nth-child(8)::before { content: "Оплачено"; }
  .payment-table tbody td:nth-child(9)::before { content: "Остаток"; }

  .payment-table tbody td:nth-child(n+5):nth-child(-n+9)::before {
    display: block;
    margin-bottom: 3px;
    color: #687c74;
    font-size: 10px;
    font-weight: 500;
    text-align: left;
  }

  .payment-table tbody td:nth-child(11) .btn {
    width: 100%;
  }

  .payment-detail-grid {
    grid-template-columns: 1fr;
  }

  .payment-detail-grid section,
  .payment-detail-grid section:last-child {
    grid-column: auto;
    border-right: 0;
    border-top: 1px solid var(--rule);
  }

  .payment-detail-grid section:first-child {
    border-top: 0;
  }

  .payment-detail summary {
    align-items: flex-start;
  }

  .payment-detail-title b {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* The corporate site remains the visual authority: light surfaces and EKRA green. */
:root {
  --ink: #333333;
  --ink-soft: #52645a;
  --canvas: #f4f6f5;
  --signal: #008967;
  --signal-dark: #007658;
  --signal-pale: #e9f5ef;
  --rule: #e3e9e6;
}

.main {
  background: var(--canvas);
}

@media (min-width: 801px) {
  .sidebar {
    color: #64716b;
    border-right: 1px solid var(--rule);
    background: #ffffff;
    box-shadow: none;
  }

  .sidebar .brand-mark {
    padding: 0;
    background: transparent;
  }

  .sidebar .nav button {
    color: #67736d;
  }

  .sidebar .nav button:hover:not(.active) {
    color: #007b5d;
    background: #eaf4ef;
  }

  .sidebar .nav button.active {
    color: #ffffff;
    background: #008967;
    box-shadow: none;
  }

  .shell.sidebar-expanded .sidebar .brand {
    background: transparent;
  }
}

.stats {
  gap: 17px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.stat {
  border: 1px solid var(--rule);
  border-radius: 13px;
  background: #ffffff;
}

.login-visual {
  color: #333333;
  border-top: 6px solid #008967;
  background: #f0f6f3;
}

.login-copy h1 {
  color: #333333;
}

.login-copy p {
  color: #697a70;
}

.login-visual footer {
  color: #77877e;
}

@media (max-width: 800px) {
  body {
    padding-bottom: 0;
  }

  .sidebar {
    position: relative;
    inset: auto;
    z-index: auto;
    height: auto;
    padding: 16px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    border-radius: 0;
    color: #64716b;
    background: #ffffff;
    box-shadow: none;
  }

  .sidebar .brand {
    display: flex;
  }

  .sidebar .nav {
    display: flex;
    width: auto;
    height: auto;
    overflow-x: auto;
  }

  .sidebar .nav button,
  .sidebar .sidebar-tools {
    width: auto;
    height: auto;
    min-height: 44px;
    padding: 9px 11px;
    color: #67736d;
  }

  .sidebar .nav button.active {
    color: #ffffff;
    background: #008967;
  }

  .sidebar .nav-label {
    max-width: none;
    font-size: 13px;
  }

  .stats {
    gap: 10px;
  }

  .stat {
    border-right: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
  }
}
