:root {
  --border-light: #DDDDDD;
  --border-btn: #D4D9DC;
  --text-title: #333333;
  --text-secondary: #777777;
  --bg-secondary-btn: #EFEFEF;
  --primary: #3044EE;
  --danger: #E74C3C;
  --hour-height: 46.8px;
  --half-hour-height: 23.4px;
  --font-main: 'Open Sans', -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-main);
  color: #333333;
  background: #F7F8FA;
}

a { color: inherit; }

.hidden { display: none !important; }

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------------- Sidebar ---------------- */

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #1F2430;
  color: #E7E9EE;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  font-weight: 700;
  font-size: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8A90A0;
  padding: 18px 20px 6px;
}

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

.sidebar-nav li a {
  display: block;
  padding: 10px 20px;
  text-decoration: none;
  font-size: 14px;
  color: #C7CAD4;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
  background: rgba(255,255,255,0.06);
}

.sidebar-nav li.active a {
  background: rgba(48,68,238,0.18);
  border-left-color: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
}

/* ---------------- Main / Planning ---------------- */

.planning {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #FFFFFF;
}

/* ---- Header ---- */

.planning-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
  flex: 0 0 auto;
}

.planning-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.planning-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.planning-title {
  font-family: var(--font-main);
  font-size: 19.5px;
  font-weight: 600;
  color: var(--text-title);
  margin: 0;
}

.planning-date {
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.planning-count {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.planning-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 4px;
  border: 0.8px solid var(--border-btn);
  background: var(--bg-secondary-btn);
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  background: var(--bg-secondary-btn);
  color: var(--text-secondary);
  border: 0.8px solid var(--border-btn);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-main);
  cursor: pointer;
  white-space: nowrap;
}

.btn-secondary:hover { background: #E5E5E5; }

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  min-width: 130px;
  height: 34px;
  cursor: pointer;
  font-family: var(--font-main);
}

.btn-primary:hover { background: #2536CC; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 0.8px solid var(--danger);
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-main);
}

.btn-danger:hover { background: #FDEDEC; }

/* ---- Filters panel ---- */

.filters-panel {
  border-bottom: 1px solid var(--border-light);
  flex: 0 0 auto;
  background: #FAFBFC;
}

.filters-toggle {
  border: none;
  background: transparent;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 10px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filters-toggle-icon {
  display: inline-block;
  transition: transform 0.15s ease;
}

.filters-toggle[aria-expanded="false"] .filters-toggle-icon {
  transform: rotate(-90deg);
}

.filters-body {
  padding: 0 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filters-body.hidden { display: none; }

.filters-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #EEF0FE;
  color: #3044EE;
  border: 1px solid #D3D8FC;
  border-radius: 14px;
  padding: 4px 8px 4px 12px;
  font-size: 12.5px;
}

.filter-chip button {
  background: none;
  border: none;
  color: #3044EE;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
}

.filters-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-add-combo { position: relative; }

.filter-add-btn {
  background: #FFFFFF;
  border: 0.8px dashed var(--border-btn);
  border-radius: 4px;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-main);
}

.filter-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 260px;
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  z-index: 20;
  padding: 8px;
}

.filter-dropdown input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-family: var(--font-main);
  font-size: 13px;
  margin-bottom: 6px;
}

.filter-dropdown ul {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
}

.filter-dropdown li {
  padding: 7px 8px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
}

.filter-dropdown li:hover { background: #F0F1F5; }

.link-remove-filters {
  font-size: 13px;
  color: var(--danger);
  text-decoration: none;
  cursor: pointer;
}

.link-remove-filters:hover { text-decoration: underline; }

.filters-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-size-label {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-size-label select {
  padding: 5px 8px;
  border: 0.8px solid var(--border-btn);
  border-radius: 4px;
  font-family: var(--font-main);
  font-size: 13px;
}

/* ---- Calendar grid ---- */

.calendar-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.calendar-scroll {
  height: 100%;
  overflow: auto;
}

.calendar-grid {
  display: flex;
  position: relative;
  min-width: 100%;
}

.calendar-hours-col {
  flex: 0 0 64px;
  position: sticky;
  left: 0;
  background: #FFFFFF;
  z-index: 5;
  border-right: 1px solid var(--border-light);
}

.calendar-header-row {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 10;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-light);
}

.calendar-header-spacer {
  flex: 0 0 64px;
  position: sticky;
  left: 0;
  background: #FFFFFF;
  z-index: 11;
  border-right: 1px solid var(--border-light);
}

.calendar-header-cell {
  flex: 1 0 160px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-right: 1px solid var(--border-light);
}

.worker-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #7B86C6;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  cursor: default;
}

.worker-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.worker-name {
  font-size: 12px;
  color: var(--text-title);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.calendar-body {
  display: flex;
  position: relative;
}

.hour-slot {
  height: var(--hour-height);
  border-bottom: 1px solid var(--border-light);
  position: relative;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 2px 6px 0 0;
  text-align: right;
}

.hour-slot .half-mark {
  position: absolute;
  top: var(--half-hour-height);
  right: 6px;
  left: 0;
  border-top: 1px dashed #EEEEEE;
}

.worker-column {
  flex: 1 0 160px;
  min-width: 160px;
  position: relative;
  border-right: 1px solid var(--border-light);
}

.half-hour-cell {
  height: var(--half-hour-height);
  border-bottom: 1px solid #EEEEEE;
  cursor: pointer;
}

.half-hour-cell:hover {
  background: #F5F6FF;
}

.half-hour-cell.hour-boundary {
  border-bottom: 1px solid var(--border-light);
}

.current-time-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px solid #FF0000;
  z-index: 8;
  pointer-events: none;
}

.current-time-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FF0000;
}

/* ---- Task card ---- */

.task-card {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 3px;
  color: #FFFFFF;
  padding: 4px 6px;
  font-size: 11.5px;
  line-height: 1.25;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  z-index: 6;
}

.task-card:hover {
  filter: brightness(1.06);
  z-index: 7;
}

.task-card.task-card--editing {
  outline: 2px solid #1E824C;
  outline-offset: 1px;
}

.task-card-time {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-card-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  flex: 0 0 auto;
}

.task-card-kind {
  font-weight: 600;
  margin-top: 1px;
}

.task-card-location {
  display: flex;
  align-items: center;
  gap: 3px;
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-card-detail {
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- Modal ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,22,30,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: #FFFFFF;
  width: 880px;
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  color: var(--text-title);
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  display: flex;
  gap: 20px;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-form {
  flex: 1 1 55%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.form-field-row {
  display: flex;
  gap: 12px;
}

.form-field-row .form-field { flex: 1; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-title);
  position: relative;
}

.form-field em {
  color: var(--danger);
  font-style: normal;
}

.form-field input,
.form-field select,
.form-field textarea {
  font-family: var(--font-main);
  font-size: 13.5px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: #333333;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  max-height: 160px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 6px 14px rgba(0,0,0,0.1);
}

.autocomplete-list div {
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
}

.autocomplete-list div:hover { background: #F0F1F5; }

.modal-preview {
  flex: 1 1 45%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-preview-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.modal-preview-calendar {
  flex: 1;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  overflow-y: auto;
  position: relative;
  background: #FAFBFC;
  max-height: 420px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
}

.modal-footer-right {
  display: flex;
  gap: 10px;
}

/* Scrollbar cosmetics */
.calendar-scroll::-webkit-scrollbar,
.modal-preview-calendar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.calendar-scroll::-webkit-scrollbar-thumb,
.modal-preview-calendar::-webkit-scrollbar-thumb {
  background: #CCCCCC;
  border-radius: 4px;
}
