body {
    font-family: 'Segoe UI', 'Arial', sans-serif;
    margin: 0;
    background: #f5f7fa;
    color: #222;
    transition: background 0.2s, color 0.2s;
}

.dashboard-header {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1976d2;
    color: #fff;
    padding: 18px 28px;
    box-shadow: 0 2px 14px #0002;
    z-index: 50;
    min-height: 64px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 14px;
}
.header-title .logo {
    font-size: 2em;
}
.header-date {
    font-size: 1.14em;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Main Layout */
.main-dashboard-layout {
    display: flex;
    flex-direction: row;
    min-height: calc(100vh - 64px);
}

/* Sidebar */
.dashboard-sidebar {
    width: 250px;
    min-width: 180px;
    background: #1976d2;
    min-height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 2px 0 18px #0003;
    position: sticky;
    top: 64px;
    left: 0;
    z-index: 10;
    transition: background 0.18s;
}
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 18px 10px 18px;
    margin-bottom: 8px;
}
.sidebar-title {
    font-size: 1.16em;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #fff;
}
.dashboard-sidebar a {
    display: flex;
    align-items: center;
    font-size: 1.13em;
    font-weight: 500;
    padding: 15px 22px;
    border-radius: 9px;
    background: #1561b8;
    color: #fff;
    text-decoration: none;
    margin: 0 18px 7px 18px;
    box-shadow: 0 2px 12px #1976d230;
    transition: background 0.16s, transform 0.12s, color 0.14s;
}
.dashboard-sidebar a:hover {
    background: #3a55bb;
    color: #fff;
    transform: scale(1.035);
}

/* Switch darkmode */
.switch-darkmode {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    margin-left: 12px;
}
.switch-darkmode input { display: none; }
.switch-darkmode .slider {
    width: 40px;
    height: 22px;
    background: #e2e6f3;
    border-radius: 14px;
    margin-right: 6px;
    position: relative;
    display: inline-block;
    transition: background 0.18s;
}
.switch-darkmode .slider:before {
    content: "";
    display: block;
    width: 19px;
    height: 19px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    left: 2px;
    top: 1.5px;
    transition: left 0.18s;
}
.switch-darkmode input:checked + .slider:before {
    left: 19px;
    background: #232e43;
}
.switch-darkmode input:checked + .slider {
    background: #3a55bb;
}
.switch-darkmode .sun-moon {
    font-size: 1.1em;
    margin-left: 3px;
    user-select: none;
    color: #ffc700;
}

/* Widgets/tuiles */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 26px;
    margin: 30px 30px 30px 0;
}
.card {
    background: var(--card-bg, #fff);
    border-radius: 18px;
    box-shadow: 0 2px 12px #0001;
    margin: 12px 14px 0 0;
    padding: 20px 18px 18px 18px;
    min-width: 260px;
    max-width: 350px;  /* Limite la largeur */
    width: 100%;
    box-sizing: border-box;
    transition: box-shadow .2s;
    display: flex;
    flex-direction: column;
    gap: 10px;
    word-break: break-word; /* force le retour à la ligne pour les longs mots */
    overflow: hidden;
}
.card h3 {
    margin-top: 0;
    font-size: 1.18em;
    margin-bottom: 10px;
    white-space: normal;
    color: #1976d2;
}
.card ul, .card div, .card table {
    width: 100%;
    font-size: 1em;
    word-break: break-word;
    overflow-wrap: break-word;
}
.card ul li,
.urssaf-link,
.card ul li a {
    white-space: normal !important;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    display: inline-block;
    padding: 2px 0;
}
.card a, .card a:visited {
    color: #1765d2;
    word-break: break-all;
    text-decoration: underline dotted;
    display: inline-block;
    max-width: 100%;
}
.card table {
    width: 100%;
    font-size: 0.95em;
    table-layout: fixed;
    word-break: break-word;
}
.card td, .card th {
    padding: 4px 6px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.widget-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 26px;
    align-items: center;
    margin: 14px 0 10px 0;
    padding: 6px 0;
    background: #eef4fd;
    border-radius: 11px;
}
.widget-toggles label {
    font-weight: 500;
    margin-right: 10px;
    color: #1976d2;
    font-size: 1em;
}

/* Mode sombre */
body.dark {
    background: #181f2a;
    color: #e0e5ee;
}
body.dark .dashboard-header {
    background: #181f2a;
    color: #fffb;
    box-shadow: 0 2px 14px #0008;
}
body.dark main,
body.dark .card,
body.dark .widget-toggles {
    background: #232e43 !important;
    color: #e0e5ee;
    box-shadow: 0 1px 12px #0013;
}
body.dark .card h3, body.dark .card th { color: #66aaff; }
body.dark .dashboard-sidebar {
    background: #101622;
}
body.dark .dashboard-sidebar a {
    background: #232e43;
    color: #e0e5ee;
}
body.dark .dashboard-sidebar a:hover {
    background: #3a55bb;
}
body.dark .quick-btns a {
    background: #232e43;
    color: #e0e5ee;
}
body.dark .urssaf-link {
    background: #3a55bb !important;
    color: #fff !important;
}
body.dark .widget-toggles label { color: #bbd1fb; }

/* Responsive */
@media (max-width: 1100px) {
    .main-dashboard-layout { flex-direction: column; }
    .dashboard-sidebar {
        flex-direction: row;
        width: 100%;
        min-width: 0;
        min-height: 0;
        padding: 12px 0 0 0;
        gap: 8px;
        box-shadow: none;
        background: #1976d2;
        position: static;
    }
    .dashboard-sidebar a {
        margin: 0 0 0 8px;
        flex: 1 1 110px;
        min-width: 90px;
        padding: 10px 4px;
        font-size: 1em;
    }
}

@media (max-width: 900px) {
    .card { min-width: 98vw; max-width: 98vw; }
}
