:root {
  --bg-soft: #f3f7f5;
  --bg-soft-2: #ebf4f2;
  --card: rgba(255, 255, 255, 0.76);
  --card-border: rgba(173, 205, 198, 0.52);
  --text-main: #18302b;
  --text-muted: #53766d;
  --primary: #1f8f7b;
  --primary-2: #166b5b;
  --danger: #c75656;
  --shadow: 0 14px 34px rgba(23, 65, 57, 0.12);
  --radius: 18px;
  --input-radius: 12px;
  --font-main: "Nunito", "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-main);
  color: var(--text-main);
  background:
    radial-gradient(circle at 14% 8%, rgba(154, 229, 205, 0.58), transparent 35%),
    radial-gradient(circle at 85% 0%, rgba(191, 221, 255, 0.46), transparent 30%),
    linear-gradient(155deg, var(--bg-soft), var(--bg-soft-2));
}

.page {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px clamp(14px, 2vw, 30px) 36px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid rgba(178, 217, 209, 0.58);
  background: linear-gradient(128deg, rgba(232, 248, 243, 0.82), rgba(242, 252, 249, 0.66));
  box-shadow: var(--shadow);
  padding: 22px clamp(16px, 2.4vw, 32px);
  animation: fade-up 0.6s ease both;
}

.hero::after {
  content: "";
  position: absolute;
  top: -45px;
  right: -30px;
  width: 200px;
  height: 200px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(145, 226, 201, 0.4), transparent 62%);
  pointer-events: none;
}

.hero-kicker {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-2);
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2.6vw, 2.35rem);
  line-height: 1.1;
}

.hero-title-status {
  display: inline-block;
  margin-left: 8px;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  font-weight: 700;
  color: #35665b;
}

.hero-save-status {
  display: inline-block;
  margin-left: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  background: rgba(29, 143, 123, 0.12);
  color: #236d5f;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(-1px);
}

.hero-save-status.visible {
  opacity: 1;
}

.hero-save-status[data-status="saving"] {
  background: rgba(63, 128, 199, 0.16);
  color: #2f5f93;
}

.hero-save-status[data-status="saved"] {
  background: rgba(30, 148, 114, 0.16);
  color: #1f7a5f;
}

.hero-save-status[data-status="error"] {
  background: rgba(199, 86, 86, 0.18);
  color: #9e3a3a;
}

.hero p {
  margin: 8px 0 0;
  max-width: 72ch;
  color: var(--text-muted);
}

.layout {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  grid-template-areas:
    "sidebar content"
    "table table";
  gap: 18px;
  align-items: start;
}

.content-column,
.sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.content-column {
  grid-area: content;
}

.sidebar-column {
  grid-area: sidebar;
  align-self: stretch;
}

.table-card {
  grid-area: table;
}

.card {
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  padding: clamp(14px, 2vw, 20px);
  animation: fade-up 0.7s ease both;
}

.sticky-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.sticky-card .actions {
  margin-top: auto;
}

.sticky-card .message {
  margin-top: 10px;
}

.section-head {
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(1.05rem, 1.7vw, 1.3rem);
}

.section-head p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.grid {
  display: grid;
  gap: 12px;
}

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

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #34574f;
}

input,
select,
button {
  min-height: 42px;
  border-radius: var(--input-radius);
  font-family: inherit;
  font-size: 14px;
}

input,
select {
  border: 1px solid rgba(157, 191, 183, 0.7);
  background: rgba(255, 255, 255, 0.84);
  padding: 10px 12px;
  color: var(--text-main);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input:focus,
select:focus {
  border-color: rgba(35, 152, 129, 0.8);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(48, 179, 152, 0.18);
  outline: none;
}

button {
  border: 1px solid transparent;
  padding: 0 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(0.98);
}

button:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #2baf95);
  color: #f7fffd;
}

.btn-soft {
  border-color: rgba(157, 191, 183, 0.7);
  background: rgba(255, 255, 255, 0.68);
  color: #274942;
}

.btn-danger {
  background: linear-gradient(135deg, #d97171, var(--danger));
  color: #fff;
}

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

.message {
  min-height: 20px;
  margin-top: 12px;
  padding-left: 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-2);
}

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

.summary-item {
  border-radius: 14px;
  border: 1px solid rgba(157, 191, 183, 0.56);
  background: linear-gradient(145deg, rgba(251, 255, 254, 0.78), rgba(241, 250, 248, 0.85));
  padding: 12px;
}

.summary-item span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.summary-item strong {
  font-size: 1.2rem;
  line-height: 1;
}

.table-wrap {
  border-radius: 14px;
  border: 1px solid rgba(176, 205, 198, 0.6);
  background: rgba(255, 255, 255, 0.52);
  overflow: auto;
  max-height: 66vh;
}

table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid rgba(183, 211, 204, 0.56);
  padding: 9px 10px;
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(226, 245, 240, 0.93);
  color: #315a50;
  font-size: 12px;
  letter-spacing: 0.02em;
}

th:first-child,
td:first-child,
th:last-child,
td:last-child {
  text-align: center;
}

tr.current-month-row {
  background: linear-gradient(90deg, rgba(52, 161, 138, 0.22), rgba(52, 161, 138, 0.1));
}

tr.current-month-row td {
  background: transparent;
  border-bottom-color: rgba(52, 161, 138, 0.34);
}

tr.current-month-row td:first-child {
  box-shadow: inset 4px 0 0 rgba(27, 120, 101, 0.7);
}

td.extra-input-cell input {
  width: 120px;
  min-height: 34px;
  text-align: right;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "sidebar"
      "content"
      "table";
  }

  .sticky-card {
    height: auto;
  }

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

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

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

@media (max-width: 640px) {
  .page {
    padding: 14px 10px 24px;
  }

  .grid-params,
  .grid-saved,
  .actions,
  .summary {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 8px;
  }
}
