.app-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #f4f4f4;
    border-bottom: 1px solid #ddd;
}

.header .logo {
    font-weight: bold;
    text-decoration: none;
    color: #000;
}

.header .user {
    margin-right: 15px;
}

.header .logout {
    color: #c00;
    text-decoration: none;
}

.install-app-wrapper {
    margin: 40px 0;
    text-align: center;
}

#install-app {
    padding: 12px 20px;
    font-size: 16px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab.active {
    font-weight: bold;
}

/* ===== Page saisie ===== */

form {
    max-width: 900px;
    margin: 0 auto;
}

h1 {
    margin-bottom: 1rem;
}

/* Date */
input[type="date"] {
    margin-bottom: 1.5rem;
}

/* ===== Fieldsets ===== */

fieldset {
    border: 1px solid #ddd;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
}

legend {
    padding: 0 0.5rem;
    font-weight: 600;
}

/* ===== Champs ===== */

label {
    display: block;
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
}

label > input,
label > select,
label > textarea {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.95rem;
    box-sizing: border-box;
}

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

/* Radios / checkboxes */
label input[type="radio"],
label input[type="checkbox"] {
    display: inline-block;
    width: auto;
    margin-right: 0.4rem;
}

/* ===== Actions ===== */

button[type="submit"] {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    margin-top: 1rem;
}

a {
    margin-left: 1rem;
    text-decoration: none;
}

/* ===== Mobile ===== */

@media (max-width: 600px) {
    fieldset {
        padding: 0.8rem;
    }
}


/* Label + aide */

.field-label {
    position: relative;
}

/* Point d’interrogation */
.field-help {
    display: inline-block;
    margin-left: 0.4rem;
    cursor: help;
    font-weight: bold;
    color: #555;
    position: relative;
}

/* Tooltip */
.field-help-text {
    display: none;
    position: absolute;
    top: 1.4rem;
    left: 0;
    z-index: 10;

    max-width: 260px;
    padding: 0.5rem 0.6rem;

    background: #333;
    color: #fff;
    font-size: 0.8rem;
    line-height: 1.4;
    border-radius: 4px;
}

/* Hover */
.field-help:hover .field-help-text {
    display: block;
}

input[type="range"].inactive {
    accent-color: #ccc;
}

/* ===== Popup ration ===== */

.popup.ration {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: #fff;
    padding: 1.5rem;
    max-width: 600px;
    width: 90%;

    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.popup.ration.open {
    display: block !important;
}

.popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 900;
}

.popup-overlay.open {
    display: block;
}

.popup.ration {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;

    background: #fff;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;

    overflow-y: auto;
    padding: 1rem;
}

.popup.ration.open {
    display: block;
}

/* zone scrollable */
.popup.ration fieldset {
    margin-bottom: 1rem;
}

/* lignes aliments */
.popup.ration .ligne {
    display: grid;
    grid-template-columns: 1fr 120px 50px;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.4rem;
}

/* boutons */
.popup.ration .submit,
.popup.ration .close-ration {
    margin-top: 1rem;
}

.aliment-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.aliment-row > label {
    min-width: 220px;
}

.aliment-details {
    display: flex;
    align-items: center;
    gap: 10px;
}

.aliment-details input[type="number"] {
    width: 80px;
}

.aliment-details label {
    margin-right: 6px;
    white-space: nowrap;
}

#statsWrapper {
    width: 100%;
    background: white;
}

#statsWrapper canvas {
    width: 100% !important;
    height: 400px !important;
    background: white;
}

@media (min-width:900px) {
    #rotateStats {
        display: none;
    }
}

#history-popup {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid #000;
    padding: 20px;
    z-index: 9999;
}

#rationFilters div {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 12px;
}

#rationFilters input {
    margin: 0;
}

#rationFilters label {
    cursor: pointer;
}
