:root {
  --bg: #f2efe7;
  --ink: #18211f;
  --muted: #6d756f;
  --panel: #fffdf7;
  --line: #d8d0bf;
  --accent: #b84a2b;
  --accent-dark: #7d2f1d;
  --sage: #5f745f;
  --yellow: #f1c85b;
}

/* ============== Единая верхняя навигация для всех страниц ============== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.6rem clamp(0.75rem, 2vw, 1.25rem);
  background: rgba(24, 33, 31, 0.92);
  backdrop-filter: blur(8px);
  color: #fbf6e6;
  font-family: Georgia, serif;
}
.top-nav .top-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 0.5rem;
  font-weight: 700;
}
.top-nav .top-nav-brand span {
  display: inline-flex;
  width: 28px; height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.85rem;
}
.top-nav a {
  color: rgba(251, 246, 230, 0.78);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.top-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.top-nav a.active {
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(241, 200, 91, 0.45), transparent 26rem),
    linear-gradient(135deg, #f8f2df 0%, var(--bg) 45%, #e4eadc 100%);
}

.widget-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 0%, rgba(184, 74, 43, 0.2), transparent 24rem),
    linear-gradient(135deg, #fbf6e6 0%, #edf1e6 100%);
}

.widget-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.25rem;
}

.project-finance-list-shell {
  width: min(1880px, calc(100vw - 48px));
  max-width: none;
}

.widget-card {
  padding: clamp(1rem, 4vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 253, 247, 0.92);
}

.finance-widget {
  border-top: 8px solid var(--yellow);
}

.widget-card h1 {
  font-size: clamp(2rem, 7vw, 4rem);
}

.project-finance-list-card {
  padding: clamp(1rem, 2vw, 1.75rem);
}

.project-finance-list-card h1 {
  max-width: 1200px;
  font-size: clamp(2.4rem, 4.2vw, 5.25rem);
  line-height: 0.95;
}

.project-finance-list-card .time-form {
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  align-items: end;
}

.deal-summary {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.55rem 1rem;
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 20px;
  background: rgba(95, 116, 95, 0.1);
}

.deal-summary span {
  color: var(--muted);
}

.time-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1rem 0 1.5rem;
}

.time-form .wide {
  grid-column: 1 / -1;
}

.widget-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.hidden {
  display: none !important;
}

.secondary-button {
  background: var(--sage);
}

.secondary-button:hover {
  background: #3f5645;
}

.active-action {
  box-shadow: 0 0 0 4px rgba(241, 200, 91, 0.42);
}

textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  resize: vertical;
  font: inherit;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  color: white;
  background: var(--accent);
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.panel-link {
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  color: white;
  background: var(--sage);
  text-decoration: none;
  font-weight: 700;
}

input,
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

label {
  display: grid;
  gap: 0.4rem;
  font-weight: 700;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 2rem clamp(1rem, 4vw, 4rem);
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-family: "Courier New", monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  max-width: 880px;
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.94;
}

h2 {
  margin-top: 0;
  font-size: 1.8rem;
}

.status-card,
.panel {
  border: 1px solid rgba(24, 33, 31, 0.12);
  border-radius: 28px;
  background: rgba(255, 253, 247, 0.86);
  box-shadow: 0 18px 60px rgba(42, 34, 20, 0.08);
}

.status-card {
  align-self: flex-start;
  display: grid;
  gap: 1rem;
  min-width: 260px;
  padding: 1rem;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.25rem;
  padding: 0 clamp(1rem, 4vw, 4rem) 4rem;
}

.tabs {
  position: sticky;
  top: 1rem;
  align-self: start;
  display: grid;
  gap: 0.55rem;
}

.tab {
  width: 100%;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.72);
  border: 1px solid var(--line);
  text-align: left;
}

.tab.active {
  color: white;
  background: var(--sage);
}

.panel {
  display: none;
  padding: clamp(1rem, 3vw, 2rem);
  overflow: hidden;
}

.panel.active {
  display: block;
  animation: rise 0.35s ease both;
}

.grid {
  display: grid;
  gap: 1rem;
}

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

.actions,
.panel-head,
.filters {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.panel-head {
  justify-content: space-between;
}

.filters {
  margin: 1rem 0;
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 0.9rem;
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.54);
}

.report-filters select[multiple] {
  min-height: 138px;
}

.filters input {
  flex: 1 1 320px;
}

.filters select {
  width: 220px;
}

.result {
  max-height: 360px;
  overflow: auto;
  padding: 1rem;
  border-radius: 18px;
  background: #1b211f;
  color: #f6ecd2;
  white-space: pre-wrap;
}

.source-grid,
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.8rem;
}

.source-grid label,
.card,
.log-item {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
}

.note {
  color: var(--muted);
}

.mapping-table {
  display: grid;
  gap: 0.7rem;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) 100px 130px minmax(190px, 0.8fr) minmax(320px, 1.4fr);
  gap: 0.65rem;
  align-items: center;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
}

.field-picker {
  display: grid;
  gap: 0.45rem;
}

.inspector-controls {
  margin: 1rem 0;
}

.inline-check {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0 1rem;
  font-weight: 700;
}

.inline-check input {
  width: auto;
}

.inspector-table {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.inspector-row {
  display: grid;
  grid-template-columns: minmax(270px, 1fr) minmax(320px, 1.2fr) minmax(320px, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
}

.inspector-row.filled {
  border-color: rgba(95, 116, 95, 0.55);
}

.inspector-value {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.inspector-value strong,
.inspector-value code {
  overflow-wrap: anywhere;
}

.inspector-value code {
  max-height: 5.5rem;
  overflow: auto;
  padding: 0.5rem;
  border-radius: 12px;
  background: rgba(24, 33, 31, 0.06);
  color: var(--accent-dark);
}

.field-main strong {
  display: block;
}

.field-main code {
  display: inline-block;
  margin-top: 0.3rem;
  color: var(--accent-dark);
}

.pill {
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  color: white;
  background: var(--sage);
  font-size: 0.86rem;
}

.pill.warn {
  background: var(--accent);
}

.small {
  color: var(--muted);
  font-size: 0.9rem;
}

.logs {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem;
  margin: 1rem 0 1.5rem;
}

.kpi-card {
  min-height: 120px;
  padding: 1rem;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(95, 116, 95, 0.95), rgba(24, 33, 31, 0.92));
  color: white;
}

.kpi-card span {
  display: block;
  color: rgba(255, 255, 255, 0.72);
}

.kpi-card strong {
  display: block;
  margin-top: 0.55rem;
  font-size: 2rem;
  line-height: 1;
}

.simple-table {
  overflow: auto;
  margin-bottom: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.simple-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.simple-table th,
.simple-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.simple-table th {
  background: rgba(95, 116, 95, 0.12);
}

.table-action {
  white-space: nowrap;
}

.finance-list-summary {
  grid-template-columns: 140px minmax(120px, 1fr);
}

.project-finance-list-card .finance-list-summary {
  grid-template-columns: repeat(6, max-content);
  justify-content: start;
  gap: 0.4rem 1.5rem;
}

.project-finance-deals-table {
  overflow-x: visible;
}

.project-finance-deals-table table {
  min-width: 0;
  table-layout: fixed;
}

.project-finance-deals-table th,
.project-finance-deals-table td {
  padding: 0.65rem 0.75rem;
  overflow-wrap: anywhere;
}

.project-finance-deals-table th:nth-child(1),
.project-finance-deals-table td:nth-child(1) {
  width: 4%;
}

.project-finance-deals-table th:nth-child(2),
.project-finance-deals-table td:nth-child(2) {
  width: 25%;
}

.project-finance-deals-table th:nth-child(3),
.project-finance-deals-table td:nth-child(3) {
  width: 8%;
}

.project-finance-deals-table th:nth-child(4),
.project-finance-deals-table td:nth-child(4) {
  width: 12%;
}

.project-finance-deals-table th:nth-child(5),
.project-finance-deals-table td:nth-child(5) {
  width: 11%;
}

.project-finance-deals-table th:nth-child(6),
.project-finance-deals-table td:nth-child(6),
.project-finance-deals-table th:nth-child(7),
.project-finance-deals-table td:nth-child(7),
.project-finance-deals-table th:nth-child(8),
.project-finance-deals-table td:nth-child(8) {
  width: 8%;
  text-align: right;
}

.project-finance-deals-table th:nth-child(9),
.project-finance-deals-table td:nth-child(9) {
  width: 5%;
  text-align: center;
}

.project-finance-deals-table th:nth-child(10),
.project-finance-deals-table td:nth-child(10) {
  width: 7%;
  text-align: right;
}

.sheet-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
  overflow-x: auto;
  padding-bottom: 0.3rem;
}

.sheet-tab {
  flex: 0 0 auto;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.sheet-tab.active {
  color: white;
  background: var(--sage);
}

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

@media (max-width: 980px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .tabs {
    position: static;
  }

  .two,
  .report-filters,
  .time-form,
  .field-row {
    grid-template-columns: 1fr;
  }

  .project-finance-list-shell {
    width: 100%;
    padding: 0.75rem;
  }

  .project-finance-list-card h1 {
    font-size: clamp(2rem, 10vw, 3.4rem);
  }

  .project-finance-list-card .time-form,
  .project-finance-list-card .finance-list-summary {
    grid-template-columns: 1fr;
  }

  .project-finance-deals-table {
    overflow-x: auto;
  }

  .project-finance-deals-table table {
    min-width: 1080px;
  }
}
