:root{
    --bg:#0b1020;
    --bg-soft:#121933;
    --panel:#ffffff;
    --panel-2:#f8faff;
    --text:#172033;
    --muted:#667085;
    --line:#e8edf5;
    --primary:#4f7cff;
    --primary-2:#6fa1ff;
    --success:#12b76a;
    --danger:#ef4444;
    --warning:#f59e0b;
    --shadow:0 18px 60px rgba(14, 24, 46, 0.12);
    --radius:22px;
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
    font-family:Inter,Arial,sans-serif;
    background:
        radial-gradient(circle at top left, rgba(79,124,255,.22), transparent 28%),
        radial-gradient(circle at top right, rgba(111,161,255,.20), transparent 26%),
        linear-gradient(180deg, #f4f8ff 0%, #edf3ff 100%);
    color:var(--text);
}
a{color:var(--primary);text-decoration:none}
h1,h2,h3,p{margin-top:0}

.auth-body{
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:24px;
}
.auth-wrap{
    width:min(1080px,100%);
    display:grid;
    grid-template-columns:1.05fr .95fr;
    gap:24px;
}
.brand-card,.auth-card,.panel,.simple-card{
    background:rgba(255,255,255,.9);
    backdrop-filter:blur(8px);
    border:1px solid rgba(255,255,255,.6);
    border-radius:28px;
    box-shadow:var(--shadow);
}
.brand-card{
    padding:42px;
    min-height:540px;
    display:flex;
    flex-direction:column;
    justify-content:center;
    background:
        linear-gradient(135deg, rgba(79,124,255,.12), rgba(111,161,255,.18)),
        rgba(255,255,255,.92);
}
.auth-card,.simple-card{
    padding:34px;
}
.logo{
    width:58px;height:58px;border-radius:18px;
    display:flex;align-items:center;justify-content:center;
    font-weight:800;font-size:26px;color:#fff;
    background:linear-gradient(135deg,var(--primary),var(--primary-2));
    box-shadow:0 12px 24px rgba(79,124,255,.28);
    margin-bottom:18px;
}
.form-stack{
    display:grid;
    gap:12px;
}
label{
    font-size:.95rem;
    font-weight:700;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="month"],
select{
    width:100%;
    border:1px solid var(--line);
    border-radius:16px;
    padding:14px 16px;
    font-size:1rem;
    background:#fff;
    color:var(--text);
    outline:none;
}
input[type="month"]{
    padding-right:48px;
}
input:focus{
    border-color:var(--primary);
    box-shadow:0 0 0 4px rgba(79,124,255,.12);
}
input[type="range"]{
    width:100%;
    accent-color:var(--primary);
}
button,.ghost-btn,.danger-btn{
    border:none;
    border-radius:16px;
    padding:13px 16px;
    font-weight:700;
    cursor:pointer;
    transition:.2s ease;
    display:inline-flex;
    align-items:center;
    justify-content:center;
}
button{
    background:linear-gradient(135deg,var(--primary),var(--primary-2));
    color:#fff;
    box-shadow:0 10px 20px rgba(79,124,255,.24);
}
button:hover,.ghost-btn:hover,.danger-btn:hover{transform:translateY(-1px)}
.ghost-btn{
    background:#eef4ff;
    color:var(--primary);
}
.danger-btn{
    background:#fff1f2;
    color:var(--danger);
}
.full{width:100%}

.alert{
    padding:14px 16px;
    border-radius:16px;
    margin-bottom:18px;
    font-weight:600;
}
.alert.success{background:#ecfdf3;color:#027a48}
.alert.error{background:#fef3f2;color:#b42318}

.muted{color:var(--muted)}
.small-text{font-size:.88rem}
.badge,.pill{
    display:inline-flex;
    align-items:center;
    gap:6px;
    padding:7px 10px;
    border-radius:999px;
    font-size:.82rem;
    font-weight:700;
}
.badge{background:#eef4ff;color:var(--primary)}
.pill.info{background:#eff6ff;color:#1d4ed8}
.pill.success{background:#ecfdf3;color:#027a48}

.app-shell{
    display:grid;
    grid-template-columns:280px 1fr;
    min-height:100vh;
}
.sidebar{
    padding:24px;
    background:linear-gradient(180deg,#0d1430 0%, #131c3f 100%);
    color:#fff;
    display:flex;
    flex-direction:column;
    justify-content:space-between;
    gap:20px;
    position:sticky;
    top:0;
    height:100vh;
}
.sidebar .logo{margin-bottom:0}
.sidebar-brand{
    display:flex;
    align-items:center;
    gap:14px;
    margin-bottom:28px;
}
.side-nav{
    display:grid;
    gap:10px;
}
.side-nav a{
    color:#dbe5ff;
    padding:12px 14px;
    border-radius:14px;
    background:rgba(255,255,255,.04);
}
.side-nav a:hover{
    background:rgba(255,255,255,.08);
}
.sidebar .ghost-btn{
    background:rgba(255,255,255,.08);
    color:#fff;
}

.main-content{
    padding:28px;
}
.page-header{
    display:flex;
    justify-content:space-between;
    gap:16px;
    align-items:flex-start;
    margin-bottom:22px;
}
.stats-grid{
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:18px;
    margin-bottom:22px;
}
.stat-card{
    background:rgba(255,255,255,.92);
    border:1px solid rgba(255,255,255,.7);
    border-radius:24px;
    padding:22px;
    box-shadow:var(--shadow);
}
.stat-card span{
    display:block;
    color:var(--muted);
    margin-bottom:8px;
}
.stat-card strong{
    font-size:1.5rem;
}

.panel-grid{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:18px;
    margin-bottom:22px;
}
.panel{
    padding:24px;
}
.panel-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom:18px;
}
.split-labels{
    display:flex;
    justify-content:space-between;
    gap:10px;
    color:var(--muted);
    font-size:.95rem;
}

.goal-list{
    display:grid;
    gap:16px;
}
.goal-card{
    border:1px solid var(--line);
    background:linear-gradient(180deg,#fff,#fbfdff);
    border-radius:22px;
    padding:20px;
}
.goal-card-top{
    display:flex;
    justify-content:space-between;
    gap:16px;
    align-items:flex-start;
    margin-bottom:12px;
}
.goal-actions{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}
.goal-actions form{margin:0}
.goal-values{
    display:flex;
    justify-content:space-between;
    gap:12px;
    font-weight:700;
    margin-bottom:10px;
}
.progress-wrap{
    display:grid;
    grid-template-columns:1fr auto;
    gap:12px;
    align-items:center;
    margin-bottom:12px;
}
.progress-bar{
    width:100%;
    height:14px;
    border-radius:999px;
    overflow:hidden;
    background:#e8eefc;
    position:relative;
}
.progress-fill{
    height:100%;
    border-radius:999px;
    background:linear-gradient(90deg,#4f7cff,#6fa1ff 55%, #8ab5ff);
    box-shadow:0 0 24px rgba(79,124,255,.28);
}
.progress-text{
    font-weight:800;
    color:var(--primary);
}
.goal-meta{
    display:flex;
    justify-content:space-between;
    gap:12px;
    align-items:center;
    flex-wrap:wrap;
}
.empty-state{
    padding:28px;
    border:1px dashed var(--line);
    border-radius:18px;
    text-align:center;
    background:var(--panel-2);
}

.simple-page{
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:24px;
}
.simple-card{
    width:min(720px,100%);
}
.action-row{
    display:flex;
    gap:12px;
    flex-wrap:wrap;
    margin-top:8px;
}

@media (max-width: 1100px){
    .stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
    .panel-grid{grid-template-columns:1fr}
}
@media (max-width: 900px){
    .auth-wrap{grid-template-columns:1fr}
    .app-shell{grid-template-columns:1fr}
    .sidebar{
        position:relative;
        height:auto;
        border-bottom-left-radius:24px;
        border-bottom-right-radius:24px;
    }
}
@media (max-width: 640px){
    .main-content{padding:18px}
    .stats-grid{grid-template-columns:1fr}
    .goal-card-top,.goal-values,.goal-meta,.panel-head,.page-header{
        flex-direction:column;
        align-items:flex-start;
    }
    .progress-wrap{grid-template-columns:1fr}
}

.table-wrap{
    width:100%;
    overflow-x:auto;
    border:1px solid var(--line);
    border-radius:18px;
    background:#fff;
}

.history-table{
    width:100%;
    border-collapse:collapse;
    min-width:760px;
}

.history-table th,
.history-table td{
    padding:14px 16px;
    text-align:left;
    border-bottom:1px solid var(--line);
    vertical-align:top;
}

.history-table th{
    font-size:.9rem;
    color:var(--muted);
    background:#f8fbff;
}

.history-table tr:last-child td{
    border-bottom:none;
}

@media (max-width: 640px){
    .history-table,
    .history-table thead,
    .history-table tbody,
    .history-table th,
    .history-table td,
    .history-table tr{
        display:block;
    }

    .history-table{
        min-width:100%;
    }

    .history-table thead{
        display:none;
    }

    .history-table tbody{
        display:grid;
        gap:12px;
        padding:12px;
    }

    .history-table tr{
        border:1px solid var(--line);
        border-radius:16px;
        padding:12px;
        background:#fff;
    }

    .history-table td{
        border:none;
        padding:8px 0;
    }

    .history-table td::before{
        content:attr(data-label);
        display:block;
        font-size:.82rem;
        font-weight:700;
        color:var(--muted);
        margin-bottom:2px;
    }
}

.main-content{
    padding:28px;
    min-width:0;
}

.panel{
    padding:24px;
    min-width:0;
}

.payment-history-panel{
    margin-top: 22px;
}

.goals-panel {
    margin-bottom:22px;
}

.table-wrap{
    width:100%;
    max-width:100%;
    overflow-x:auto;
}

.goal-card,
.goal-card-top,
.goal-actions,
.progress-wrap,
.stats-grid,
.panel-grid{
    min-width:0;
}

@media (max-width: 900px){
    .app-shell{
        grid-template-columns:1fr;
        width:100%;
        max-width:100%;
        overflow-x:hidden;
    }

    .sidebar,
    .main-content{
        width:100%;
        max-width:100%;
    }
}

select{
    width:100%;
    border:1px solid var(--line);
    border-radius:16px;
    padding:14px 16px;
    font-size:1rem;
    background:#fff;
    color:var(--text);
    outline:none;
}
select:focus{
    border-color:var(--primary);
    box-shadow:0 0 0 4px rgba(79,124,255,.12);
}

.history-accordion{
    display:grid;
    gap:14px;
}

.history-group{
    border:1px solid var(--line);
    border-radius:18px;
    background:linear-gradient(180deg,#fff,#fbfdff);
    overflow:hidden;
}

.history-summary{
    list-style:none;
    cursor:pointer;
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:16px;
    padding:18px 20px;
}

.history-summary::-webkit-details-marker{
    display:none;
}

.history-summary-main{
    display:flex;
    flex-direction:column;
    gap:4px;
}

.history-type{
    color:var(--muted);
    font-size:.95rem;
}

.history-summary-side{
    display:flex;
    flex-direction:column;
    align-items:flex-end;
    gap:4px;
    flex-shrink:0;
}

.history-total{
    font-weight:800;
    color:var(--primary);
}

.history-count{
    color:var(--muted);
    font-size:.9rem;
}

.history-details{
    border-top:1px solid var(--line);
    padding:10px 20px 16px;
    background:#fcfdff;
}

.history-detail-head,
.history-detail-row{
    display:grid;
    grid-template-columns:2fr 1fr 1fr;
    gap:14px;
    padding:10px 0;
}

.history-detail-head{
    color:var(--muted);
    font-size:.85rem;
    font-weight:700;
}

.history-detail-row{
    border-top:1px solid #eef2f8;
}

.history-detail-row:first-of-type{
    border-top:none;
}

.history-group[open] .history-summary{
    background:#f8fbff;
}

@media (max-width: 640px){
    .history-summary{
        flex-direction:column;
        align-items:flex-start;
    }

    .history-summary-side{
        align-items:flex-start;
    }

    .history-detail-head{
        display:none;
    }

    .history-detail-row{
        grid-template-columns:1fr;
        gap:8px;
        padding:12px 0;
    }

    .history-detail-row span::before{
        content:attr(data-label);
        display:block;
        font-size:.82rem;
        font-weight:700;
        color:var(--muted);
        margin-bottom:2px;
    }
}
