/* =====================================================================
   Confroom — feuille de style principale
   Thème clair/sombre, couleur de marque par société (--brand)
   ===================================================================== */

:root {
  --brand: #4f46e5;
  --brand-ink: #fff;
  --bg: #f5f6fa;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, color-mix(in srgb, var(--brand) 9%, transparent), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef0f6;
  --border: #e6e8ef;
  --border-strong: #d5d9e3;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #eceef4;
  --line-soft: #f4f5f9;
  --danger: #e11d48;
  --success: #059669;
  --warning: #d97706;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -8px rgba(15, 23, 42, .10);
  --shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, .28);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 268px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --hour-h: 64px;
  --time-w: 62px;
  --colmin: 150px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12; --surface: #13161d; --surface-2: #171b23; --surface-3: #1e2330;
    --border: #232835; --border-strong: #2f3646; --text: #e8ebf2; --text-2: #c3c9d6;
    --muted: #8b93a7; --faint: #5d6579; --line: #1f2430; --line-soft: #191d26;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.5); --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d12; --surface: #13161d; --surface-2: #171b23; --surface-3: #1e2330;
  --border: #232835; --border-strong: #2f3646; --text: #e8ebf2; --text-2: #c3c9d6;
  --muted: #8b93a7; --faint: #5d6579; --line: #1f2430; --line-soft: #191d26;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.5); --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text);
  background: var(--bg-grad), var(--bg); background-attachment: fixed;
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.micro { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.ic { flex: none; display: block; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------------------------------------------------------- Shell */
.shell { min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 6px; padding: 18px 14px 14px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-right: 1px solid var(--border);
}
.main { margin-left: var(--sidebar-w); padding: 26px 30px 40px; min-width: 0; }
.topbar { display: none; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 12px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sidebar-brand-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-brand-text strong { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.sidebar-brand-text small { color: var(--muted); font-size: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 60%, #000));
  color: var(--brand-ink); font-weight: 800; font-size: 14px; letter-spacing: .02em;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--brand) 70%, transparent);
}
.brand-mark.is-logo { background: #fff; object-fit: contain; padding: 4px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.brand-mark.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }
.ctx-switch { padding: 10px 8px 12px; border-bottom: 1px dashed var(--border); margin-bottom: 6px; }
.ctx-switch select { width: 100%; margin-top: 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { margin: 16px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 650; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
  color: var(--text-2); font-weight: 550; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.is-active { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
:root[data-theme="dark"] .nav-item.is-active { color: color-mix(in srgb, var(--brand) 55%, #fff); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav-item.is-active { color: color-mix(in srgb, var(--brand) 55%, #fff); } }
.sidebar-foot { display: flex; align-items: center; gap: 4px; padding: 12px 4px 0; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border-radius: 10px; }
.me:hover { background: var(--surface-3); }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-text strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); font-size: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--brand) 16%, var(--surface)); color: var(--brand); font-weight: 700; font-size: 12.5px;
}
.avatar.sm { width: 30px; height: 30px; font-size: 11.5px; }
.theme-sun { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; } :root[data-theme="dark"] .theme-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-sun { display: block; } :root:not([data-theme="light"]) .theme-moon { display: none; } }
.scrim { display: none; }
.only-mobile, .icon-btn.only-mobile { display: none; }

@media (max-width: 1023px) {
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30;
    padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
  }
  .topbar-brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-weight: 700; }
  .topbar-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
  .sidebar { transform: translateX(-102%); transition: transform .28s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow-lg); background: var(--surface); }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(2,6,23,.45); z-index: 35; }
  .main { margin-left: 0; padding: 16px 16px 32px; }
  .only-mobile, .icon-btn.only-mobile { display: grid; }
}

/* -------------------------------------------------------- Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: transform .08s, background .15s, box-shadow .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--brand) 80%, transparent); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); border-color: var(--danger); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-lg { height: 48px; font-size: 15.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0;
  background: transparent; color: var(--text-2); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.bordered { border: 1px solid var(--border); background: var(--surface); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 9px 12px; min-height: 42px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
input[type="color"] { padding: 4px; width: 56px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); margin: 0; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field small { color: var(--muted); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.radio { display: inline-flex; align-items: center; gap: 8px; margin-right: 14px; cursor: pointer; }
.form-error { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); font-weight: 550; font-size: 13.5px; }
.form-error ul { margin: 6px 0 0; padding-left: 18px; font-weight: 450; }

/* ---------------------------------------------------- Cards, pages */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; }
.card + .card { margin-top: 16px; }
.section-title { margin: 28px 0 12px; }
.flash {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-weight: 550;
  background: color-mix(in srgb, var(--brand) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
}
.flash-success { background: color-mix(in srgb, var(--success) 10%, var(--surface)); border-color: color-mix(in srgb, var(--success) 28%, transparent); color: color-mix(in srgb, var(--success) 75%, var(--text)); }
.flash-error { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 28%, transparent); color: var(--danger); }
.flash-x { margin-left: auto; background: none; border: 0; font-size: 20px; color: inherit; cursor: pointer; opacity: .6; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge-brand { background: color-mix(in srgb, var(--brand) 13%, transparent); color: var(--brand); }
.badge-success { background: color-mix(in srgb, var(--success) 13%, transparent); color: var(--success); }
.badge-danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--brand)); flex: none; display: inline-block; }
.empty { text-align: center; padding: 64px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-ic { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); margin-bottom: 6px; }
.empty .btn { margin-top: 10px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-2); }
.table .actions { text-align: right; white-space: nowrap; }
.cell-user { display: flex; align-items: center; gap: 12px; }
.cell-user small { display: block; color: var(--muted); font-size: 12.5px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tile { position: relative; padding: 18px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c, var(--brand)); }
.tile-head { display: flex; align-items: flex-start; gap: 12px; }
.tile-ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--c, var(--brand)) 14%, transparent); color: var(--c, var(--brand)); }
.tile-title { flex: 1; min-width: 0; }
.tile-title h3 { font-size: 16px; }
.tile-title p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tile-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tile-foot { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }
.tile.is-off { opacity: .6; }
.equip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 550; }
.equip .ic { width: 14px; height: 14px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; }
.stat b { display: block; font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 13px; }

.settings-grid { display: grid; grid-template-columns: 260px 1fr; gap: 28px; padding: 24px 0; border-bottom: 1px solid var(--border); }
.settings-grid:last-of-type { border-bottom: 0; }
.settings-grid > div:first-child p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); transition: transform .1s; }
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.logo-drop { display: flex; align-items: center; gap: 16px; }
.logo-preview { width: 76px; height: 76px; border-radius: 18px; border: 1px dashed var(--border-strong); display: grid; place-items: center; overflow: hidden; background: var(--surface-2); }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; padding: 6px; background: #fff; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.secret-box { padding: 16px; border-radius: 12px; background: color-mix(in srgb, var(--success) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); margin-bottom: 18px; }
.secret-box p { margin-bottom: 10px; font-weight: 600; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 12px; overflow-x: auto; line-height: 1.6; margin: 10px 0 0; }
.doc h3 { margin: 22px 0 6px; }
.doc p, .doc li { color: var(--text-2); }
.doc code:not(pre code) { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.endpoint { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; flex-wrap: wrap; }
.method { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px; min-width: 60px; text-align: center; }
.m-get { background: #dbeafe; color: #1d4ed8; } .m-post { background: #dcfce7; color: #15803d; }
.m-patch { background: #fef3c7; color: #b45309; } .m-delete { background: #ffe4e6; color: #be123c; }

@media (max-width: 860px) {
  .settings-grid { grid-template-columns: 1fr; gap: 14px; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :first-child { grid-column: 1 / -1; }
  h1 { font-size: 22px; }
  .table .hide-sm { display: none; }
}

/* ---------------------------------------------------------- Calendar */
.cal-page { display: flex; flex-direction: column; gap: 14px; height: calc(100dvh - 66px); min-height: 520px; }
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cal-nav, .cal-actions { display: flex; align-items: center; gap: 8px; }
.cal-title { position: relative; display: inline-flex; align-items: center; margin-left: 8px; cursor: pointer; }
.cal-title span { font-size: 22px; font-weight: 750; letter-spacing: -.02em; text-transform: capitalize; white-space: nowrap; }
.cal-title input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; padding: 0; }
.cal-title input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 13.5px; color: var(--muted); padding: 7px 14px; border-radius: 9px; cursor: pointer; touch-action: manipulation; }
.seg button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; flex: none;
  transition: all .15s; touch-action: manipulation;
}
.chip .dot { background: var(--c); }
.chip.is-off { opacity: .45; }
.chip.is-off .dot { background: var(--faint); }
.chip.chip-toggle.is-on { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.chip small { color: var(--muted); font-weight: 500; }
.cal-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 296px; gap: 16px; }
.cal-stage { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; position: relative; }
.cal-side { display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow-y: auto; }
@media (max-width: 1279px) { .cal-body { grid-template-columns: 1fr; } .cal-side { display: none; } }
.loading-bar { position: absolute; top: 0; left: 0; height: 2px; width: 30%; background: var(--brand); animation: load 1s ease-in-out infinite; z-index: 9; }
@keyframes load { 0% { left: -30%; } 100% { left: 100%; } }

/* Time grid */
.tg { flex: 1; overflow: auto; position: relative; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.tg-head, .tg-body { display: grid; grid-template-columns: var(--time-w) repeat(var(--cols), minmax(var(--colmin), 1fr)); min-width: min-content; }
.tg-head { position: sticky; top: 0; z-index: 6; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.tg-corner { position: sticky; left: 0; z-index: 2; background: var(--surface); }
.tg-colhead { padding: 10px 12px; border-left: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; gap: 3px; cursor: default; }
.tg-colhead .ch-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tg-colhead strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-colhead .ch-sub { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; min-width: 0; }
.tg-colhead .ch-sub > span { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.tg-colhead .ch-sub .status { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: block; }
.tg-colhead .ch-sub .status::before { display: inline-block; margin-right: 5px; vertical-align: 1px; }
.tg-colhead .ch-sub .ic { width: 13px; height: 13px; }
.status { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.free { color: var(--success); } .status.busy { color: var(--danger); }
.tg-colhead.day { align-items: center; text-align: center; cursor: pointer; }
.tg-colhead.day .dow { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.tg-colhead.day .dnum { font-size: 22px; font-weight: 700; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; line-height: 1; }
.tg-colhead.day.is-today .dnum { background: var(--brand); color: var(--brand-ink); }
.tg-times { position: sticky; left: 0; z-index: 4; background: var(--surface); border-right: 1px solid var(--line); }
.tg-time { position: absolute; right: 10px; transform: translateY(-50%); font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; font-weight: 500; }
.tg-col {
  position: relative; border-left: 1px solid var(--line); cursor: cell; touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none;
  background-image:
    linear-gradient(to bottom, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
  background-size: 100% var(--hour-h), 100% calc(var(--hour-h) / 2);
}
.tg-col.is-weekend { background-color: var(--surface-2); }
.tg-col.is-closed { cursor: not-allowed; background-color: var(--surface-2); }
.tg-past { position: absolute; left: 0; right: 0; top: 0; background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--text) 3%, transparent) 6px 7px); pointer-events: none; }
.now-line { position: absolute; left: -1px; right: 0; height: 2px; background: #ef4444; z-index: 5; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; }
.now-label { position: absolute; right: 6px; transform: translateY(-50%); font-size: 11px; font-weight: 700; color: #fff; background: #ef4444; padding: 1px 6px; border-radius: 6px; z-index: 5; }

.ev {
  position: absolute; left: 4px; right: 4px; z-index: 3; overflow: hidden; border-radius: 10px; padding: 6px 9px;
  background: color-mix(in srgb, var(--c) 15%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 25%, transparent);
  border-left: 3px solid var(--c); color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 1px;
  transition: box-shadow .15s, transform .15s; font-size: 12.5px; line-height: 1.3; -webkit-tap-highlight-color: transparent;
}
.ev:hover { box-shadow: var(--shadow); z-index: 4; }
.ev b { font-weight: 650; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev i { font-style: normal; color: var(--text-2); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.short { flex-direction: row; align-items: center; gap: 6px; padding-top: 2px; padding-bottom: 2px; }
.ev.mine::after { content: ""; position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.ev.masked {
  --c: #94a3b8; cursor: default; color: var(--muted);
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, var(--surface-3) 8px 16px);
}
.ev.is-past { opacity: .62; }
.ev-ghost { position: absolute; left: 4px; right: 4px; z-index: 5; border-radius: 10px; border: 2px dashed var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); pointer-events: none; padding: 5px 8px; font-size: 12px; font-weight: 700; color: var(--brand); }

/* Month grid */
.mg { flex: 1; display: grid; grid-template-rows: auto 1fr; min-height: 0; overflow: auto; }
.mg-head, .mg-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mg-head div { padding: 10px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.mg-grid { grid-auto-rows: minmax(108px, 1fr); }
.mg-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; cursor: pointer; transition: background .12s; }
.mg-cell:nth-child(7n) { border-right: 0; }
.mg-cell:hover { background: var(--surface-2); }
.mg-cell.is-out { background: var(--surface-2); }
.mg-cell.is-out .mg-num { color: var(--faint); }
.mg-num { font-size: 13px; font-weight: 650; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; }
.mg-cell.is-today .mg-num { background: var(--brand); color: var(--brand-ink); }
.pill { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, var(--c) 13%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pill time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.pill span { overflow: hidden; text-overflow: ellipsis; }
.pill.masked { --c: #94a3b8; color: var(--muted); }
.mg-more { font-size: 12px; color: var(--muted); font-weight: 600; padding-left: 6px; }
@media (max-width: 700px) {
  .mg-grid { grid-auto-rows: minmax(64px, 1fr); }
  .pill { font-size: 0; padding: 0; height: 6px; border-radius: 3px; background: var(--c); }
  .pill time, .pill span { display: none; }
  .mg-more { font-size: 10px; }
}

/* Agenda list */
.agenda { flex: 1; overflow: auto; padding: 8px 20px 24px; }
.ag-day { display: grid; grid-template-columns: 92px 1fr; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.ag-date { position: sticky; top: 8px; align-self: start; }
.ag-date b { display: block; font-size: 26px; font-weight: 750; line-height: 1; letter-spacing: -.02em; }
.ag-date span { color: var(--muted); font-size: 12.5px; text-transform: capitalize; }
.ag-date.is-today b { color: var(--brand); }
.ag-list { display: flex; flex-direction: column; gap: 8px; }
.ag-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.ag-item:hover { background: var(--surface-3); }
.ag-item .bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--c); }
.ag-item time { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 98px; font-size: 13.5px; }
.ag-item .ag-main { flex: 1; min-width: 0; }
.ag-item .ag-main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-item .ag-main small { color: var(--muted); }
.ag-item.masked { cursor: default; opacity: .75; }
.ag-empty { color: var(--faint); font-size: 13.5px; padding: 6px 0; }
@media (max-width: 600px) { .ag-day { grid-template-columns: 1fr; gap: 8px; } .ag-date { position: static; display: flex; align-items: baseline; gap: 8px; } .ag-item time { min-width: 80px; } }

/* Mini calendar + upcoming */
.mini-cal { padding: 14px; }
.mc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mc-head strong { text-transform: capitalize; font-size: 14px; }
.mc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.mc-dow { font-size: 11px; color: var(--faint); font-weight: 600; padding: 4px 0; }
.mc-day { position: relative; height: 34px; border-radius: 9px; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 550; color: var(--text-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.mc-day:hover { background: var(--surface-3); }
.mc-day.is-out { color: var(--faint); }
.mc-day.is-today { color: var(--brand); font-weight: 800; }
.mc-day.is-sel { background: var(--brand); color: var(--brand-ink); }
.mc-day.has::after { content: ""; position: absolute; bottom: 4px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; opacity: .6; }
.upcoming { padding: 0 8px 10px; }
.up-item { display: flex; gap: 12px; padding: 10px 8px; border-radius: 10px; cursor: pointer; }
.up-item:hover { background: var(--surface-2); }
.up-item .bar { width: 3px; border-radius: 3px; background: var(--c); }
.up-item b { display: block; font-size: 13.5px; }
.up-item small { color: var(--muted); font-size: 12.5px; }

/* Responsive calendar */
@media (max-width: 1023px) { .cal-page { height: calc(100dvh - 58px - env(safe-area-inset-top)); } }
@media (max-width: 760px) {
  :root { --hour-h: 56px; --time-w: 50px; --colmin: 128px; }
  .cal-page { gap: 10px; }
  .cal-toolbar { gap: 10px; }
  .cal-nav { width: 100%; }
  .cal-title { margin-left: 4px; flex: 1; min-width: 0; }
  .cal-title span { font-size: 17px; overflow: hidden; text-overflow: ellipsis; }
  .cal-actions { width: 100%; justify-content: space-between; }
  .seg button { padding: 7px 10px; font-size: 13px; }
  #btn-new span { display: none; }
  #btn-new { width: 42px; padding: 0; }
  .tg-colhead { padding: 8px; }
  .main { padding: 12px 12px 0; }
}
/* Tablettes tactiles : cibles plus grandes */
@media (pointer: coarse) {
  :root { --hour-h: 72px; }
  .btn { height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .seg button { padding: 9px 14px; }
  .chip { padding: 9px 14px 9px 12px; }
  input, select, textarea { min-height: 46px; font-size: 16px; }
}

/* ------------------------------------------------------------- Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; visibility: hidden; }
.modal.is-open { visibility: visible; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 23, .5); backdrop-filter: blur(3px); opacity: 0; transition: opacity .2s; }
.modal.is-open .modal-backdrop { opacity: 1; }
.modal-card {
  position: relative; width: min(560px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; background: var(--surface);
  border-radius: 20px; box-shadow: var(--shadow-lg); padding: 22px 24px 20px; transform: translateY(16px) scale(.98); opacity: 0;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .2s; border: 1px solid var(--border);
}
.modal.is-open .modal-card { transform: none; opacity: 1; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.bm-readonly:empty { display: none; }
#bm-fields { display: flex; flex-direction: column; gap: 14px; }
.chip input[type=checkbox] { width: 16px; height: 16px; }
.ro-block { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.ro-row { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.ro-row .ic { color: var(--muted); }
.avail { font-size: 13px; padding: 9px 12px; border-radius: 10px; font-weight: 550; display: flex; align-items: center; gap: 8px; }
.avail.ok { background: color-mix(in srgb, var(--success) 10%, transparent); color: var(--success); }
.avail.ko { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.series-scope { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); display: flex; flex-wrap: wrap; gap: 8px 4px; align-items: center; }
.series-scope .micro { width: 100%; }
@media (max-width: 640px) {
  .modal { padding: 0; place-items: end stretch; }
  .modal-card { width: 100%; border-radius: 22px 22px 0 0; max-height: 92dvh; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); }
  .modal-card::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: -6px auto 12px; }
}

/* ------------------------------------------------------------- Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: #0f172a; color: #fff; box-shadow: var(--shadow-lg); font-weight: 550; font-size: 14px; animation: toastIn .3s cubic-bezier(.2,.8,.2,1); max-width: 380px; }
.toast.error { background: var(--danger); }
.toast.success::before { content: "✓"; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--success); font-size: 12px; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } }
@media (max-width: 640px) { .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); } .toast { max-width: none; } }

/* ------------------------------------------------------------- Auth */
body.auth { background: var(--bg); }
.auth-wrap { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-visual {
  position: relative; overflow: hidden; color: #fff; display: flex; align-items: center; justify-content: center; padding: 48px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--brand) 92%, #000), color-mix(in srgb, var(--brand) 55%, #000) 70%, #050816);
}
.auth-visual-inner { position: relative; max-width: 460px; z-index: 1; }
.auth-visual h2 { font-size: 34px; font-weight: 800; letter-spacing: -.03em; margin-top: 36px; }
.auth-visual p { opacity: .8; font-size: 16px; margin-top: 10px; }
.auth-orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; z-index: 0; }
.auth-orb.o1 { width: 340px; height: 340px; background: color-mix(in srgb, var(--brand) 60%, #fff); top: -120px; left: -80px; }
.auth-orb.o2 { width: 260px; height: 260px; background: #22d3ee; bottom: -60px; right: -40px; opacity: .3; }
.auth-orb.o3 { width: 200px; height: 200px; background: #f472b6; top: 40%; right: 10%; opacity: .25; }
.auth-preview { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 22px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); }
.ap-row { display: flex; align-items: center; gap: 14px; }
.ap-time { font-size: 12px; opacity: .7; width: 40px; font-variant-numeric: tabular-nums; }
.ap-ev { flex: 1; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.95); color: #0f172a; border-left: 4px solid var(--c); display: flex; flex-direction: column; }
.ap-ev b { font-size: 13.5px; } .ap-ev i { font-style: normal; font-size: 12px; color: #64748b; }
.ap-ev.ap-free { background: rgba(255,255,255,.12); color: #fff; border: 1px dashed rgba(255,255,255,.5); }
.ap-ev.ap-free i { color: rgba(255,255,255,.7); }
.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; gap: 18px; }
.auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 10px; }
.auth-card h1 { font-size: 28px; margin-top: 8px; }
.auth-card .form { margin-top: 18px; }
.auth-foot { display: flex; gap: 14px; justify-content: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.auth-foot a.is-active { color: var(--text); font-weight: 650; }
.powered { color: var(--faint); font-size: 12px; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-visual { display: none; } }

/* Install */
.install { max-width: 720px; margin: 40px auto; padding: 0 16px; }
h1 .ic, h2 .ic, h3 .ic { display: inline-block; vertical-align: -3px; }
.tiles { align-items: start; }
