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

:root {
  --bg: #eef7f2;
  --paper: #fff;
  --ink: #10251b;
  --muted: #607268;
  --brand: #004929;
  --brand-dark: #00321d;
  --gold: #c7a35c;
  --line: #c9ddd2;
  --soft: #f4faf7;
  --input: #fff;
  --green: #e4f4ec;
  --danger: #b42318;
  --blue: #edf7f2;
  --shadow: 0 16px 42px rgba(0, 73, 41, .12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
  min-width: 0
}

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

body {
  font-family: 'Manrope', Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f8fffb 0%, var(--bg) 48%, #dbece4 100%);
  line-height: 1.42;
  overflow-x: hidden
}

img {
  display: block;
  max-width: 100%
}

.page {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: clamp(10px, 1.4vw, 20px)
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 2px 2px 0
}

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

.brand img {
  width: clamp(112px, 11vw, 170px)
}

.brand small {
  display: block;
  color: var(--gold);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px
}

.brand h1 {
  margin: 2px 0 0;
  color: var(--brand);
  font-size: clamp(20px, 1.5vw, 30px);
  line-height: 1.05
}

.owner-link {
  color: var(--brand);
  font-weight: 900;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  background: #fff
}

.owner-link:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand)
}

.workbook {
  background: var(--paper);
  border: 1px solid #d7e9df;
  border-radius: 26px;
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(2px)
}

.hero {
  padding: clamp(16px, 2vw, 24px);
  background: linear-gradient(135deg, #fff, #f0fbf5 64%, #d7eee2);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap
}

.hero-content {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 560px;
  min-width: 0
}

.hero-text {
  flex: 1 1 auto;
  min-width: 0
}

.hero h2 {
  margin: 0;
  color: var(--brand);
  font-size: clamp(24px, 2.3vw, 40px);
  line-height: 1.05
}

.hero p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 820px
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #b7d8c7;
  background: #eaf7ef;
  color: var(--brand);
  font-weight: 900;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px
}

.hero-badge {
  flex: 0 0 auto;
  white-space: nowrap
}

.grid {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 16px;
  padding: 16px
}

.stack {
  display: grid;
  gap: 14px;
  align-content: start
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 15px;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(0, 73, 41, .06)
}

.card.soft {
  background: linear-gradient(180deg, #fff 0%, var(--soft) 100%)
}

.section-title {
  margin: 0 0 9px;
  color: var(--brand);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px
}

.subtle {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45
}

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

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

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px
}

.required label:after {
  content: ' *';
  color: var(--danger)
}

input,
select {
  width: 100%;
  border: 1px solid #bfd8ca;
  background: var(--input);
  border-radius: 12px;
  padding: 10px 11px;
  font: inherit;
  font-size: 14px;
  outline: none;
  min-height: 43px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 73, 41, .14)
}

.readonly-value {
  width: 100%;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 11px 12px;
  font-weight: 800;
  color: var(--ink);
  text-align: right;
  box-sizing: border-box;
}

.unit-summary {
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  padding: 10px 11px;
}

.unit-summary strong {
  color: var(--brand);
}

.unit-summary.err {
  border-color: #efb4ae;
  color: var(--danger);
}

.customer-save {
  margin-top: 9px;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  padding: 10px 11px;
  border: 1px dashed #8fbea6;
  background: #f3fbf7;
  border-radius: 14px;
  cursor: pointer;
  align-items: start
}

.customer-save input {
  width: 18px;
  height: 18px;
  padding: 0;
  margin-top: 2px
}

.customer-save strong {
  display: block;
  color: var(--brand);
  font-size: 12px
}

.customer-save small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin-top: 2px
}

.gate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 35, 20, .74);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  backdrop-filter: blur(3px)
}

.hidden {
  display: none !important
}

.gate-overlay.hidden {
  display: none !important
}

.gate-card {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid #c2dece;
  border-radius: 28px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .24);
  padding: clamp(20px, 4vw, 30px)
}

.gate-card img {
  width: 142px;
  margin: 0 auto 12px
}

.gate-card h2 {
  margin: 0;
  color: var(--brand);
  font-size: 24px;
  line-height: 1.08;
  text-align: center
}

.gate-card p {
  margin: 8px 0 15px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center
}

.gate-form {
  display: grid;
  gap: 13px
}

.gate-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 4px
}

.gate-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  background: rgba(180, 35, 24, .06);
  border-radius: 999px;
  padding: 0 8px
}

.gate-error:empty {
  background: transparent;
  padding: 0
}

.gate-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
  background: #eef8f3;
  border-left: 4px solid var(--gold);
  padding: 9px 10px;
  border-radius: 10px
}

body.gate-locked {
  overflow: hidden
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: min(460px, 100%)
}

.top-actions .btn {
  min-width: 190px
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 13px;
  font-weight: 900;
  cursor: pointer;
  min-height: 42px;
  font-size: 13px;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease
}

.btn.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 22px rgba(0, 73, 41, .22)
}

.btn.primary:hover {
  background: var(--brand-dark)
}

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

.btn.secondary {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(0, 73, 41, .08)
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .55;
  box-shadow: none
}

.status {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  min-height: 17px;
  border-radius: 12px
}

.status.ok {
  color: var(--brand)
}

.status.err {
  color: var(--danger)
}

.excel-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 26px rgba(0, 73, 41, .06)
}

.excel-title {
  padding: 10px 13px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 12px
}

.table-wrap {
  overflow: auto;
  background: #fff;
  scrollbar-width: thin
}

.loan-dialog {
  width: min(1180px, calc(100vw - 24px));
  max-height: min(86vh, 860px);
  border: 0;
  border-radius: 26px;
  padding: 0;
  background: #fff;
  box-shadow: 0 28px 90px rgba(0, 35, 20, .32);
  overflow: hidden
}

.loan-dialog::backdrop {
  background: rgba(0, 35, 20, .64);
  backdrop-filter: blur(2px)
}

.loan-dialog-panel {
  display: flex;
  flex-direction: column;
  max-height: min(86vh, 860px)
}

.loan-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #fff, #eef8f3)
}

.loan-dialog-head h3 {
  margin: 0;
  color: var(--brand);
  font-size: 18px;
  line-height: 1.15
}

.loan-dialog-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px
}

.loan-dialog-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer
}

.loan-dialog-body {
  padding: 16px;
  overflow: auto;
  background: #f7fcf9
}

.loan-dialog-body .excel-box {
  min-width: 920px
}

.loan-dialog-summary {
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 16px;
  background: #fff;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px
}

.loan-summary-row {
  padding: 4px 0;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 28px
}

.loan-summary-label {
  font-weight: 800;
  text-transform: uppercase;
  color: #111827;
  font-size: 13px
}

.loan-summary-value {
  font-weight: 800;
  color: #111827;
  font-size: 13px
}

.loan-summary-control {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px
}

.loan-summary-input {
  width: 100%;
  max-width: 260px;
  height: 32px;
  padding: 6px 10px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 8px;
  font: inherit;
  font-weight: 700
}

.loan-summary-suffix {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900
}

.loan-dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
  grid-column: 1 / -1;
  justify-content: flex-end
}

.loan-dialog-message {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800
}

.loan-dialog-message.err {
  color: var(--danger)
}

.loan-dialog-foot {
  display: flex;
  justify-content: flex-end;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fff
}

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

.excel.compact {
  min-width: 0
}

.excel th,
.excel td {
  border: 1px solid #d9e9e0;
  padding: 7px 8px;
  font-size: 12px;
  vertical-align: middle
}

.excel th {
  background: #eef8f3;
  color: var(--brand);
  font-weight: 900;
  position: sticky;
  top: 0;
  z-index: 1
}

.excel td.num,
.excel th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap
}

.excel td.center {
  text-align: center
}

.excel .section-row td {
  background: #f4faf7;
  color: var(--brand);
  font-weight: 900
}

.excel .total-row td {
  background: #eaf7ef;
  color: var(--brand);
  font-weight: 900
}

.excel tr.payment-row-selected td {
  background: #fff3bf;
  color: #4a3a05;
  font-weight: 900;
}

.excel .note-row td {
  background: #fffbe8;
  color: var(--brand);
  font-weight: 800
}

.excel .muted {
  color: var(--muted)
}

.excel input[type=checkbox] {
  width: 16px;
  height: 16px;
  padding: 0
}

.program-rate {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end
}

.program-rate input {
  width: 82px;
  text-align: right;
  background: #fff;
  padding: 6px 7px
}

.program-cash {
  width: 120px;
  text-align: right;
  background: #fff !important;
  padding: 6px 7px !important
}

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

.kpi.kpi-loan {
  grid-template-columns: repeat(3, minmax(0, 1fr))
}

.metric {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px
}

.metric .k {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800
}

.metric .v {
  margin-top: 3px;
  color: var(--brand);
  font-weight: 900;
  font-size: clamp(15px, 1.25vw, 22px);
  line-height: 1.1
}

.metric.big {
  /* grid-column: span 2; */
  background: linear-gradient(135deg, #f3fbf7, #dff3e8);
  border-color: #acd1bf;
  box-shadow: 0 10px 24px rgba(0, 73, 41, .08)
}

.kpi.kpi-loan .metric.big {
  grid-column: span 1
}

.metric.summary-card-hdmb {
  background: linear-gradient(135deg, #004929, #0f766e);
  border-color: #00321d;
  box-shadow: 0 12px 28px rgba(0, 73, 41, .18);
}

.metric.summary-card-hdmb .k,
.metric.summary-card-hdmb .v {
  color: #fff;
}

.metric.summary-card-hdmb .v {
  font-size: clamp(17px, 1.35vw, 24px);
}

.note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px
}
