@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&family=Source+Sans+3:wght@400;600;700&display=swap');

:root {
  --bg: #e8efe8;
  --bg-deep: #d5e2d6;
  --ink: #1a2a1c;
  --muted: #5a6b5c;
  --panel: rgba(252, 255, 252, 0.88);
  --line: #b7c8b8;
  --accent: #1f6b4a;
  --accent-2: #0e3d2c;
  --warn: #9a5b14;
  --shadow: 0 18px 50px rgba(20, 50, 30, 0.12);
  --radius: 18px;
  --font-display: 'Manrope', system-ui, sans-serif;
  --font-body: 'Source Sans 3', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background: linear-gradient(165deg, #f3f7f2 0%, var(--bg) 45%, #cfdccf 100%);
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

.app {
  position: relative;
  min-height: 100vh;
  padding: 28px 22px 56px;
  overflow: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(31, 107, 74, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 107, 74, 0.05) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse at 30% 10%, black 20%, transparent 70%);
  pointer-events: none;
}

.bg-glow {
  position: fixed;
  width: 48vw;
  height: 48vw;
  top: -18vw;
  right: -12vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(31, 107, 74, 0.18), transparent 68%);
  pointer-events: none;
}

.topbar {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #f4fff8;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 24px rgba(14, 61, 44, 0.28);
}

.brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(183, 200, 184, 0.8);
  backdrop-filter: blur(8px);
}

.tab {
  border: 0;
  background: transparent;
  padding: 10px 18px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.tab.is-active {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.main {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(183, 200, 184, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 22px 22px 24px;
  animation: rise 0.45s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel__head {
  margin-bottom: 18px;
}

.panel__head--row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel__head h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.panel__head p {
  margin: 0;
  color: var(--muted);
}

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

.field {
  display: grid;
  gap: 6px;
}

.field--wide {
  margin-bottom: 14px;
}

.field span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field textarea,
.lab-name,
.lab-table input[type='number'] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 11px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field textarea:focus,
.lab-name:focus,
.lab-table input[type='number']:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 107, 74, 0.15);
}

.hint {
  font-style: normal;
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
}

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

.meta-strip > div {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(183, 200, 184, 0.85);
  border-radius: 14px;
  padding: 14px 16px;
  animation: rise 0.5s ease both;
}

.meta-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.meta-strip strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
}

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

.btn {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 22px rgba(14, 61, 44, 0.22);
}

.btn--ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.result-table-wrap,
.lab-table-wrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.result-table,
.lab-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.result-table th,
.result-table td,
.lab-table th,
.lab-table td {
  padding: 12px 12px;
  border-bottom: 1px solid #e4ece4;
  vertical-align: top;
  text-align: left;
}

.result-table th,
.lab-table th {
  position: sticky;
  top: 0;
  background: #f2f7f2;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  z-index: 1;
}

.col-num {
  width: 48px;
  text-align: center !important;
  font-weight: 700;
}

.col-unit {
  width: 110px;
  white-space: nowrap;
}

.col-price {
  width: 140px;
  white-space: nowrap;
  text-align: right !important;
}

.col-qty {
  width: 80px;
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.col-sum {
  width: 120px;
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.col-check {
  width: 72px;
  text-align: center !important;
}

.col-name {
  line-height: 1.45;
  font-size: 0.95rem;
}

.cell-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f7faf7;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cell-input:hover {
  border-color: var(--line);
  background: #fff;
}

.cell-input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 107, 74, 0.12);
}

.cell-input--num {
  text-align: center;
  font-weight: 700;
  max-width: 64px;
}

.cell-input--name {
  resize: vertical;
  min-height: 72px;
  line-height: 1.4;
}

.cell-input--right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-input--sum {
  font-weight: 700;
}

.lab-table .is-off {
  opacity: 0.55;
}

.lab-name {
  min-height: 64px;
  resize: vertical;
}

.empty {
  text-align: center !important;
  color: var(--muted);
  padding: 28px !important;
}

.total-label {
  text-align: right !important;
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #eef5ef;
}

.total-value {
  background: #eef5ef;
  color: var(--accent-2);
  font-size: 1.1rem;
}

.tabs--main {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto 18px;
  width: fit-content;
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(183, 200, 184, 0.85);
}

.account-bar__label {
  color: var(--muted);
}

.account-bar__edit {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.account-bar__edit input {
  min-width: 200px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}

.calc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(183, 200, 184, 0.85);
}

.calc-toolbar__meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(31, 107, 74, 0.12);
  color: var(--accent-2);
  font-weight: 700;
  font-size: 0.85rem;
}

.pill--muted {
  background: rgba(90, 107, 92, 0.12);
  color: var(--muted);
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.inline-field input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  min-width: 180px;
}

.panel--compact {
  padding-bottom: 18px;
}

.formula-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.formula-result {
  margin-top: 8px;
}

.hint--error {
  color: #a33a2a !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(18, 32, 22, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal {
  width: min(480px, 100%);
  background: #fbfffb;
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.modal h2 {
  margin: 0;
  font-family: var(--font-display);
}

.modal__hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.modal__actions {
  justify-content: flex-end;
  margin-top: 4px;
}

.archive-table-wrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.archive-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.archive-table th,
.archive-table td {
  padding: 12px;
  border-bottom: 1px solid #e4ece4;
  text-align: left;
  vertical-align: middle;
}

.archive-table th {
  background: #f2f7f2;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.archive-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.btn--tiny {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.linkish {
  border: 0;
  background: none;
  color: var(--accent-2);
  font-weight: 700;
  text-align: left;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.nowrap {
  white-space: nowrap;
}

.col-info {
  width: 44px;
  text-align: center !important;
  vertical-align: middle !important;
}

.btn-info {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: #fff;
  color: var(--accent-2);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  font-style: italic;
  line-height: 1;
  padding: 0;
  display: inline-grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn-info:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

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

.norm-modal__head h2 {
  margin: 0;
}

.norm-modal__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1.35;
}

.norm-modal__body {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.5;
  max-height: 55vh;
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  background: #f7faf7;
  border: 1px solid var(--line);
}

.norm-body-edit {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  font-family: var(--font-body);
  line-height: 1.45;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
  outline: none;
}

.norm-body-edit:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 107, 74, 0.12);
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-icon--danger:hover {
  background: #fdeceb;
  border-color: #e3a39a;
  color: #a33a2a;
}

.add-row td {
  padding: 10px 12px !important;
  background: #f7faf7;
  border-bottom: 0 !important;
}

.btn-add {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px dashed var(--accent);
  background: rgba(31, 107, 74, 0.06);
  color: var(--accent-2);
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-add:hover {
  background: rgba(31, 107, 74, 0.12);
  transform: translateY(-1px);
}

.btn-add__plus {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
}

.btn-add__count {
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(31, 107, 74, 0.15);
  font-size: 0.85rem;
}

.modal--wide {
  width: min(720px, 100%);
  max-height: min(84vh, 900px);
  display: flex;
  flex-direction: column;
}

.picker-list {
  overflow: auto;
  max-height: 48vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.picker-item {
  display: grid;
  grid-template-columns: auto 40px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border-bottom: 1px solid #e4ece4;
  cursor: pointer;
}

.picker-item:last-child {
  border-bottom: 0;
}

.picker-item:hover {
  background: #f5faf6;
}

.picker-item__num {
  font-weight: 800;
  color: var(--accent-2);
}

.picker-item__name {
  font-size: 0.92rem;
  line-height: 1.4;
}

.picker-item__meta {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.lab-add-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.lab-add-row input {
  flex: 1;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 11px 12px;
}

.lab-list-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.lab-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lab-list__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid #e4ece4;
}

.lab-list__item:last-child {
  border-bottom: 0;
}

.lab-list__item:hover {
  background: #f5faf6;
}

.lab-list__open {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.lab-list__open:hover {
  background: rgba(31, 107, 74, 0.08);
}

.lab-list__open strong {
  font-size: 1.05rem;
  color: var(--accent-2);
}

.lab-list__open span {
  font-size: 0.85rem;
  color: var(--muted);
}

.lab-list__name {
  flex: 1;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 8px 10px;
  font-weight: 600;
}

.lab-list__name:hover,
.lab-list__name:focus {
  border-color: var(--line);
  background: #fff;
  outline: none;
}

.lab-list__count {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.fields-grid--5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .fields-grid--5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.trip-panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
}

.trip-panel h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.trip-hint {
  display: block;
  margin-top: 12px;
}

.toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.toggle input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.toggle span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle strong {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.toggle em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-inline {
  margin: 0;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 860px) {
  .fields-grid,
  .meta-strip {
    grid-template-columns: 1fr;
  }

  .app {
    padding: 16px 12px 40px;
  }

  .brand__mark {
    width: 44px;
    height: 44px;
  }
}
