/* =========================================
   CREDIT & DEBT TRACKER
   RESPONSIVE DARK THEME
   ========================================= */


/* =========================================
   ROOT VARIABLES
   ========================================= */

:root {
    --bg: #0b0d10;
    --surface: #111418;
    --surface-2: #171b21;
    --surface-3: #1c2229;

    --border: #252b33;
    --border-light: #303741;

    --text: #f3f4f6;
    --muted: #8b949e;

    --primary: #4ade80;
    --primary-hover: #22c55e;

    --danger: #f87171;
    --danger-hover: #ef4444;

    --warning: #fbbf24;

    --radius: 10px;
    --radius-small: 8px;

    --content-width: 1400px;

    --shadow:
        0 8px 30px rgba(0, 0, 0, 0.18);
}


/* =========================================
   RESET
   ========================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    width: 100%;
    min-height: 100vh;
    margin: 0;

    background: var(--bg);
    color: var(--text);

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    font-size: 15px;
    line-height: 1.5;

    overflow-x: hidden;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}


/* =========================================
   ELEMENT DEFAULTS
   ========================================= */

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
}

form {
    margin: 0;
}

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(26px, 3vw, 36px);
    line-height: 1.2;
}

h2 {
    font-size: clamp(21px, 2vw, 26px);
    line-height: 1.25;
}

h3 {
    font-size: 17px;
    line-height: 1.3;
}


/* =========================================
   NAVBAR
   ========================================= */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;

    width: 100%;

    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: 64px;
    padding: 12px 24px;

    background: rgba(11, 13, 16, 0.95);
    border-bottom: 1px solid var(--border);

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.brand {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}


/* =========================================
   MAIN CONTAINER
   ========================================= */

.container {
    width: min(
        calc(100% - 32px),
        var(--content-width)
    );

    margin: 0 auto;
    padding: 32px 0 60px;
}


/* =========================================
   DASHBOARD HEADER
   ========================================= */

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 28px;
}

.dashboard-header h1 {
    margin-bottom: 0;
}

.dashboard-header p {
    margin: 6px 0 0;
}


/* =========================================
   TEXT
   ========================================= */

.muted {
    color: var(--muted);
}

.text-center {
    text-align: center;
}


/* =========================================
   BUTTONS
   ========================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 44px;

    padding: 0 16px;

    border: 1px solid transparent;
    border-radius: var(--radius-small);

    font-size: 14px;
    font-weight: 600;

    line-height: 1;

    white-space: nowrap;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}


/* PRIMARY */

.btn-primary {
    background: var(--primary);
    color: #07130b;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}


/* SECONDARY */

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-light);
}

.btn-secondary:hover {
    background: var(--surface-3);
    border-color: #3a424d;
}


/* SUCCESS */

.btn-success {
    background: var(--primary);
    color: #07130b;
    border-color: var(--primary);
}

.btn-success:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}


/* DANGER */

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.35);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.10);
    border-color: var(--danger);
}


/* SMALL BUTTON */

.btn-small {
    min-height: 36px;
    height: 36px;

    padding: 0 12px;

    font-size: 13px;

    border-radius: 8px;
}


/* =========================================
   FOCUS
   ========================================= */

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}


/* =========================================
   SUMMARY GRID
   ========================================= */

.summary-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 16px;

    margin-bottom: 40px;
}


/* =========================================
   SUMMARY CARD
   ========================================= */

.summary-card {
    min-width: 0;

    padding: 22px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);
}

.summary-label {
    display: block;

    margin-bottom: 8px;

    color: var(--muted);

    font-size: 13px;
}

.summary-card strong {
    display: block;

    font-size: clamp(22px, 3vw, 30px);
    line-height: 1.2;

    overflow-wrap: anywhere;
}


/* =========================================
   DASHBOARD SECTIONS
   ========================================= */

.dashboard-section {
    margin-top: 42px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;

    margin-bottom: 18px;
}

.section-header h2 {
    margin-bottom: 0;
}

.section-header p {
    margin: 5px 0 0;
}


/* =========================================
   CARD GRID
   ========================================= */

.card-grid {
    display: grid;

    grid-template-columns:
        repeat(
            auto-fit,
            minmax(
                min(100%, 300px),
                1fr
            )
        );

    gap: 16px;
}


/* =========================================
   ITEM CARD
   ========================================= */

.item-card {
    min-width: 0;

    padding: 20px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);

    overflow: hidden;
}


/* =========================================
   CARD HEADER
   ========================================= */

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 12px;
}

.card-header h3 {
    margin-bottom: 5px;

    overflow-wrap: anywhere;
}

.card-header p {
    margin-bottom: 0;

    overflow-wrap: anywhere;
}


/* =========================================
   STATUS
   ========================================= */

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 28px;

    padding: 0 9px;

    border-radius: 999px;

    font-size: 11px;
    font-weight: 700;

    white-space: nowrap;
}

.status-active {
    color: var(--warning);
    background: rgba(251, 191, 36, 0.10);

    border: 1px solid rgba(251, 191, 36, 0.20);
}

.status-paid {
    color: var(--primary);
    background: rgba(74, 222, 128, 0.10);

    border: 1px solid rgba(74, 222, 128, 0.20);
}


/* =========================================
   SAVINGS AMOUNT
   ========================================= */

.saving-amount {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;

    gap: 5px;

    margin-top: 18px;
}

.saving-amount strong {
    font-size: 24px;
    line-height: 1.2;
}

.saving-amount span {
    color: var(--muted);
    font-size: 14px;
}


/* =========================================
   PROGRESS BAR
   ========================================= */

.progress {
    width: 100%;
    height: 8px;

    margin-top: 14px;

    background: var(--surface-3);

    border-radius: 999px;

    overflow: hidden;
}

.progress-bar {
    height: 100%;

    background: var(--primary);

    border-radius: inherit;

    transition: width 0.25s ease;
}


/* =========================================
   SAVINGS INFO
   ========================================= */

.saving-info {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 14px;

    margin-top: 18px;
}

.saving-info div {
    min-width: 0;

    display: flex;
    flex-direction: column;

    gap: 3px;
}

.saving-info .muted {
    font-size: 12px;
}

.saving-info strong {
    font-size: 14px;

    overflow-wrap: anywhere;
}


/* =========================================
   SAVINGS GOAL COMPLETE
   ========================================= */

.goal-complete {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    height: 36px;
    min-height: 36px;

    padding: 0 12px;

    border-radius: 8px;

    background: rgba(74, 222, 128, 0.10);

    color: var(--primary);

    border: 1px solid rgba(74, 222, 128, 0.20);

    font-size: 13px;
    font-weight: 600;

    white-space: nowrap;
}


/* =========================================
   CARD ACTIONS
   ========================================= */

.card-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;

    gap: 8px;

    margin-top: 20px;
}

.card-actions form {
    margin: 0;
}

.card-actions .btn {
    width: auto;
    min-width: 0;
}


/* =========================================
   DEBT AMOUNT
   ========================================= */

.debt-amount {
    display: flex;
    flex-direction: column;

    gap: 3px;

    margin-top: 18px;
}

.debt-amount .muted {
    font-size: 12px;
}

.debt-amount strong {
    font-size: 25px;
    line-height: 1.2;

    overflow-wrap: anywhere;
}


/* =========================================
   DEBT INFO
   ========================================= */

.debt-info {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 12px;

    margin-top: 18px;
}

.debt-info > div {
    min-width: 0;

    display: flex;
    flex-direction: column;

    gap: 3px;
}

.debt-info .muted {
    font-size: 12px;
}

.debt-info strong {
    font-size: 14px;

    overflow-wrap: anywhere;
}


/* =========================================
   EMPTY STATE
   ========================================= */

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;

    gap: 14px;

    min-height: 180px;

    padding: 30px;

    background: var(--surface);

    border: 1px dashed var(--border-light);
    border-radius: var(--radius);

    text-align: center;
}

.empty-state p {
    margin: 0;

    color: var(--muted);
}


/* =========================================
   FLASH MESSAGES
   ========================================= */

.flash-container {
    display: flex;
    flex-direction: column;

    gap: 10px;

    margin-bottom: 24px;
}

.flash {
    padding: 13px 15px;

    border-radius: var(--radius-small);

    border: 1px solid var(--border);

    font-size: 14px;
}

.flash.success {
    background: rgba(74, 222, 128, 0.10);
    color: var(--primary);

    border-color: rgba(74, 222, 128, 0.20);
}

.flash.error {
    background: rgba(248, 113, 113, 0.10);
    color: var(--danger);

    border-color: rgba(248, 113, 113, 0.20);
}

.flash.warning {
    background: rgba(251, 191, 36, 0.10);
    color: var(--warning);

    border-color: rgba(251, 191, 36, 0.20);
}

.flash.info {
    background: rgba(96, 165, 250, 0.10);
    color: #60a5fa;

    border-color: rgba(96, 165, 250, 0.20);
}


/* =========================================
   FORMS
   ========================================= */

.form-container {
    width: 100%;
    max-width: 760px;

    margin: 0 auto;
}

.form-card {
    padding: 24px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);
}

.form-card h1 {
    margin-bottom: 6px;
}

.form-card > p {
    margin-bottom: 24px;
}


.form-group {
    display: flex;
    flex-direction: column;

    gap: 7px;

    margin-bottom: 18px;
}

.form-group label {
    color: var(--text);

    font-size: 13px;
    font-weight: 600;
}


.form-row {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 16px;
}


input,
select,
textarea {
    width: 100%;

    min-height: 44px;

    padding: 10px 12px;

    color: var(--text);

    background: var(--surface-2);

    border: 1px solid var(--border-light);
    border-radius: var(--radius-small);

    outline: none;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #68717c;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px
        rgba(74, 222, 128, 0.10);
}


.form-help {
    margin-top: -10px;

    color: var(--muted);

    font-size: 12px;
}


.form-actions {
    display: flex;
    align-items: center;

    gap: 10px;

    margin-top: 24px;
}


/* =========================================
   PAYMENT FORM
   ========================================= */

.payment-form {
    display: flex;
    align-items: flex-end;

    gap: 10px;

    margin-top: 20px;
}

.payment-form .form-group {
    flex: 1;

    margin-bottom: 0;
}


/* =========================================
   TABLE
   ========================================= */

.table-wrapper {
    width: 100%;

    overflow-x: auto;

    -webkit-overflow-scrolling: touch;

    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--surface);
}

table {
    width: 100%;

    min-width: 600px;

    border-collapse: collapse;
}

th,
td {
    padding: 13px 15px;

    border-bottom: 1px solid var(--border);

    text-align: left;

    font-size: 13px;
}

th {
    color: var(--muted);

    background: var(--surface-2);

    font-size: 12px;
    font-weight: 600;

    white-space: nowrap;
}

tr:last-child td {
    border-bottom: none;
}


/* =========================================
   DEBT DETAIL
   ========================================= */

.debt-summary {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 16px;

    margin-bottom: 28px;
}


/* =========================================
   BACK LINK
   ========================================= */

.back-link {
    display: inline-flex;
    align-items: center;

    min-height: 36px;

    margin-bottom: 20px;

    color: var(--muted);

    font-size: 14px;
}

.back-link:hover {
    color: var(--text);
}


/* =========================================
   ULTRAWIDE SCREENS
   ========================================= */

@media (min-width: 1600px) {

    :root {
        --content-width: 1500px;
    }

    .container {
        padding-top: 40px;
    }

    .card-grid {
        grid-template-columns:
            repeat(
                4,
                minmax(0, 1fr)
            );
    }
}


/* =========================================
   TABLETS / SMALL LAPTOPS
   ========================================= */

@media (max-width: 900px) {

    .container {
        width: min(
            calc(100% - 28px),
            var(--content-width)
        );

        padding-top: 28px;
    }

    .debt-info {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .debt-summary {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .summary-grid {
        gap: 12px;
    }

    .summary-card {
        padding: 18px;
    }
}


/* =========================================
   SMALL TABLETS / LARGE PHONES
   ========================================= */

@media (max-width: 700px) {

    .navbar {
        min-height: 58px;

        padding: 10px 16px;
    }

    .brand {
        font-size: 18px;
    }

    .container {
        width: calc(100% - 24px);

        padding-top: 22px;
        padding-bottom: 40px;
    }


    /* Dashboard */

    .dashboard-header {
        align-items: stretch;

        flex-direction: column;

        gap: 14px;

        margin-bottom: 24px;
    }

    .dashboard-header .btn {
        width: 100%;
    }


    /* Summary */

    .summary-grid {
        grid-template-columns: 1fr;

        margin-bottom: 30px;
    }


    /* Sections */

    .dashboard-section {
        margin-top: 32px;
    }

    .section-header {
        align-items: stretch;

        flex-direction: column;

        gap: 12px;
    }

    .section-header .btn {
        align-self: flex-start;
    }


    /* Forms */

    .form-row {
        grid-template-columns: 1fr;
    }


    /* Debt */

    .debt-info {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }


    .debt-summary {
        grid-template-columns: 1fr;
    }


    /* Actions */

    .card-actions {
        flex-wrap: wrap;
    }


    /* Payment */

    .payment-form {
        align-items: stretch;

        flex-direction: column;
    }

    .payment-form .btn {
        width: 100%;
    }
}


/* =========================================
   PHONES
   ========================================= */

@media (max-width: 520px) {

    .navbar {
        padding: 10px 12px;
    }

    .container {
        width: calc(100% - 20px);

        padding-top: 18px;
    }


    h1 {
        font-size: 26px;
    }

    h2 {
        font-size: 21px;
    }


    /* Cards */

    .item-card {
        padding: 16px;
    }

    .summary-card {
        padding: 16px;
    }


    /* Saving */

    .saving-amount strong {
        font-size: 22px;
    }

    .saving-info {
        gap: 10px;
    }


    /* Debt */

    .debt-info {
        grid-template-columns: 1fr 1fr;

        gap: 10px;
    }


    /* Buttons */

    .btn-small {
        height: 34px;
        min-height: 34px;

        padding: 0 10px;

        font-size: 12px;
    }

    .goal-complete {
        height: 34px;
        min-height: 34px;

        padding: 0 10px;

        font-size: 12px;
    }


    .card-actions {
        gap: 6px;
    }


    /* Forms */

    .form-card {
        padding: 18px 16px;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions .btn {
        width: 100%;
    }
}


/* =========================================
   VERY SMALL PHONES
   ========================================= */

@media (max-width: 360px) {

    .container {
        width: calc(100% - 16px);
    }

    .navbar {
        padding-left: 10px;
        padding-right: 10px;
    }

    .brand {
        font-size: 17px;
    }

    .item-card {
        padding: 14px;
    }

    .summary-card {
        padding: 14px;
    }