:root {
    --navy: #161f4d;
    --navy-dark: #0f1638;
    --yellow: #f7c600;
    --yellow-dark: #d9ad00;
    --black: #111111;
    --blue: #1d4ed8;
    --blue-dark: #1739a6;
    --red: #c0392b;
    --grey-bg: #f4f5f8;
    --grey-border: #dde0e8;
    --text: #1a1a1a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--grey-bg);
    color: var(--text);
}

.topbar {
    background: var(--black);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar-brand {
    display: flex;
    align-items: center;
}

.brand-logo {
    height: 56px;
    width: auto;
    display: block;
    background: #fff;
    border-radius: 6px;
    padding: 6px 10px;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 16px 60px;
}

.date-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.date-nav-current {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.date-label {
    font-weight: 700;
    color: var(--navy);
    font-size: 15px;
}

#date-picker {
    border: 1px solid var(--grey-border);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 14px;
}

.btn {
    display: inline-block;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: filter .15s ease;
}
.btn:hover { filter: brightness(0.93); }

.btn-nav {
    background: #fff;
    color: var(--navy);
    border: 1px solid var(--grey-border);
    padding: 8px 14px;
}

.btn-today {
    background: var(--navy);
    color: #fff;
}

.btn-yellow {
    background: var(--yellow);
    color: var(--black);
}

.btn-blue {
    background: var(--blue);
    color: #fff;
}

.btn-outline {
    background: #fff;
    color: var(--navy);
    border: 1px solid var(--grey-border);
}

.btn-danger {
    background: #fff;
    color: var(--red);
    border: 1px solid var(--red);
}

.btn-large {
    padding: 13px 20px;
    font-size: 15px;
}

.toolbar {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.appointments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.loading, .empty-state {
    text-align: center;
    color: #777;
    padding: 30px 0;
}

.appt-card {
    background: #fff;
    border: 1px solid var(--grey-border);
    border-left: 6px solid var(--blue);
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    gap: 14px;
    align-items: center;
    cursor: pointer;
}
.appt-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }

.appt-card.type-huile { border-left-color: var(--blue); }
.appt-card.type-pneus { border-left-color: var(--yellow-dark); }
.appt-card.type-mecanique { border-left-color: var(--navy); }
.appt-card.has-storage { background: #fff9e6; }

.appt-time {
    font-weight: 800;
    font-size: 16px;
    color: var(--navy);
    min-width: 78px;
}

.appt-main {
    flex: 1;
    min-width: 0;
}

.appt-name {
    font-weight: 700;
    font-size: 15px;
}

.appt-detail {
    font-size: 13px;
    color: #555;
    margin-top: 2px;
}

.appt-badge {
    display: inline-block;
    background: var(--yellow);
    color: var(--black);
    font-size: 12px;
    font-weight: 800;
    border-radius: 4px;
    padding: 3px 8px;
    margin-top: 4px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 30, .55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 12px;
    overflow-y: auto;
    z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 520px;
    padding: 0;
    overflow: hidden;
}

.modal-header {
    background: var(--navy);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { margin: 0; font-size: 18px; }

.modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

#appointment-form {
    padding: 18px 20px 20px;
}

.field { margin-bottom: 14px; position: relative; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.field label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    color: #333;
}

.field input[type=text],
.field input[type=tel],
.field input[type=date],
.field input[type=time],
.field select,
.field textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--grey-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.time-picker {
    display: flex;
    align-items: center;
    gap: 6px;
}
.time-picker select {
    padding: 10px 6px;
    border: 1px solid var(--grey-border);
    border-radius: 6px;
    font-size: 14px;
    flex: 1;
    min-width: 0;
}
.time-picker span { color: #888; font-weight: 700; }

.type-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.type-btn {
    border: 2px solid var(--grey-border);
    background: #fff;
    border-radius: 8px;
    padding: 12px 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    text-align: center;
    line-height: 1.3;
}
.type-btn:hover { border-color: var(--blue); }
.type-btn.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

@media (max-width: 480px) {
    .type-buttons { grid-template-columns: 1fr; }
}

.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 500; }

.tile-checkbox-row {
    display: flex;
    gap: 8px;
}

.tile-checkbox {
    position: relative;
    flex: 1;
    cursor: pointer;
}
.tile-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.tile-checkbox-content {
    display: block;
    text-align: center;
    border: 2px solid var(--grey-border);
    border-radius: 8px;
    padding: 10px 8px;
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    background: #fff;
    transition: background .1s ease, border-color .1s ease, color .1s ease;
}
.tile-checkbox input:checked + .tile-checkbox-content {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}
.tile-checkbox input:focus-visible + .tile-checkbox-content {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}
.radio-group { display: flex; gap: 16px; font-weight: 500; font-size: 14px; }
.radio-group label { display: flex; align-items: center; gap: 6px; }

.conditional-fields.hidden,
#field-storage-number.hidden,
.hidden { display: none !important; }

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--grey-border);
    border-radius: 6px;
    z-index: 10;
    max-height: 160px;
    overflow-y: auto;
    box-shadow: 0 4px 10px rgba(0,0,0,.1);
}
.suggestion-item {
    padding: 8px 10px;
    cursor: pointer;
    font-size: 14px;
}
.suggestion-item:hover { background: var(--grey-bg); }

.form-error {
    background: #fdecea;
    color: var(--red);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
    flex-wrap: wrap;
}
.modal-footer-right { display: flex; gap: 10px; margin-left: auto; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--grey-border);
    padding: 32px 28px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-logo {
    height: 56px;
    margin-bottom: 16px;
}

.login-title {
    color: var(--navy);
    margin: 0 0 20px;
}

.container-wide { max-width: 1400px; }

.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    align-items: start;
}

.week-day {
    background: #fff;
    border: 1px solid var(--grey-border);
    border-radius: 8px;
    overflow: hidden;
    min-height: 120px;
}
.week-day.is-today { border-color: var(--blue); border-width: 2px; }

.week-day-header {
    display: block;
    text-align: center;
    background: var(--navy);
    color: #fff;
    text-decoration: none;
    padding: 8px 4px;
}
.week-day.is-today .week-day-header { background: var(--blue); }
.week-day-name { display: block; font-weight: 700; font-size: 12.5px; }
.week-day-date { display: block; font-size: 11px; opacity: .85; }

.week-day-appts {
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.week-empty {
    text-align: center;
    color: #bbb;
    font-size: 12px;
    margin: 8px 0;
}

.week-appt {
    display: flex;
    flex-direction: column;
    background: var(--grey-bg);
    border-left: 4px solid var(--blue);
    border-radius: 4px;
    padding: 5px 6px;
    text-decoration: none;
    color: var(--text);
    font-size: 11.5px;
    line-height: 1.3;
}
.week-appt.type-pneus { border-left-color: var(--yellow-dark); }
.week-appt.type-mecanique { border-left-color: var(--navy); }
.week-appt.has-storage { background: #fff9e6; }
.week-appt-time { font-weight: 700; }
.week-appt-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.week-appt .appt-badge { align-self: flex-start; margin-top: 2px; padding: 1px 5px; font-size: 10px; }

@media (max-width: 900px) {
    .week-grid { grid-template-columns: 1fr; }
    .week-day-header { display: flex; justify-content: space-between; padding: 8px 12px; text-align: left; }
}

.page-title {
    color: var(--navy);
    text-align: center;
    margin: 10px 0 20px;
}

.card {
    background: #fff;
    border: 1px solid var(--grey-border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}
.card h2 {
    margin-top: 0;
    color: var(--navy);
    font-size: 17px;
}

.muted { color: #666; font-size: 13.5px; }

.info-box {
    background: #e8f4ea;
    border: 1px solid #a9d8b0;
    color: #205c2b;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 18px;
}

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

.table-scroll { overflow-x: auto; margin-top: 10px; }

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}
.preview-table th, .preview-table td {
    border: 1px solid var(--grey-border);
    padding: 6px 10px;
    text-align: left;
}
.preview-table th { background: var(--grey-bg); }

.source-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}
.source-manuel { background: #e4e6ef; color: var(--navy); }
.source-nch { background: #d9ecff; color: #0b5ed7; }

@media (max-width: 600px) {
    .topbar-actions .btn { font-size: 13px; padding: 8px 10px; }
    .field-row { flex-direction: column; }
    .appt-card { flex-wrap: wrap; }
    .modal { max-width: 100%; }
}
