﻿:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --primary: #1f4b99;
    --primary-hover: #163b7a;
    --secondary: #eef2f7;
    --secondary-hover: #e4e9f1;
    --success: #1f8f5f;
    --warning: #d97706;
    --danger: #c0392b;
    --info: #4b5563;
    --shadow-sm: 0 4px 12px rgba(17, 24, 39, 0.05);
    --shadow-md: 0 10px 28px rgba(17, 24, 39, 0.08);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(circle at 0% 0%, #edf2fa 0%, transparent 32%),
        radial-gradient(circle at 100% 0%, #eef3fb 0%, transparent 28%),
        var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    width: 100%;
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
    background: linear-gradient(180deg, #1d3f84 0%, #19356f 100%);
    color: #e8eef9;
    border-right: 1px solid rgba(255, 255, 255, 0.16);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.brand {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 9px;
    color: #d9e4f8;
    font-size: 0.94rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.35);
    color: #ffffff;
}

.logout-link {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.1);
}

.content {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.45rem, 1.4vw + 1rem, 2rem);
    line-height: 1.12;
    letter-spacing: -0.01em;
}

.subtitle {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.user-chip {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 13px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #344152;
    box-shadow: var(--shadow-sm);
}

.readonly-badge {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #ead9b7;
    background: #fcf7ee;
    color: #7a5a24;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.last-update-card {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #eadfc8;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, #fdf8ee 0%, #fbf4e7 100%);
    color: #6f4f23;
}

.last-update-card small {
    color: #8b6a3d;
}

.alert {
    margin-bottom: 12px;
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.92rem;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: #e6f5ed;
    border-color: #c6e9d5;
    color: #155b3a;
}

.alert-error {
    background: #fdeceb;
    border-color: #f3c6c1;
    color: #872a22;
}

.alert ul {
    margin: 8px 0 0;
    padding-left: 17px;
}

.panel {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    margin-bottom: 16px;
}

.filter-panel {
    position: sticky;
    top: 10px;
    z-index: 15;
}

.panel-header {
    margin-bottom: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.panel h2,
.panel h3 {
    margin: 0;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.card {
    background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
    border: 1px solid var(--border);
    border-left: 4px solid #cad6e6;
    border-radius: var(--radius-sm);
    box-shadow: 0 3px 9px rgba(17, 24, 39, 0.04);
    padding: 10px 11px;
}

.card-link {
    display: block;
    cursor: pointer;
    transition: box-shadow 0.16s ease, border-color 0.16s ease;
}

.card-link:hover {
    box-shadow: 0 6px 14px rgba(17, 24, 39, 0.08);
}

.panel-preview {
    scroll-margin-top: 88px;
}

.panel-preview:target {
    border-color: #b9c9e6;
    box-shadow: 0 0 0 2px rgba(31, 75, 153, 0.14), var(--shadow-sm);
}

.card h3 {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.77rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.card-value {
    margin: 6px 0 0;
    font-size: clamp(1.45rem, 1.2vw + 1rem, 2.1rem);
    line-height: 1;
    letter-spacing: -0.02em;
    font-weight: 800;
    color: #101828;
}

.card p {
    margin: 4px 0 0;
}

.card .muted {
    font-size: 0.78rem;
    line-height: 1.3;
}

.stats-grid.compact .card {
    padding: 9px 10px;
}

.stats-grid.compact .card-value {
    font-size: 1.25rem;
}

.warning-card {
    border-left-color: #f0b56a;
    background: linear-gradient(180deg, #fffaf3 0%, #fff6ea 100%);
}

.danger-card {
    border-left-color: #e59d95;
    background: linear-gradient(180deg, #fff7f7 0%, #ffefef 100%);
}

.two-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
}

.kpi-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 18px;
    color: #435264;
}

.table-wrapper {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #ffffff;
}

.table {
    width: 100%;
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
}

.table th,
.table td {
    padding: 11px 12px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #edf1f4;
    font-variant-numeric: tabular-nums;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(180deg, #f7f9fc 0%, #eff3f8 100%);
    color: #334155;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
}

.table th a {
    color: inherit;
}

.table tbody tr:nth-child(even) td {
    background: #fcfdff;
}

.table tbody tr:hover td {
    background: #f5f8fd;
}

.table tbody tr.row-low td {
    background: #fffbf4;
}

.table tbody tr.row-zero td {
    background: #fff6f5;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table td small.muted {
    display: inline-block;
    margin-left: 4px;
}

.form-grid,
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field.full-width {
    grid-column: 1 / -1;
}

.duplicate-hint {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 0.84rem;
    line-height: 1.35;
}

.duplicate-hint-visible {
    display: flex;
}

.duplicate-hint-loading {
    background: #f5f8fd;
    border-color: #d7e2f3;
    color: #3f587d;
}

.duplicate-hint-warning {
    background: #fff8ef;
    border-color: #f0d6af;
    color: #8a5a18;
}

.duplicate-link {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 8px;
    border: 1px solid #e4c797;
    background: #fff3df;
    color: #73450f;
    font-weight: 700;
    font-size: 0.8rem;
}

.duplicate-link:hover {
    background: #ffe9ca;
}

.form-grid label,
.filter-grid label {
    color: #364152;
    font-size: 0.86rem;
    font-weight: 700;
}

.form-grid small,
.form-field small,
.muted {
    color: var(--text-muted);
    font-size: 0.82rem;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    min-height: 41px;
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid #d2dae4;
    background: #ffffff;
    color: var(--text);
    transition: border-color 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}

textarea {
    min-height: 88px;
    resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #bdc9d8;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #5c7fb9;
    box-shadow: 0 0 0 3px rgba(31, 75, 153, 0.15);
    background: #ffffff;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
}

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

.btn {
    min-height: 40px;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.89rem;
    font-weight: 700;
    white-space: nowrap;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

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

.btn-secondary {
    background: var(--secondary);
    border-color: #d5dde8;
    color: #334155;
}

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

.btn-light {
    background: #ffffff;
    border-color: #d5dde8;
    color: #334155;
}

.btn-light:hover {
    background: #f8fafc;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background: #9e2f24;
    border-color: #9e2f24;
}

.inline-form {
    margin: 0;
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.actions-inline {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.table .actions-inline .btn,
.table .inline-form .btn {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.82rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 23px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-rouge {
    background: #fde8e8;
    border-color: #f6c3c3;
    color: #8f2e2e;
}

.badge-blanc {
    background: #fff8dc;
    border-color: #f0e2a8;
    color: #6d5b00;
}

.badge-rose {
    background: #fce8f3;
    border-color: #efc1da;
    color: #8c3b63;
}

.badge-cremant {
    background: #e6f4fb;
    border-color: #c2e1f0;
    color: #245a7c;
}

.badge-autre {
    background: #edf1f5;
    border-color: #d5dde5;
    color: #4b5563;
}

.badge-format-bouteille {
    background: #eaf0fb;
    border-color: #cad8ef;
    color: #344b72;
}

.badge-format-magnum {
    background: #dfe9fb;
    border-color: #b8caf0;
    color: #1f4b99;
}

.stock-badge {
    min-width: 92px;
    justify-content: center;
}

.stock-badge-ok {
    background: #e8f6ef;
    border-color: #c6e6d5;
    color: #1a6d48;
}

.stock-badge-low {
    background: #fff7eb;
    border-color: #f0d8b0;
    color: #9a5f12;
}

.stock-badge-zero {
    background: #fdeeee;
    border-color: #f1c8c4;
    color: #a32f26;
}

.movement-entree {
    background: #e6f5ed;
    border-color: #c5e8d5;
    color: #146c46;
}

.movement-sortie {
    background: #fdecea;
    border-color: #f3c8c4;
    color: #992f27;
}

.movement-correction_inventaire {
    background: #e8edf8;
    border-color: #ccd7ed;
    color: #334d7a;
}

.qty-low {
    color: var(--warning);
    font-weight: 800;
}

.qty-zero {
    color: var(--danger);
    font-weight: 800;
}

.pagination {
    margin-top: 13px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.page-link {
    min-width: 34px;
    min-height: 34px;
    padding: 6px 9px;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    font-size: 0.86rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.flash-stack {
    position: fixed;
    right: 18px;
    top: 14px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 24px));
    pointer-events: none;
}

.flash-stack .alert {
    margin-bottom: 0;
    pointer-events: auto;
}

.footer {
    margin-top: 22px;
    color: #8a93a1;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at 10% 0%, #ecf2fb 0%, transparent 40%),
        radial-gradient(circle at 85% 0%, #e8eef8 0%, transparent 35%),
        #f3f6fb;
}

.login-card {
    width: min(440px, 100%);
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 24px;
}

.login-card h1 {
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: -0.01em;
}

.login-card p {
    margin: 7px 0 14px;
    color: var(--text-muted);
}

@media (max-width: 1180px) {
    .content {
        padding: 18px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 40;
        gap: 8px;
        padding: 10px;
    }

    .sidebar nav {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .logout-link {
        margin-top: 0;
    }

    .nav-link {
        min-height: 36px;
    }

    .two-columns {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        gap: 10px;
    }

    .user-chip {
        align-self: flex-start;
    }

    .filter-panel {
        position: static;
    }

    .flash-stack {
        right: 10px;
        top: 10px;
    }
}

@media (max-width: 760px) {
    .content {
        padding: 12px;
    }

    .panel {
        padding: 13px;
    }

    .table {
        min-width: 700px;
    }

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

    .actions-inline,
    .inline-form,
    .form-actions {
        width: 100%;
    }

    .actions-inline .btn,
    .inline-form .btn,
    .form-actions .btn {
        width: 100%;
    }
}
