:root {
    --bg-color: #f8f9fa;
    --text-primary: #212529;
    --primary: #228be6;
    --success: #40c057;
    --warning: #fa5252;
    --card-bg: #ffffff;
    --border: #dee2e6;
    --radius: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Base Dark Mode */
[data-theme="dark"] {
    --bg-color: #141517;
    --text-primary: #c1c2c5;
    --card-bg: #25262b;
    --border: #373a40;
}

/* Girl Mode Overrides */
[data-style="girl"] {
    --primary: #ff85a2;
    --success: #f06292;
}

/* Fix: Combined Dark + Girl Mode */
[data-theme="dark"][data-style="girl"] {
    --card-bg: #2d1b1e;
    --bg-color: #1a1012;
    --border: #442a2e;
    --text-primary: #f8f0f2;
}

/* Base Reset & Browser Fixes */
* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font);
    padding: 12px;
    line-height: 1.4;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container { max-width: 500px; margin: 0 auto; }

header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 10px 0 20px 0; 
}

h1 { 
    font-size: 20px; 
    font-weight: 800; 
    letter-spacing: -0.5px; 
    display: flex; 
    align-items: center; 
}

/* Mascot Setup */
#pompom-icon {
    display: none; 
    width: 30px;
    height: 30px;
    margin-right: 8px;
    object-fit: contain;
}

[data-style="girl"] #pompom-icon {
    display: block;
    animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Card Styling */
.mantine-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

.card-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    cursor: pointer; 
}

.card-header h2, .card-header h3 { 
    font-size: 15px; 
    font-weight: 700; 
}

/* Status Indicator */
.status-indicator { 
    display: flex; 
    justify-content: space-between;
    align-items: center; 
    width: 100%;
    margin-right: 10px;
}

.live-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 800;
}

.code-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: monospace;
    font-size: 13px;
    font-weight: 700;
    opacity: 0.8;
}

.dot { 
    height: 8px; 
    width: 8px; 
    border-radius: 50%; 
    flex-shrink: 0;
}
.dot.disconnected { background: #fd7e14; }
.dot.connected { background: var(--success); }

/* Grid System */
.config-grid { 
    display: grid; 
    grid-template-columns: 1.3fr 0.7fr; 
    gap: 8px; 
    margin-top: 15px; 
    width: 100%;
    align-items: flex-end;
}

.input-group { display: flex; flex-direction: column; min-width: 0; }

label { 
    font-size: 10px; 
    font-weight: 800; 
    text-transform: uppercase; 
    margin-bottom: 4px; 
    opacity: 0.6; 
}

/* Inputs */
input[type="text"], 
input[type="number"], 
input[type="date"] { 
    height: 40px; 
    padding: 0 10px; 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    background: var(--bg-color); 
    color: var(--text-primary); 
    font-size: 16px; 
    width: 100%;
    outline: none;
    -webkit-appearance: none; 
    appearance: none;
}

input[type="date"] {
    font-size: 13px;
    padding: 0 4px;
    text-align: center;
}

/* Buttons */
.btn { 
    height: 40px; 
    padding: 0 16px; 
    border-radius: 8px; 
    border: none; 
    font-weight: 700; 
    cursor: pointer; 
    font-size: 14px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: opacity 0.2s, background-color 0.3s;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }

.btn-danger { 
    background: #fff5f5; 
    color: var(--warning); 
    border: 1px solid #ffc9c9; 
    justify-content: center;
}
[data-theme="dark"] .btn-danger { background: #2c1a1a; border-color: #442a2e; }

.icon-btn { padding: 8px; width: 38px; height: 38px; flex-shrink: 0; }

/* Dashboard */
.dashboard-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr 1fr; 
    gap: 8px; 
    text-align: center; 
    margin-top: 15px; 
}

.stat-box h3 { font-size: 10px; text-transform: uppercase; opacity: 0.5; margin-bottom: 2px; }
.stat-box p { font-weight: 800; font-size: 13px; }

/* Spending List */
.spending-list { margin-top: 15px; }
.spending-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 10px 0; 
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.spending-item > span { 
    flex: 1; 
    min-width: 0; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    font-size: 14px; 
}

/* FIXED: Tiny Trash Button */
.spending-item .btn-danger.icon-btn {
    width: 28px !important; 
    height: 28px !important; 
    min-width: 28px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    border-radius: 6px !important;
    background: #fff5f5;
}

/* FIXED: Icon inside */
.spending-item .btn-danger.icon-btn i,
.spending-item .btn-danger.icon-btn svg {
    width: 14px !important; 
    height: 14px !important;
    stroke: var(--warning) !important;
}

/* Collapsible */
.collapse-icon { transition: transform 0.3s; opacity: 0.4; width: 18px; height: 18px; }
.collapsed .collapse-icon { transform: rotate(-90deg); }
.collapsed .collapsible-content { display: none; }

/* Modals */
.modal { 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.8); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 1000; 
    padding: 20px; 
    backdrop-filter: blur(4px); 
    -webkit-backdrop-filter: blur(4px);
}

/* FIXED: Modal sizing */
.modal-content {
    animation: modalPop 0.25s ease-out;
    max-height: 90vh;
    width: 95%;
    max-width: 400px;
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 20px;
    border-radius: var(--radius);
}

.hidden { display: none !important; }

/* Scrollable history */
#history-list {
    max-height: 60vh;
    overflow-y: auto;
    margin-top: 15px;
}
