/* ============================================================
   Smart Receipt — UI styling
   ============================================================ */
:root {
    --primary: #6c5ce7;
    --primary-hover: #5649c0;
    --secondary: #00b894;
    --danger: #e74c3c;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --card-bg: rgba(255, 255, 255, 0.96);
    --text-dark: #2d3436;
    --text-light: #7a868f;
    --line: #eef0f3;
    --border-radius: 16px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);

    /* category accents */
    --cat-fuel: #e67e22;
    --cat-groceries: #00b894;
    --cat-dining: #e84393;
    --cat-travel: #0984e3;
    --cat-office: #6c5ce7;
    --cat-utilities: #00cec9;
    --cat-health: #d63031;
    --cat-electronics: #2d3436;
    --cat-general: #b2bec3;
}

* { box-sizing: border-box; }

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-dark);
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

.main-container { width: 100%; max-width: 760px; }
.muted { color: var(--text-light); }

/* ---------- Header ---------- */
header { text-align: center; margin-bottom: 28px; }
.logo {
    font-size: 2.2rem; font-weight: 700;
    color: var(--text-dark); letter-spacing: -1px;
}
.badge {
    background: var(--primary); color: #fff; font-size: 0.7rem;
    padding: 4px 8px; border-radius: 6px; vertical-align: middle;
    letter-spacing: 1px; font-weight: 600;
}
header p { color: var(--text-light); font-weight: 300; margin-top: 6px; }

/* ---------- Cards ---------- */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    backdrop-filter: blur(10px);
}
.card-title { margin: 0; font-size: 1.2rem; }
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 18px; border-bottom: 1px solid var(--line); padding-bottom: 14px;
}
.actions { display: flex; gap: 8px; align-items: center; }
.actions form { margin: 0; }

/* ---------- Banners ---------- */
.banner {
    padding: 14px 18px; border-radius: 12px; margin-bottom: 18px;
    font-weight: 500; font-size: 0.92rem; animation: slideDown 0.4s ease;
}
.banner-success { background: #e3fcef; color: #0a8b5c; }
.banner-error   { background: #fdecea; color: #c0392b; }
.banner-warn    { background: #fff6e0; color: #b9770e; }

/* ---------- Upload ---------- */
.upload-area {
    display: block; border: 2px dashed #d3d9e0; border-radius: 12px;
    padding: 36px; position: relative; cursor: pointer;
    transition: all 0.25s ease; background: #fafbfc; text-align: center;
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary); background: #f3f1ff;
}
.upload-area .icon { font-size: 3rem; margin-bottom: 8px; }
.upload-area h3 { margin: 0 0 4px; }
.file-input {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}
.file-summary { margin: 12px 0 0; font-weight: 600; color: var(--primary); min-height: 1.1em; }

/* ---------- Buttons ---------- */
.btn-primary {
    background: var(--primary); color: #fff; border: none;
    padding: 15px 40px; font-size: 1rem; font-weight: 600; font-family: inherit;
    border-radius: 50px; margin-top: 18px; cursor: pointer; width: 100%;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(108, 92, 231, 0.55); }
.btn-primary:disabled { opacity: 0.7; cursor: progress; transform: none; }

.btn-secondary {
    text-decoration: none; color: var(--primary); font-weight: 600;
    font-size: 0.85rem; border: 2px solid rgba(108, 92, 231, 0.25);
    padding: 7px 14px; border-radius: 8px; transition: all 0.2s;
}
.btn-secondary:hover { background: var(--primary); color: #fff; }

.btn-ghost {
    background: none; border: 2px solid var(--line); color: var(--text-light);
    font-weight: 600; font-size: 0.85rem; font-family: inherit;
    padding: 7px 14px; border-radius: 8px; cursor: pointer; transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--danger); color: var(--danger); }

.btn-del {
    background: none; border: none; color: #c5ccd3; cursor: pointer;
    font-size: 0.95rem; padding: 4px 6px; border-radius: 6px; transition: all 0.15s;
}
.btn-del:hover { background: #fdecea; color: var(--danger); }

/* ---------- Stat cards ---------- */
.stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 14px; margin-bottom: 24px;
}
.stat {
    background: var(--card-bg); border-radius: 14px; padding: 18px;
    box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-light); }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-value.sm { font-size: 1.05rem; }

/* ---------- Category breakdown ---------- */
.cat-bars { display: flex; flex-direction: column; gap: 12px; }
.cat-row { display: grid; grid-template-columns: 130px 1fr 90px; align-items: center; gap: 12px; }
.cat-name { font-size: 0.88rem; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.cat-track { background: var(--line); border-radius: 20px; height: 10px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 20px; background: var(--cat-general); transition: width 0.5s ease; }
.cat-val { text-align: right; font-weight: 600; font-size: 0.88rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--cat-general); }

/* category color hooks (fill, dot, pill) */
.cat-fuel        { background: var(--cat-fuel); }
.cat-groceries   { background: var(--cat-groceries); }
.cat-dining      { background: var(--cat-dining); }
.cat-travel      { background: var(--cat-travel); }
.cat-office      { background: var(--cat-office); }
.cat-utilities   { background: var(--cat-utilities); }
.cat-health      { background: var(--cat-health); }
.cat-electronics { background: var(--cat-electronics); }
.cat-general     { background: var(--cat-general); }

/* ---------- Table ---------- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; color: var(--text-light); font-size: 0.74rem;
    text-transform: uppercase; letter-spacing: 1px; padding: 0 10px 14px; font-weight: 600;
}
th.num, td.num { text-align: right; }
td { padding: 13px 10px; border-bottom: 1px solid #f4f5f7; font-size: 0.92rem; }
.date-badge {
    background: #f1f2f6; color: var(--text-light); padding: 4px 10px;
    border-radius: 6px; font-size: 0.82rem; white-space: nowrap;
}
.vendor-name { font-weight: 600; }
.amount { font-weight: 700; }
.flag {
    color: var(--cat-fuel); font-weight: 700; cursor: help;
    margin-left: 4px; font-size: 0.85rem;
}

/* category pills */
.pill {
    display: inline-block; padding: 3px 11px; border-radius: 20px;
    font-size: 0.76rem; font-weight: 600; color: #fff;
}

tfoot td { padding-top: 18px; border-bottom: none; font-weight: 700; }
.grand-total { color: var(--secondary); font-size: 1.35rem; }

/* ---------- Empty + footer ---------- */
.empty { text-align: center; padding: 50px 28px; }
.empty .icon { font-size: 2.6rem; margin-bottom: 8px; }
.empty h3 { margin: 0 0 4px; }
.footer { text-align: center; font-size: 0.8rem; margin-top: 8px; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .cat-row { grid-template-columns: 100px 1fr 70px; }
    .card { padding: 20px; }
}
