/* ── BASE RESET ───────────────────────────────────────────────────── */
.dti-widget *, .dti-widget *::before, .dti-widget *::after { box-sizing: border-box; }

/* ── TWO-COLUMN LAYOUT ────────────────────────────────────────────── */
.dti-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 820px) {
    .dti-layout { grid-template-columns: 1fr; }
}

/* ── PANEL CARDS ──────────────────────────────────────────────────── */
.dti-panel {
    background: var(--clr-bg);
    border: 1.5px solid var(--clr-border);
    border-radius: 14px;
    overflow: hidden;
}
.dti-panel-head {
    background: var(--clr-bg-muted);
    padding: .75rem 1.125rem;
    border-bottom: 1.5px solid var(--clr-border);
    display: flex;
    align-items: center;
    gap: .5rem;
}
.dti-panel-head-icon { font-size: 1rem; line-height: 1; }
.dti-panel-head-title {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--clr-text-secondary);
}
.dti-panel-body { padding: 1rem 1.125rem; }

/* ── INPUT FIELDS ─────────────────────────────────────────────────── */
.dti-field {
    margin-bottom: .75rem;
}
.dti-field:last-child { margin-bottom: 0; }

.dti-label {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--clr-text-secondary);
    margin-bottom: .3rem;
}
.dti-hint {
    font-size: .68rem;
    font-weight: 400;
    color: var(--clr-text-muted);
    margin-left: auto;
}
.dti-input-row {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--clr-border);
    border-radius: 9px;
    background: var(--clr-bg-soft);
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s;
}
.dti-input-row:focus-within {
    border-color: var(--clr-accent);
    box-shadow: var(--shadow-focus);
    background: var(--clr-bg);
}
.dti-sym {
    padding: 0 .625rem;
    font-size: .8125rem;
    font-weight: 700;
    color: var(--clr-text-muted);
    user-select: none;
    flex-shrink: 0;
    border-right: 1.5px solid var(--clr-border);
    align-self: stretch;
    display: flex;
    align-items: center;
    background: var(--clr-bg-muted);
}
.dti-sym.dti-sym-right {
    border-right: none;
    border-left: 1.5px solid var(--clr-border);
}
.dti-input {
    flex: 1;
    padding: .55rem .625rem;
    font-size: .9rem;
    font-weight: 600;
    color: var(--clr-text-primary);
    border: none;
    background: transparent;
    outline: none;
    min-width: 0;
    -moz-appearance: textfield;
}
.dti-input::-webkit-inner-spin-button,
.dti-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.dti-input-desc {
    display: block;
    font-size: .68rem;
    color: var(--clr-text-muted);
    margin-top: .2rem;
    padding-left: .1rem;
}

/* section divider */
.dti-divider {
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--clr-text-muted);
    padding: .5rem 0 .4rem;
    border-bottom: 1px solid var(--clr-border-soft);
    margin-bottom: .6rem;
}

/* tooltip */
.dti-tip-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--clr-bg-muted); border: 1px solid var(--clr-border);
    font-size: .58rem; font-weight: 800; color: var(--clr-text-muted);
    cursor: default; position: relative; flex-shrink: 0;
}
.dti-tip-btn::after {
    content: attr(data-tip);
    position: absolute; bottom: calc(100% + 6px); left: 50%;
    transform: translateX(-50%);
    background: var(--clr-text-primary); color: #fff;
    font-size: .67rem; font-weight: 400; padding: .35rem .6rem;
    border-radius: 6px; max-width: 210px; white-space: normal;
    text-align: center; pointer-events: none;
    opacity: 0; transition: opacity .15s; z-index: 99; line-height: 1.45;
}
.dti-tip-btn:hover::after { opacity: 1; }

/* income toggle */
.dti-freq-toggle {
    display: flex;
    background: var(--clr-bg-muted);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
    margin-bottom: .625rem;
}
.dti-freq-btn {
    flex: 1;
    padding: .3rem .5rem;
    font-size: .72rem;
    font-weight: 600;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--clr-text-muted);
    transition: background .2s, color .2s;
    text-align: center;
}
.dti-freq-btn.dti-active {
    background: #fff;
    color: var(--clr-accent-dark);
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ── CALCULATE BUTTON ─────────────────────────────────────────────── */
.dti-calc-btn {
    width: 100%;
    margin-top: 1rem;
    padding: .75rem 1.25rem;
    background: var(--clr-accent);
    color: #fff;
    font-size: .9375rem;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    transition: background .2s, box-shadow .2s, transform .1s;
    box-shadow: 0 2px 14px rgba(14,165,233,.28);
}
.dti-calc-btn:hover  { background: var(--clr-accent-dark); box-shadow: 0 4px 20px rgba(14,165,233,.38); }
.dti-calc-btn:active { transform: translateY(1px); }

/* ══════════════════════════════════════════════
   RESULTS — always visible on page load
══════════════════════════════════════════════ */
.dti-results-wrap {
    grid-column: 1 / -1;
}

/* ── GAUGE HERO ───────────────────────────────────────────────────── */
.dti-gauge-hero {
    background: var(--clr-bg);
    border: 1.5px solid var(--clr-border);
    border-radius: 14px;
    padding: 1.375rem 1.5rem 1.25rem;
    margin-bottom: 1.25rem;
}
.dti-gauge-hero-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1rem;
}
.dti-gauge-badge-wrap { display: flex; flex-direction: column; gap: .3rem; }
.dti-gauge-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .75rem;
    border-radius: 99px;
    font-size: .775rem;
    font-weight: 700;
}
.dti-badge-excellent { background: #dcfce7; color: #15803d; }
.dti-badge-good      { background: #d1fae5; color: #065f46; }
.dti-badge-fair      { background: #fef9c3; color: #854d0e; }
.dti-badge-caution   { background: #ffedd5; color: #9a3412; }
.dti-badge-high      { background: #fee2e2; color: #b91c1c; }

.dti-gauge-nums {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.dti-gauge-num-item { text-align: right; }
.dti-gauge-num-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--clr-text-muted);
}
.dti-gauge-num-value {
    font-size: 2rem;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -.02em;
}
.dti-gauge-num-sub {
    font-size: .7rem;
    color: var(--clr-text-muted);
}

/* Segmented gauge bar */
.dti-gauge-bar-wrap { position: relative; }
.dti-gauge-track {
    display: flex;
    height: 18px;
    border-radius: 99px;
    overflow: hidden;
    gap: 2px;
    background: var(--clr-bg-muted);
    padding: 2px;
}
.dti-gauge-seg {
    border-radius: 99px;
    transition: flex .6s cubic-bezier(.4,0,.2,1);
}
.dti-gauge-pointer-wrap {
    position: relative;
    margin-top: 4px;
    height: 20px;
}
.dti-gauge-pointer {
    position: absolute;
    transform: translateX(-50%);
    transition: left .6s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.dti-gauge-pointer-arrow {
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 8px solid var(--clr-text-primary);
}
.dti-gauge-pointer-label {
    font-size: .7rem;
    font-weight: 800;
    color: var(--clr-text-primary);
    white-space: nowrap;
    margin-top: 2px;
}
.dti-gauge-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 22px;
    font-size: .65rem;
    font-weight: 600;
    color: var(--clr-text-muted);
}
.dti-gauge-scale-legend {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-top: .6rem;
}
.dti-gauge-legend-item {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .68rem;
    color: var(--clr-text-secondary);
}
.dti-gauge-legend-dot {
    width: 9px; height: 9px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ── METRICS GRID ─────────────────────────────────────────────────── */
.dti-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .75rem;
    margin-bottom: 1.25rem;
}
@media (max-width: 640px) { .dti-metrics { grid-template-columns: 1fr 1fr; } }
@media (max-width: 360px) { .dti-metrics { grid-template-columns: 1fr; } }

.dti-metric {
    background: var(--clr-bg-soft);
    border: 1.5px solid var(--clr-border);
    border-radius: 11px;
    padding: .875rem .75rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.dti-metric::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 99px 99px 0 0;
}
.dti-metric.dti-m-accent::before  { background: var(--clr-accent); }
.dti-metric.dti-m-teal::before    { background: var(--clr-teal); }
.dti-metric.dti-m-green::before   { background: var(--clr-green); }
.dti-metric.dti-m-amber::before   { background: var(--clr-interest); }

.dti-metric-label {
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--clr-text-muted);
    margin-bottom: .3rem;
}
.dti-metric-value {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--clr-text-primary);
    line-height: 1.1;
}
.dti-metric-sub {
    font-size: .67rem;
    color: var(--clr-text-muted);
    margin-top: .2rem;
}

/* ── BOTTOM GRID: chart left, lender table right ──────────────────── */
.dti-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}
@media (max-width: 700px) { .dti-bottom-grid { grid-template-columns: 1fr; } }

/* ── STACKED BAR CHART ────────────────────────────────────────────── */
.dti-chart-card {
    background: var(--clr-bg);
    border: 1.5px solid var(--clr-border);
    border-radius: 12px;
    padding: 1rem 1.125rem;
}
.dti-chart-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--clr-text-muted);
    margin-bottom: .875rem;
}

/* Horizontal stacked bar */
.dti-hbar-wrap { margin-bottom: 1rem; }
.dti-hbar-label-row {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    font-weight: 600;
    color: var(--clr-text-secondary);
    margin-bottom: .3rem;
}
.dti-hbar-track {
    height: 22px;
    background: var(--clr-bg-muted);
    border-radius: 99px;
    overflow: hidden;
    display: flex;
}
.dti-hbar-seg {
    height: 100%;
    transition: width .7s cubic-bezier(.4,0,.2,1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
}
.dti-hbar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem .875rem;
    margin-top: .5rem;
}
.dti-hbar-leg-item {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .7rem;
    color: var(--clr-text-secondary);
}
.dti-hbar-leg-dot {
    width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}

/* Debt breakdown rows */
.dti-debt-rows { margin-top: .875rem; }
.dti-debt-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem 0;
    border-bottom: 1px solid var(--clr-border-soft);
}
.dti-debt-row:last-child { border-bottom: none; }
.dti-debt-row-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dti-debt-row-name { flex: 1; font-size: .775rem; color: var(--clr-text-secondary); }
.dti-debt-row-amount {
    font-size: .8rem; font-weight: 700; color: var(--clr-text-primary);
    min-width: 4rem; text-align: right;
}
.dti-debt-row-pct {
    font-size: .68rem; color: var(--clr-text-muted);
    min-width: 2.5rem; text-align: right;
}

/* ── LENDER TABLE ─────────────────────────────────────────────────── */
.dti-lender-card {
    background: var(--clr-bg);
    border: 1.5px solid var(--clr-border);
    border-radius: 12px;
    overflow: hidden;
}
.dti-lender-head {
    background: var(--clr-bg-muted);
    padding: .75rem 1.125rem;
    border-bottom: 1.5px solid var(--clr-border);
}
.dti-lender-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--clr-text-muted);
}
.dti-lender-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .78rem;
}
.dti-lender-table thead th {
    padding: .45rem .875rem;
    text-align: left;
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--clr-text-muted);
    background: var(--clr-bg-soft);
    border-bottom: 1px solid var(--clr-border);
}
.dti-lender-table thead th:not(:first-child) { text-align: center; }
.dti-lender-table tbody td {
    padding: .6rem .875rem;
    border-bottom: 1px solid var(--clr-border-soft);
    color: var(--clr-text-secondary);
    vertical-align: middle;
}
.dti-lender-table tbody tr:last-child td { border-bottom: none; }
.dti-lender-table tbody td:not(:first-child) { text-align: center; }
.dti-lender-table tbody td:first-child { font-weight: 600; color: var(--clr-text-primary); }
.dti-lender-table tbody tr:nth-child(even) td { background: var(--clr-bg-soft); }

.dti-status-pill {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .5rem;
    border-radius: 99px;
    font-size: .67rem;
    font-weight: 700;
    white-space: nowrap;
}
.dti-pill-pass   { background: #dcfce7; color: #15803d; }
.dti-pill-maybe  { background: #fef9c3; color: #854d0e; }
.dti-pill-fail   { background: #fee2e2; color: #b91c1c; }

/* ── IMPROVEMENT CARD ─────────────────────────────────────────────── */
.dti-improve-card {
    background: var(--clr-bg);
    border: 1.5px solid var(--clr-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.dti-improve-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--clr-text-muted);
    margin-bottom: .875rem;
}
.dti-improve-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .625rem;
}
@media (max-width: 560px) { .dti-improve-grid { grid-template-columns: 1fr; } }

.dti-improve-row {
    background: var(--clr-bg-soft);
    border: 1.5px solid var(--clr-border);
    border-radius: 9px;
    padding: .75rem .875rem;
}
.dti-improve-row-label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .25rem;
}
.dti-improve-row-value {
    font-size: .9375rem;
    font-weight: 800;
    color: var(--clr-accent-dark);
}
.dti-improve-row-note {
    font-size: .7rem;
    color: var(--clr-text-secondary);
    margin-top: .2rem;
    line-height: 1.4;
}

/* ── TIPS BOX ─────────────────────────────────────────────────────── */
.dti-tips {
    background: var(--clr-warning-bg);
    border: 1.5px solid var(--clr-warning-brd);
    border-radius: 11px;
    padding: .875rem 1.125rem;
    margin-bottom: 1.25rem;
}
.dti-tips-title {
    font-size: .75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--clr-warning-text); margin-bottom: .5rem;
}
.dti-tips ul { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .3rem; }
.dti-tips li { font-size: .8rem; color: var(--clr-text-secondary); line-height: 1.5; }

/* ── ANIMATION ────────────────────────────────────────────────────── */
@keyframes dtiSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.dti-animate { animation: dtiSlideUp .35s ease both; }
.dti-lender-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .78rem;
    
    /* Forces the table to stay within its 100% width */
    table-layout: fixed; 
}

@media screen and (max-width: 600px) {
    .dti-lender-table {
        /* Drop the font size further for mobile */
        font-size: 0.68rem; 
    }

    .dti-lender-table th,
    .dti-lender-table td {
        /* Minimize padding to save horizontal space */
        padding: 4px 2px;
        /* Force long words/numbers to wrap onto new lines */
        word-break: break-all;
        overflow-wrap: break-word;
    }
}