/* ==========================================
   Money Tracker — Custom CSS
   ========================================== */

:root {
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --success: #43e97b;
    --danger: #f5576c;
    --warning: #fda085;
    --info: #4facfe;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #2d3748;
    --text-muted: #718096;
    --border: #e2e8f0;
    --nav-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
}

/* ---- Navbar ---- */
#mainNav {
    background: var(--nav-bg) !important;
    box-shadow: 0 2px 20px rgba(102,126,234,.4);
    min-height: 56px;
}
#mainNav .navbar-brand { font-weight: 700; font-size: 1.1rem; }
#mainNav .nav-link { color: rgba(255,255,255,.85) !important; font-size: 0.875rem; padding: .4rem .75rem; border-radius: 6px; transition: background .15s; }
#mainNav .nav-link:hover, #mainNav .nav-link.active { color: #fff !important; background: rgba(255,255,255,.18); }
#mainNav .dropdown-menu { border: none; box-shadow: 0 8px 25px rgba(0,0,0,.15); border-radius: 10px; }

/* ---- Page layout ---- */
.page-wrapper { padding: 1.25rem; max-width: 1400px; margin: 0 auto; }
.page-header { margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; color: var(--text); margin: 0; }
.page-header .text-muted { font-size: 0.85rem; }

/* ---- Stat Cards ---- */
.stat-card {
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
    color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,.12);
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.stat-card .stat-label { font-size: .75rem; opacity: .85; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat-card .stat-sub   { font-size: .75rem; opacity: .8; }
.stat-card .stat-icon  { font-size: 1.8rem; opacity: .25; position: absolute; right: 1rem; top: 1rem; }
.stat-card { position: relative; overflow: hidden; }

.stat-danger  { background: linear-gradient(135deg, #f5576c, #f093fb); }
.stat-success { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.stat-blue    { background: linear-gradient(135deg, #667eea, #764ba2); }
.stat-orange  { background: linear-gradient(135deg, #fda085, #f093fb); }
.stat-teal    { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.stat-green   { background: linear-gradient(135deg, #43e97b, #3dd871); }
.stat-purple  { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }

/* ---- Cards ---- */
.card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    background: var(--card-bg);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: .9rem 1.1rem;
    font-weight: 700;
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.card-body { padding: 1rem 1.1rem; }

/* ---- Tables ---- */
.table { font-size: 0.85rem; }
.table th { font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
.table td { vertical-align: middle; }
.table tbody tr:hover { background: rgba(102,126,234,.04); }

/* ---- Badges & Pills ---- */
.badge { font-weight: 600; font-size: .7rem; }
.pill-status { border-radius: 20px; padding: .2rem .6rem; font-size: .7rem; font-weight: 700; white-space: nowrap; }
.pill-paid    { background: #d1fae5; color: #065f46; }
.pill-unpaid  { background: #fee2e2; color: #991b1b; }
.pill-pending { background: #fef3c7; color: #92400e; }
.pill-received { background: #d1fae5; color: #065f46; }
.pill-expected { background: #e0e7ff; color: #3730a3; }

/* ---- User Badge ---- */
.user-badge {
    width: 36px; height: 36px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-badge.sm { width: 26px; height: 26px; font-size: 11px; }

/* ---- Category Icon ---- */
.cat-icon {
    width: 32px; height: 32px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}

/* ---- Amount colors ---- */
.amount-bill    { color: #e53e3e; font-weight: 700; }
.amount-income  { color: #276749; font-weight: 700; }
.amount-neutral { color: var(--text); font-weight: 700; }

/* ---- Buttons ---- */
.btn { border-radius: 8px; font-weight: 600; font-size: .8rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { padding: .25rem .5rem; font-size: .75rem; }
.btn-icon { padding: .3rem .45rem; border-radius: 6px; }

/* ---- Forms ---- */
.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid var(--border);
    font-size: .85rem;
    padding: .45rem .7rem;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102,126,234,.18);
}
.form-label { font-weight: 600; font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .3rem; }
.input-group-text { background: var(--bg); border: 1.5px solid var(--border); font-size: .85rem; }

/* ---- Modals ---- */
.modal-content { border: none; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-header { border-bottom: 1px solid var(--border); padding: 1rem 1.2rem; }
.modal-header .modal-title { font-weight: 700; font-size: .95rem; }
.modal-footer { border-top: 1px solid var(--border); padding: .8rem 1.2rem; }
.btn-close { opacity: .5; }

/* ---- Alerts ---- */
.alert { border-radius: 10px; border: none; font-size: .85rem; }

/* ---- Next bill card ---- */
.next-bill-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 14px;
    padding: 1rem 1.2rem;
    box-shadow: 0 4px 15px rgba(102,126,234,.35);
}
.next-bill-card .nbc-label { font-size: .7rem; opacity: .8; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.next-bill-card .nbc-name  { font-size: 1.1rem; font-weight: 700; }
.next-bill-card .nbc-date  { font-size: .85rem; opacity: .85; }
.next-bill-card .nbc-amount { font-size: 1.4rem; font-weight: 800; }

/* ---- Chart containers ---- */
.chart-container { position: relative; }
.chart-wrap { max-height: 220px; }

/* ---- Calendar ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day-header { text-align: center; font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); padding: .3rem 0; }
.cal-day {
    min-height: 70px;
    border-radius: 8px;
    padding: .3rem .35rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background .1s;
    overflow: hidden;
}
.cal-day:hover { background: #eef2ff; border-color: var(--primary); }
.cal-day.today { border-color: var(--primary); border-width: 2px; }
.cal-day.other-month { opacity: .35; cursor: default; }
.cal-day .cal-day-num { font-size: .75rem; font-weight: 700; margin-bottom: .15rem; }
.cal-day.today .cal-day-num { color: var(--primary); }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin: 1px; }
.cal-dot.bill   { background: #f5576c; }
.cal-dot.income { background: #43e97b; }

/* ---- Activity log ---- */
.activity-item { display: flex; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.activity-body { flex: 1; min-width: 0; }
.activity-desc { font-size: .83rem; line-height: 1.4; }
.activity-time { font-size: .72rem; color: var(--text-muted); }

/* ---- Account tabs ---- */
.account-tabs .nav-link { border-radius: 8px; font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.account-tabs .nav-link.active { color: var(--primary); background: rgba(102,126,234,.1); }

/* ---- Section heading ---- */
.section-heading { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .5rem; margin-top: 1rem; padding-bottom: .25rem; border-bottom: 2px solid var(--border); }

/* ---- Frequency badge ---- */
.freq-badge { font-size: .68rem; background: #e0e7ff; color: #4338ca; border-radius: 20px; padding: .15rem .5rem; font-weight: 700; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; opacity: .25; margin-bottom: .75rem; display: block; }

/* ---- Filter bar ---- */
.filter-bar { background: white; border-radius: 10px; padding: .6rem .8rem; margin-bottom: 1rem; box-shadow: 0 1px 6px rgba(0,0,0,.06); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---- Loading spinner ---- */
.spinner-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.6); z-index: 9999; display: none; align-items: center; justify-content: center; }
.spinner-overlay.show { display: flex; }

/* ---- Toast ---- */
#toastContainer { position: fixed; top: 70px; right: 1rem; z-index: 9000; display: flex; flex-direction: column; gap: .4rem; }
.toast-msg { padding: .6rem 1rem; border-radius: 10px; font-size: .83rem; font-weight: 600; color: white; box-shadow: 0 4px 15px rgba(0,0,0,.2); animation: slideIn .2s ease; max-width: 300px; }
.toast-success { background: linear-gradient(135deg, #43e97b, #38f9d7); color: #065f46; }
.toast-error   { background: linear-gradient(135deg, #f5576c, #f093fb); }
.toast-info    { background: linear-gradient(135deg, #667eea, #764ba2); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Due soon highlight ---- */
.due-soon td { background: #fffbeb !important; }
.due-today td { background: #fff1f2 !important; }
.due-overdue td { background: #fee2e2 !important; }
.due-overdue .amount-bill,
.due-overdue .fw-600,
.due-overdue .fw-semibold { color: #dc2626 !important; }

/* ---- Scrollable table wrapper ---- */
.table-responsive { border-radius: 10px; }

/* ---- Progress bar ---- */
.progress { height: 6px; border-radius: 3px; }

/* ---- Symbol badges ---- */
.sym-badge { font-family: monospace; font-size: .75rem; background: var(--bg); border-radius: 4px; padding: .1rem .35rem; border: 1px solid var(--border); }

/* =====================================================
   Info modal
   ===================================================== */
.info-modal-body { }
.info-hero {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.info-hero-bill    { background: linear-gradient(135deg, #fff5f5, #fff); }
.info-hero-income  { background: linear-gradient(135deg, #f0fdf4, #fff); }
.info-hero-type    { font-size: .8rem; color: #6c757d; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.info-hero-amount  { font-size: 1.6rem; font-weight: 700; color: #212529; }
.info-hero-bill   .info-hero-amount { color: #dc3545; }
.info-hero-income .info-hero-amount { color: #198754; }

.info-rows        { padding: .5rem 0; }
.info-row {
    display: flex;
    align-items: flex-start;
    padding: .5rem 1.5rem;
    gap: .75rem;
    border-bottom: 1px solid #f3f4f6;
}
.info-row:last-child { border-bottom: none; }
.info-label {
    flex: 0 0 140px;
    font-size: .78rem;
    color: #6c757d;
    font-weight: 600;
    padding-top: 2px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.info-value {
    flex: 1;
    font-size: .9rem;
    color: #212529;
    word-break: break-word;
}
.info-cat-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.info-notes {
    white-space: pre-wrap;
    font-size: .85rem;
    color: #555;
}
.info-row-notes { align-items: flex-start; }

/* info button */
.btn-icon.btn-info-rec {
    color: #0dcaf0;
    border-color: #0dcaf0;
}
.btn-icon.btn-info-rec:hover {
    background: #0dcaf0;
    color: #fff;
}

@media (max-width: 576px) {
    .info-label { flex: 0 0 110px; }
    .info-hero-amount { font-size: 1.3rem; }
}

/* Ended repeating record pill */
.pill-ended { background: #e2e8f0; color: #475569; }