:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --border: #d8dee6;
    --text: #1a2a3d;
    --muted: #5b6a7d;
    --accent: #2d6cdf;
    --accent-dark: #1f4ea3;
    --green: #2f8f5b;
    --red: #c4453a;
    --orange: #d68c2a;
    --shadow: 0 2px 6px rgba(20, 30, 50, 0.05);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --------- header --------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}
.site-header__brand {
    font-weight: 700;
    color: var(--text);
    font-size: 1.05rem;
}
.site-header__brand small {
    font-weight: 400;
    color: var(--muted);
    margin-left: 0.4rem;
}
.site-header__nav { display: flex; gap: 1.2rem; align-items: center; }
.site-header__nav a { color: var(--muted); font-weight: 600; }
.site-header__nav a:hover, .site-header__nav a.is-active { color: var(--text); text-decoration: none; }
.site-header__user { display: flex; align-items: center; gap: 0.7rem; color: var(--muted); }
.site-header__user a { color: var(--muted); font-size: 0.9rem; }

.main {
    max-width: 1100px;
    margin: 1.5rem auto 4rem;
    padding: 0 1.5rem;
}

h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 0.8rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }

/* --------- flash --------- */
.flash {
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    border: 1px solid;
}
.flash--success { background: #e8f5ec; border-color: #b8dcc4; color: #1c5b34; }
.flash--error   { background: #fbe9e6; border-color: #e2b3ad; color: #7a261e; }
.flash--info    { background: #e8eff8; border-color: #b9cbe5; color: #1c3f7a; }

/* --------- cards / surfaces --------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.muted { color: var(--muted); font-size: 0.9rem; }

/* --------- list of tickets --------- */
.ticket-list { list-style: none; padding: 0; margin: 0; }
.ticket-list__item {
    display: grid;
    grid-template-columns: 110px 1fr 90px 120px 110px;
    gap: 1rem;
    padding: 0.65rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    align-items: center;
}
.ticket-list__item:hover { border-color: var(--accent); }
.ticket-key { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; color: var(--muted); font-size: 0.85rem; }
.ticket-title { color: var(--text); font-weight: 500; }
.ticket-title a { color: var(--text); }

/* --------- badges --------- */
.badge {
    display: inline-block;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid;
    white-space: nowrap;
}
.badge--status-open         { background: #eaf1fb; color: #1c4ea3; border-color: #c8d8ef; }
.badge--status-in_progress  { background: #fdf3e0; color: #7d4f12; border-color: #ecd6a7; }
.badge--status-resolved     { background: #e8f5ec; color: #1c5b34; border-color: #b8dcc4; }
.badge--status-closed       { background: #ececec; color: #5a5a5a; border-color: #c8c8c8; }

/* --- select inline pour changer le statut d'un dossier directement dans la liste --- */
.status-select {
    padding: 0.18rem 0.4rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 14px) calc(50% - 2px),
                         calc(100% - 9px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 1.6rem;
    font-family: inherit;
}
.status-select--open         { background-color: #eaf1fb; color: #1c4ea3; border-color: #c8d8ef; }
.status-select--in_progress  { background-color: #fdf3e0; color: #7d4f12; border-color: #ecd6a7; }
.status-select--resolved     { background-color: #e8f5ec; color: #1c5b34; border-color: #b8dcc4; }
.status-select--closed       { background-color: #ececec; color: #5a5a5a; border-color: #c8c8c8; }
.status-select option { background: #fff; color: #19314a; text-transform: none; }
.badge--prio-low      { background: #f3f3f3; color: #5a5a5a; border-color: #d8d8d8; }
.badge--prio-medium   { background: #eaf1fb; color: #1c4ea3; border-color: #c8d8ef; }
.badge--prio-high     { background: #fdf3e0; color: #7d4f12; border-color: #ecd6a7; }
.badge--prio-critical { background: #fbe9e6; color: #7a261e; border-color: #e2b3ad; }

/* --------- forms --------- */
.form-grid { display: grid; gap: 0.9rem; max-width: 720px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.form-row input[type=text],
.form-row input[type=email],
.form-row input[type=url],
.form-row input[type=number],
.form-row input[type=date],
.form-row input[type=password],
.form-row textarea,
.form-row select {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-family: inherit;
    font-size: 0.95rem;
    -webkit-user-select: text;
    user-select: text;
}
.form-row textarea { min-height: 140px; resize: vertical; }
.form-actions { display: flex; gap: 0.7rem; align-items: center; margin-top: 0.4rem; }
.button {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
}
.button:hover { background: var(--accent-dark); text-decoration: none; }
.button--ghost { background: transparent; color: var(--accent); border-color: var(--border); }
.button--ghost:hover { background: var(--bg); color: var(--accent-dark); }
.button--small { padding: 0.32rem 0.7rem; font-size: 0.85rem; }

/* --------- ticket detail --------- */
.ticket-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.7rem 1.4rem;
    margin: 0.6rem 0 1.4rem;
}
.ticket-meta dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.15rem; }
.ticket-meta dd { margin: 0; font-weight: 500; }
.ticket-description { white-space: pre-wrap; line-height: 1.6; }
.comment { padding: 0.7rem 1rem; border-left: 3px solid var(--border); margin-bottom: 0.8rem; }
.comment__author { font-weight: 600; }
.comment__date { color: var(--muted); font-size: 0.85rem; }
.comment__body { margin-top: 0.4rem; white-space: pre-wrap; }

/* --------- commission cards --------- */
.commission-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.8rem; }
.commission-card {
    display: block;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
}
.commission-card:hover { border-color: var(--accent); text-decoration: none; }
.commission-card__code { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.06em; }
.commission-card__name { font-weight: 600; margin-top: 0.2rem; }
.commission-card__counts { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }

/* --------- responsive minimum --------- */
@media (max-width: 720px) {
    .ticket-list__item { grid-template-columns: 1fr; }
    .site-header__nav { display: none; }
}

/* --------- variantes commission-card par catégorie --------- */
.commission-card--obligatoire { border-left: 3px solid var(--red); }
.commission-card--facultative { border-left: 3px solid var(--accent); }
.commission-card--exterieur   { border-left: 3px solid var(--green); }
.commission-card--divers      { border-left: 3px solid var(--muted); }
