:root {
  --accent: #2bbf9a;
  --accent-soft: rgba(43, 191, 154, 0.14);
  --accent-strong: #1fa883;
  --sidebar-bg: #f3f4f6;
  --page-bg: #f9fafb;
  --surface: #ffffff;
  --border: #ededed;
  --text: #111827;
  --muted: #6b7280;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
  --sidebar-w: 252px;
  --radius: 10px;
  --radius-pill: 999px;
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 18px;
  color: var(--text);
  background: var(--page-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: default;
}

.nav-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.scrim {
  display: none;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 1.35rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.75rem;
  padding: 0 0.35rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.brand-title {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.brand-kicker {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.nav-section + .nav-section {
  margin-top: 1.35rem;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #9ca3af;
  padding: 0 0.65rem 0.45rem;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  margin: 0.15rem 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #374151;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.7);
}

.nav-link .ic {
  width: 18px;
  height: 18px;
  color: #9ca3af;
  flex-shrink: 0;
}

.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent-strong);
}

.nav-link.is-active:hover {
  background: rgba(43, 191, 154, 0.2);
}

.nav-link.is-active .ic {
  color: var(--accent-strong);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.5rem;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.user-info:hover {
  background: rgba(255, 255, 255, 0.5);
}

.user-av {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(43, 191, 154, 0.25);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-initial {
  font-size: 1rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
}

.user-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-logout {
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.user-logout:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.top-bar-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.burger svg {
  width: 22px;
  height: 22px;
  color: var(--text);
}

.mobile-brand {
  font-weight: 600;
  font-size: 0.9rem;
}

.top-bar-spacer {
  width: 40px;
  flex-shrink: 0;
}

.main {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.shell {
  padding: 1.25rem 1.75rem 2rem;
  max-width: 1440px;
  margin-inline: auto;
  width: 100%;
}

/* Rule edit: use full main column width (no 1440px cap), keep comfortable padding */
.shell.shell--rule-edit {
  max-width: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-left: clamp(1.25rem, 4vw, 2.5rem);
  padding-right: clamp(1.25rem, 4vw, 2.5rem);
  padding-bottom: 2.5rem;
}

.view--rule-edit {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.crumb {
  font-size: 0.95rem;
  color: var(--muted);
}

.crumb strong {
  color: var(--text);
  font-weight: 600;
}

.crumb-sep {
  margin: 0 0.35rem;
  color: #d1d5db;
}

.tool-ic {
  box-sizing: border-box;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.045);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  position: relative;
  flex-shrink: 0;
}

.tool-ic svg {
  width: 20px;
  height: 20px;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.title-block {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.title-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.title-line h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.chev-btn {
  border: none;
  background: transparent;
  padding: 0;
  display: inline-flex;
  color: var(--muted);
}

.title-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.28rem 0.65rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: #fafafa;
  color: var(--muted);
}

.pill--live {
  background: rgba(43, 191, 154, 0.15);
  border-color: rgba(43, 191, 154, 0.35);
  color: var(--accent-strong);
}

.title-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

/* Même gabarit que Save / Supprimer sur la fiche placement (.placement-form-title-save, .btn-danger) */
.title-actions .btn-primary {
  min-height: 2.35rem;
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
  border-radius: var(--radius);
}

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.5rem 0.85rem;
  border-radius: 9px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 0;
}

.stats-bar {
  display: flex;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.06), 0 20px 50px -20px rgba(17, 24, 39, 0.12);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.stat {
  flex: 1;
  padding: 1.5rem 1.6rem 1.6rem;
  min-width: 0;
  min-height: 6.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: background 0.2s ease;
}

.stat:hover {
  background: rgba(255, 255, 255, 0.8);
}

.stat + .stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--border) 20%, var(--border) 80%, transparent);
}

.stat-k {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  font-weight: 700;
  margin-bottom: 0.65rem;
}

.stat-v {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-v .mini-ic {
  width: 20px;
  height: 20px;
  color: #64748b;
  flex-shrink: 0;
}

.tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: flex;
  gap: 1.25rem;
}

.tab {
  padding: 0.65rem 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.is-active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
}

.tab-count {
  color: var(--muted);
  font-weight: 500;
}

.filters-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin: 0.85rem 0 1.15rem;
  padding: 0.75rem 0;
  justify-content: flex-start;
}

.search {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  box-sizing: border-box;
  min-height: 50px;
  padding: 0 1.05rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
  flex: 1 1 360px;
  min-width: min(100%, 280px);
  max-width: 720px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search input {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  flex: 1 1 auto;
  width: 100%;
  min-width: 8rem;
  outline: none;
  color: var(--text);
}

.search:focus-within {
  border-color: rgba(43, 191, 154, 0.45);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 2px 6px rgba(17, 24, 39, 0.05);
}

.search input::placeholder {
  color: #9ca3af;
}

.search svg {
  width: 20px;
  height: 20px;
  color: #6b7280;
  flex-shrink: 0;
}

.search-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-strong);
  padding: 0.25rem 0.6rem;
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  border: 1px solid rgba(43, 191, 154, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.subtab {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: inherit;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

button.subtab {
  margin: 0;
}

a.subtab {
  display: inline-block;
  text-decoration: none;
  color: inherit;
  margin: 0;
}

.subtab.is-active {
  background: var(--accent-soft);
  border-color: rgba(43, 191, 154, 0.35);
  color: var(--accent-strong);
}

.banner-notice {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  min-width: 280px;
  max-width: 420px;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 1px solid rgba(43, 191, 154, 0.3);
  box-shadow: 0 8px 32px rgba(43, 191, 154, 0.15), 0 2px 8px rgba(17, 24, 39, 0.08);
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.banner-notice::before {
  content: "✓";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

.banner-notice--warn {
  position: relative;
  top: auto;
  right: auto;
  z-index: auto;
  min-width: auto;
  max-width: none;
  margin-bottom: 1rem;
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.35);
  color: #c2410c;
  box-shadow: none;
  animation: none;
}

.banner-notice--warn::before {
  content: "⚠";
  background: #f97316;
}

.placement-section-title {
  margin: 1.5rem 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.placement-metadata-card .placement-section-title:first-of-type,
.placement-form .placement-section-title:first-of-type {
  margin-top: 0;
}

/* Page fiche placement (lecture seule) */
.placement-show-hero {
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.4rem 1.35rem;
  border-radius: calc(var(--radius) + 2px);
  background: rgba(43, 191, 154, 0.09);
  border: 1px solid rgba(43, 191, 154, 0.32);
  box-shadow: 0 4px 18px rgba(17, 24, 39, 0.07);
}

.placement-show-toolbar {
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(43, 191, 154, 0.2);
}

.placement-show-toolbar-actions {
  margin-left: auto;
}

.placement-show-title {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.45rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text);
}

.placement-show-kleekr {
  margin: 0.45rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
}

.placement-show-kleekr .placement-show-id {
  margin-left: 0.35rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--muted);
}

.placement-show-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1rem;
}

.placement-show-dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.65rem 1.5rem;
  margin: 1.1rem 0 0;
  padding: 0;
}

.placement-show-dl div {
  margin: 0;
}

.placement-show-dl dt {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.2rem;
}

.placement-show-dl dd {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.placement-show-panel {
  margin-bottom: 1.35rem;
  padding: 1.15rem 1.25rem 1.3rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.placement-show-panel .form-section-title {
  margin: 0 0 0.35rem;
}

.placement-show-code {
  margin: 0.75rem 0 0;
  padding: 1rem 1.05rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: min(40vh, 20rem);
  overflow: auto;
}

.placement-show-window-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.placement-show-window-card {
  margin: 0;
  padding: 0.95rem 1rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.05);
}

.placement-show-window-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.placement-show-window-head strong {
  font-size: 0.92rem;
}

.placement-show-window-sched {
  margin: 0;
  font-size: 0.84rem;
  color: #4b5563;
  line-height: 1.45;
}

/* Formulaires placement : sections + barre d’actions */
.placement-form-toolbar {
  margin-bottom: 1.1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.placement-form-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Titre page édition + bouton « désactiver tout le placement » */
.placement-form-title-row {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.06);
}

.placement-form-title-block {
  min-width: 0;
  flex: 1;
}

.placement-form-page-title {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  font-size: clamp(1.12rem, 2.2vw, 1.38rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.25;
  color: var(--text);
}

.placement-form-page-title-text {
  font-weight: inherit;
  letter-spacing: inherit;
}

.placement-form-updated-at {
  font-size: 0.52em;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #94a3b8;
  white-space: nowrap;
  align-self: center;
}

.placement-inactive-note {
  display: none;
  margin: -0.35rem 0 1.25rem;
  max-width: 36rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #b45309;
  font-weight: 500;
}

.placement-form:has(.placement-deactivate-input:checked) .placement-inactive-note {
  display: block;
}

.placement-form:has(.placement-deactivate-input:checked) .placement-form-title-row {
  border-color: rgba(217, 119, 6, 0.4);
  background: #fffbeb;
}

.placement-form:has(.placement-deactivate-input:checked) > .form-section {
  opacity: 0.72;
  transition: opacity 0.2s ease;
}


.placement-form-title-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.placement-form-title-cancel {
  white-space: nowrap;
  min-height: 2.35rem;
  padding: 0.45rem 1.05rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.placement-form-title-save {
  white-space: nowrap;
  min-height: 2.35rem;
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
  border-radius: var(--radius);
  border: 1px solid rgba(43, 191, 154, 0.3);
  background: #f0fdf9;
  color: #0f766e;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.placement-form-title-save:hover {
  background: #e6fcf5;
  border-color: rgba(43, 191, 154, 0.45);
  color: #0d5f58;
}

.placement-form-title-save:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.placement-deactivate-control {
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
}

.placement-deactivate-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.placement-deactivate-face {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 2.35rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
  border: 1px solid rgba(100, 116, 139, 0.45);
  background: #f8fafc;
  color: #475569;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease;
}

.placement-deactivate-control:hover .placement-deactivate-face {
  background: #f1f5f9;
  border-color: rgba(71, 85, 105, 0.55);
  color: #334155;
}

.placement-deactivate-label--on {
  display: none;
}

.placement-deactivate-input:checked ~ .placement-deactivate-face {
  border-color: rgba(217, 119, 6, 0.55);
  background: #fef3c7;
  color: #92400e;
  box-shadow: 0 1px 3px rgba(180, 83, 9, 0.12);
}

.placement-deactivate-input:checked ~ .placement-deactivate-face .placement-deactivate-label--off {
  display: none;
}

.placement-deactivate-input:checked ~ .placement-deactivate-face .placement-deactivate-label--on {
  display: inline;
}

.placement-deactivate-control:has(.placement-deactivate-input:focus-visible) .placement-deactivate-face {
  outline: 2px solid rgba(43, 191, 154, 0.65);
  outline-offset: 2px;
}

@media (max-width: 680px) {
  .placement-form-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .placement-form-title-actions {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .placement-deactivate-control {
    align-self: stretch;
  }

  .placement-deactivate-face {
    width: 100%;
  }

  .placement-form-title-cancel,
  .placement-form-title-save {
    width: 100%;
  }
}

.placement-form > .form-section {
  margin-bottom: 1.75rem;
}

.form-section-head {
  margin-bottom: 1.1rem;
}

.form-section-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
}

.form-section-desc {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--muted);
  max-width: 44rem;
}

.placement-form .placement-metadata-card .form-section-head {
  margin-bottom: 1.1rem;
}

.placement-form-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.75rem;
  margin-bottom: -0.5rem;
  padding: 1rem 1.1rem;
  background: #f3f4f6;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 -4px 16px rgba(17, 24, 39, 0.05);
}

.placement-form-footer .btn-ghost {
  margin-right: auto;
}

.chip-hero {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(43, 191, 154, 0.4);
  color: var(--accent-strong);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.chip-hero--link {
  text-decoration: none;
  color: #0f766e;
  transition: background 0.15s, border-color 0.15s;
}

.chip-hero--link:hover {
  background: #fff;
  border-color: var(--accent-strong);
}

.chip-hero--muted {
  color: #64748b;
  border-color: rgba(100, 116, 139, 0.35);
  background: rgba(248, 250, 252, 0.95);
}

.placement-metadata-card {
  padding: 1.15rem 1.2rem 1.25rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.placement-callback-card {
  padding: 1.15rem 1.2rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.placement-metadata-card .placement-callback-card {
  padding: 1.1rem 0 0;
  margin: 1.1rem 0 0;
  border: none;
  border-top: 1px dashed var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.placement-callback-fallback-list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.placement-callback-fallback-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.65rem;
  margin-bottom: 0.45rem;
}

.placement-callback-fallback-label {
  font-size: 0.95rem;
}

.placement-callback-fallback-id {
  font-size: 0.78rem;
}

.placement-callback-fallback-item .field {
  margin-bottom: 0;
}


.placement-settings-callback-pre {
  max-height: min(70vh, 28rem);
  overflow: auto;
}

.placement-scripts-row {
  display: grid;
  gap: 1rem 1.35rem;
  grid-template-columns: 1fr;
  align-items: start;
  margin-top: 0.25rem;
}

@media (min-width: 900px) {
  .placement-scripts-row {
    grid-template-columns: 1fr 1fr;
  }
}

.placement-scripts-row .placement-script-field {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.placement-scripts-row .field {
  min-width: 0;
}

.placement-script-field {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px dashed var(--border);
}

.placement-script-field-hint {
  margin: 0 0 0.65rem;
  max-width: 42rem;
}

.placement-script-compact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
  width: 100%;
}

.placement-script-preview {
  display: block;
  flex: 1 1 12rem;
  min-width: 0;
  margin: 0;
  padding: 0.75rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.45;
  color: #1f2937;
  background: #ffffff;
  border-radius: 9px;
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.placement-script-dialog .fallback-dialog-surface {
  width: min(42rem, calc(100vw - 1.75rem));
  max-height: min(92vh, 40rem);
}

.placement-script-dialog .placement-script-textarea {
  min-height: 12rem;
  max-height: min(55vh, 22rem);
  resize: vertical;
  width: 100%;
}

.code-editor-wrapper {
  position: relative;
  width: 100%;
  min-height: 12rem;
}

.code-editor-highlight {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid #1e293b;
  border-radius: 9px;
  background: #0f172a;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  overflow: auto;
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e2e8f0;
  tab-size: 2;
  scrollbar-width: none;
}

.code-editor-highlight::-webkit-scrollbar {
  display: none;
}

.code-editor-highlight code {
  color: inherit;
  background: transparent;
  padding: 0;
  border: none;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  display: block;
}

.code-editor-textarea {
  position: relative;
  background: transparent !important;
  color: #e2e8f0;
  caret-color: #94a3b8;
  z-index: 1;
  resize: vertical;
  min-height: 12rem;
  max-height: min(55vh, 22rem);
  border: 1px solid #1e293b;
  border-radius: 9px;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  tab-size: 2;
  -webkit-text-fill-color: transparent;
}

.code-editor-textarea::selection {
  background: rgba(148, 163, 184, 0.3);
  -webkit-text-fill-color: #e2e8f0;
}

/* Syntax highlighting colors (editor overlay + readonly blocks e.g. callback modal) */
.code-editor-highlight .token.comment,
.code-readonly-block .token.comment {
  color: #64748b;
  font-style: italic;
}

.code-editor-highlight .token.keyword,
.code-readonly-block .token.keyword {
  color: #c792ea;
  font-weight: 600;
}

.code-editor-highlight .token.string,
.code-readonly-block .token.string {
  color: #c3e88d;
}

.code-editor-highlight .token.number,
.code-readonly-block .token.number {
  color: #f78c6c;
}

.code-editor-highlight .token.function,
.code-readonly-block .token.function {
  color: #82aaff;
}

.code-editor-highlight .token.operator,
.code-editor-highlight .token.punctuation,
.code-readonly-block .token.operator,
.code-readonly-block .token.punctuation {
  color: #89ddff;
}

.code-editor-highlight .token.class-name,
.code-readonly-block .token.class-name {
  color: #ffcb6b;
}

.code-editor-highlight .token.boolean,
.code-editor-highlight .token.null,
.code-editor-highlight .token.undefined,
.code-readonly-block .token.boolean,
.code-readonly-block .token.null,
.code-readonly-block .token.undefined {
  color: #ff5370;
}

.code-editor-highlight .token.constant,
.code-readonly-block .token.constant {
  color: #ffcb6b;
}

.code-readonly-block {
  margin: 0;
  padding: 1rem 1.1rem;
  min-height: 8rem;
  max-height: min(55vh, 22rem);
  overflow: auto;
  border: 1px solid #1e293b;
  border-radius: 9px;
  background: #0f172a;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 2;
  color: #e2e8f0;
}

.code-readonly-block code {
  color: inherit;
  background: transparent;
  padding: 0;
  border: none;
  font-family: inherit;
  font-size: inherit;
}

.disclosure-chevron {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  margin-top: 0.15rem;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(43, 191, 154, 0.14);
  border: 1px solid rgba(43, 191, 154, 0.3);
  transition: transform 0.2s ease, background 0.15s ease;
}

.disclosure-chevron::after {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  margin-top: -0.15rem;
  border-right: 2px solid var(--accent-strong);
  border-bottom: 2px solid var(--accent-strong);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.placement-show-script-details:not([open]) .disclosure-chevron::after {
  margin-top: 0;
  transform: rotate(-45deg);
}

.placement-show-script-details[open] .disclosure-chevron {
  background: rgba(43, 191, 154, 0.2);
}

/* Fiche placement : script en disclosure */
.placement-show-panel--script .placement-show-script-details {
  margin: 0;
}

.placement-show-script-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  list-style: none;
  cursor: pointer;
  padding: 0.15rem 0;
  border-radius: calc(var(--radius) - 2px);
}

.placement-show-script-summary::-webkit-details-marker {
  display: none;
}

.placement-show-script-summary:focus {
  outline: none;
}

.placement-show-script-summary:focus-visible {
  outline: 2px solid rgba(43, 191, 154, 0.5);
  outline-offset: 3px;
}

.placement-show-script-details .placement-show-code {
  margin-top: 1rem;
}

.placement-windows-panel {
  margin-top: 0.5rem;
  padding: 1.3rem 1.3rem 1.6rem;
  border-radius: var(--radius);
  border: 1px solid rgba(43, 191, 154, 0.32);
  background: rgba(43, 191, 154, 0.06);
  box-shadow: 0 2px 10px rgba(17, 24, 39, 0.055);
  scroll-margin-top: 1rem;
}

.placement-windows-lead {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-weight: 500;
  color: #374151;
}

.placement-fallbacks-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.placement-windows-panel > .form-section-head.placement-fallbacks-head {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

.placement-fallbacks-head .form-section-title {
  margin-bottom: 0.3rem;
}

.btn-sm {
  font-size: 0.9rem;
  padding: 0.4rem 0.8rem;
}

.placement-show-window-card .schedule-pill {
  margin-top: 0.5rem;
}

.fallback-windows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  grid-auto-rows: 10.25rem;
  gap: 1rem;
  margin-top: 0.25rem;
}

.fallback-window-item {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.fallback-window-delete {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  margin: -0.2rem -0.15rem -0.2rem 0;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
  align-self: flex-start;
}

.fallback-window-delete:hover {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
}

.fallback-window-delete:active {
  transform: scale(0.94);
}

.fallback-window-delete:focus {
  outline: none;
}

.fallback-window-delete:focus-visible {
  outline: 2px solid rgba(220, 38, 38, 0.5);
  outline-offset: 1px;
  color: #dc2626;
}

.fallback-window-delete-icon {
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}

.fallback-window-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  min-width: 0;
  flex: 1;
  min-height: 0;
  height: 100%;
  padding: 0.7rem 0.75rem 0.75rem 0.9rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 3px);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.06);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
  border-left: 4px solid rgba(43, 191, 154, 0.65);
  position: relative;
}

.fallback-window-card:hover {
  border-color: rgba(43, 191, 154, 0.45);
  box-shadow: 0 6px 20px rgba(17, 24, 39, 0.09);
}

.fallback-window-card:focus {
  outline: none;
}

.fallback-window-card:focus-visible {
  outline: 2px solid rgba(43, 191, 154, 0.65);
  outline-offset: 2px;
}

.fallback-window-card-top {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
  width: 100%;
  margin-bottom: 0.65rem;
}

.fallback-window-card-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.fallback-window-card-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.22rem 0.5rem;
  border-radius: var(--radius-pill);
}

.fallback-window-card-badge--on {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(43, 191, 154, 0.35);
}

.fallback-window-card-badge--off {
  background: #f3f4f6;
  color: #64748b;
  border: 1px solid #e5e7eb;
}

.fallback-window-card-title {
  margin: 0 0 0.22rem;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.22;
  color: var(--text);
  width: 100%;
  min-height: 2.2em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}

.fallback-window-card-schedule {
  margin: 0;
  margin-top: auto;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #4b5563;
  width: 100%;
  min-height: calc(1.35em * 2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}

.fallback-window-card .schedule-pill--night {
  margin: 0;
  font-size: 0.58rem;
}

.fallback-edit-dialog {
  padding: 0;
  border: none;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
}

.fallback-edit-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.fallback-dialog-surface {
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 52rem);
  width: min(36rem, calc(100vw - 1.75rem));
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 25px 55px -15px rgba(15, 23, 42, 0.35);
  overflow: hidden;
}

.fallback-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.15rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.fallback-dialog-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
}

.fallback-dialog-close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  margin: -0.35rem -0.35rem 0 0;
  padding: 0;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-size: 1.45rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.fallback-dialog-close:hover {
  background: #e5e7eb;
  color: var(--text);
}

.fallback-dialog-body {
  padding: 1.25rem 1.35rem 1.4rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.fallback-dialog-footer {
  padding: 0.95rem 1.35rem 1.15rem;
  border-top: 1px solid var(--border);
  background: #f9fafb;
  display: flex;
  justify-content: flex-end;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-scroll table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead th {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: #9ca3af;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #fafafa;
  white-space: nowrap;
}

tbody td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

.clickable-row {
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.clickable-row:hover {
  background-color: rgba(43, 191, 154, 0.05);
}

.clickable-row:active {
  background-color: rgba(43, 191, 154, 0.1);
  transform: scale(0.998);
}

.muted {
  color: var(--muted);
}

.cell-check {
  width: 44px;
}

.checkbox {
  width: 16px;
  height: 16px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  display: inline-block;
  background: #fff;
}

.cell-no {
  font-weight: 600;
  color: #9ca3af;
  width: 52px;
}

.plc-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.plc-name-link {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.plc-name-link:hover {
  color: var(--accent-strong);
  border-bottom-color: rgba(43, 191, 154, 0.45);
}

.plc-sub {
  font-size: 0.72rem;
}

.plc-sub .inv-id {
  font-family: var(--font-mono);
  font-size: 0.68em;
  color: var(--muted);
  background: rgba(17, 24, 39, 0.045);
  padding: 0.08em 0.35em;
  border-radius: 4px;
}

.plc-sub .inv-sep {
  margin: 0 0.25em;
  color: var(--muted);
  opacity: 0.7;
}

.badge {
  display: inline-flex;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.32rem 0.65rem;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.badge--live {
  background: rgba(34, 197, 94, 0.16);
  color: #15803d;
}

.badge--pending {
  background: rgba(249, 115, 22, 0.18);
  color: #c2410c;
}

.badge--optimizing {
  background: rgba(20, 184, 166, 0.18);
  color: #0f766e;
}

.badge--completed {
  background: rgba(59, 130, 246, 0.15);
  color: #1d4ed8;
}

.badge--archived {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
}

.badge--off {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid var(--border);
}

.cell-actions {
  width: 48px;
  text-align: right;
}

.dots {
  border: none;
  background: transparent;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding-bottom: 0.5rem;
}

.pg-btn {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}

.pg-btn:hover:not(:disabled) {
  background: var(--hover-bg);
  border-color: var(--border-hover);
}

.pg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pg-num {
  min-width: 36px;
  height: 36px;
  padding: 0 0.35rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

.pg-num:hover:not(.is-active) {
  background: var(--hover-bg);
  border-color: var(--border-hover);
}

.pg-num.is-active {
  background: var(--accent-soft);
  border-color: rgba(43, 191, 154, 0.45);
  color: var(--accent-strong);
}

.pg-ellipsis {
  padding: 0 0.25rem;
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 1024px) {
  .stats-bar {
    flex-wrap: wrap;
  }
  .stat {
    flex: 1 1 33%;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .stat + .stat::before {
    display: none;
  }
  .shell {
    padding: 1rem 1.1rem 1.5rem;
  }
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }
  .top-bar-mobile {
    display: flex;
  }
  /* Sous la barre mobile (sticky z-index 40) pour garder le bandeau titre visible */
  .placement-form-title-row {
    top: calc(0.65rem * 2 + 40px + 1px);
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.08);
  }
  .scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(17, 24, 39, 0.35);
  }
  #nav-toggle:checked ~ .layout .sidebar {
    transform: translateX(0);
  }
  #nav-toggle:checked ~ .layout .scrim {
    display: block;
  }
  .main {
    width: 100%;
  }
  .nav-toggle-input:focus-visible + .layout .burger {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

@media (max-width: 640px) {
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .filters-right {
    width: 100%;
  }
  .search {
    flex: 1;
    min-width: 0;
  }
  .search input {
    flex: 1;
    width: 100%;
  }
  .stat {
    flex: 1 1 50%;
  }
  .banner-notice {
    top: 1rem;
    right: 1rem;
    left: 1rem;
    min-width: auto;
    max-width: none;
  }
}

/* --- Fallback console views --- */
.view-lead {
  margin: 0 0 1.25rem;
  max-width: 42rem;
  font-size: 1.05rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  padding: 0.85rem 1.15rem;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(17, 24, 39, 0.25);
  max-width: min(90vw, 22rem);
}

.toast[hidden] {
  display: none;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.dash-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dash-card-k {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #9ca3af;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.dash-card-v {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.dash-card-hint {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.dash-footnote {
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.stub-panel {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: #fafafa;
  max-width: 28rem;
}

.stub-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.crumb-back {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.crumb-back:hover {
  color: var(--accent-strong);
}

.toolbar--edit {
  margin-bottom: 0.5rem;
}

.table-scroll--rules table {
  min-width: 720px;
}

.code-inline {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: #f3f4f6;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.schedule-summary {
  font-size: 0.78rem;
  display: block;
  line-height: 1.35;
}

.schedule-pill {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-pill);
  background: rgba(99, 102, 241, 0.15);
  color: #4338ca;
}

.schedule-pill--night {
  background: rgba(79, 70, 229, 0.12);
  color: #4f46e5;
}

.snippet-preview {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #4b5563;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-edit {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent-strong);
}

.link-edit:hover {
  text-decoration: underline;
}

.link-edit--secondary {
  font-weight: 500;
  color: var(--muted);
}

.link-edit--secondary:hover {
  color: var(--accent-strong);
}

.cell-actions-split {
  white-space: nowrap;
}

.action-sep {
  margin: 0 0.35rem;
  color: var(--border);
  font-weight: 400;
}

.cell-actions-col {
  width: 7rem;
}

.rule-form {
  max-width: 52rem;
  margin-top: 1rem;
}

.rule-form--wide {
  max-width: none;
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Full-height code area only for non-placement forms */
.view--rule-edit .rule-form--wide:not(.placement-form) .field:has(textarea.input-code) {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

.view--rule-edit .rule-form--wide:not(.placement-form) textarea.input-code {
  flex: 1;
  min-height: clamp(18rem, 45vh, 36rem);
  resize: vertical;
}

.view--rule-edit .placement-form.rule-form--wide .placement-script-dialog .field:has(textarea.placement-script-textarea) {
  flex: 0 1 auto;
  min-height: 0;
  margin-bottom: 0;
}

.view--rule-edit .rule-form--wide .placement-form-footer {
  margin-top: 1.25rem;
  flex-shrink: 0;
}

.rule-form-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
  grid-template-columns: 1fr 1fr;
}

.rule-form-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
  .rule-form-grid,
  .rule-form-grid--3 {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}

.field-row .field-toggle--compact {
  padding-bottom: 0.2rem;
}

.field--grow {
  flex: 1;
  min-width: 0;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
}

.field-label-inline {
  margin: 0;
}

.field-hint {
  font-size: 0.76rem;
  color: var(--muted);
  margin: 0 0 0.55rem;
  line-height: 1.45;
}

.field-hint--muted {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: -0.5rem;
  margin-bottom: 0;
}

.field-hint--callout {
  padding: 0.85rem 1.05rem;
  background: var(--accent-soft);
  border: 1px solid rgba(43, 191, 154, 0.25);
  border-radius: 9px;
  margin: 0;
}

.fieldset-days {
  border: none;
  padding: 0;
  margin: 0 0 1.35rem;
}

.fieldset-days > .field-hint {
  margin: 0 0 0.75rem;
}

.fallback-dialog-body .rule-form-grid {
  margin-bottom: 1.3rem;
}

.fieldset-days legend {
  padding: 0;
}

.field-toggle {
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.field-toggle--inline {
  margin-bottom: 0;
}

.field-toggle--compact {
  margin-bottom: 0;
  min-width: 140px;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}

.toggle-label-on,
.toggle-label-off {
  display: none;
}

.toggle-input:checked ~ .toggle-label .toggle-label-on {
  display: inline;
  color: var(--accent);
}

.toggle-input:not(:checked) ~ .toggle-label .toggle-label-off {
  display: inline;
  color: #6b7280;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-ui {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #d1d5db;
  flex-shrink: 0;
  position: relative;
  transition: background 0.2s;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s;
}

.toggle-input:focus-visible + .toggle-ui {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle-input:checked + .toggle-ui {
  background: var(--accent);
}

.toggle-input:checked + .toggle-ui::after {
  transform: translateX(20px);
}

.day-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.day-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.65rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 600;
  color: #4b5563;
  cursor: pointer;
  user-select: none;
}

.day-chip:has(input:checked) {
  background: var(--accent-soft);
  border-color: rgba(43, 191, 154, 0.45);
  color: var(--accent-strong);
}

.day-chip input {
  margin: 0;
  accent-color: var(--accent-strong);
}

.input {
  font: inherit;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-size: 1rem;
}

.input:focus {
  outline: none;
  border-color: rgba(43, 191, 154, 0.55);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.input-readonly {
  background: #f9fafb;
  color: #6b7280;
}

.input-select {
  cursor: pointer;
}

.input-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 200px;
  tab-size: 2;
}

.form-actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.3rem;
  border-radius: 9px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
  border: 1px solid rgba(220, 38, 38, 0.45);
  background: #fee2e2;
  color: #991b1b;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn-danger:hover {
  background: #fecaca;
  border-color: rgba(220, 38, 38, 0.55);
  color: #7f1d1d;
}

.btn-danger:focus-visible {
  outline: 2px solid rgba(220, 38, 38, 0.65);
  outline-offset: 2px;
}

.delete-form-inline {
  display: inline;
  margin: 0;
}

.schedule-calendar-section-fullwidth {
  background: transparent;
  border-top: 1px solid var(--border);
  margin-top: 2.5rem;
  padding-top: 2.5rem;
  margin-bottom: 0;
}

.schedule-calendar-container {
  max-width: 100%;
}

.schedule-calendar-head {
  margin-bottom: 1rem;
}

.schedule-calendar-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.schedule-calendar-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.schedule-calendar {
  overflow-x: auto;
}

.schedule-grid {
  display: grid;
  grid-template-columns: auto repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

.schedule-header {
  display: contents;
}

.schedule-row {
  display: contents;
}

.schedule-cell {
  background: var(--surface);
  padding: 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  font-size: 0.7rem;
}

.schedule-cell-corner {
  background: var(--sidebar-bg);
}

.schedule-cell-day {
  background: var(--sidebar-bg);
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.schedule-cell-hour {
  background: var(--sidebar-bg);
  font-weight: 500;
  color: var(--muted);
  text-align: right;
  padding-right: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.schedule-cell-data {
  background: #fafafa;
  position: relative;
  cursor: default;
}

.schedule-cell-active {
  background: var(--accent-soft);
}

.schedule-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
}

.table-scroll--users table {
  min-width: 800px;
}

.cell-actions-col-wide {
  width: 12rem;
}

.user-row {
  transition: background 0.15s ease;
}

.user-row:hover {
  background: #fafbfc;
}

.user-name-cell {
  font-size: 0.95rem;
}

.user-date-cell {
  font-size: 0.85rem;
}

.user-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.user-action-btn:hover {
  background: var(--accent-soft);
  border-color: rgba(43, 191, 154, 0.4);
  color: var(--accent-strong);
}

.user-action-btn--edit:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.4);
  color: #2563eb;
}

.user-action-btn--delete {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.2);
}

.user-action-btn--delete:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.4);
  color: #b91c1c;
}

.user-action-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.user-delete-form {
  display: inline;
  margin: 0;
}

.password-form-row {
  display: none;
}

.password-form-cell {
  background: linear-gradient(to bottom, #f9fafb, #f3f4f6);
  padding: 1.25rem 1.35rem !important;
  border-bottom: 1px solid var(--border) !important;
}

.password-update-form {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.password-field {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.password-form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.placement-archived-banner {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15);
}

.placement-archived-content {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.placement-archived-icon {
  width: 28px;
  height: 28px;
  color: #d97706;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.placement-archived-text {
  flex: 1;
  min-width: 0;
}

.placement-archived-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 0.35rem;
}

.placement-archived-desc {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #92400e;
}

.placement-archived-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  background: #f59e0b;
  color: white;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.placement-archived-btn:hover {
  background: #d97706;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.placement-archived-btn svg {
  width: 16px;
  height: 16px;
}

.placement-form-title-row--archived {
  border-color: rgba(245, 158, 11, 0.4) !important;
  background: #fffbeb !important;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.1) !important;
}

.badge--archived-large {
  background: #fef3c7;
  color: #92400e;
  border: 2px solid #f59e0b;
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  font-weight: 700;
}

.view--archived .placement-metadata-card,
.view--archived .placement-windows-panel {
  opacity: 0.75;
  position: relative;
}

.view--archived .placement-metadata-card::after,
.view--archived .placement-windows-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(245, 158, 11, 0.03) 10px,
    rgba(245, 158, 11, 0.03) 20px
  );
  pointer-events: none;
  border-radius: var(--radius);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge--active {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-badge--inactive {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-open {
  display: flex;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  width: 95vw;
  max-width: 1400px;
  max-height: 90vh;
  overflow: auto;
  z-index: 1001;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

.placement-fallbacks-actions {
  display: flex;
  gap: 0.5rem;
}
