@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-start: #cbd5df;
  --bg-mid: #eef2f6;
  --bg-end: #bdc9d6;
  --ink: #11151b;
  --muted: #56616d;
  --line: rgba(255, 255, 255, 0.68);
  --line-dark: rgba(20, 26, 34, 0.12);
  --glass: rgba(248, 251, 253, 0.54);
  --glass-strong: rgba(255, 255, 255, 0.68);
  --glass-soft: rgba(255, 255, 255, 0.24);
  --shadow: 0 18px 48px rgba(21, 29, 38, 0.1);
  --shadow-strong: 0 24px 62px rgba(18, 24, 32, 0.18);
  --green: #08764f;
  --red: #b42318;
  --amber: #8a5a00;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg-mid);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Montserrat", Inter, "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0;
}

.calc-page {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0) 26%),
    linear-gradient(135deg, var(--bg-start) 0%, var(--bg-mid) 44%, var(--bg-end) 100%);
}

.calc-page::before,
.calc-page::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.calc-page::before {
  background:
    linear-gradient(106deg, transparent 0 9%, rgba(255, 255, 255, 0.72) 18%, rgba(255, 255, 255, 0.26) 30%, transparent 43%),
    linear-gradient(286deg, transparent 0 12%, rgba(127, 151, 177, 0.32) 29%, transparent 50%),
    conic-gradient(from 0.71turn at 10% 14%, transparent 0 10%, rgba(255, 255, 255, 0.92) 16% 29%, rgba(153, 176, 199, 0.58) 35% 48%, transparent 60% 100%),
    conic-gradient(from 0.17turn at 88% 14%, transparent 0 15%, rgba(135, 162, 190, 0.52) 23% 39%, rgba(255, 255, 255, 0.5) 46% 58%, transparent 69% 100%),
    conic-gradient(from 0.58turn at 51% 79%, transparent 0 13%, rgba(255, 255, 255, 0.78) 21% 39%, rgba(145, 170, 195, 0.38) 47% 63%, transparent 74% 100%);
  background-blend-mode: screen, multiply, screen, multiply, screen;
  filter: blur(18px) saturate(1.12);
  transform: scale(1.05);
}

.calc-page::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 360 360'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='360' height='360' filter='url(%23n)' opacity='.46'/%3E%3C/svg%3E");
  background-size: 460px 460px;
  opacity: 0.12;
  mix-blend-mode: soft-light;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  min-width: 1180px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(17, 23, 31, 0.1);
  background: rgba(242, 246, 249, 0.34);
  color: var(--ink);
  backdrop-filter: blur(22px) saturate(116%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.64);
}

.brand {
  width: 210px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.4);
  color: #121820;
  font-weight: 820;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 8px 22px rgba(24, 30, 38, 0.06);
}

.brand strong {
  display: block;
  font-size: 14px;
  font-weight: 780;
  line-height: 16px;
}

.brand span:last-child {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 2px;
}

.top-field {
  min-width: 128px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
}

.top-field.grow {
  flex: 1;
  min-width: 220px;
}

.top-field span {
  color: var(--muted);
  white-space: nowrap;
  font-weight: 620;
}

input,
select,
textarea,
output {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.32);
  color: var(--ink);
  min-height: 28px;
  padding: 4px 7px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(73, 99, 128, 0.36);
  background: rgba(255, 255, 255, 0.56);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.76),
    0 0 0 2px rgba(116, 144, 173, 0.16);
}

.topbar input,
.topbar select {
  background: rgba(255, 255, 255, 0.3);
}

button {
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.26);
  color: var(--ink);
  padding: 0 11px;
  cursor: pointer;
  font-weight: 680;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

button:hover {
  background: rgba(255, 255, 255, 0.44);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.primary-button {
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.5);
  font-weight: 760;
}

.hidden {
  display: none !important;
}

.auth-view,
.portal-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.auth-view {
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(420px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(242, 246, 250, 0.34));
  backdrop-filter: blur(30px) saturate(112%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    var(--shadow-strong);
}

.auth-brand {
  width: auto;
  margin-bottom: 4px;
}

.auth-card label,
.user-form label {
  display: grid;
  gap: 4px;
  font-weight: 700;
}

.auth-card label span,
.user-form label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
}

.form-error {
  min-height: 18px;
  color: var(--red);
  font-weight: 720;
}

.portal-view {
  height: 100vh;
  overflow: hidden;
}

.portal-topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(17, 23, 31, 0.1);
  background: rgba(242, 246, 249, 0.34);
  backdrop-filter: blur(22px) saturate(116%);
}

.portal-layout {
  height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 430px;
  gap: 10px;
  padding: 10px;
  overflow: hidden;
}

.portal-panel {
  padding: 12px;
  overflow: auto;
}

.calc-list,
.users-list,
.access-users {
  display: grid;
  gap: 8px;
}

.calc-card,
.user-row,
.access-row {
  display: grid;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.26);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.calc-card {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  padding: 10px;
}

.calc-card strong,
.user-row strong,
.access-row strong {
  display: block;
  font-weight: 780;
}

.calc-card span,
.user-row span,
.access-row span {
  color: var(--muted);
  font-size: 11px;
}

.permission-pill {
  min-width: 66px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
  text-align: center;
  font-weight: 760;
  color: #304454;
}

.danger-button {
  color: var(--red);
}

.user-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.user-form button {
  grid-column: 1 / -1;
}

.toggle-line.compact {
  margin-top: 0;
}

.user-row {
  grid-template-columns: minmax(0, 1fr) 86px 92px;
  padding: 8px;
}

.access-row {
  grid-template-columns: minmax(0, 1fr) 120px;
  padding: 8px;
}

.save-status {
  min-width: 82px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.user-badge {
  max-width: 110px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 40, 50, 0.18);
  backdrop-filter: blur(18px);
}

.modal-panel {
  width: min(620px, calc(100vw - 36px));
  max-height: min(720px, calc(100vh - 36px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.68), rgba(242, 246, 250, 0.42));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    var(--shadow-strong);
}

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

.access-users {
  overflow: auto;
  padding-right: 2px;
}

.workspace {
  height: calc(100vh - 58px);
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(360px, 1fr) 640px;
  grid-template-rows: minmax(0, 1fr) 410px;
  gap: 10px;
  padding: 10px;
  overflow: hidden;
}

.panel {
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.56), rgba(242, 246, 250, 0.3));
  backdrop-filter: blur(30px) saturate(112%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    var(--shadow);
  overflow: hidden;
}

.meta-panel {
  grid-row: 1 / span 2;
  overflow: auto;
  padding: 10px;
}

.lines-panel {
  grid-column: 2 / span 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.summary-panel {
  overflow: hidden;
  padding: 8px 10px;
}

.terms-panel {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  padding: 8px;
}

.terms-panel label {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 720;
}

textarea {
  min-height: 0;
  flex: 1;
  resize: none;
  line-height: 1.25;
  white-space: pre-wrap;
}

.panel-title {
  font-weight: 820;
  font-size: 13px;
  line-height: 18px;
  margin-bottom: 8px;
}

.panel-title.secondary {
  margin-top: 8px;
  border-top: 1px solid rgba(20, 26, 34, 0.1);
  padding-top: 7px;
}

.panel-head {
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid rgba(20, 26, 34, 0.1);
  background: rgba(255, 255, 255, 0.2);
}

.soft-label {
  color: var(--muted);
  font-size: 11px;
}

.button-row {
  display: flex;
  gap: 6px;
}

.field-grid {
  display: grid;
  gap: 7px;
}

.field-grid.two {
  grid-template-columns: 1fr 1fr;
}

.field-grid label,
.toggle-line {
  display: grid;
  gap: 3px;
}

.field-grid label span,
.toggle-line span,
.terms-panel label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
}

.meta-panel input,
.meta-panel output {
  border-color: rgba(22, 34, 48, 0.2);
  background: rgba(255, 255, 255, 0.54);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 0 0 1px rgba(255, 255, 255, 0.28);
}

.toggle-line {
  grid-template-columns: 16px 1fr;
  align-items: center;
  margin-top: 8px;
}

.toggle-line input {
  min-height: auto;
  padding: 0;
  accent-color: #2f6578;
}

.table-wrap {
  min-height: 0;
  overflow: auto;
  margin: 0 8px 8px;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
}

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

.calc-table {
  table-layout: fixed;
}

th,
td {
  border: 1px solid rgba(23, 31, 42, 0.08);
  padding: 3px 4px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(232, 239, 244, 0.82);
  color: #2a3a45;
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
  backdrop-filter: blur(16px) saturate(112%);
}

.calc-table td {
  background: rgba(255, 255, 255, 0.24);
}

.calc-table tr.inactive td {
  background: rgba(235, 240, 244, 0.28);
  color: #6f7a86;
}

.calc-table input,
.calc-table select,
.mini-table input,
.mini-table select {
  width: 100%;
  min-height: 22px;
  height: 22px;
  border-color: rgba(27, 40, 56, 0.2);
  border-radius: 7px;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 0 0 1px rgba(255, 255, 255, 0.18);
}

.calc-table input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.calc-table input[type="number"]::-webkit-inner-spin-button,
.calc-table input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.calc-table input:focus,
.calc-table select:focus,
.mini-table input:focus,
.mini-table select:focus {
  background: rgba(255, 255, 255, 0.62);
}

.calc-table select {
  min-width: 0;
}

.mini-table select {
  min-width: 38px;
}

.calc-table td:nth-child(1) {
  text-align: center;
}

.calc-table td:nth-child(2) {
  text-align: center;
}

.calc-table select[data-field="costCurrency"],
.calc-table select[data-field="sellCurrency"] {
  font-size: 11px;
  padding-right: 0;
  padding-left: 2px;
}

.calc-table input[type="checkbox"] {
  height: auto;
  min-height: 0;
  accent-color: #2f6578;
}

.calc-table input[type="checkbox"],
.supplier-check input {
  width: 16px;
}

.calc-table td {
  overflow: hidden;
}

.narrow {
  width: 100%;
  min-width: 0;
}

.micro {
  width: 100%;
  min-width: 0;
  padding-right: 2px;
  padding-left: 2px;
}

.wide {
  width: 100%;
  min-width: 0;
}

.supplier-row td {
  padding: 5px 6px;
  background: rgba(255, 255, 255, 0.34);
}

.supplier-head {
  display: grid;
  grid-template-columns: 28px 24px minmax(170px, 1fr) auto auto auto auto 28px;
  gap: 7px;
  align-items: center;
}

.supplier-head .icon-button {
  width: 26px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 999px;
  font-size: 16px;
  line-height: 1;
}

.supplier-check {
  display: grid;
  place-items: center;
}

.supplier-check input {
  min-height: 0;
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: #2f6578;
}

.supplier-name {
  min-height: 25px;
  height: 25px;
  font-weight: 760;
}

.supplier-meta,
.supplier-total {
  color: var(--muted);
  white-space: nowrap;
  font-size: 11px;
}

.supplier-total b {
  color: var(--ink);
  font-weight: 760;
}

.service-column-row th {
  position: sticky;
  top: 0;
  background: rgba(232, 239, 244, 0.72);
  color: #34424d;
  padding-right: 10px;
  white-space: normal;
  overflow: visible;
  line-height: 1.04;
}

.th-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  z-index: 4;
  width: 9px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.col-resizer::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 2px;
  height: calc(100% - 8px);
  border-radius: 999px;
  background: rgba(47, 101, 120, 0.18);
}

.col-resizer:hover::after,
body.resizing-column .col-resizer::after {
  background: rgba(47, 101, 120, 0.62);
}

body.resizing-column {
  cursor: col-resize;
  user-select: none;
}

.add-supplier-row td {
  padding: 7px;
  background: rgba(255, 255, 255, 0.2);
}

.add-supplier-row button,
.add-service-row button {
  width: 100%;
  height: 30px;
  border-style: dashed;
}

.add-service-row td {
  padding: 6px;
  background: rgba(255, 255, 255, 0.16);
}

.delete-service {
  width: 24px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 999px;
  color: var(--red);
  font-size: 16px;
  font-weight: 820;
  line-height: 1;
}

.delete-supplier {
  width: 26px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 999px;
  color: var(--red);
  font-size: 17px;
  font-weight: 820;
  line-height: 1;
}

.computed {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.status-ok {
  color: var(--green);
  font-weight: 760;
}

.status-warn {
  color: var(--amber);
  font-weight: 760;
}

.status-error {
  color: var(--red);
  font-weight: 760;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.kpi {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.28);
  padding: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.kpi span {
  color: var(--muted);
  display: block;
  margin-bottom: 3px;
}

.kpi strong {
  display: block;
  font-size: 12px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.margin-status {
  min-height: 20px;
  display: flex;
  align-items: center;
  margin-top: 6px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.28);
}

.summary-panel .panel-title {
  margin-bottom: 6px;
}

.summary-panel .panel-title.secondary {
  margin-top: 6px;
  padding-top: 5px;
}

.mini-table {
  overflow: hidden;
  border-radius: 12px;
  table-layout: fixed;
}

.mini-table th {
  position: static;
}

.mini-table td,
.mini-table th {
  height: 21px;
  white-space: nowrap;
}

.summary-panel .mini-table td,
.summary-panel .mini-table th {
  height: 18px;
  padding: 2px 4px;
}

.summary-panel .mini-table input,
.summary-panel .mini-table select {
  min-height: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 6px;
}

.mini-table td:not(:first-child),
.mini-table th:not(:first-child) {
  text-align: right;
}

.rates-list {
  display: grid;
  gap: 4px;
}

.rate-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 4px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(20, 26, 34, 0.08);
}

.rate-row span:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1250px) {
  .app-shell {
    min-width: 1020px;
  }

  .workspace {
    grid-template-columns: 270px minmax(360px, 1fr) 540px;
  }

}
