:root {
    --bg-main: #000000;
    --bg-sidebar: #1C1C1E;
    --bg-card: #1C1C1E;
    --bg-input: #2C2C2E;
    --bg-input-hover: #3A3A3D;

    --text-primary: #FFFFFF;
    --text-secondary: #8E8E93;

    --accent-blue: #0A84FF;
    --accent-blue-hover: #0066CC;
    --accent-green: #32D74B;
    --accent-green-hover: #24A135;
    --accent-amber: #FF9F0A;
    --accent-red: #FF453A;

    --border-color: #38383A;
    --border-radius: 12px;
    --radius-lg: 16px;
    --radius-full: 999px;

    --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    justify-content: space-between;
}

.sidebar-header {
    margin-bottom: 32px;
    padding: 0 8px;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.sidebar-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
}

.nav-links li:hover {
    background-color: var(--bg-input);
    color: var(--text-primary);
}

.nav-links li.active {
    background-color: var(--bg-input-hover);
    color: var(--accent-blue);
}

.nav-links li ion-icon {
    font-size: 20px;
}

/* Sidebar footer — exit button */
.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.btn-exit {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 14px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--accent-red);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.15s;
}

.btn-exit:hover {
    background-color: rgba(255, 69, 58, 0.12);
    transform: scale(0.98);
}

.btn-exit ion-icon {
    font-size: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    background-color: var(--bg-main);
    padding: 32px 48px;
    position: relative;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.view-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Forms & Inputs */
.form-container {
    display: flex;
    gap: 24px;
}

.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    flex: 1;
    border: 1px solid var(--border-color);
}

.card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group {
    margin-bottom: 16px;
}

.row {
    display: flex;
    gap: 16px;
}

.col {
    flex: 1;
}

label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input,
select,
textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 15px;
    transition: border-color 0.2s, background-color 0.2s;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-blue);
    background-color: var(--bg-input-hover);
}

input[readonly] {
    opacity: 0.7;
    cursor: default;
}

/* Switch (Apple style toggle) */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-input);
    transition: .3s;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: #FFF;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-green);
    border-color: var(--accent-green);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-blue-hover);
    transform: scale(0.98);
}

.btn-secondary {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-input-hover);
}

.btn-success {
    background-color: var(--accent-green);
    color: white;
}

.btn-danger {
    background-color: rgba(255, 69, 58, 0.2);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}

.full-width {
    width: 100%;
}

/* Filters & Lists */
.filters {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.search-bar {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: var(--bg-input);
    border-radius: 10px;
    padding: 0 12px;
}

.search-bar ion-icon {
    font-size: 20px;
    color: var(--text-secondary);
}

.search-bar input {
    background: transparent;
    border: none;
    padding: 10px;
}

.search-bar input:focus {
    background: transparent;
    border: none;
}

.filter-tabs {
    display: flex;
    background: var(--bg-input);
    border-radius: 8px;
    padding: 3px;
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: 0.2s;
}

.filter-btn.active {
    background: var(--accent-blue);
    color: white;
}

.list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* List Item (Invoice / Income row) */
.list-item {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.list-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.item-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.item-title {
    font-size: 16px;
    font-weight: 600;
}

.item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.item-amount {
    font-size: 20px;
    font-weight: 700;
}

.item-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: 0.2s;
}

.icon-btn:hover {
    background: var(--bg-input-hover);
    transform: scale(1.05);
}

/* Utility Classes */
.text-amber {
    color: var(--accent-amber);
}

.text-green {
    color: var(--accent-green);
}

.text-red {
    color: var(--accent-red);
}

.text-blue {
    color: var(--accent-blue);
}

.bold {
    font-weight: 700;
}

.mt-2 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 24px;
}

.mb-3 {
    margin-bottom: 20px;
}

.ml-1 {
    margin-left: 8px;
}

.align-center {
    align-items: center;
}

.separator {
    height: 1px;
    background: var(--border-color);
    margin: 24px 0;
}

/* Stats Grid */
.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    margin-top: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.stats-grid.large {
    grid-template-columns: repeat(2, 1fr);
}

.stats-grid.full {
    grid-template-columns: 1fr;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
}

.stat-card p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-card h2 {
    font-size: 28px;
    font-weight: 700;
}

.stat-card.highlight-green {
    border-color: rgba(50, 215, 75, 0.4);
}

.stat-card.highlight-amber {
    border-color: rgba(255, 159, 10, 0.4);
}

.stat-card.highlight-red {
    border-color: rgba(255, 69, 58, 0.4);
}

.stat-card.grand-total {
    background: rgba(50, 215, 75, 0.1);
    border-color: var(--accent-green);
}


/* Toasts */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background: rgba(44, 44, 46, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    color: white;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.success ion-icon {
    color: var(--accent-green);
}

.toast.error ion-icon {
    color: var(--accent-red);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ---- Lignes multi-row table ---- */
#lignes-section {
    margin-top: 8px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.lignes-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--bg-input);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.ligne-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--border-color);
    transition: background 0.15s;
}

.ligne-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.ligne-row td,
.ligne-row input,
.ligne-row select {
    font-size: 13px;
    padding: 6px 8px;
}

.ligne-row input[type="number"] {
    text-align: right;
}

.ligne-row .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
}

.ligne-row .icon-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

/* ── URSSAF Reminder Banner ── */
.urssaf-reminder {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    margin: 0 0 16px 0;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(255, 159, 10, 0.15), rgba(255, 69, 58, 0.10));
    border: 1px solid rgba(255, 159, 10, 0.4);
    animation: reminderPulse 3s ease-in-out infinite;
}

.urssaf-reminder.urgent {
    background: linear-gradient(135deg, rgba(255, 69, 58, 0.20), rgba(255, 45, 85, 0.15));
    border-color: rgba(255, 69, 58, 0.6);
}

.reminder-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reminder-icon {
    font-size: 28px;
    color: #FF9F0A;
    flex-shrink: 0;
}

.urssaf-reminder.urgent .reminder-icon {
    color: #FF453A;
}

.reminder-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.reminder-text strong {
    color: #FF9F0A;
    font-size: 14px;
}

.urssaf-reminder.urgent .reminder-text strong {
    color: #FF453A;
}

.reminder-text span {
    color: var(--text-secondary);
    font-size: 13px;
}

.reminder-dismiss {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.reminder-dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

@keyframes reminderPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.85;
    }
}
/* ============ LOGIN OVERLAY ============ */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-box {
    width: 100%;
    max-width: 340px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-box h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-align: center;
}

.login-box .login-sub {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 8px;
}

.login-box input[type="password"] {
    width: 100%;
    padding: 13px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.login-box input[type="password"]:focus {
    border-color: var(--accent-blue);
}

.login-error {
    color: var(--accent-red);
    font-size: 13px;
    text-align: center;
    padding: 8px;
    background: rgba(255, 69, 58, 0.1);
    border-radius: 8px;
}

/* ============ MOBILE / iPhone ============ */
@media (max-width: 820px) {
    body {
        overflow: auto;
    }

    #app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .sidebar {
        width: 100%;
        padding: calc(env(safe-area-inset-top) + 12px) 12px 12px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        gap: 8px;
    }

    .sidebar-header {
        margin-bottom: 0;
        padding: 0;
        flex-shrink: 0;
    }

    .sidebar-header h2 {
        font-size: 16px;
    }

    .sidebar-header p {
        display: none;
    }

    .nav-links {
        flex-direction: row;
        gap: 4px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .nav-links li {
        padding: 8px 10px;
        font-size: 12px;
        gap: 6px;
    }

    .nav-links li span {
        display: none;
    }

    .nav-links li ion-icon {
        font-size: 20px;
    }

    .sidebar-footer {
        padding-top: 0;
        border-top: none;
        flex-shrink: 0;
    }

    .btn-exit {
        width: auto;
        padding: 8px 10px;
    }

    .btn-exit span {
        display: none;
    }

    .main-content {
        padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 24px);
        overflow: visible;
    }

    .view-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .view-header h1 {
        font-size: 22px;
    }

    .view-header .actions {
        width: 100%;
        justify-content: space-between;
    }

    .form-container {
        grid-template-columns: 1fr !important;
    }

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

    .lignes-header {
        display: none !important;
    }

    .ligne-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 12px !important;
        margin-bottom: 10px;
    }

    .ligne-row > div:has(> input.lg-tr-cout[style*='display: none']) {
        display: none !important;
    }

    .ligne-row > div {
        width: 100%;
    }

    .ligne-row .switch {
        margin: 0 auto !important;
    }

    .list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .item-right {
        width: 100%;
        justify-content: space-between;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .filters {
        flex-direction: column;
        align-items: stretch !important;
    }

    .search-bar {
        width: 100% !important;
    }
}

@media (max-width: 420px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
}
