:root {
  --ground: #F6F4EF; --ink: #1B2430; --muted: #4F5966; --line: #E2DED4; --line-strong: #CFC9BB;
  --soft: #EFEBE2; --card: #FFFFFF; --nav: #14222B; --nav-text: #D5DDE2; --nav-muted: #B9C4CC;
  --accent: #0E5A5A; --accent-dark: #093F3F; --accent-tint: #DCE9E7;
  --warn-bg: #F3E3C3; --warn-ink: #6B4A0B; --danger: #9A2B1E;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Instrument Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--body); background: var(--ground); color: var(--ink); font-size: 15px; line-height: 1.4; }
a { color: var(--accent); } a:hover { color: var(--accent-dark); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; }
h1 { font-size: 34px; letter-spacing: -0.7px; } h2 { font-size: 20px; }
button, input, select, textarea { font-family: inherit; font-size: 15px; color: var(--ink); }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #2F7F7F; outline-offset: 2px; }

/* Structure */
.shell { display: flex; min-height: 100vh; }
.nav { width: 248px; flex-shrink: 0; padding: 32px 20px; background: var(--nav); color: var(--ground); display: flex; flex-direction: column; gap: 32px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 0 12px; display: flex; flex-direction: column; gap: 4px; }
.brand-name { font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.brand-sub { font-size: 13px; color: var(--nav-muted); }
.nav-links { display: flex; flex-direction: column; gap: 4px; }
.nav-links a { padding: 12px; border-radius: 10px; color: var(--nav-text); text-decoration: none; }
.nav-links a:hover { background: #1E313C; color: #fff; }
.nav-links a.on { background: var(--accent); color: #fff; font-weight: 600; }
.nav-block { padding: 0 12px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--nav-muted); }
.nav-block strong { color: var(--ground); font-size: 15px; }
.nav-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.nav-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid #2C3D48; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.linkish { background: none; border: none; padding: 0; color: var(--nav-muted); text-decoration: underline; font-size: 13px; text-align: left; min-height: 32px; }
.main { flex-grow: 1; min-width: 0; padding: 40px 48px 64px; display: flex; flex-direction: column; gap: 32px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.head p { margin: 6px 0 0; color: var(--muted); font-size: 16px; }

/* Champs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .legend { font-size: 13px; font-weight: 600; }
.input { height: 46px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; width: 100%; }
textarea.input { height: auto; padding: 12px 14px; min-height: 120px; line-height: 1.45; }
.search { width: 340px; max-width: 100%; }
.check { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 46px; padding: 0 18px; border: none; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; }
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line-strong); }
.btn.danger { background: var(--danger); }
.text-btn { background: none; border: none; min-height: 44px; padding: 0 10px; font-weight: 600; font-size: 14px; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; }
.text-btn.danger { color: var(--danger); }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.notice { padding: 14px 16px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-ink); }

/* Tuiles */
.section { display: flex; flex-direction: column; gap: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; gap: 12px; min-height: 132px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-2px); }
.tile-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mono { width: 44px; height: 44px; border-radius: 11px; background: var(--accent-tint); color: var(--accent); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 700; font-size: 17px; flex-shrink: 0; }
.badge { white-space: nowrap; padding: 4px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-ink); font-size: 11px; font-weight: 600; }
.tile-name { font-size: 16px; font-weight: 600; }
.tile-desc { font-size: 13px; color: var(--muted); }
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.pc { padding: 16px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 12px; }
.pc-row { display: flex; align-items: center; gap: 16px; }
.pc-row > div { flex-grow: 1; }
.pc summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 32px; }
.guide { white-space: pre-line; margin: 8px 0 0; color: var(--ink); }
.empty { padding: 32px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted); text-align: center; }

/* Connexion */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--nav); }
.login-card { width: 440px; max-width: 100%; padding: 40px; border-radius: 18px; background: var(--ground); display: flex; flex-direction: column; gap: 20px; }
.login-card .brand-name { font-size: 34px; }

/* Administration */
.admin-cols { display: flex; gap: 28px; align-items: flex-start; }
.admin-cols > .grow { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.panel { width: 340px; flex-shrink: 0; padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 16px; }
.panel.wide { width: 100%; max-width: 640px; }
.table { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.table table { width: 100%; border-collapse: collapse; }
.table th { background: var(--soft); font-size: 12px; font-weight: 600; color: #3A4450; text-align: left; padding: 12px 16px; line-height: 1.25; }
.table th.c, .table td.c { text-align: center; padding-left: 6px; padding-right: 6px; }
.table td { padding: 8px 16px; border-top: 1px solid #ECE8DF; vertical-align: middle; }
.table .cat-row td { background: #FAF8F3; font-family: var(--display); font-weight: 600; padding: 10px 16px; }
.sub { font-size: 12px; color: var(--muted); }
.toggle { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line-strong); background: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.toggle.on { background: var(--accent); border-color: var(--accent); }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 4px; white-space: nowrap; }
details.confirm { position: relative; }
details.confirm summary { list-style: none; }
details.confirm summary::-webkit-details-marker { display: none; }
details.confirm[open] .pop { position: absolute; right: 0; top: 44px; z-index: 5; padding: 12px; background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 8px 24px rgba(20,34,43,.15); display: flex; flex-direction: column; gap: 8px; width: 240px; white-space: normal; font-size: 13px; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--accent-tint); color: var(--accent-dark); font-size: 12px; font-weight: 600; margin: 2px 4px 2px 0; }
.pill.off { background: #EADAD7; color: #6E1F15; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex-grow: 1; }
fieldset { margin: 0; padding: 0; border: none; display: flex; flex-direction: column; gap: 8px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }

@media (max-width: 1500px) {
  .admin-cols { flex-direction: column; }
  .admin-cols > .grow { width: 100%; }
  .admin-cols > .panel { width: 100%; max-width: 640px; }
}

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .nav { width: 100%; height: auto; position: static; padding: 20px 16px; gap: 16px; }
  .nav-links { flex-direction: row; flex-wrap: wrap; }
  .nav-block { display: none; }
  .nav-foot { margin-top: 0; flex-direction: row; justify-content: space-between; align-items: center; }
  .main { padding: 24px 16px 48px; }
  .admin-cols, .two { display: flex; flex-direction: column; }
  .panel { width: 100%; }
  .pc-grid { grid-template-columns: 1fr; }
  h1 { font-size: 28px; }
}
[hidden] { display: none !important; }

/* Aperçus des tuiles */
.tile.has-preview { padding: 0; overflow: hidden; gap: 0; }
.tile-shot { position: relative; aspect-ratio: 16 / 10; background: var(--soft); border-bottom: 1px solid var(--line); }
.tile-shot img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.tile-shot .badge { position: absolute; top: 8px; right: 8px; }
.tile.has-preview .tile-text { padding: 12px 14px 14px; }
.preview-current { width: 240px; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; display: block; }

/* Ma journée */
.today-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.today-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.today-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.today-list a { display: flex; gap: 12px; align-items: baseline; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; text-decoration: none; color: var(--ink); border-left: 4px solid var(--c, var(--accent)); }
.today-list a:hover { background: var(--soft); }
.today-list time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 96px; }
.today-list .sub { margin-left: auto; white-space: nowrap; }

/* Agenda */
.ag-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: #fff; }
.seg a { min-height: 44px; min-width: 44px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); font-weight: 500; border-right: 1px solid var(--line); }
.seg a:last-child { border-right: none; }
.seg a:hover { background: var(--soft); }
.seg a.on { background: var(--accent); color: #fff; }
.ag-cals { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: center; }
.dot { width: 12px; height: 12px; border-radius: 4px; background: var(--c, var(--accent)); display: inline-block; flex-shrink: 0; }
.ag-body { display: flex; gap: 24px; align-items: flex-start; }
.ag-view { flex-grow: 1; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: auto; }
.detail { width: 340px; position: sticky; top: 24px; }
.detail h2 { font-size: 22px; }
.detail dl { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.detail dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-top: 10px; }
.detail dd { margin: 0; }
.detail-src { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.detail-actions { display: flex; gap: 8px; align-items: center; }

.grid { display: grid; grid-template-columns: 64px repeat(var(--cols), minmax(110px, 1fr)); min-width: calc(64px + var(--cols) * 110px); }
.grid-corner, .grid-day, .grid-label, .grid-allday { border-bottom: 1px solid var(--line); }
.grid-day { padding: 10px 8px; text-align: center; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); }
.grid-day span { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.grid-day strong { font-family: var(--display); font-size: 22px; font-weight: 600; }
.grid-day.today strong { background: var(--accent); color: #fff; border-radius: 999px; width: 38px; height: 38px; line-height: 38px; margin: 0 auto; }
.grid-label { font-size: 11px; color: var(--muted); padding: 8px 8px 8px 0; text-align: right; }
.grid-allday { border-left: 1px solid var(--line); padding: 4px; display: flex; flex-direction: column; gap: 3px; min-height: 32px; }
.grid-hours div { font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.grid-col { position: relative; border-left: 1px solid var(--line); background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px); }
.grid-col.today { background-color: #F3F8F7; }
.slot { position: absolute; left: 0; right: 0; }
.slot:hover { background: rgba(14, 90, 90, .07); }
.ev { position: absolute; overflow: hidden; border-radius: 8px; padding: 4px 8px; text-decoration: none; color: #fff; background: var(--c); display: flex; flex-direction: column; font-size: 13px; line-height: 1.25; border: 1px solid rgba(255, 255, 255, .7); }
.ev:hover { color: #fff; filter: brightness(1.12); }
.ev.sel, .chip.sel { outline: 3px solid #1B2430; outline-offset: 1px; z-index: 2; }
.ev-time { font-size: 11px; opacity: .92; font-variant-numeric: tabular-nums; }
.ev-title { font-weight: 600; }
.ev-loc { font-size: 11px; opacity: .92; }
.chip { display: block; padding: 3px 8px; border-radius: 6px; background: var(--c); color: #fff; text-decoration: none; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip:hover { color: #fff; filter: brightness(1.12); }
.chip b { font-weight: 600; font-variant-numeric: tabular-nums; }

.month { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); min-width: 840px; }
.month-head { padding: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); }
.month-cell { min-height: 118px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.month-cell:nth-child(7n) { border-right: none; }
.month-cell.out { background: #FAF8F3; }
.month-cell.out .month-num { color: #8A929B; }
.month-num { align-self: flex-end; min-width: 30px; height: 30px; line-height: 30px; text-align: center; border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14px; }
.month-cell.today .month-num { background: var(--accent); color: #fff; }
.more { font-size: 12px; padding: 2px 8px; }

@media (max-width: 1100px) {
  .ag-body { flex-direction: column; }
  .detail { width: 100%; position: static; order: -1; }
}
