:root {
    --qinc-bg: #f4f7fb;
    --qinc-surface: #ffffff;
    --qinc-surface-soft: #f8fafc;
    --qinc-text: #0f172a;
    --qinc-muted: #64748b;
    --qinc-border: rgba(148, 163, 184, 0.28);
    --qinc-primary: #059669;
    --qinc-primary-dark: #047857;
    --qinc-primary-soft: #d1fae5;
    --qinc-warning: #f59e0b;
    --qinc-danger: #dc2626;
    --qinc-sidebar: #0f172a;
    --qinc-sidebar-soft: rgba(255, 255, 255, 0.08);
    --qinc-radius: 18px;
    --qinc-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --qinc-shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body.qinc-body,
body.qinc-login-body,
body.qinc-simple-body {
    min-height: 100vh;
    margin: 0;
    color: var(--qinc-text);
    background:
        radial-gradient(circle at top left, rgba(5, 150, 105, 0.16), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.10), transparent 30rem),
        var(--qinc-bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.qinc-body {
    overflow-x: hidden;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.app-sidebar {
    width: 292px;
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    padding: 18px 15px;
    background:
        linear-gradient(180deg, rgba(5, 150, 105, 0.16), transparent 36%),
        var(--qinc-sidebar);
    color: #e5e7eb;
    box-shadow: 22px 0 55px rgba(15, 23, 42, 0.24);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.25) transparent;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.10);
    margin-bottom: 14px;
}

.sidebar-logo {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 25px;
    box-shadow: 0 14px 30px rgba(5, 150, 105, 0.35);
}

.sidebar-title {
    font-size: 17px;
    line-height: 1.1;
    font-weight: 850;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.sidebar-subtitle {
    margin-top: 4px;
    font-size: 11px;
    color: #94a3b8;
}

.sidebar-section-title {
    padding: 12px 12px 7px;
    color: #94a3b8;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 800;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-bottom: 14px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 14px;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
    transition: 180ms ease;
}

.sidebar-link:hover {
    color: #ffffff;
    background: var(--qinc-sidebar-soft);
    transform: translateX(3px);
}

.sidebar-link.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.92), rgba(5, 150, 105, 0.84));
    box-shadow: 0 12px 25px rgba(5, 150, 105, 0.24);
}

.sidebar-link.logout {
    color: #fecaca;
    margin-top: 8px;
}

.sidebar-link.logout:hover {
    color: #ffffff;
    background: rgba(220, 38, 38, 0.18);
}

.nav-icon {
    width: 22px;
    text-align: center;
    font-size: 17px;
    flex: 0 0 22px;
}

.sidebar-user-card {
    margin-top: auto;
    padding: 13px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 18px;
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(8px);
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 800;
    color: white;
}

.sidebar-user-role {
    margin-top: 3px;
    color: #a7f3d0;
    font-size: 11px;
}

.app-main {
    min-height: 100vh;
    width: 100%;
    margin-left: 292px;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 14px 24px;
    background: rgba(244, 247, 251, 0.80);
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    backdrop-filter: blur(18px);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1320px;
    margin: 0 auto;
}

.topbar-title {
    font-weight: 900;
    font-size: clamp(18px, 2vw, 24px);
    letter-spacing: -0.04em;
    color: var(--qinc-text);
}

.topbar-subtitle {
    color: var(--qinc-muted);
    font-size: 12px;
    margin-top: 3px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--qinc-border);
    border-radius: 999px;
    background: rgba(255,255,255,0.78);
    box-shadow: var(--qinc-shadow-soft);
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: white;
    font-weight: 900;
    background: linear-gradient(135deg, #0f172a, #059669);
}

.mobile-menu-btn {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--qinc-border);
    border-radius: 14px;
    background: white;
    color: var(--qinc-text);
    box-shadow: var(--qinc-shadow-soft);
}

.subscription-banner {
    max-width: 1320px;
    margin: 18px auto 0;
    padding: 0 24px;
}

.subscription-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(245, 158, 11, 0.28);
    background: linear-gradient(135deg, #fffbeb, #ffffff);
    box-shadow: var(--qinc-shadow-soft);
    font-size: 13px;
}

.subscription-card.expired {
    border-color: rgba(220, 38, 38, 0.22);
    background: linear-gradient(135deg, #fef2f2, #ffffff);
}

.subscription-pay-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 13px;
    border-radius: 999px;
    color: #ffffff;
    font-weight: 800;
    font-size: 12px;
    text-decoration: none;
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 12px 25px rgba(5, 150, 105, 0.22);
    white-space: nowrap;
}

.app-content {
    flex: 1;
    padding: 24px;
}

.content-inner {
    max-width: 1320px;
    margin: 0 auto;
}

.app-footer {
    padding: 18px 24px 24px;
}

.app-footer-inner {
    max-width: 1320px;
    margin: 0 auto;
    color: #64748b;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.24);
}

.content-inner > .grid,
.content-inner > .bg-white,
.content-inner > form,
.content-inner > .rounded-2xl,
.content-inner > div.bg-white {
    animation: qincFadeIn 260ms ease both;
}

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

/* Amélioration globale des cartes existantes Tailwind */
.bg-white.rounded-2xl.shadow,
.bg-white.rounded-2xl.shadow-md,
.bg-white.shadow,
.bg-white.shadow-md,
form.bg-white,
.content-inner > .bg-white {
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
    box-shadow: var(--qinc-shadow) !important;
}

.rounded-2xl {
    border-radius: var(--qinc-radius) !important;
}

h1, h2, h3 {
    letter-spacing: -0.02em;
}

.content-inner h1,
.content-inner h2:first-child,
.content-inner .font-bold.text-xl,
.content-inner .font-bold.text-2xl {
    color: #0f172a;
}

/* Formulaires */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
    min-height: 40px;
    border-radius: 12px !important;
    border: 1px solid #dbe3ef !important;
    background: #ffffff;
    color: #0f172a;
    outline: none;
    transition: 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(5, 150, 105, 0.70) !important;
    box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.12) !important;
}

label {
    color: #334155;
}

/* Boutons et liens d'action */
button,
a[class*="bg-emerald"],
a[class*="bg-blue"],
a[class*="bg-slate"],
a[class*="bg-red"],
a[class*="bg-amber"],
button[class*="bg-emerald"],
button[class*="bg-blue"],
button[class*="bg-slate"],
button[class*="bg-red"],
button[class*="bg-amber"] {
    transition: 180ms ease;
}

button:hover,
a[class*="bg-emerald"]:hover,
a[class*="bg-blue"]:hover,
a[class*="bg-slate"]:hover,
a[class*="bg-red"]:hover,
a[class*="bg-amber"]:hover,
button[class*="bg-emerald"]:hover,
button[class*="bg-blue"]:hover,
button[class*="bg-slate"]:hover,
button[class*="bg-red"]:hover,
button[class*="bg-amber"]:hover {
    transform: translateY(-1px);
    filter: saturate(1.08);
}

button:active,
a[class*="bg-"]:active {
    transform: translateY(0);
}

/* Tableaux */
.overflow-x-auto {
    border-radius: 16px;
}

table {
    width: 100%;
    border-collapse: separate !important;
    border-spacing: 0;
}

thead tr {
    background: #f8fafc;
}

th {
    color: #475569;
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

td, th {
    border-color: rgba(148, 163, 184, 0.22) !important;
}

tbody tr {
    transition: 140ms ease;
}

tbody tr:hover {
    background: rgba(5, 150, 105, 0.045) !important;
}

/* Badges génériques */
.badge,
[class*="rounded-full"] {
    font-weight: 750;
}

/* Login et pages simples */
.qinc-login-body,
.qinc-simple-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
}

.login-shell,
.simple-shell {
    width: 100%;
    max-width: 430px;
}

.login-card,
.simple-card {
    position: relative;
    overflow: hidden;
    padding: 30px;
    border-radius: 28px;
    background: rgba(255,255,255,0.88);
    border: 1px solid rgba(255,255,255,0.68);
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(18px);
}

.login-card::before,
.simple-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 6px;
    background: linear-gradient(90deg, #0f172a, #059669, #10b981);
}

.login-logo,
.simple-logo {
    width: 66px;
    height: 66px;
    margin: 0 auto 12px;
    display: grid;
    place-items: center;
    border-radius: 24px;
    color: white;
    font-size: 34px;
    background: linear-gradient(135deg, #0f172a, #059669);
    box-shadow: 0 18px 35px rgba(5, 150, 105, 0.24);
}

.login-title,
.simple-title {
    text-align: center;
    font-size: 25px;
    font-weight: 950;
    letter-spacing: -0.05em;
}

.login-subtitle,
.simple-subtitle {
    margin: 6px auto 22px;
    text-align: center;
    color: #64748b;
    font-size: 13px;
    max-width: 320px;
}

.login-submit,
.simple-action {
    width: 100%;
    min-height: 46px;
    border: 0;
    border-radius: 15px;
    color: white;
    font-weight: 900;
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 18px 35px rgba(5, 150, 105, 0.24);
}

/* Mobile */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 1023px) {
    .app-sidebar {
        transform: translateX(-105%);
        transition: transform 220ms ease;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(15, 23, 42, 0.42);
        opacity: 0;
        pointer-events: none;
        transition: opacity 220ms ease;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .app-main {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: grid;
        place-items: center;
    }

    .topbar {
        padding: 12px 15px;
    }

    .topbar-user-details {
        display: none;
    }

    .subscription-banner,
    .app-content,
    .app-footer {
        padding-left: 15px;
        padding-right: 15px;
    }

    .subscription-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-content {
        padding-top: 18px;
    }

    .app-footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .app-sidebar {
        width: min(88vw, 292px);
    }

    .topbar-title {
        font-size: 18px;
    }

    .topbar-subtitle {
        display: none;
    }

    .content-inner .grid {
        gap: 14px !important;
    }

    .bg-white.rounded-2xl.shadow,
    .bg-white.rounded-2xl.shadow-md,
    .bg-white.shadow,
    .bg-white.shadow-md,
    form.bg-white,
    .content-inner > .bg-white {
        border-radius: 16px !important;
    }

    td, th {
        white-space: nowrap;
    }

    .login-card,
    .simple-card {
        padding: 26px 20px;
        border-radius: 24px;
    }
}

@media print {
    .app-sidebar,
    .topbar,
    .subscription-banner,
    .app-footer,
    .mobile-menu-btn,
    .sidebar-backdrop {
        display: none !important;
    }

    .app-main {
        margin-left: 0 !important;
    }

    .app-content {
        padding: 0 !important;
    }

    body.qinc-body {
        background: white !important;
    }

    .bg-white.rounded-2xl.shadow,
    .bg-white.shadow,
    .content-inner > .bg-white {
        box-shadow: none !important;
        border: 1px solid #e5e7eb !important;
    }
}
