/* Days cash on hand calculator (/days-cash-on-hand-calculator).
   Loaded only by that page. Uses the design tokens from main.css. */

.dcoh-calc {
  background: var(--off-white);
  padding: clamp(48px, 7vw, var(--section-v)) 0;
  border-bottom: 1px solid rgba(209,211,212,0.4);
}

.dcoh-calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
  max-width: 1120px;
}

.dcoh-noscript {
  margin-bottom: 24px;
  padding: 14px 18px;
  background: var(--white);
  border-left: 4px solid var(--teal);
}

/* ── Form ── */
.dcoh-form {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(22px, 3vw, 36px);
}
.dcoh-form fieldset { border: 0; }
.dcoh-form fieldset + fieldset {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid rgba(209,211,212,0.6);
}
.dcoh-form legend {
  /* Floated so the legend sits inside the fieldset instead of cutting into
     its top border. */
  float: left;
  width: 100%;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-dim);
  margin-bottom: 14px;
}

.dcoh-form legend + * { clear: both; }
.dcoh-field + .dcoh-field { margin-top: 18px; }
.dcoh-field > label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-dark);
  margin-bottom: 6px;
}
.dcoh-optional {
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--text-body);
  margin-left: 6px;
}
.dcoh-form legend .dcoh-optional { text-transform: lowercase; letter-spacing: 0.04em; }

.dcoh-input { position: relative; }
.dcoh-input input,
.dcoh-field select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--text-dark);
  background: var(--white);
  border: 1px solid #b7c2cc;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-variant-numeric: tabular-nums;
}
.dcoh-input input::placeholder { color: #9aa8b5; }
.dcoh-input--usd input { padding-left: 30px; }
.dcoh-input--usd::before {
  content: "$";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-body);
  pointer-events: none;
}
.dcoh-input--days input { padding-right: 56px; }
.dcoh-input--days::after {
  content: "days";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-body);
  font-size: 0.9rem;
  pointer-events: none;
}
#dcoh-period-custom-wrap { margin-top: 10px; max-width: 220px; }

.dcoh-input input:focus,
.dcoh-field select:focus {
  outline: none;
  border-color: var(--teal-dim);
  box-shadow: 0 0 0 3px var(--teal-glow);
}
.dcoh-form [aria-invalid="true"] { border-color: #b3261e; }

.dcoh-hint {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-body);
  margin-top: 6px;
}
.dcoh-error {
  font-size: 0.82rem;
  font-weight: 600;
  color: #b3261e;
}
.dcoh-error:not(:empty) { margin-top: 6px; }

.dcoh-form-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 28px;
}
.dcoh-reset {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-body);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}
.dcoh-reset:hover { color: var(--text-dark); }

/* ── Result ── */
.dcoh-result {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  background: var(--deep);
  color: var(--text-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: clamp(24px, 3vw, 36px);
}
.dcoh-result-heading {
  scroll-margin-top: calc(var(--header-h) + 24px);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
}
.dcoh-result-empty p {
  margin-top: 18px;
  color: rgba(255,255,255,0.75);
}

.dcoh-big {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 6vw, 4.6rem);
  line-height: 1;
  color: var(--white);
  margin: 14px 0 22px;
  font-variant-numeric: tabular-nums;
}
.dcoh-big-unit {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: rgba(255,255,255,0.7);
}

.dcoh-figures > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 0.9rem;
}
.dcoh-figures dt { color: rgba(255,255,255,0.72); }
.dcoh-figures dd {
  color: var(--white);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dcoh-flag {
  margin-top: 18px;
  padding: 14px 16px;
  border-left: 3px solid var(--teal);
  background: rgba(93,182,191,0.1);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.dcoh-flag--short { border-left-color: #f2a65a; background: rgba(242,166,90,0.1); }
.dcoh-flag-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.72);
}
.dcoh-flag-value {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--white);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.dcoh-flag-note { font-size: 0.85rem; color: rgba(255,255,255,0.72); }

.dcoh-privacy {
  margin-top: 22px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
}

/* ── Explanation below the calculator ── */
.dcoh-content .dcoh-faq-item h3 { margin-bottom: 0.4em; }
.dcoh-content .dcoh-faq-item p { margin-top: 0; }
.dcoh-cta { margin: 2.5em 0 1em; text-align: center; }
/* Long label: wrap on phones instead of widening the page. */
.dcoh-cta .btn { white-space: normal; max-width: 100%; }

@media (max-width: 900px) {
  .dcoh-calc-grid { grid-template-columns: 1fr; }
  /* Result above the form would hide the inputs; below it, it can't stick. */
  .dcoh-result { position: static; }
  .dcoh-mobile-bar:not([hidden]) {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 50;
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 12px 18px;
    background: var(--deep);
    color: var(--text-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
  }
  .dcoh-mobile-bar-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--teal);
  }
  .dcoh-mobile-bar strong {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--white);
    font-variant-numeric: tabular-nums;
  }
  .dcoh-mobile-bar-more {
    margin-left: auto;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.75);
  }
}
/* Never on wide screens, where the result panel sticks beside the form. */
@media (min-width: 901px) {
  .dcoh-mobile-bar { display: none !important; }
}
@media (max-width: 480px) {
  .dcoh-figures > div { flex-direction: column; gap: 2px; }
  .dcoh-figures dd { text-align: left; }
}
