:root {
    --blue: #1F4E78;
    --blue-light: #EAF2F8;
    --green: #1E8E3E;
    --red: #C0392B;
    --gray-bg: #F5F6F8;
    --gray-border: #E1E4E8;
    --text: #1C2530;
    --text-muted: #6B7280;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--gray-bg);
    color: var(--text);
}

.topnav {
    background: var(--blue);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
}
.topnav .brand { font-weight: bold; font-size: 1.1rem; }
.topnav .nav-links a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    font-size: 0.95rem;
    opacity: 0.9;
}
.topnav .nav-links a:hover { opacity: 1; text-decoration: underline; }

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}

h1 { font-size: 1.5rem; margin-bottom: 8px; }
h2 {
    font-size: 1.05rem;
    color: var(--blue);
    border-bottom: 2px solid var(--blue-light);
    padding-bottom: 6px;
    margin-top: 28px;
}

.flash-success {
    background: #E6F4EA;
    color: var(--green);
    border: 1px solid #B7E1C3;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.flash-info {
    background: #FFF8E1;
    color: #8A6D00;
    border: 1px solid #FCE7A1;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.field-date {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    max-width: 220px;
}
.field-date label { font-weight: bold; font-size: 0.9rem; }
.field-date input {
    font-size: 1.1rem;
    padding: 8px 10px;
    border: 1px solid var(--gray-border);
    border-radius: 6px;
}

.denom-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

.denom-row {
    display: grid;
    grid-template-columns: 1fr auto 90px;
    align-items: center;
    gap: 12px;
    background: white;
    border: 1px solid var(--gray-border);
    border-radius: 8px;
    padding: 10px 14px;
}
.denom-label { font-size: 0.98rem; }

.stepper {
    display: flex;
    align-items: center;
    gap: 6px;
}
.stepper button {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    border: 1px solid var(--gray-border);
    background: var(--gray-bg);
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}
.stepper button:hover { background: var(--blue-light); }
.stepper button:active { transform: scale(0.95); }
.stepper input {
    width: 56px;
    text-align: center;
    font-size: 1rem;
    padding: 6px 4px;
    border: 1px solid var(--gray-border);
    border-radius: 6px;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input[type=number] { -moz-appearance: textfield; }

.denom-subtotal {
    text-align: right;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
}

.total-bar {
    margin-top: 24px;
    background: var(--blue);
    color: white;
    padding: 16px 18px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 1.3rem;
    font-weight: bold;
}

.field-theorique {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 320px;
}
.field-theorique label { font-size: 0.85rem; color: var(--text-muted); }
.field-theorique input {
    padding: 8px 10px;
    border: 1px solid var(--gray-border);
    border-radius: 6px;
    font-size: 1rem;
}

.ecart-bar {
    margin-top: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 1.05rem;
}
.ecart-bar.ok { background: #E6F4EA; color: var(--green); }
.ecart-bar.warn { background: #FDECEA; color: var(--red); }

.text-ok { color: var(--green); font-weight: bold; }
.text-warn { color: var(--red); font-weight: bold; }
.text-muted-cell { color: var(--text-muted); }

.actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn-primary, .btn-secondary, .btn-danger-solid {
    display: inline-block;
    padding: 12px 22px;
    border-radius: 6px;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.btn-primary { background: var(--green); color: white; }
.btn-primary:hover { background: #17702F; }
.btn-secondary { background: white; color: var(--blue); border: 1px solid var(--blue); }
.btn-secondary:hover { background: var(--blue-light); }
.btn-danger-solid { background: var(--red); color: white; }
.btn-danger-solid:hover { background: #9C2E22; }

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--blue);
}
.login-card {
    background: white;
    padding: 36px 32px;
    border-radius: 10px;
    width: 320px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-card h1 { font-size: 1.2rem; color: var(--blue); margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 20px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card label { text-align: left; font-size: 0.85rem; font-weight: bold; }
.login-card input {
    padding: 10px;
    border: 1px solid var(--gray-border);
    border-radius: 6px;
    font-size: 1rem;
}
.login-card button {
    margin-top: 8px;
    padding: 10px;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}
.login-card .error { color: var(--red); font-size: 0.85rem; }

/* Historique */
.hist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.hist-export-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.hist-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    margin-top: 16px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.hist-table th, .hist-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--gray-border);
    font-size: 0.95rem;
}
.hist-table th { background: var(--blue-light); color: var(--blue); }
.cell-total { font-weight: bold; }
.cell-muted { color: var(--text-muted); font-size: 0.85rem; }
.cell-actions { display: flex; gap: 14px; }
.btn-link {
    background: none;
    border: none;
    color: var(--blue);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
    padding: 0;
}
.btn-link.btn-danger { color: var(--red); }
.empty-state { color: var(--text-muted); margin-top: 20px; }

/* Modal */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: white;
    padding: 24px;
    border-radius: 10px;
    width: 320px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

@media (max-width: 480px) {
    .denom-row { grid-template-columns: 1fr auto; }
    .denom-subtotal { display: none; }
}
