:root {
  --bg: #f3efe8;
  --surface: #fffdf9;
  --surface-2: #f8f2ea;
  --line: #ddcfbf;
  --text: #2b241f;
  --muted: #736559;
  --accent: #c25b2c;
  --accent-strong: #9f4318;
  --green: #dfeee4;
  --green-text: #2f6b45;
  --red: #f8e2db;
  --shadow: 0 18px 50px rgba(58, 39, 18, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(194, 91, 44, 0.12), transparent 28%),
    linear-gradient(180deg, #f8f3eb 0%, #f1ece4 100%);
  color: var(--text);
  font-family: "Segoe UI Variable", "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.auth-card {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
  margin-top: 48px;
  border: 1px solid rgba(194, 91, 44, 0.15);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 32px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-copy h1,
.topbar h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.auth-copy p {
  max-width: 560px;
  color: var(--muted);
  font-size: 17px;
}

.auth-form,
.panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  padding: 20px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 0 14px;
  color: var(--text);
}

select {
  cursor: pointer;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0 16px;
  transition: 120ms ease;
}

.button.primary {
  background: var(--accent);
  color: white;
}

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

.button.secondary,
.button.nav {
  border-color: var(--line);
  background: white;
  color: var(--text);
}

.button.wide {
  width: 100%;
}

.button.compact {
  min-height: 34px;
  border-color: var(--line);
  border-radius: 10px;
  background: white;
  padding: 0 11px;
  color: var(--text);
  font-size: 12px;
}

.error {
  margin: 0;
  color: #b4482f;
  font-size: 13px;
}

.demo-box {
  display: grid;
  gap: 10px;
  border: 1px dashed var(--line);
  border-radius: 22px;
  background: var(--surface-2);
  padding: 18px;
}

.demo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.demo-account {
  display: grid;
  width: 100%;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 12px 14px;
  text-align: left;
}

.demo-account span,
.demo-account em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  border: 1px solid rgba(194, 91, 44, 0.12);
  border-radius: 24px;
  background: rgba(255, 253, 249, 0.86);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  backdrop-filter: blur(14px);
}

.topbar h2 {
  font-size: 32px;
}

.app-navigation {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline mandatory;
  touch-action: pan-x;
}

.app-nav-button {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  padding: 0 13px;
  color: var(--muted);
  font-weight: 700;
}

.app-nav-button.active {
  border-color: var(--text);
  background: var(--text);
  color: white;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.identity {
  display: grid;
  justify-items: end;
}

.identity span {
  color: var(--muted);
  font-size: 13px;
}

.account-form {
  display: grid;
  gap: 14px;
}

.account-modal .modal-header p {
  max-width: 390px;
}

.account-section-title {
  margin: 4px 0 0;
  font-size: 16px;
}

.account-divider {
  height: 1px;
  margin: 22px 0;
  background: var(--line);
}

.company-switcher {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  border: 1px solid rgba(194, 91, 44, 0.12);
  border-radius: 18px;
  background: var(--surface);
  padding: 10px;
}

.company-tabs {
  display: flex;
  flex: 1;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline proximity;
  touch-action: pan-x;
}

.company-tab {
  min-height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 0 14px;
  color: var(--muted);
  font-weight: 700;
  scroll-snap-align: start;
}

.company-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.view-toggle {
  display: flex;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 3px;
}

.view-button {
  min-height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 700;
}

.view-button.active {
  background: var(--text);
  color: white;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
}

.sidebar {
  display: grid;
  gap: 16px;
}

.period-nav {
  display: grid;
  gap: 10px;
}

.period-label {
  display: block;
  margin-top: 18px;
  font-size: 26px;
}

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

.small {
  font-size: 12px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: #efe7dc;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
}

.version {
  color: var(--muted);
  font-size: 12px;
}

.employee-list,
.notification-list {
  display: grid;
  gap: 10px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.employee-chip,
.notification-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 12px;
}

.employee-chip.with-action {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.employee-chip-content {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.employee-remove {
  border: 1px solid #edc8bd;
  background: #fff5f1;
  color: #a33f24;
}

.employee-order-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.employee-order-actions .button:disabled {
  cursor: default;
  opacity: 0.35;
}

.employee-chip span,
.notification-item span {
  color: var(--muted);
  font-size: 12px;
}

.board {
  min-width: 0;
}

.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 10px 12px;
}

.sheet-selection {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sheet-actions {
  display: flex;
  gap: 7px;
  overflow-x: auto;
}

.employee-banner {
  margin-bottom: 12px;
  border: 1px solid #cde2d3;
  border-radius: 16px;
  background: var(--green);
  color: var(--green-text);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(194, 91, 44, 0.12);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

table.month-view {
  min-width: 920px;
  table-layout: fixed;
}

table.month-view th:first-child {
  width: 150px;
}

table.month-view .shift-cell {
  padding: 4px;
}

table.month-view .shift {
  min-height: 50px;
  border-radius: 10px;
  padding: 5px 3px;
  font-size: 10px;
}

th,
td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

th:last-child,
td:last-child {
  border-right: 0;
}

tr:last-child td {
  border-bottom: 0;
}

th {
  background: #fbf6ef;
  padding: 14px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 150px;
  text-align: left;
}

.employee-head {
  min-width: 150px;
}

.employee-head strong,
.employee-head span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-head strong {
  color: var(--text);
  font-size: 14px;
}

.employee-head span {
  margin-top: 4px;
  font-size: 10px;
}

.day-head {
  display: grid;
  gap: 4px;
}

.day-head strong {
  color: var(--text);
  font-size: 18px;
}

.employee-cell {
  padding: 14px;
  background: #fffaf4;
}

.employee-cell strong {
  display: block;
  margin-bottom: 4px;
}

.employee-cell span {
  color: var(--muted);
  font-size: 12px;
}

.date-cell {
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 12px;
  background: #fffaf4;
}

.date-cell strong,
.date-cell span {
  display: block;
}

.date-cell span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.shift-cell {
  padding: 10px;
}

.shift-cell.selected {
  position: relative;
  box-shadow: inset 0 0 0 3px var(--accent);
}

.shift-cell.selected .shift {
  border-radius: 13px;
}

.shift-cell.modified {
  position: relative;
  background: #fff1ad;
  box-shadow: inset 0 0 0 2px #e6a700;
}

.shift-cell.modified .shift {
  box-shadow: 0 0 0 3px #e6a700, 0 4px 12px rgba(148, 101, 0, 0.18);
}

.shift-cell.modified::after {
  content: "Modifié";
  position: absolute;
  top: 3px;
  right: 4px;
  border-radius: 999px;
  background: #e6a700;
  color: #352700;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 800;
  pointer-events: none;
}

.shift {
  width: 100%;
  min-height: 66px;
  border: 0;
  border-radius: 18px;
  background: #f5ede5;
  color: var(--text);
  padding: 12px;
  font-weight: 700;
  white-space: pre-line;
}

.shift.work {
  background: #d9e8ff;
  color: #244a7c;
}

.shift.rest {
  background: #e3e5e8;
  color: #4c535c;
}

.shift.leave {
  background: #d9f3df;
  color: #24643a;
}

.sunday-row td {
  background-color: #f1f2f4;
}

.sunday-row .date-cell {
  background: #d8dadd;
  color: #41464d;
}

.shift.empty {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.shift:disabled {
  cursor: default;
}

.empty-row {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(45, 31, 18, 0.32);
  padding: 20px;
}

.modal {
  width: min(520px, 100%);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-header h3 {
  margin: 0;
  font-size: 24px;
}

.modal-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #f4ece2;
  font-size: 22px;
}

.type-picker {
  display: grid;
  gap: 10px;
  margin: 0;
  border: 0;
  padding: 0;
}

.preset-picker {
  margin-bottom: 16px;
}

.preset-picker select {
  width: 100%;
}

.type-picker label {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 12px;
}

.time-fields {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.time-periods {
  display: grid;
  gap: 10px;
}

.time-period-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.time-period-row label {
  display: grid;
  gap: 6px;
}

.time-period-row .button:disabled {
  opacity: 0.4;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.form-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.management-page,
.settings-page {
  display: grid;
  gap: 18px;
}

.management-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(194, 91, 44, 0.12);
  border-radius: 22px;
  background: var(--surface);
  padding: 22px;
}

.management-heading h3,
.management-heading p {
  margin: 0;
}

.management-heading h3 {
  font-size: 26px;
}

.management-heading p:last-child {
  margin-top: 7px;
  color: var(--muted);
}

.management-heading-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.management-heading-actions label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.management-hours {
  color: #8a5a00 !important;
  font-weight: 800;
}

.employee-hours-panel {
  display: grid;
  gap: 4px;
  background: #fff8d9;
}

.employee-hours-total {
  color: #7b5200;
  font-size: 30px;
}

.settings-heading,
.color-settings-card {
  border: 1px solid rgba(194, 91, 44, 0.12);
  border-radius: 22px;
  background: var(--surface);
  padding: 22px;
}

.settings-heading h3,
.settings-heading p {
  margin: 0;
}

.settings-heading h3 {
  font-size: 26px;
}

.settings-heading p:last-child {
  margin-top: 7px;
  color: var(--muted);
}

.fixed-color-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 20px;
  color: var(--muted);
  font-weight: 700;
}

.fixed-color-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
}

.leave-swatch {
  background: #d9f3df;
}

.sunday-swatch {
  background: #d8dadd;
}

.color-rules {
  display: grid;
  gap: 12px;
}

.color-rule-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.5fr) minmax(110px, 0.7fr) minmax(110px, 0.7fr) minmax(100px, 0.5fr) auto;
  align-items: end;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.color-rule-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.color-rule-color {
  width: 100%;
  min-height: 43px;
  padding: 4px;
}

.color-settings-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

.color-rules-empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.management-companies {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.management-company {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  padding: 18px;
}

.management-company-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.management-company-header h4 {
  margin: 0;
  font-size: 20px;
}

.management-company-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.management-employee-list {
  display: grid;
  gap: 9px;
}

.management-employee {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 12px;
}

.management-employee-info {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.management-employee-info span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
}

.management-employee-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.management-assign {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.management-assign .button {
  width: 100%;
}

.management-assign :disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.danger {
  border-color: #edc8bd;
  background: #fff5f1;
  color: #a33f24;
}

@media (max-width: 560px) {
  .management-company-header {
    align-items: stretch;
    flex-direction: column;
  }

  .management-company-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .management-company-actions .button {
    width: 100%;
  }

}

.toast {
  position: fixed;
  z-index: 1100;
  right: 24px;
  bottom: 24px;
  transform: translateY(20px);
  opacity: 0;
  border-radius: 14px;
  background: #2f241d;
  color: white;
  padding: 12px 16px;
  transition: 140ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .auth-card,
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .company-switcher,
  .sheet-toolbar,
  .management-heading,
  .management-heading-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .form-columns {
    grid-template-columns: 1fr;
  }

  .management-employee {
    grid-template-columns: 1fr;
  }

  .color-rule-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .color-rule-row > :first-child,
  .color-rule-row .remove-color-rule {
    grid-column: 1 / -1;
  }

  .shell {
    width: min(100%, calc(100% - 20px));
  }

  .topbar {
    align-items: start;
    gap: 16px;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 700px) {
  body {
    background: var(--surface);
  }

  .shell {
    width: 100%;
    padding: 0 0 20px;
  }

  .topbar {
    margin: 0;
    border-width: 0 0 1px;
    border-radius: 0;
    padding: 12px;
    box-shadow: none;
  }

  .topbar > div:first-child {
    width: 100%;
  }

  .topbar h2 {
    font-size: 26px;
  }

  .topbar .eyebrow {
    margin-bottom: 4px;
  }

  .app-navigation {
    width: 100%;
    margin-top: 10px;
  }

  .app-nav-button {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
  }

  .topbar-actions {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
  }

  .identity {
    align-content: center;
    justify-items: start;
    min-width: 0;
  }

  .identity strong {
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions .button {
    min-height: 36px;
    padding: 0 10px;
    font-size: 12px;
  }

  #planning-page .company-switcher {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    border-width: 0 0 1px;
    border-radius: 0;
    padding: 7px;
  }

  #planning-page .company-tabs {
    grid-column: 1 / -1;
  }

  #planning-page .company-tab {
    min-height: 34px;
    padding: 0 11px;
    font-size: 12px;
  }

  #planning-page .view-toggle {
    width: max-content;
  }

  #planning-page #open-company-modal {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }

  #planning-page .sidebar {
    display: grid;
    grid-template-columns: 1fr;
    border-left: 0;
    border-right: 0;
  }

  #planning-page .sidebar .panel,
  #planning-page .sidebar .panel:first-child {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--sheet-grid);
    padding: 6px 7px;
  }

  #planning-page .sidebar .panel:first-child {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
  }

  #planning-page .period-nav {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #planning-page .period-nav .button {
    min-height: 34px;
    padding: 0 5px;
    font-size: 11px;
    line-height: 1.05;
  }

  #planning-page .period-label {
    margin: 0;
    text-align: center;
    font-size: 14px;
  }

  #planning-page #manager-status-panel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  #planning-page #manager-status-panel .status-row {
    margin: 0;
  }

  #planning-page #manager-status-panel .button {
    width: 100%;
    min-height: 36px;
    overflow: hidden;
    padding: 0 8px;
    font-size: 12px;
    text-overflow: ellipsis;
  }

  #planning-page .sheet-toolbar {
    display: block;
    padding: 5px 7px;
  }

  #planning-page .sheet-selection {
    display: none;
  }

  #planning-page .sheet-actions {
    display: flex;
    width: 100%;
    gap: 5px;
    overflow-x: auto;
    scroll-snap-type: inline proximity;
  }

  #planning-page .sheet-actions .button {
    min-height: 34px;
    flex: 0 0 auto;
    padding: 0 10px;
    scroll-snap-align: start;
    font-size: 11px;
  }

  #planning-page .table-wrap {
    max-width: 100vw;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  #planning-page table,
  #planning-page table.month-view {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
  }

  #planning-page th:nth-child(3),
  #planning-page .event-cell {
    width: 132px;
    min-width: 132px;
    max-width: 132px;
  }

  #planning-page .employee-head,
  #planning-page .shift-cell {
    width: 126px;
    min-width: 126px;
    max-width: 126px;
  }

  #planning-page .employee-head strong {
    font-size: 11px;
  }

  #planning-page th,
  #planning-page td {
    height: 44px;
  }

  #planning-page .shift {
    min-height: 43px;
    padding: 4px 7px;
    font-size: 12px;
  }

  #planning-page .event-input,
  #planning-page .event-readonly {
    min-height: 43px;
    font-size: 11px;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 18px 14px;
  }
}

/* Dialogues tactiles : hauteur dynamique et actions toujours accessibles. */
#shift-modal {
  overflow: hidden;
}

#shift-modal .modal {
  display: flex;
  max-height: calc(100dvh - 24px);
  flex-direction: column;
  overflow: hidden;
}

#shift-modal .modal-header {
  flex: 0 0 auto;
}

#shift-form {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

#shift-form .modal-actions {
  position: sticky;
  z-index: 2;
  bottom: 0;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-top: 12px;
  padding-bottom: max(2px, env(safe-area-inset-bottom));
}

@media (max-width: 700px), (max-height: 600px) {
  #shift-modal {
    align-items: end;
    padding: 0;
  }

  #shift-modal .modal {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 4px);
    border-radius: 18px 18px 0 0;
    padding: 12px 14px max(8px, env(safe-area-inset-bottom));
  }

  #shift-modal .modal-header {
    gap: 8px;
    margin-bottom: 10px;
  }

  #shift-modal .modal-header h3 {
    font-size: 20px;
  }

  #shift-modal .modal-header p {
    margin-top: 2px;
    font-size: 12px;
  }

  #shift-modal .close {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
  }

  #shift-form .preset-picker {
    margin-bottom: 10px;
  }

  #shift-form .modal-actions .button {
    min-height: 42px;
    flex: 1 1 0;
  }
}

@media (max-width: 560px) {
  .time-period-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .time-period-row .button {
    grid-column: 1 / -1;
  }

  .color-rule-row {
    grid-template-columns: 1fr;
  }

  .color-rule-row > * {
    grid-column: 1;
  }

  .color-settings-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Vue planning officielle : volontairement proche d'une feuille Sheets / Excel. */
#planning-page {
  --sheet-grid: #c9cdd2;
  --sheet-header: #f1f3f4;
  --sheet-green: #188038;
}

#planning-page .company-switcher {
  margin: 0;
  border-color: var(--sheet-grid);
  border-radius: 8px 8px 0 0;
  box-shadow: none;
  padding: 6px 8px;
}

#planning-page .company-tab,
#planning-page .view-toggle,
#planning-page .view-button,
#planning-page .button {
  border-radius: 4px;
}

#planning-page .company-tab.active {
  border-color: var(--sheet-green);
  background: #e6f4ea;
  color: #137333;
  box-shadow: inset 0 -3px 0 var(--sheet-green);
}

#planning-page .layout {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#planning-page .sidebar {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-right: 1px solid var(--sheet-grid);
  border-left: 1px solid var(--sheet-grid);
  background: white;
}

#planning-page .sidebar .panel {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--sheet-grid);
  border-radius: 0;
  padding: 7px 9px;
}

#planning-page .sidebar .panel:first-child {
  flex: 1 1 auto;
}

#planning-page .sidebar .panel:nth-child(3),
#planning-page #notifications-panel {
  display: none !important;
}

#planning-page .period-nav {
  display: flex;
  gap: 5px;
}

#planning-page .period-label {
  margin: 0 8px;
  font-size: 16px;
  white-space: nowrap;
}

#planning-page #page-help,
#planning-page #publish-help,
#planning-page .version {
  display: none;
}

#planning-page .status-row {
  margin: 0;
}

#planning-page #manager-status-panel .button {
  width: auto;
  white-space: nowrap;
}

#planning-page .pill {
  min-height: 26px;
  border-radius: 4px;
  background: #fff4ce;
  padding: 0 8px;
}

#planning-page .sheet-toolbar {
  justify-content: flex-start;
  gap: 0;
  margin: 0;
  border-color: var(--sheet-grid);
  border-radius: 0;
  padding: 4px 7px;
  box-shadow: none;
}

.cell-reference {
  width: 58px;
  flex: 0 0 58px;
  border-right: 1px solid var(--sheet-grid);
  color: #3c4043;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.formula-symbol {
  padding: 0 10px;
  color: #5f6368;
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
}

#planning-page .sheet-selection {
  flex: 1 1 auto;
  min-width: 180px;
  color: #3c4043;
  font-weight: 400;
}

#planning-page .sheet-actions {
  margin-left: auto;
}

#planning-page .table-wrap {
  max-height: calc(100vh - 280px);
  overflow: auto;
  border-color: var(--sheet-grid);
  border-radius: 0 0 6px 6px;
  box-shadow: none;
}

#planning-page table,
#planning-page table.month-view {
  min-width: max(100%, 760px);
  border-collapse: collapse;
  table-layout: fixed;
  font-family: Arial, sans-serif;
}

#planning-page th,
#planning-page td {
  height: 36px;
  border: 1px solid var(--sheet-grid);
  padding: 0;
}

#planning-page thead th {
  position: sticky;
  z-index: 5;
  top: 22px;
  height: 40px;
  background: var(--sheet-header);
  color: #3c4043;
  padding: 4px 6px;
  font-weight: 600;
}

#planning-page thead .column-letters th {
  top: 0;
  z-index: 7;
  height: 22px;
  background: #e8eaed;
  color: #5f6368;
  font-size: 10px;
  font-weight: 500;
}

#planning-page th:first-child,
#planning-page table.month-view th:first-child,
#planning-page .day-number-cell {
  width: 42px;
  min-width: 42px;
}

#planning-page th:nth-child(2),
#planning-page .date-cell {
  width: 74px;
  min-width: 74px;
}

#planning-page .column-letters th:first-child,
#planning-page .day-number-head,
#planning-page .day-number-cell {
  position: sticky;
  left: 0;
  z-index: 6;
  background: var(--sheet-header);
  text-align: center;
}

#planning-page .column-letters th:nth-child(2),
#planning-page .weekday-head,
#planning-page .date-cell {
  position: sticky;
  left: 42px;
  z-index: 6;
  background: white;
}

#planning-page thead .column-letters th:first-child,
#planning-page thead .column-letters th:nth-child(2),
#planning-page .day-number-head,
#planning-page .weekday-head {
  z-index: 8;
  background: var(--sheet-header);
}

#planning-page .employee-head {
  min-width: 116px;
}

#planning-page th:nth-child(3),
#planning-page .event-cell {
  width: 150px;
  min-width: 150px;
}

#planning-page .event-cell {
  background: #fffdf1;
  padding: 0 4px;
}

#planning-page .event-cell.event-modified {
  background: #fff2cc;
  box-shadow: inset 0 0 0 2px #f9ab00;
}

#planning-page .event-input {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 3px 5px;
  color: #5f4b00;
  font-size: 12px;
}

#planning-page .event-input:focus {
  outline: 2px solid #1a73e8;
  outline-offset: -2px;
}

#planning-page .event-readonly {
  padding: 3px 8px;
  color: #5f4b00;
  font-size: 12px;
}

#planning-page .employee-head strong {
  font-size: 12px;
}

#planning-page .date-cell,
#planning-page .day-number-cell {
  padding: 0 7px;
  color: #3c4043;
  font-size: 12px;
}

#planning-page .shift-cell {
  padding: 0;
  background: white;
}

#planning-page .shift {
  min-height: 35px;
  border: 0;
  border-radius: 0;
  background: white;
  padding: 3px 5px;
  color: #202124;
  font-size: 12px;
  line-height: 1.15;
}

#planning-page .shift.empty {
  border: 0;
  background: white;
}

#planning-page .sunday-row td,
#planning-page .sunday-row .date-cell,
#planning-page .sunday-row .day-number-cell,
#planning-page .sunday-row .event-cell,
#planning-page .sunday-row .event-input,
#planning-page .sunday-row .shift {
  background: var(--sunday-color, #595959) !important;
  color: var(--sunday-text, white) !important;
}

#planning-page .shift-cell.selected {
  z-index: 3;
  box-shadow: inset 0 0 0 2px #1a73e8;
}

#planning-page .shift-cell.selected .shift {
  border-radius: 0;
}

#planning-page .shift-cell.modified {
  background: #fff2cc;
  box-shadow: inset 0 0 0 2px #f9ab00;
}

#planning-page .shift-cell.modified .shift {
  box-shadow: none;
}

#planning-page .shift-cell.modified::after {
  content: "";
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-top: 8px solid #f9ab00;
  border-left: 8px solid transparent;
  border-radius: 0;
  padding: 0;
}

/* Repères de lecture : aujourd'hui en ligne et compte connecté en colonne. */
#planning-page .current-day-row > td {
  box-shadow: inset 0 2px 0 #1a73e8, inset 0 -2px 0 #1a73e8;
}

#planning-page .current-day-row > .day-number-cell,
#planning-page .current-day-row > .date-cell,
#planning-page .current-day-row > .event-cell {
  background-color: #e8f0fe;
  color: #174ea6;
  font-weight: 800;
}

#planning-page th.current-user-column {
  background: #d7e6ff;
  color: #174ea6;
  box-shadow: inset 2px 0 0 #1a73e8, inset -2px 0 0 #1a73e8;
}

#planning-page td.current-user-column {
  box-shadow: inset 2px 0 0 #1a73e8, inset -2px 0 0 #1a73e8;
}

#planning-page .current-day-row > td.current-user-column {
  box-shadow:
    inset 0 2px 0 #1a73e8,
    inset 0 -2px 0 #1a73e8,
    inset 2px 0 0 #1a73e8,
    inset -2px 0 0 #1a73e8;
}

@media (max-width: 980px) {
  #planning-page .sidebar {
    flex-wrap: wrap;
  }

  #planning-page .sidebar .panel:first-child {
    flex-basis: 100%;
  }

  #planning-page .sheet-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 5px;
  }

  #planning-page .formula-symbol,
  #planning-page .cell-reference {
    display: none;
  }

  #planning-page .sheet-actions {
    width: 100%;
    margin: 0;
  }

  .app-navigation,
  .company-tabs,
  #planning-page .sheet-actions {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .app-navigation::-webkit-scrollbar,
  .company-tabs::-webkit-scrollbar,
  #planning-page .sheet-actions::-webkit-scrollbar {
    display: none;
  }

  #planning-page .table-wrap {
    max-height: none;
  }
}

/* La vue mobile doit rester en dernier : elle prime sur la grille bureau. */
@media (max-width: 700px) {
  body {
    background: var(--surface);
  }

  .shell {
    width: 100%;
    padding: 0 0 16px;
  }

  .topbar {
    display: grid;
    gap: 8px;
    margin: 0;
    border-width: 0 0 1px;
    border-radius: 0;
    padding: 9px 10px;
    box-shadow: none;
  }

  .topbar > div:first-child {
    width: 100%;
  }

  .topbar .eyebrow {
    display: none;
  }

  .topbar h2 {
    margin: 0;
    font-size: 23px;
    line-height: 1.1;
  }

  .app-navigation {
    width: 100%;
    margin-top: 8px;
    overflow-x: auto;
  }

  .app-nav-button {
    min-height: 34px;
    flex: 0 0 auto;
    padding: 0 11px;
    font-size: 12px;
  }

  .topbar-actions {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 5px;
  }

  .identity {
    align-content: center;
    justify-items: start;
    min-width: 0;
    font-size: 12px;
  }

  .identity strong {
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .identity span {
    font-size: 10px;
  }

  .topbar-actions .button {
    min-height: 32px;
    padding: 0 8px;
    font-size: 11px;
  }

  #planning-page .company-switcher {
    display: grid;
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px;
    margin: 0;
    border-width: 0 0 1px;
    border-radius: 0;
    padding: 5px 7px;
  }

  #planning-page .company-tabs {
    grid-column: 1 / -1;
    overflow-x: auto;
  }

  #planning-page .company-tab {
    min-height: 32px;
    flex: 0 0 auto;
    padding: 0 10px;
    font-size: 11px;
  }

  #planning-page .view-toggle {
    width: max-content;
  }

  #planning-page .view-button,
  #planning-page #open-company-modal {
    min-height: 32px;
    padding: 0 9px;
    font-size: 11px;
  }

  #planning-page .sidebar {
    display: grid;
    grid-template-columns: 1fr;
    border-right: 0;
    border-left: 0;
  }

  #planning-page .sidebar .panel,
  #planning-page .sidebar .panel:first-child {
    display: grid;
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--sheet-grid);
    padding: 5px 7px;
  }

  #planning-page .sidebar .panel:first-child {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  #planning-page .period-nav {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  #planning-page .period-nav .button {
    min-height: 32px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 1.05;
  }

  #planning-page .period-label {
    margin: 0;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    font-size: 13px;
    white-space: nowrap;
  }

  #planning-page #manager-status-panel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 5px;
  }

  #planning-page #manager-status-panel .status-row {
    margin: 0;
  }

  #planning-page #manager-status-panel .button {
    width: 100%;
    min-height: 34px;
    overflow: hidden;
    padding: 0 7px;
    font-size: 11px;
    text-overflow: ellipsis;
  }

  #planning-page .sheet-toolbar {
    display: block;
    padding: 4px 6px;
  }

  #planning-page .sheet-selection,
  #planning-page .formula-symbol,
  #planning-page .cell-reference {
    display: none;
  }

  #planning-page .sheet-actions {
    display: flex;
    width: 100%;
    gap: 4px;
    margin: 0;
    overflow-x: auto;
  }

  #planning-page .sheet-actions .button {
    min-height: 32px;
    flex: 0 0 auto;
    padding: 0 9px;
    font-size: 10px;
  }

  #planning-page .table-wrap {
    width: 100%;
    max-width: 100vw;
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  #planning-page table,
  #planning-page table.month-view {
    width: max-content;
    min-width: 100%;
    table-layout: fixed;
  }

  #planning-page th:first-child,
  #planning-page table.month-view th:first-child,
  #planning-page .day-number-cell {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
  }

  #planning-page th:nth-child(2),
  #planning-page .date-cell {
    width: 54px;
    min-width: 54px;
    max-width: 54px;
  }

  #planning-page .column-letters th:nth-child(2),
  #planning-page .weekday-head,
  #planning-page .date-cell {
    left: 36px;
  }

  #planning-page th:nth-child(3),
  #planning-page .event-cell {
    width: 76px;
    min-width: 76px;
    max-width: 76px;
  }

  #planning-page .employee-head,
  #planning-page .shift-cell {
    width: 118px;
    min-width: 118px;
    max-width: 118px;
  }

  #planning-page .employee-head {
    overflow: hidden;
    padding: 3px 4px;
  }

  #planning-page .employee-head strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
  }

  #planning-page th,
  #planning-page td {
    height: 40px;
  }

  #planning-page thead th {
    height: 36px;
  }

  #planning-page .shift {
    min-height: 39px;
    padding: 3px 6px;
    font-size: 11px;
  }

  #planning-page .event-input,
  #planning-page .event-readonly {
    min-height: 39px;
    overflow: hidden;
    padding: 2px 3px;
    text-overflow: ellipsis;
    font-size: 10px;
    white-space: nowrap;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 18px 14px;
  }
}
