:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333333;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --accent: #4a9eff;
    --accent-hover: #3a8eef;
    --success: #4caf50;
    --danger: #f44336;
    --warning: #ff9800;
    --border: #444444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--bg-secondary);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    transition: left 0.3s ease;
    z-index: 1001;
    display: flex;
    flex-direction: column;
}

@media (max-width: 768px) {
    .sidebar {
        left: -280px;
    }

    .sidebar.active {
        left: 0;
    }
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    margin: 0;
    color: var(--accent);
    font-size: 1.5rem;
}

.sidebar-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.3s;
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: none;
}

@media (max-width: 768px) {
    .sidebar-close {
        display: block;
    }
}

.sidebar-close:hover {
    color: var(--text-primary);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav-top {
    display: flex;
    flex-direction: column;
}

.sidebar-nav-bottom {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.3s;
}

.sidebar-link:hover {
    background: var(--bg-tertiary);
}

.sidebar-link.active {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent);
}

.sidebar-icon {
    font-size: 1.5rem;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    display: none;
}

@media (max-width: 768px) {
    .sidebar-overlay {
        display: block;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* Hamburger */
.hamburger {
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 50px;
    height: 50px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    z-index: 999;
    transition: background 0.3s;
}

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
}

.hamburger:hover {
    background: var(--bg-tertiary);
}

.hamburger span {
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

.container {
    max-width: min(90vw, 1200px);
    margin: 0 auto;
    margin-left: 280px;
    padding: clamp(1rem, 3vw, 2rem);
}

@media (max-width: 768px) {
    .container {
        margin-left: auto;
    }
}

/* Header */
header {
    background: var(--bg-secondary);
    padding: clamp(0.75rem, 2vw, 1.25rem);
    border-radius: 0.5rem;
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.month-navigation {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.month-navigation h1 {
    font-size: clamp(1.2rem, 3vw, 1.75rem);
    color: var(--accent);
    margin: 0;
    min-width: 150px;
    text-align: center;
    white-space: nowrap;
}

.month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 0.25rem;
    font-size: 1.2rem;
    transition: background 0.3s;
    flex-shrink: 0;
}

.month-nav:hover:not(.disabled) {
    background: var(--border);
}

.month-nav.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.header-stats-inline {
    display: flex;
    gap: clamp(1rem, 3vw, 2rem);
    flex-wrap: wrap;
}

.header-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

@media (max-width: 1024px) {
    header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .month-navigation {
        justify-content: center;
    }

    .header-stats-inline {
        justify-content: space-around;
    }

    .header-stat {
        align-items: center;
    }
}

@media (max-width: 768px) {
    .header-stats-inline {
        flex-direction: column;
        gap: 0.75rem;
    }

    .header-stat {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .stat-label {
        text-align: left;
    }

    .stat-value {
        text-align: right;
    }
}

/* Balance */
.balance {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: bold;
}

.balance.positive {
    color: var(--success);
}

.balance.negative {
    color: var(--danger);
}

/* Stats */
.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: bold;
}

.stat-value.positive {
    color: var(--success);
}

.stat-value.negative {
    color: var(--danger);
}

/* Forms */
.add-transaction, .login-box {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.add-transaction .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(0.75rem, 2vw, 1.25rem);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.add-transaction .section-header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.add-transaction h3 {
    margin: 0;
    color: var(--accent);
    font-size: clamp(1.2rem, 3vw, 1.5rem);
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.3s;
    padding: 0.5rem;
    line-height: 1;
}

.toggle-btn.collapsed {
    transform: rotate(-90deg);
}

.section-content {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.3s ease, padding 0.3s ease;
    padding: 0 clamp(0.75rem, 2vw, 1.25rem) clamp(0.75rem, 2vw, 1.25rem);
}

.section-content > * {
    overflow: hidden;
}

.section-content.collapsed {
    grid-template-rows: 0fr;
    padding-top: 0;
    padding-bottom: 0;
}

.login-box {
    padding: clamp(0.75rem, 2vw, 1.25rem);
}

.login-box h1 {
    margin-bottom: 0.75rem;
    color: var(--accent);
    font-size: clamp(1.2rem, 3vw, 1.5rem);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 0.75rem;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row-icon-color {
    grid-template-columns: 1fr 1fr;
}

.form-submit {
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.modal-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.2rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.form-group input, .form-group select {
    padding: 0.6rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input[type="color"] {
    height: 3rem;
    padding: 0.25rem;
    cursor: pointer;
    width: 100%;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.radio-group {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

.radio-label input[type="radio"] {
    width: auto;
    cursor: pointer;
}

.recurring-options {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border);
}

.field-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    display: block;
}

.tooltip-icon {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    line-height: 1rem;
    text-align: center;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 0.75rem;
    margin-left: 0.25rem;
    cursor: help;
    font-weight: normal;
    border: 1px solid var(--border);
    position: relative;
}

.tooltip-icon:hover {
    background: var(--border);
    color: var(--text-primary);
}

.tooltip-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.tooltip-icon:hover::after {
    opacity: 1;
}

button[type="submit"], .btn-add {
    padding: 0.6rem 1.25rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 0.25rem;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.3s;
    height: fit-content;
}

button[type="submit"]:hover, .btn-add:hover {
    background: var(--accent-hover);
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
    padding: 1rem;
}

.login-container {
    width: 100%;
    max-width: 450px;
}

.login-card {
    background: var(--bg-secondary);
    border-radius: 1rem;
    padding: 3rem 2.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    margin: 0 auto 1rem;
    box-shadow: 0 10px 30px rgba(74, 158, 255, 0.3);
}

.login-header h1 {
    font-size: 2rem;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

.login-form {
    margin-bottom: 1.5rem;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    flex: 1;
    padding-right: 3rem;
}

.toggle-password {
    position: absolute;
    right: 0.75rem;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    font-size: 1.2rem;
}

.toggle-password:hover {
    transform: scale(1.1);
}

.toggle-password:active {
    transform: scale(0.95);
}

.eye-icon {
    user-select: none;
    filter: grayscale(0.3);
}

.btn-login {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(74, 158, 255, 0.3);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 158, 255, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.login-footer {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.login-footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.login-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.login-footer a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.error {
    background: rgba(244, 67, 54, 0.2);
    color: var(--danger);
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--danger);
    animation: shake 0.5s;
}

.success {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid #4caf50;
    animation: fadeIn 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Transactions */
.transactions {
    background: var(--bg-secondary);
    padding: clamp(1rem, 3vw, 2rem);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.transactions h3 {
    margin-bottom: 1rem;
    color: var(--accent);
    font-size: clamp(1.2rem, 3vw, 1.5rem);
}

.no-data {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    overflow-x: auto;
    display: block;
}

@media (min-width: 768px) {
    table {
        display: table;
    }
}

thead {
    background: var(--bg-tertiary);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.sort-link {
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
    display: inline-block;
}

.sort-link:hover {
    color: var(--accent);
}

tbody tr {
    transition: all 0.2s ease;
    position: relative;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

tbody tr:target {
    animation: flashGreen 1.5s ease-out;
}

@keyframes flashGreen {
    0% {
        background: rgba(76, 175, 80, 0.4);
    }
    100% {
        background: transparent;
    }
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge.recette {
    background: rgba(76, 175, 80, 0.2);
    color: var(--success);
}

.badge.depense {
    background: rgba(244, 67, 54, 0.2);
    color: var(--danger);
}

.recurring-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(74, 158, 255, 0.2);
    color: var(--accent);
    border: 1px solid var(--accent);
}

.recurring-badge.infinite {
    background: rgba(255, 152, 0, 0.2);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.amount {
    font-weight: 600;
}

.amount.recette {
    color: var(--success);
}

.amount.depense {
    color: var(--danger);
}

.btn-delete {
    padding: 0.5rem;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
    line-height: 1;
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
}

.btn-edit {
    padding: 0.5rem;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
    line-height: 1;
    margin-right: 0.5rem;
}

.btn-edit:hover {
    background: var(--accent);
    color: white;
}

.actions {
    white-space: nowrap;
}

/* Modales */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: min(90vw, 500px);
    width: 100%;
    animation: slideIn 0.3s ease;
}

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

.modal-content.modal-confirm {
    max-width: min(90vw, 400px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--accent);
    font-size: 1.25rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.3s;
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content form {
    padding: 1.5rem;
}

.modal-content p {
    padding: 1.5rem;
    padding-top: 0;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.btn-primary {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 0.25rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    padding: 0.75rem 1.5rem;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 0.25rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-danger:hover {
    background: #d32f2f;
}

/* Delete modal info */
.delete-transaction-info {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1rem 1.5rem;
    border-left: 3px solid var(--danger);
}

.delete-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.delete-info-item:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.delete-info-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Autocomplétion */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 0.25rem 0.25rem;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.autocomplete-item {
    padding: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-primary);
}

.autocomplete-item:hover {
    background: var(--bg-secondary);
}

/* Categories page */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 450px), 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.category-section h2 {
    color: var(--accent);
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    margin-bottom: 1rem;
}

.categories-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.category-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s;
}

.category-card:hover {
    transform: translateY(-2px);
}

.category-info {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.category-details h4 {
    margin: 0 0 0.25rem 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.category-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.category-actions {
    display: flex;
    gap: 0.5rem;
}

/* Icon picker */
.form-group input[readonly] {
    text-align: center;
    font-size: 1.5rem;
}

.modal-emoji {
    max-width: min(90vw, 600px);
    max-height: 80vh;
}

.emoji-grid {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.emoji-category {
    margin-bottom: 1.5rem;
}

.emoji-category h4 {
    margin: 0 0 0.75rem 0;
    color: var(--accent);
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.emoji-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.5rem;
}

.emoji-item-wrapper {
    position: relative;
}

.emoji-item {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.emoji-item:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.1);
}

.emoji-item.emoji-used {
    border-color: var(--warning);
    background: rgba(255, 152, 0, 0.1);
}

.emoji-item.emoji-used:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.emoji-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--warning);
    color: var(--bg-primary);
    font-size: 0.7rem;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.emoji-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--warning);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    white-space: nowrap;
    font-size: 0.85rem;
    pointer-events: none;
}

.emoji-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--warning);
}

.emoji-tooltip.emoji-tooltip-below::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--warning);
}

.emoji-tooltip strong {
    color: var(--warning);
}

.emoji-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    border-left: 4px solid var(--warning);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    max-width: 400px;
}

.emoji-notification.show {
    opacity: 1;
    transform: translateY(0);
}

/* Stats page */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 500px), 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.chart-card {
    background: var(--bg-secondary);
    padding: clamp(1rem, 3vw, 2rem);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.chart-card h3 {
    margin-bottom: 1.5rem;
    color: var(--accent);
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    text-align: center;
}

.chart-card canvas {
    max-height: 400px;
}

/* Settings page */
.settings-header {
    display: block !important;
    padding: clamp(0.75rem, 2vw, 1.25rem) !important;
}

.settings-header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: var(--accent);
    margin: 0;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.settings-card {
    background: var(--bg-secondary);
    padding: clamp(1rem, 3vw, 2rem);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.settings-card h3 {
    margin: 0 0 1.5rem 0;
    color: var(--accent);
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    gap: 2rem;
}

.setting-item:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.setting-info {
    flex: 1;
}

.setting-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.setting-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.4;
}

.setting-control {
    flex-shrink: 0;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 28px;
    transition: all 0.3s;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent);
    border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
    background-color: white;
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Admin page */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.admin-stat-card {
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 0.5rem;
    text-align: center;
    border: 1px solid var(--border);
}

.admin-stat-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.admin-stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.admin-stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.migration-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.migration-badge.warning {
    background: rgba(255, 152, 0, 0.2);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.migration-badge.success {
    background: rgba(76, 175, 80, 0.2);
    color: var(--success);
    border: 1px solid var(--success);
}

.migration-warning {
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid var(--warning);
    border-left: 4px solid var(--warning);
    padding: 1rem;
    border-radius: 0.25rem;
    margin-bottom: 1.5rem;
}

.migrations-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.migration-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.25rem;
    border-left: 3px solid var(--border);
}

.migration-item.executed {
    border-left-color: var(--success);
    opacity: 0.7;
}

.migration-item.pending {
    border-left-color: var(--warning);
}

.migration-info {
    flex: 1;
}

.migration-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.migration-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-secondary-small {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary-small:hover {
    background: var(--border);
}

.pending-migrations-alert {
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid var(--warning);
    border-left: 4px solid var(--warning);
    padding: 1rem;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pending-migrations-alert a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.pending-migrations-alert a:hover {
    text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 0.75rem 0.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-row.form-row-icon-color {
        grid-template-columns: 1fr 1fr;
    }

    .form-group {
        min-width: 0;
    }

    input[type="text"],
    input[type="color"] {
        max-width: 100%;
    }

    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .setting-control {
        align-self: flex-end;
    }
}

/* Flash Messages */
.flash-messages {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 400px;
}

.flash-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background: var(--bg-secondary);
    border-left: 4px solid;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.flash-message.flash-success {
    border-left-color: var(--success);
}

.flash-message.flash-error {
    border-left-color: var(--danger);
}

.flash-message.flash-info {
    border-left-color: var(--accent);
}

.flash-icon {
    font-size: 1.5rem;
    font-weight: bold;
    flex-shrink: 0;
}

.flash-success .flash-icon {
    color: var(--success);
}

.flash-error .flash-icon {
    color: var(--danger);
}

.flash-info .flash-icon {
    color: var(--accent);
}

.flash-text {
    flex: 1;
    color: var(--text-primary);
    line-height: 1.4;
}

.flash-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    flex-shrink: 0;
}

.flash-close:hover {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .flash-messages {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }

    .flash-message {
        padding: 0.875rem 1rem;
    }
}

/* Category Display with Color Dot */
.category-display {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.category-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.category-icon {
    font-size: 1.2rem;
    line-height: 1;
}

/* Action Buttons in Table */
.actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.btn-edit,
.btn-delete {
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
}

.btn-edit {
    background: rgba(74, 158, 255, 0.15);
    color: var(--accent);
}

.btn-edit:hover {
    background: rgba(74, 158, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(74, 158, 255, 0.3);
}

.btn-delete {
    background: rgba(244, 67, 54, 0.15);
    color: var(--danger);
}

.btn-delete:hover {
    background: rgba(244, 67, 54, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(244, 67, 54, 0.3);
}

/* Header Stats with Animated Gradient */
.header-stat.balance {
    position: relative;
    overflow: hidden;
}

.header-stat.balance::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    opacity: 0.1;
    animation: gradientSlide 3s ease-in-out infinite;
    pointer-events: none;
}

.header-stat.balance .stat-value.positive::before {
    background: linear-gradient(90deg, transparent, #4caf50, transparent);
}

.header-stat.balance .stat-value.negative::before {
    background: linear-gradient(90deg, transparent, #f44336, transparent);
}

@keyframes gradientSlide {
    0% {
        left: -100%;
    }
    50% {
        left: 100%;
    }
    100% {
        left: 100%;
    }
}

/* Recurring Progress Bar */
.recurring-progress-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
}

.recurring-progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.recurring-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #6bb6ff);
    border-radius: 10px;
    transition: width 0.3s ease;
    position: relative;
}

.recurring-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

.recurring-progress-fill.completed {
    background: linear-gradient(90deg, var(--success), #66bb6a);
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.recurring-progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
}

/* View Toggle */
.transactions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: 0.5rem;
}

.view-toggle-btn {
    background: transparent;
    border: none;
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-toggle-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.view-toggle-btn.active {
    background: var(--accent);
    color: white;
}

/* Card View (both mobile and desktop) */
.transactions-cards {
    display: none;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.transactions[data-view="cards"] table {
    display: none;
}

.transactions[data-view="cards"] .transactions-cards {
    display: grid;
}

/* Responsive grid: adapt columns based on screen size */
@media (min-width: 769px) {
    .transactions-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .transactions-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Transaction Cards (works on both mobile and desktop) */
.transaction-card {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.2s ease;
    position: relative;
}

.transaction-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.15);
}

.transaction-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.transaction-card-date {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.transaction-card-amount {
    font-size: 1.25rem;
    font-weight: 600;
}

.transaction-card-amount.recette {
    color: var(--success);
}

.transaction-card-amount.depense {
    color: var(--danger);
}

.transaction-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.transaction-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.transaction-card-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.transaction-card-value {
    color: var(--text-primary);
    text-align: right;
}

.transaction-card-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.transaction-card-actions .btn-edit,
.transaction-card-actions .btn-delete {
    flex: 1;
    max-width: 120px;
}

/* Mobile: Force card view, hide toggle */
@media (max-width: 768px) {
    .view-toggle {
        display: none;
    }

    .transactions table {
        display: none !important;
    }

    .transactions-cards {
        display: grid !important;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: floatIcon 3s ease-in-out infinite;
}

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

.empty-state-title {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state-message {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto;
}

/* Form Validation Checkmarks */
.validation-check {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--success);
    font-size: 1.2rem;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.validation-check.show {
    opacity: 1;
    animation: checkPop 0.3s ease;
}

@keyframes checkPop {
    0% {
        transform: translateY(-50%) scale(0);
    }
    50% {
        transform: translateY(-50%) scale(1.2);
    }
    100% {
        transform: translateY(-50%) scale(1);
    }
}
